diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-06-30 17:53:26 +0100 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-09-12 12:09:44 -0400 |
commit | 8ef5fa4c56c82dfbd6e8fc5e4e08c4be843abc3e (patch) | |
tree | c1b43b01f3079e3a6f0667338a1152cfc80b0d4d /gcc/tree-ssa.cc | |
parent | 2e7bc76d84f0aa2f08bc01407ffcdca43c15f2ff (diff) | |
download | gcc-8ef5fa4c56c82dfbd6e8fc5e4e08c4be843abc3e.zip gcc-8ef5fa4c56c82dfbd6e8fc5e4e08c4be843abc3e.tar.gz gcc-8ef5fa4c56c82dfbd6e8fc5e4e08c4be843abc3e.tar.bz2 |
c++: Refer to internal linkage for -Wsubobject-linkage [PR86491]
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, if the type isn't actually a member of the anonymous namespace.
Making that distinction involved renaming the current decl_anon_ns_mem_p to
something that better expresses its semantics.
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.
PR c++/86491
gcc/cp/ChangeLog:
* decl2.cc (constrain_class_visibility): Adjust wording of
-Wsubobject-linkage for cases where anonymous
namespaces aren't used.
* tree.cc (decl_anon_ns_mem_p): Now only true for actual anonymous
namespace members, rename old semantics to...
(decl_internal_context_p): ...this.
* cp-tree.h, name-lookup.cc, pt.cc: Adjust.
gcc/testsuite/ChangeLog:
* g++.dg/warn/anonymous-namespace-3.C: Use separate dg-warning
directives for C++98 and everything else.
* g++.dg/warn/Wsubobject-linkage-5.C: New test.
Diffstat (limited to 'gcc/tree-ssa.cc')
0 files changed, 0 insertions, 0 deletions