зеркало из https://github.com/microsoft/clang.git
Don't allow taking the address of an element in an ext_vector
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64614 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
8e9dcb720b
Коммит
b104b1f6ca
|
@ -3485,10 +3485,10 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
|
|||
}
|
||||
}
|
||||
// Check for Apple extension for accessing vector components.
|
||||
} else if (isa<ArraySubscriptExpr>(op) &&
|
||||
cast<ArraySubscriptExpr>(op)->getBase()->getType()->isVectorType()) {
|
||||
} else if (isa<ExtVectorElementExpr>(op) || (isa<ArraySubscriptExpr>(op) &&
|
||||
cast<ArraySubscriptExpr>(op)->getBase()->getType()->isVectorType())){
|
||||
Diag(OpLoc, diag::err_typecheck_address_of)
|
||||
<< "vector" << op->getSourceRange();
|
||||
<< "vector element" << op->getSourceRange();
|
||||
return QualType();
|
||||
} else if (dcl) { // C99 6.5.3.2p1
|
||||
// We have an lvalue with a decl. Make sure the decl is not declared
|
||||
|
|
|
@ -28,9 +28,14 @@ void foo() {
|
|||
void testVectorComponentAccess() {
|
||||
typedef float v4sf __attribute__ ((vector_size (16)));
|
||||
static v4sf q;
|
||||
float* r = &q[0]; // expected-error {{address of vector requested}}
|
||||
float* r = &q[0]; // expected-error {{address of vector element requested}}
|
||||
}
|
||||
|
||||
typedef __attribute__(( ext_vector_type(4) )) float float4;
|
||||
|
||||
float *testExtVectorComponentAccess(float4 x) {
|
||||
return &x.w; // expected-error {{address of vector element requested}}
|
||||
}
|
||||
|
||||
void f0() {
|
||||
register int *x0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче