Author: sampo
Date: Sun Feb 15 16:45:20 2009
New Revision: 64614

URL: http://llvm.org/viewvc/llvm-project?rev=64614&view=rev
Log:
Don't allow taking the address of an element in an ext_vector

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/expr-address-of.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=64614&r1=64613&r2=64614&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Feb 15 16:45:20 2009
@@ -3485,10 +3485,10 @@
       }
     }
   // 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 

Modified: cfe/trunk/test/Sema/expr-address-of.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/expr-address-of.c?rev=64614&r1=64613&r2=64614&view=diff

==============================================================================
--- cfe/trunk/test/Sema/expr-address-of.c (original)
+++ cfe/trunk/test/Sema/expr-address-of.c Sun Feb 15 16:45:20 2009
@@ -28,9 +28,14 @@
 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;


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to