On Apr 15, 2011, at 11:58 AM, Richard Trieu wrote:
> When a valid expression is followed by a colon inside a switch scope, suggest
> a fix-it hint to insert a case before the expression.
>
> int f1(int i) {
> switch (i) {
> 0: return 1;
> default: return 0;
> }
> }
>
> case.cc:3:4: error: expected 'case' keyword before expression
> 0: return 1;
> ^
> case
Cool idea, but this...
+ // If a case statement is missing, then back-track to this point and
+ // insert case keyword.
+ Token OldToken = Tok;
+ TentativeParsingAction TPA(*this);
is a huge performance problem, since tentative parsing is expensive and should
be avoided except after an error occurs or when required by the language.
Is there a way to make this diagnostic kick in only when an error is imminent,
e.g., because we've seen <expression> ':' somewhere within a switch statement?
- Doug
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits