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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Sep 25 06:23:10 PDT 2013

> I'll also explain the reasoning behind our implementation, which is
> borne of practical needs as much as correctness:
> Language linkage specifications can only appear at namespace scope
> ([dcl.link]p4).
> So this is invalid:
> class ... {
>   friend extern "C" int bar(Foo *y);
> };
> Therefore pre-declaring the desired language linkage and retaining it in
> the friend declaration is the _only_ way to implement a friend function
> with different language linkage to its declaration context.

I think I agree. Even if this is not standard compliant, it seems a
useful gcc/msvc extension and less crazy than other extensions we

Richard, do you see a case where supporting this extension (assuming
it is one) would break standard conformant code?


More information about the cfe-commits mailing list