diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4080,9 +4080,10 @@ /// getExtVectorType - Return the unique reference to an extended vector type of /// the specified element type and size. VectorType must be a built-in type. -QualType -ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) const { - assert(vecType->isBuiltinType() || vecType->isDependentType()); +QualType ASTContext::getExtVectorType(QualType vecType, + unsigned NumElts) const { + assert(vecType->isBuiltinType() || vecType->isDependentType() || + vecType->isBitIntType()); // Check if we've already instantiated a vector of this type. llvm::FoldingSetNodeID ID; diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2707,7 +2707,7 @@ // 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->isBitIntType() || + !T->isRealFloatingType()) || (IsNoBoolVecLang && T->isBooleanType())) { Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << T; return QualType(); diff --git a/clang/test/Sema/builtin-classify-type.c b/clang/test/Sema/builtin-classify-type.c --- a/clang/test/Sema/builtin-classify-type.c +++ b/clang/test/Sema/builtin-classify-type.c @@ -29,6 +29,8 @@ __attribute__((vector_size(16))) int vec; typedef __attribute__((ext_vector_type(4))) int evec_t; evec_t evec; + typedef _BitInt(16) int16_t3 __attribute__((ext_vector_type(3))); + int16_t3 t3; _Atomic int atomic_i; _Atomic double atomic_d; _Complex int complex_i; diff --git a/clang/test/SemaCXX/ext-int.cpp b/clang/test/SemaCXX/ext-int.cpp --- a/clang/test/SemaCXX/ext-int.cpp +++ b/clang/test/SemaCXX/ext-int.cpp @@ -83,11 +83,6 @@ static constexpr bool value = true; }; -// 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;