Oops, failed to CC the list. -------- Forwarded Message -------- Subject: Re: [PATCH] c++: Refer to internal linkage for -Wsubobject-linkage [PR86491] Date: Mon, 12 Sep 2022 12:09:38 -0400 From: Jason Merrill To: Jonathan Wakely On 7/23/22 07:31, Jonathan Wakely wrote: > I'll try that on Monday, thanks! > > On Fri, 22 Jul 2022 at 22:30, Jason Merrill wrote: >> >> On 6/30/22 12:53, Jonathan Wakely via Gcc-patches wrote: >>> Tested powerpc64le-linux, OK for trunk? >>> >>> -- >8 -- >>> >>> Since C++11 relaxed the requirement for template arguments to have >>> external linkage, it's possible to get -Wsubobject-linkage warnings >>> without using any anonymous namespaces. This confuses users when they >>> get diagnostics that refer to an anonymous namespace that doesn't exist >>> in their code. >>> >>> This changes the diagnostic to say "has internal linkage" for C++11 and >>> later, which is accurate whether internal linkage is due to the 'static' >>> specifier, or due to the use of anonymous namespaces. >>> >>> For C++98 template arguments declared with 'static' are ill-formed >>> anyway, so the only way this warning can arise is via anonymous >>> namespaces. That means the existing wording is accurate for C++98 and so >>> we can keep it. >> >> I'd prefer to keep the existing wording for types that are actually in >> an anonymous namespace. Checking decl_anon_ns_mem_p seems like the way >> to do that, though it would probably need to remove the existing type >> shortcut and instead just do decl = TYPE_MAIN_DECL (decl). I decided to follow up on this myself, and ended up renaming the current function as other users relied on its semantics. Tested x86_64-pc-linux-gnu, applying to trunk.