[cfe-commits] r57108 - in /cfe/trunk: lib/Parse/ParseTentative.cpp test/SemaCXX/decl-expr-ambiguity.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Sun Oct 5 07:27:20 PDT 2008


Author: akirtzidis
Date: Sun Oct  5 09:27:18 2008
New Revision: 57108

URL: http://llvm.org/viewvc/llvm-project?rev=57108&view=rev
Log:
Consider GNU attributes when doing ambiguity resolution.

Modified:
    cfe/trunk/lib/Parse/ParseTentative.cpp
    cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=57108&r1=57107&r2=57108&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Sun Oct  5 09:27:18 2008
@@ -164,12 +164,13 @@
   return TPR_ambiguous;
 }
 
-/// init-declarator-list:
-///   init-declarator
-///   init-declarator-list ',' init-declarator
-///
-/// init-declarator:
-///   declarator initializer[opt]
+///       init-declarator-list:
+///         init-declarator
+///         init-declarator-list ',' init-declarator
+///
+///       init-declarator:
+///         declarator initializer[opt]
+/// [GNU]   declarator simple-asm-expr[opt] attributes[opt] initializer[opt]
 ///
 /// initializer:
 ///   '=' initializer-clause
@@ -195,6 +196,10 @@
     if (TPR != TPR_ambiguous)
       return TPR;
 
+    // [GNU] simple-asm-expr[opt] attributes[opt]
+    if (Tok.is(tok::kw_asm) || Tok.is(tok::kw___attribute))
+      return TPR_true;
+
     // initializer[opt]
     if (Tok.is(tok::l_paren)) {
       // Parse through the parens.
@@ -230,6 +235,7 @@
 ///                 cv-qualifier-seq[opt] exception-specification[opt]
 ///           direct-declarator '[' constant-expression[opt] ']'
 ///           '(' declarator ')'
+/// [GNU]     '(' attributes declarator ')'
 ///
 ///         abstract-declarator:
 ///           ptr-operator abstract-declarator[opt]
@@ -302,8 +308,11 @@
         return TPR;
     } else {
       // '(' declarator ')'
+      // '(' attributes declarator ')'
       // '(' abstract-declarator ')'
-     ConsumeParen();
+      ConsumeParen();
+      if (Tok.is(tok::kw___attribute))
+        return TPR_true; // attributes indicate declaration
       TentativeParsingResult TPR = TryParseDeclarator(mayBeAbstract);
       if (TPR != TPR_ambiguous)
         return TPR;

Modified: cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp?rev=57108&r1=57107&r2=57108&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp (original)
+++ cfe/trunk/test/SemaCXX/decl-expr-ambiguity.cpp Sun Oct  5 09:27:18 2008
@@ -17,4 +17,5 @@
   T(d)[5]; // expected-warning {{statement was disambiguated as declaration}} expected-error {{redefinition of 'd'}}
   typeof(int[])(f) = { 1, 2 }; // expected-warning {{statement was disambiguated as declaration}}
   void(b)(int);
+  int(d2) __attribute__(()); // expected-warning {{statement was disambiguated as declaration}}
 }





More information about the cfe-commits mailing list