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 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: