<div>On Wed Jan 29 2014 at 3:05:34 PM, John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Jan 29, 2014, at 8:45 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br>
> When we see the class definition, we already have to cache the tokens in member functions until we hit the close brace. It doesn't seem too hard or expensive to look ahead and see if we have a typedef name for linkage purposes if the class is anonymous and is preceded or followed by typedef.<br>
<br>
I don’t think we can actually tentatively parse declarators. Remember that we might have something like<br>
<br>
typedef struct { … } (*FnType)(), (*ArrayType)[sizeof(decltype(<u></u>declval<FnType>()()))], StructType;<br>
<br>
because C++ is dumb.<br>
<br>
But obviously we could recognize some simple cases and limit the damage of my proposed diagnostic.<br></blockquote><div><br></div><div>Your example doesn't seem to show a problem (since we're just looking to see if there's any declarator with nothing more interesting than parens around the declarator-id). I can imagine trouble with something like this, though:</div>
<div><br></div><div>typedef struct { ... } *A, X<Y<A>::Z < Q>::*foo, S;</div><div><br></div><div>(because we don't know if the < after 'Z' begins a template-argument-list or not). Yes, this may be infeasible.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Can this go wrong in any non-delay-parsed context?<br>
<br>
‘this’ is legal in some non-delay-parsed contexts, namely trailing result types.<br>
<br>
Do you have any objection to adopting my proposed diagnostic as a semi-temporary fix? All the code it would affect currently triggers an assertion, and frankly it feels like a “real” fix here would require a pretty disproportionate amount of effort for the expected benefit.</blockquote>
<div><br></div><div>I'm fine with it right up until people start filing bugs saying we broke them ;-)</div><div><br></div><div>Honestly, I think your approach of a diagnostic in this case is not only reasonable, it's a reasonable thing to propose as a DR, assuming it doesn't break the world.</div>