Author: Zahira Ammarguellat Date: 2020-09-28T17:10:32-07:00 New Revision: efd04721c9a2a856dd47e47a08c42d21efd5dd2b
URL: https://github.com/llvm/llvm-project/commit/efd04721c9a2a856dd47e47a08c42d21efd5dd2b DIFF: https://github.com/llvm/llvm-project/commit/efd04721c9a2a856dd47e47a08c42d21efd5dd2b.diff LOG: BuildVectorType with a dependent (array) type is crashing the compiler - Fix for PR-47542 Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D88150 Added: Modified: clang/lib/Sema/SemaType.cpp clang/test/SemaCXX/attr-gnu.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index d8ea9c037259..b823c962f21d 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2517,9 +2517,10 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr, SourceLocation AttrLoc) { // The base type must be integer (not Boolean or enumeration) or float, and // can't already be a vector. - if (!CurType->isDependentType() && - (!CurType->isBuiltinType() || CurType->isBooleanType() || - (!CurType->isIntegerType() && !CurType->isRealFloatingType()))) { + if ((!CurType->isDependentType() && + (!CurType->isBuiltinType() || CurType->isBooleanType() || + (!CurType->isIntegerType() && !CurType->isRealFloatingType()))) || + CurType->isArrayType()) { Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType; return QualType(); } diff --git a/clang/test/SemaCXX/attr-gnu.cpp b/clang/test/SemaCXX/attr-gnu.cpp index 9eb42342df31..83e58bbcd5e2 100644 --- a/clang/test/SemaCXX/attr-gnu.cpp +++ b/clang/test/SemaCXX/attr-gnu.cpp @@ -12,6 +12,13 @@ void f() { void g(int a[static [[]] 5]); // expected-error {{static array size is a C99 feature, not permitted in C++}} +template<typename T> struct A { + int x[sizeof(T)] __attribute((vector_size(8))); // expected-error {{invalid vector element type 'int [sizeof(T)]'}} +}; + +typedef int myvect[4] __attribute__((vector_size(16))); // expected-error {{invalid vector element type 'int [4]'}} +void foo(myvect *in, myvect *out) { (*out)[0] = (*in)[0]; } + namespace { class B { public: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits