[PR c++/87155] Anonymous namespace and
authorNathan Sidwell <nathan@acm.org>
Fri, 31 Aug 2018 12:38:00 +0000 (12:38 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 31 Aug 2018 12:38:00 +0000 (12:38 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg02031.html
PR c++/87155
PR c++/84707
cp/
* name-lookup.c (name_lookup::search_namespace): Don't look at
inlines when searching for NULL names.
testsuite/
* g++.dg/cpp0x/pr87155.C: New.
* g++.dg/cpp0x/inline-ns10.C: Adjust.

From-SVN: r264016

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/inline-ns10.C
gcc/testsuite/g++.dg/cpp0x/pr87155.C [new file with mode: 0644]

index 0c5a4bf71c59ca7adcd2ca835d01ae2a92e28699..9e135b345351a4bc8030c388394d4f1dbeaecc7e 100644 (file)
@@ -1,5 +1,10 @@
 2018-08-31  Nathan Sidwell  <nathan@acm.org>
 
+       PR c++/87155
+       PR c++/84707
+       * name-lookup.c (name_lookup::search_namespace): Don't look at
+       inlines when searching for NULL names.
+
        * decl.c (decls_match): Remove SYSTEM_IMPLICIT_EXTERN_C matching
        of return types and parms.
        * parser.c (cp_parser_parameter_declaration_clause): Likewise,
index c0a12d746343a5c92f73d82ac66e1ec6526863dd..bb0a70e1877923d0f24fffb9d880c2426060bb97 100644 (file)
@@ -558,11 +558,14 @@ name_lookup::search_namespace (tree scope)
 
   /* Look in exactly namespace. */
   bool found = search_namespace_only (scope);
-  
-  /* Recursively look in its inline children.  */
-  if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
-    for (unsigned ix = inlinees->length (); ix--;)
-      found |= search_namespace ((*inlinees)[ix]);
+
+  /* Don't look into inline children, if we're looking for an
+     anonymous name -- it must be in the current scope, if anywhere.  */
+  if (name)
+    /* Recursively look in its inline children.  */
+    if (vec<tree, va_gc> *inlinees = DECL_NAMESPACE_INLINEES (scope))
+      for (unsigned ix = inlinees->length (); ix--;)
+       found |= search_namespace ((*inlinees)[ix]);
 
   if (found)
     mark_found (scope);
index ac3722a58ebfa6981e3e732c6ded9a0f08be3bab..a588e18871bb12a704de2d8c3e8e9c87a993fd2f 100644 (file)
@@ -1,3 +1,10 @@
+2018-08-31  Nathan Sidwell  <nathan@acm.org>
+
+       PR c++/87155
+       PR c++/84707
+       * g++.dg/cpp0x/pr87155.C: New.
+       * g++.dg/cpp0x/inline-ns10.C: Adjust.
+
 2018-08-31  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/87138
index 3ab425f7be4a8bec390304e60ad2cedff993dc9d..68e8034d4fddbf5785913594ad21db4d4c3a0ca6 100644 (file)
@@ -2,7 +2,10 @@
 // { dg-do compile { target c++11 } }
 
 inline namespace {
-  namespace {}
+        namespace {} // not this one
+        void a ();
 }
 
-namespace {} // { dg-error "conflicts" }
+namespace {
+  int a (); // { dg-error "ambiguating" "" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr87155.C b/gcc/testsuite/g++.dg/cpp0x/pr87155.C
new file mode 100644 (file)
index 0000000..7c7e8fb
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile { target c++11 } }
+// PR c++/87155 confused about which anon namespace
+
+namespace {
+  void a (); // this one
+}
+
+inline namespace n2 {
+        namespace {}
+} 
+
+namespace {
+  int a ();  // { dg-error "ambiguating" "" }
+}