<div dir="ltr">Problem solved. r184577. <div style>I hope I got everything right. </div><div style>Thanks,</div><div style>-- Larisse.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 19, 2013 at 2:17 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Jun 19, 2013, at 2:12 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>


> On Wed, Jun 19, 2013 at 11:42 AM, John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:<br>
>> On Jun 19, 2013, at 10:59 AM, Larisse Voufo <<a href="mailto:lvoufo@google.com">lvoufo@google.com</a>> wrote:<br>
>><br>
>> On Wed, Jun 19, 2013 at 10:43 AM, John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:<br>
>>><br>
>>> On Jun 19, 2013, at 9:15 AM, Larisse Voufo <<a href="mailto:lvoufo@google.com">lvoufo@google.com</a>> wrote:<br>
>>>> Just out of curiosity, I have noticed that Clang currently allows the<br>
>>>> following program:<br>
>>>><br>
>>>> template<typename T> T f() { return 13; }<br>
>>>> template int f() { return 1; }<br>
>>>><br>
>>>> It essentially parses the body of the explicit instantiation only to<br>
>>>> ignore it.<br>
>>>> Was this a conscious decision?<br>
>><br>
>><br>
>> I just spoke to Richard Smith about this, and it appears that the current<br>
>> behavior is a bit different from the way I just described it above.<br>
>> The declaration for the template instantiation is parsed, but the 'template'<br>
>> keyword is ignored, which leads to two different behaviors for the calls f()<br>
>> and f<int>().<br>
>> While f() returns 1, f<int>() returns 13. f() picks up the declaration "int<br>
>> f() { return 1; }" while f<int>() picks up the template declaration and<br>
>> implicitly instantiates it.<br>
>><br>
>>><br>
>>><br>
>>> No;  please file a bug.  You cannot define a function in an explicit<br>
>>> instantiation.<br>
>><br>
>><br>
>> I can quickly fix this or submit a patch. Should I still file a bug?<br>
>><br>
>><br>
>> Fixing it is better. :)<br>
>><br>
>>>> GCC 4.6.3 rejects the program with "expected ‘;’ before ‘{’ token".<br>
>>><br>
>>> Well, hopefully we can do better than that.<br>
>><br>
>><br>
>> What do you have in mind?<br>
>><br>
>><br>
>> "error: cannot implement a function in an explicit instantiation"<br>
>><br>
>> or something along those lines.<br>
><br>
> My suggestion was:<br>
> * If the declarator-id is not a template-id, issue a "function cannot<br>
> be defined in an explicit instantiation" diagnostic and recover by<br>
> ignoring the 'template' keyword<br>
> * If the declarator-id is a template-id, issue an "explicit<br>
> specialization requires 'template<>'" diagnostic with a fixit to add<br>
> the <>, and recover as if it were an explicit specialization<br>
<br>
</div></div>Ah, yes, I wasn't thinking about the different recovery paths.<br>
Good point.<br>
<span class="HOEnZb"><font color="#888888"><br>
John.</font></span></blockquote></div><br></div>