<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 4, 2014 at 9:17 AM, Faisal Vali <span dir="ltr"><<a href="mailto:faisalv@yahoo.com" target="_blank">faisalv@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi rsmith, krememek,<br>
<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=19339" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=19339</a><br>
<br>
Here is a reduced test case:<br>
<br>
struct Foo {<br>
template<class T> Foo(T) {}<br>
};<br>
<br>
Foo f3 { [i{0}]{} };<br>
<br>
The Parser gets confused in bool Parser::MayBeDesignationStart() in trying to distinguish between a lambda or a designated initializer when parsing<br>
[i{0}]<br>
<br>
FYI: Sema does not yet implement (recently voted into C++14? or is it C++17 I forget) the proper deduction for one element in a brace initializer yet.<br></blockquote><div><br></div><div>It's not been voted into anything yet, but I agree we should probably go ahead with this sooner rather than later.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
This is a very cursory rough stab (includes a use of goto) at addressing this - just to draw attention to where i think the problem lies. I will leave it to those who grok the Parser better than me to either help me refine it - or conjure up their own fix.<br>
</blockquote><br>I fixed it by changing it to reuse the correct lambda recognition code we already have elsewhere (rather than inventing its own disambiguation logic), in r206128.<br> <br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<a href="http://llvm-reviews.chandlerc.com/D3290" target="_blank">http://llvm-reviews.chandlerc.com/D3290</a><br>
<br>
Files:<br>
lib/Parse/ParseInit.cpp<br>
<br>
Index: lib/Parse/ParseInit.cpp<br>
===================================================================<br>
--- lib/Parse/ParseInit.cpp<br>
+++ lib/Parse/ParseInit.cpp<br>
@@ -75,11 +75,24 @@<br>
case tok::amp:<br>
case tok::identifier:<br>
case tok::kw_this:<br>
+ case tok::numeric_constant:<br>
// These tokens can occur in a capture list or a constant-expression.<br>
// Keep looking.<br>
ConsumeToken();<br>
continue;<br>
-<br>
+<br>
+ case tok::l_brace:<br>
+ case tok::r_brace:<br>
+ if (PP.getLangOpts().CPlusPlus11) {<br>
+ // These tokens can occur in a capture list or a constant-expression.<br>
+ // Keep looking.<br>
+ // Vec{[i{0}]() { }};<br>
+ // int a[10] = { [Literal{}] = 3, 4 };<br>
+ ConsumeBrace();<br>
+ continue;<br>
+ } else {<br>
+ goto default_label;<br>
+ }<br>
case tok::comma:<br>
// Since a comma cannot occur in a constant-expression, this must<br>
// be a lambda.<br>
@@ -99,11 +112,13 @@<br>
}<br>
<br>
default:<br>
+ default_label:<br>
// Anything else cannot occur in a lambda capture list, so it<br>
// must be a designator.<br>
Tentative.Revert();<br>
return true;<br>
}<br>
+<br>
}<br>
}<br>
</blockquote></div><br></div></div>