forked from OSchip/llvm-project
BuildVectorType with a dependent (array) type is crashing the compiler - Fix for PR-47542
Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D88150
This commit is contained in:
parent
54d9f743c8
commit
efd04721c9
|
@ -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() &&
|
||||
if ((!CurType->isDependentType() &&
|
||||
(!CurType->isBuiltinType() || CurType->isBooleanType() ||
|
||||
(!CurType->isIntegerType() && !CurType->isRealFloatingType()))) {
|
||||
(!CurType->isIntegerType() && !CurType->isRealFloatingType()))) ||
|
||||
CurType->isArrayType()) {
|
||||
Diag(AttrLoc, diag::err_attribute_invalid_vector_type) << CurType;
|
||||
return QualType();
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue