Hi,<div><br></div><div>This patch needs a few more testcases (both positive and negative). I'd particularly like tests which cover the places where C++11 allows a braced initializer list, since you're using '{' as an indicator of not-an-assignment-expression.</div>
<div><br></div><div>Please make isNotExpressionStart be a static function local to ParseExpr.cpp, rather than a member of Parser.</div><div><br></div><div>Also, instead of replacing the ',' with a ';' and producing a diagnostic, please just leave the ',' in the token stream and bail out. This will allow the appropriate point higher up in the parser to produce the relevant diagnostic (which may not be to replace with a semicolon, depending on the context). This affects cases like "if (1, {".</div>
<div><br></div><div>You can avoid the EnterToken call by moving the check above the ConsumeToken call, and checking isNotExpressionStart(NextToken().getKind()).</div><div><br></div><div>Thanks!</div><div>Richard</div><div>
<br><div class="gmail_quote">On Sat, Sep 1, 2012 at 7:48 AM, Ahmed Bougacha <span dir="ltr"><<a href="mailto:ahmed.bougacha@gmail.com" target="_blank">ahmed.bougacha@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello, this small patch improves the diagnostic for a typo of ','<br>
instead of ';' at the end of a statement.<br>
<br>
% cat t.c<br>
int foo() {<br>
  return 42,<br>
}<br>
<br>
Now yields the following :<br>
<br>
% clang -fsyntax-only t.c<br>
t.c:2:12: error: expected ';' at end of statement<br>
  return 42,<br>
           ^<br>
           ;<br>
1 error generated.<br>
<br>
Whereas it previously led to :<br>
<br>
% clang -fsyntax-only t.c<br>
<br>
t.c:3:1: error: expected expression<br>
}<br>
^<br>
t.c:3:2: error: expected '}'<br>
}<br>
 ^<br>
t.c:1:11: note: to match this '{'<br>
int foo() {<br>
          ^<br>
2 errors generated.<br>
<br>
--<br>
Amaury de la Vieuville<br>
<span class="HOEnZb"><font color="#888888">Ahmed Bougacha<br>
</font></span><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>