diff options
author | Nathan Sidwell <nathan@acm.org> | 2021-03-23 12:23:30 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2021-03-23 12:29:14 -0700 |
commit | bd71889b9017751e1a06970d20b28b9fe9479bdc (patch) | |
tree | b5e5818717b8f8f1542e8489ce7e4e6b3bab4e1b /gcc/cp/name-lookup.c | |
parent | b61461ac7f9bdd0e98145be79423d19b933afaa0 (diff) | |
download | gcc-bd71889b9017751e1a06970d20b28b9fe9479bdc.zip gcc-bd71889b9017751e1a06970d20b28b9fe9479bdc.tar.gz gcc-bd71889b9017751e1a06970d20b28b9fe9479bdc.tar.bz2 |
c++: Note duplicates in symbol table [PR 99283]
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.
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r-- | gcc/cp/name-lookup.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index a6257f5..f4263f1 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -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 |