<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 12, 2015 at 9:28 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Mon Jan 12 23:28:24 2015<br>
New Revision: 225768<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=225768&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=225768&view=rev</a><br>
Log:<br>
Parse: Don't crash if missing an initializer expression<br>
<br>
Modified:<br>
    cfe/trunk/lib/Parse/ParseDecl.cpp<br>
    cfe/trunk/test/Parser/cxx-default-args.cpp<br>
<br>
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=225768&r1=225767&r2=225768&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=225768&r1=225767&r2=225768&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)<br>
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Jan 12 23:28:24 2015<br>
@@ -5625,13 +5625,14 @@ void Parser::ParseParameterDeclarationCl<br>
           // FIXME: Can we use a smart pointer for Toks?<br>
           DefArgToks = new CachedTokens;<br>
<br>
+          SourceLocation ArgStartLoc = NextToken().getLocation();<br>
           if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {<br>
             delete DefArgToks;<br>
             DefArgToks = nullptr;<br>
             Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);<br></blockquote><div><br></div><div>Shouldn't your test case go down this path?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
           } else {<br>
             Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,<br>
-                                                (*DefArgToks)[1].getLocation());<br>
+                                                      ArgStartLoc);<br>
           }<br>
         } else {<br>
           // Consume the '='.<br>
<br>
Modified: cfe/trunk/test/Parser/cxx-default-args.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-default-args.cpp?rev=225768&r1=225767&r2=225768&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-default-args.cpp?rev=225768&r1=225767&r2=225768&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Parser/cxx-default-args.cpp (original)<br>
+++ cfe/trunk/test/Parser/cxx-default-args.cpp Mon Jan 12 23:28:24 2015<br>
@@ -36,3 +36,7 @@ struct T {<br>
 struct S {<br>
   void f(int &r = error);  // expected-error {{use of undeclared identifier 'error'}}<br>
 };<br>
+<br>
+struct U {<br>
+  void i(int x = ) {} // expected-error{{expected expression}}<br>
+};<br>
<br>
<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>
</blockquote></div><br></div></div>