* C++ PATCH to warn about undefined functions in anonymous namespace
@ 2013-06-10 19:37 Jason Merrill
2013-06-12 15:53 ` Gabriel Dos Reis
0 siblings, 1 reply; 2+ messages in thread
From: Jason Merrill @ 2013-06-10 19:37 UTC (permalink / raw)
To: gcc-patches List; +Cc: Gabriel Dos Reis
[-- Attachment #1: Type: text/plain, Size: 195 bytes --]
Since members of the anonymous namespace can't be defined in another
translation unit, we should treat them like statics for diagnostic purposes.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: anon-warn.patch --]
[-- Type: text/x-patch, Size: 1122 bytes --]
commit 815fbf1df6dafdbeb04a35827222d78c9b419219
Author: Jason Merrill <jason@redhat.com>
Date: Mon Jun 10 12:29:35 2013 -0400
* name-lookup.c (add_decl_to_level): Add decls in an anonymous
namespace to static_decls.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 17d5ca2..2b1f9fb 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -597,7 +597,9 @@ add_decl_to_level (tree decl, cp_binding_level *b)
if ((VAR_P (decl)
&& (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
|| (TREE_CODE (decl) == FUNCTION_DECL
- && (!TREE_PUBLIC (decl) || DECL_DECLARED_INLINE_P (decl))))
+ && (!TREE_PUBLIC (decl)
+ || decl_anon_ns_mem_p (decl)
+ || DECL_DECLARED_INLINE_P (decl))))
vec_safe_push (b->static_decls, decl);
}
}
diff --git a/gcc/testsuite/g++.dg/warn/anonymous-namespace-5.C b/gcc/testsuite/g++.dg/warn/anonymous-namespace-5.C
new file mode 100644
index 0000000..6f5a081
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/anonymous-namespace-5.C
@@ -0,0 +1,8 @@
+namespace {
+ void f(); // { dg-message "never defined" }
+}
+
+int main()
+{
+ f();
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ PATCH to warn about undefined functions in anonymous namespace
2013-06-10 19:37 C++ PATCH to warn about undefined functions in anonymous namespace Jason Merrill
@ 2013-06-12 15:53 ` Gabriel Dos Reis
0 siblings, 0 replies; 2+ messages in thread
From: Gabriel Dos Reis @ 2013-06-12 15:53 UTC (permalink / raw)
To: Jason Merrill, Andrew Sutton; +Cc: gcc-patches List
On Mon, Jun 10, 2013 at 2:37 PM, Jason Merrill <jason@redhat.com> wrote:
> Since members of the anonymous namespace can't be defined in another
> translation unit, we should treat them like statics for diagnostic purposes.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.
Thank you!
-- Gaby
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-12 15:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-10 19:37 C++ PATCH to warn about undefined functions in anonymous namespace Jason Merrill
2013-06-12 15:53 ` Gabriel Dos Reis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).