Author: Aaron Ballman Date: 2022-08-03T14:05:09-04:00 New Revision: c9edf843fcf954132271214445857498fb47bb72
URL: https://github.com/llvm/llvm-project/commit/c9edf843fcf954132271214445857498fb47bb72 DIFF: https://github.com/llvm/llvm-project/commit/c9edf843fcf954132271214445857498fb47bb72.diff LOG: Error instead of assert when making a _BitInt vector We already correctly rejected: typedef __attribute__((vector_size(16))) _BitInt(4) Ty; but we would assert with: typedef __attribute__((ext_vector_type(4))) _BitInt(4) Ty; Now we issue the same error in both cases. Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaType.cpp clang/test/SemaCXX/ext-int.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 4af8ebec3a97..e42ed9dd025b 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -57,6 +57,9 @@ Bug Fixes - Improve compile-times with large dynamic array allocations with trivial constructors. This fixes `Issue 56774 <https://github.com/llvm/llvm-project/issues/56774>`_. +- No longer assert/miscompile when trying to make a vectorized ``_BitInt`` type + using the ``ext_vector_type`` attribute (the ``vector_size`` attribute was + already properly diagnosing this case). Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 398006e88cd0..ee5f203f7049 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2691,7 +2691,7 @@ QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize, // We explictly allow bool elements in ext_vector_type for C/C++. bool IsNoBoolVecLang = getLangOpts().OpenCL || getLangOpts().OpenCLCPlusPlus; if ((!T->isDependentType() && !T->isIntegerType() && - !T->isRealFloatingType()) || + !T->isRealFloatingType()) || T->isBitIntType() || (IsNoBoolVecLang && T->isBooleanType())) { Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T; return QualType(); diff --git a/clang/test/SemaCXX/ext-int.cpp b/clang/test/SemaCXX/ext-int.cpp index 5d4d8966cde2..72bbae65ace7 100644 --- a/clang/test/SemaCXX/ext-int.cpp +++ b/clang/test/SemaCXX/ext-int.cpp @@ -86,6 +86,8 @@ struct is_same<T,T> { // Reject vector types: // expected-error@+1{{invalid vector element type '_BitInt(32)'}} typedef _BitInt(32) __attribute__((vector_size(16))) VecTy; +// expected-error@+1{{invalid vector element type '_BitInt(32)'}} +typedef _BitInt(32) __attribute__((ext_vector_type(32))) OtherVecTy; // Allow _Complex: _Complex _BitInt(3) Cmplx; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits