[cfe-commits] r156503 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/Parser/altivec.c test/SemaCXX/altivec.cpp

Richard Smith richard-llvm at metafoo.co.uk
Wed May 9 11:56:44 PDT 2012


Author: rsmith
Date: Wed May  9 13:56:43 2012
New Revision: 156503

URL: http://llvm.org/viewvc/llvm-project?rev=156503&view=rev
Log:
Stop AltiVec parsing from going down the 'implicit int' codepath as part of its
normal parse for token sequences like 'vector pixel foo'. This incidentally also
fixes a couple of wrong-parse issues.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/Parser/altivec.c
    cfe/trunk/test/SemaCXX/altivec.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=156503&r1=156502&r2=156503&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed May  9 13:56:43 2012
@@ -1921,7 +1921,7 @@
       continue;
 
     case tok::annot_cxxscope: {
-      if (DS.hasTypeSpecifier())
+      if (DS.hasTypeSpecifier() || DS.isTypeAltiVecVector())
         goto DoneWithDeclSpec;
 
       CXXScopeSpec SS;
@@ -2119,6 +2119,11 @@
       if (TryAltiVecToken(DS, Loc, PrevSpec, DiagID, isInvalid))
         break;
 
+      // [AltiVec] 2.2: [If the 'vector' specifier is used] The syntax does not
+      //                allow the use of a typedef name as a type specifier.
+      if (DS.isTypeAltiVecVector())
+        goto DoneWithDeclSpec;
+
       ParsedType TypeRep =
         Actions.getTypeName(*Tok.getIdentifierInfo(),
                             Tok.getLocation(), getCurScope());

Modified: cfe/trunk/test/Parser/altivec.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/altivec.c?rev=156503&r1=156502&r2=156503&view=diff
==============================================================================
--- cfe/trunk/test/Parser/altivec.c (original)
+++ cfe/trunk/test/Parser/altivec.c Wed May  9 13:56:43 2012
@@ -76,6 +76,16 @@
 vector bool long v_bl;               // expected-error {{cannot use 'long' with '__vector bool'}}
 vector bool long long v_bll;         // expected-error {{cannot use 'long long' with '__vector bool'}}
 
+typedef char i8;
+typedef short i16;
+typedef int i32;
+struct S {
+  // i8, i16, i32 here are field names, not type names.
+  vector bool i8;                    // expected-error {{requires a specifier or qualifier}}
+  vector pixel i16;
+  vector long i32;                   // expected-warning {{deprecated}}
+};
+
 void f() {
   __vector unsigned int v = {0,0,0,0};
   __vector int v__cast = (__vector int)v;

Modified: cfe/trunk/test/SemaCXX/altivec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/altivec.cpp?rev=156503&r1=156502&r2=156503&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/altivec.cpp (original)
+++ cfe/trunk/test/SemaCXX/altivec.cpp Wed May  9 13:56:43 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -verify %s
+// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -fcxx-exceptions -verify %s
 
 typedef int V4i __attribute__((vector_size(16)));
 
@@ -76,3 +76,8 @@
   vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}}
   vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}}
 }
+
+void f() {
+  try {}
+  catch (vector pixel px) {}
+};





More information about the cfe-commits mailing list