This revision was automatically updated to reflect the committed changes. Closed by commit rG856bdd01fd65: [Sema][SVE] Allow casting SVE types to themselves in C (authored by rsandifo-arm).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76694/new/ https://reviews.llvm.org/D76694 Files: clang/lib/Sema/SemaCast.cpp clang/test/Sema/sizeless-1.c Index: clang/test/Sema/sizeless-1.c =================================================================== --- clang/test/Sema/sizeless-1.c +++ clang/test/Sema/sizeless-1.c @@ -108,6 +108,8 @@ sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}} + local_int8 = (svint8_t)local_int8; + local_int8 = (const svint8_t)local_int8; local_int8 = (svint8_t)local_int16; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}} local_int8 = (svint8_t)0; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}} sel = (int)local_int8; // expected-error {{operand of type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}} Index: clang/lib/Sema/SemaCast.cpp =================================================================== --- clang/lib/Sema/SemaCast.cpp +++ clang/lib/Sema/SemaCast.cpp @@ -2652,6 +2652,13 @@ return; } + // Allow casting a sizeless built-in type to itself. + if (DestType->isSizelessBuiltinType() && + Self.Context.hasSameUnqualifiedType(DestType, SrcType)) { + Kind = CK_NoOp; + return; + } + if (!DestType->isScalarType() && !DestType->isVectorType()) { const RecordType *DestRecordTy = DestType->getAs<RecordType>();
Index: clang/test/Sema/sizeless-1.c =================================================================== --- clang/test/Sema/sizeless-1.c +++ clang/test/Sema/sizeless-1.c @@ -108,6 +108,8 @@ sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}} + local_int8 = (svint8_t)local_int8; + local_int8 = (const svint8_t)local_int8; local_int8 = (svint8_t)local_int16; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}} local_int8 = (svint8_t)0; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}} sel = (int)local_int8; // expected-error {{operand of type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}} Index: clang/lib/Sema/SemaCast.cpp =================================================================== --- clang/lib/Sema/SemaCast.cpp +++ clang/lib/Sema/SemaCast.cpp @@ -2652,6 +2652,13 @@ return; } + // Allow casting a sizeless built-in type to itself. + if (DestType->isSizelessBuiltinType() && + Self.Context.hasSameUnqualifiedType(DestType, SrcType)) { + Kind = CK_NoOp; + return; + } + if (!DestType->isScalarType() && !DestType->isVectorType()) { const RecordType *DestRecordTy = DestType->getAs<RecordType>();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits