[PATCH] Suggest fix-it for missing '{' after base-clause
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Mon Aug 11 11:05:42 PDT 2014
Hi rsmith, rtrieu,
Suggest fix-it for missing '{' after base-clause, and try to recover.
http://reviews.llvm.org/D4848
Files:
lib/Parse/ParseDeclCXX.cpp
test/FixIt/fixit.cpp
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2597,11 +2597,12 @@
ParseBaseClause(TagDecl);
if (!Tok.is(tok::l_brace)) {
- Diag(Tok, diag::err_expected_lbrace_after_base_specifiers);
-
- if (TagDecl)
- Actions.ActOnTagDefinitionError(getCurScope(), TagDecl);
- return;
+ SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
+ Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers)
+ << FixItHint::CreateInsertion(BraceLoc, "{");
+ // Try recovering from missing { after base-clause.
+ PP.EnterToken(Tok);
+ Tok.setKind(tok::l_brace);
}
}
Index: test/FixIt/fixit.cpp
===================================================================
--- test/FixIt/fixit.cpp
+++ test/FixIt/fixit.cpp
@@ -340,3 +340,11 @@
return c->a; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; maybe you meant to use '.'?}}
}
}
+
+namespace curly_after_base_clause {
+struct A { };
+struct B : A // expected-error{{expected '{' after base class list}}
+ // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:"{"
+ int i;
+};
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4848.12355.patch
Type: text/x-patch
Size: 1266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140811/b3dc18ec/attachment.bin>
More information about the cfe-commits
mailing list