[cfe-commits] C++0x Attributes Patch - INCOMPLETE

Argyris Kyrtzidis akyrtzi at gmail.com
Sun Sep 13 02:17:56 PDT 2009


Hi Sean,

+bool Parser::isCXX0XAttributeSpecifier (tok::TokenKind *After) {
+  struct TentativeReverter {
+    TentativeParsingAction PA;
+
+    TentativeReverter (Parser& P)
+      : PA(P)
+    {}
+    ~TentativeReverter () {
+      PA.Revert();
+    }
+  } R(*this);
+
+  if (Tok.isNot(tok::l_square))
+    return false;
+  ConsumeBracket();
+  if (Tok.isNot(tok::l_square))
+    return false;
+  ConsumeBracket();
+
+  SkipUntil(tok::r_square, false);
+
+  if (Tok.isNot(tok::r_square))
+    return false;
+  ConsumeBracket();
+
+  if (After)
+    *After = Tok.getKind();
+
+  return true;
+}

Why do we need to verify that ']]' follows '[[', isn't it enough for  
isCXX0XAttributeSpecifier to just return true if the current tokens  
are '[[' ?

The latter will fix:

+/// FIXME: If an error is in the closing ]] brackets, the program  
assumes
+/// the absence of an attribute-specifier, which causes very yucky  
errors
+/// to occur.

Since an error in closing ]] brackets will happen in the context of  
attribute parsing and we'll get something like "expected ']]' for  
attribute".

-Argiris



More information about the cfe-commits mailing list