<div dir="ltr">+static SourceLocation getDiagLoc(Declarator &D, SourceLocation Loc) {<br><div><br></div><div>This is a very generic name for quite a specific behavior. 'getMissingDeclaratorIdLoc' or similar?</div>
<div><br></div><div><br></div><div><div>+    if (Tok.is(tok::l_square)) {</div></div><div><br></div><div>Maybe factor this out into a separate function. 'ParseMisplacedBracketDeclarator' or similar?</div><div><br>
</div><div><br></div><div><div>+      SavedBracketInfo SavedInfo;</div><div>+      SourceLocation Loc = Tok.getLocation();</div><div>+</div><div>+      while (Tok.is(tok::l_square)) {</div><div>+        ParseBracketDeclarator(D, &SavedInfo);</div>
</div><div><br></div><div>Is it possible to handle this by parsing into a new Declarator here (and copying its chunks into D once we're done), instead of introducing a separate SavedBracketInfo code path into ParseBracketDeclarator?</div>
<div><br></div><div><br></div><div>+      // Something went wrong parsing the parens, in which case,<br></div><div>[...]</div><div>+      // Adding back the paren info to the end of the Declarator.<br></div><div><br></div>
<div>Please say "brackets" rather than "parens"; we're pretty consistent about using "parens" to mean () and not [].</div><div><br></div><div><br></div><div><div>+      SavedInfo->push_back(</div>
<div>+          {DeclaratorChunk::getArray(0, false, false, 0, T.getOpenLocation(),</div></div><div><br></div><div>MSVC doesn't support this syntax.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, May 13, 2014 at 3:44 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Switching to a recursive solution for misplaced brackets.  Upon seeing a bracket before the identifier, parse the brackets and store the info.  Call ParseDirectDeclarator again to continue parsing.  After that returns, attach the bracket info the Declarator and emit the misplaced bracket error with fix-it hint to move the brackets after the identifier.  Additionally, store the location of the beginning of the brackets so that other error messages may point to a better location.<br>

<div class="HOEnZb"><div class="h5"><br>
<a href="http://reviews.llvm.org/D2712" target="_blank">http://reviews.llvm.org/D2712</a><br>
<br>
Files:<br>
  include/clang/Basic/DiagnosticParseKinds.td<br>
  include/clang/Parse/Parser.h<br>
  lib/Parse/ParseDecl.cpp<br>
  test/Parser/brackets.c<br>
  test/Parser/brackets.cpp<br>
</div></div><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>