[PATCH] Improve diagnostic message for misplaced square brackets
Richard Smith
richard at metafoo.co.uk
Thu May 22 17:12:27 PDT 2014
+static SourceLocation getDiagLoc(Declarator &D, SourceLocation Loc) {
This is a very generic name for quite a specific behavior.
'getMissingDeclaratorIdLoc' or similar?
+ if (Tok.is(tok::l_square)) {
Maybe factor this out into a separate function.
'ParseMisplacedBracketDeclarator' or similar?
+ SavedBracketInfo SavedInfo;
+ SourceLocation Loc = Tok.getLocation();
+
+ while (Tok.is(tok::l_square)) {
+ ParseBracketDeclarator(D, &SavedInfo);
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?
+ // Something went wrong parsing the parens, in which case,
[...]
+ // Adding back the paren info to the end of the Declarator.
Please say "brackets" rather than "parens"; we're pretty consistent about
using "parens" to mean () and not [].
+ SavedInfo->push_back(
+ {DeclaratorChunk::getArray(0, false, false, 0,
T.getOpenLocation(),
MSVC doesn't support this syntax.
http://reviews.llvm.org/D2712
More information about the cfe-commits
mailing list