]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Note duplicates in symbol table [PR 99283]
authorNathan Sidwell <nathan@acm.org>
Tue, 23 Mar 2021 19:23:30 +0000 (12:23 -0700)
committerNathan Sidwell <nathan@acm.org>
Tue, 23 Mar 2021 19:29:14 +0000 (12:29 -0700)
I ran into this reducing 99283, we were failing to mark binding
vectors when the current TU declares a duplicate decl (as opposed to
an import introduces a duplicate).

PR c++/99283
gcc/cp/
* name-lookup.c (check_module_override): Set global or partition
DUP on the binding vector.
gcc/testsuite/
* g++.dg/modules/pr99283-1_a.H: New.
* g++.dg/modules/pr99283-1_b.H: New.

gcc/cp/name-lookup.c
gcc/testsuite/g++.dg/modules/pr99283-1_a.H [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr99283-1_b.H [new file with mode: 0644]

index a6257f5da32f61bdff9932d3be17f79df16d61ee..f4263f15f6203ce7016acf8e26ae6f292df6b95f 100644 (file)
@@ -3528,6 +3528,7 @@ static tree
 check_module_override (tree decl, tree mvec, bool hiding,
                       tree scope, tree name)
 {
+  tree match = NULL_TREE;
   bitmap imports = get_import_bitmap ();
   binding_cluster *cluster = BINDING_VECTOR_CLUSTER_BASE (mvec);
   unsigned ix = BINDING_VECTOR_NUM_CLUSTERS (mvec);
@@ -3566,13 +3567,15 @@ check_module_override (tree decl, tree mvec, bool hiding,
          bind = STAT_VISIBLE (bind);
 
        for (ovl_iterator iter (bind); iter; ++iter)
-         if (iter.using_p ())
-           ;
-         else if (tree match = duplicate_decls (decl, *iter, hiding))
-           return match;
+         if (!iter.using_p ())
+           {
+             match = duplicate_decls (decl, *iter, hiding);
+             if (match)
+               goto matched;
+           }
       }
 
-  if (TREE_PUBLIC (scope) && TREE_PUBLIC (decl) && !not_module_p ()
+  if (TREE_PUBLIC (scope) && TREE_PUBLIC (STRIP_TEMPLATE (decl))
       /* Namespaces are dealt with specially in
         make_namespace_finish.  */
       && !(TREE_CODE (decl) == NAMESPACE_DECL && !DECL_NAMESPACE_ALIAS (decl)))
@@ -3588,14 +3591,26 @@ check_module_override (tree decl, tree mvec, bool hiding,
 
       for (ovl_iterator iter (mergeable); iter; ++iter)
        {
-         tree match = *iter;
-         
-         if (duplicate_decls (decl, match, hiding))
-           return match;
+         match = duplicate_decls (decl, *iter, hiding);
+         if (match)
+           goto matched;
        }
     }
 
   return NULL_TREE;
+
+ matched:
+  if (match != error_mark_node)
+    {
+      if (named_module_p ())
+       BINDING_VECTOR_PARTITION_DUPS_P (mvec) = true;
+      else
+       BINDING_VECTOR_GLOBAL_DUPS_P (mvec) = true;
+    }
+
+  return match;
+
+  
 }
 
 /* Record DECL as belonging to the current lexical scope.  Check for
diff --git a/gcc/testsuite/g++.dg/modules/pr99283-1_a.H b/gcc/testsuite/g++.dg/modules/pr99283-1_a.H
new file mode 100644 (file)
index 0000000..95c8c06
--- /dev/null
@@ -0,0 +1,6 @@
+// PR 99283 part 1 ICE on specialization
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+
+template<typename _Facet>
+_Facet &use_facet ();
diff --git a/gcc/testsuite/g++.dg/modules/pr99283-1_b.H b/gcc/testsuite/g++.dg/modules/pr99283-1_b.H
new file mode 100644 (file)
index 0000000..cd15a1b
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+
+import  "pr99283-1_a.H";
+
+template<typename _Facet>
+_Facet &use_facet ();
+
+extern template
+char &use_facet<char> ();