[PATCH] PR17337 - Retain previous linkage of friend function declarations

Richard Smith richard at metafoo.co.uk
Tue Sep 24 12:26:23 PDT 2013


FWIW, the standard's wording was clarified by core issue 564:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#564

Prior to this, it was less obvious that the redeclaration with a different
implied language linkage would have been an error (but it still was,
because the function /types/ are different, if nothing else).


On Tue, Sep 24, 2013 at 12:19 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> On Tue, Sep 24, 2013 at 9:14 AM, Alp Toker <alp at nuanti.com> wrote:
>
>>  gcc and MSVC both intentionally* retain the language linkage, and they
>> accept both test cases in the PR.
>>
>> I already explained in PR17337 why this special handling is important,
>> and it becomes more so in the face of nested language linkage
>> specifications:
>>
>>   http://llvm.org/bugs/show_bug.cgi?id=17337
>>
>> The previous release of clang correctly accepted the code, just like
>> every other C++ compiler, up until checking was added in r171139 / r181163
>> so this is a recent rejects-valid regression.
>>
>
> If you can explain, with references to the standard, why you think we
> should inherit the language linkage, then I'll agree. As far as I can see,
> other compilers are getting this wrong. EDG rejects the code, just like we
> do. g++ and MSVC are known to have weak implementations of the language
> linkage rules.
>
> clang r171139 states "The language linkage of redeclarations must match.
>> GCC was already reporting an error for this."
>>
>> If you don't feel comfortable reviewing this patch could you give others
>> a chance to take a look instead of marking the PR Invalid?
>>
>> * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41020
>>
>>
>>
>>
>>
>> On 24/09/2013 14:43, Richard Smith wrote:
>>
>> On Tue, Sep 24, 2013 at 3:00 AM, Alp Toker <alp at nuanti.com> wrote:
>>
>>> The previous language linkage needs to be retained as described in
>>> [class.friend]p3 otherwise valid friend redeclarations differing only in
>>> lexical linkage are rejected.
>>>
>>
>>  [class.friend]p3 says the previous linkage (internal/external/no
>> linkage) is retained, not the previous language linkage. Our current
>> behavior appears to be correct here.
>>
>>
>>> Fixes PR17337.
>>>
>>> --
>>> http://www.nuanti.com
>>> the browser experts
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>
>>>
>>
>> -- http://www.nuanti.com
>> the browser experts
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130924/31af94e9/attachment.html>


More information about the cfe-commits mailing list