* name-lookup.c (add_decl_to_level): Add decls in an anonymous
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Jun 2013 19:38:42 +0000 (19:38 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 10 Jun 2013 19:38:42 +0000 (19:38 +0000)
namespace to static_decls.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199906 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/warn/anonymous-namespace-5.C [new file with mode: 0644]

index ebf7179..0245153 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-10  Jason Merrill  <jason@redhat.com>
+
+       * name-lookup.c (add_decl_to_level): Add decls in an anonymous
+       namespace to static_decls.
+
 2013-06-07  Sriraman Tallam  <tmsriram@google.com>
 
        PR c++/57548
index 17d5ca2..2b1f9fb 100644 (file)
@@ -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 (file)
index 0000000..6f5a081
--- /dev/null
@@ -0,0 +1,8 @@
+namespace {
+  void f();                    // { dg-message "never defined" }
+}
+
+int main()
+{
+  f();
+}