]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++/modules: Use decl_linkage in maybe_record_mergeable_decl
authorNathaniel Shead <nathanieloshead@gmail.com>
Tue, 3 Sep 2024 16:42:58 +0000 (02:42 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 27 Sep 2024 03:49:23 +0000 (13:49 +1000)
This avoids any possible inconsistencies (current or future) about
whether a declaration is internal or not.

gcc/cp/ChangeLog:

* name-lookup.cc (maybe_record_mergeable_decl): Use decl_linkage
instead of ad-hoc checks.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/name-lookup.cc

index 50e169eca43eadec4c43d59f47c5f24cccfc2c0d..c0f89f98d87e87e36cf9aae2ce7047cfcee2fc5e 100644 (file)
@@ -3725,17 +3725,10 @@ maybe_record_mergeable_decl (tree *slot, tree name, tree decl)
   if (TREE_CODE (*slot) != BINDING_VECTOR)
     return;
 
-  if (!TREE_PUBLIC (CP_DECL_CONTEXT (decl)))
-    /* Member of internal namespace.  */
+  if (decl_linkage (decl) == lk_internal)
     return;
 
   tree not_tmpl = STRIP_TEMPLATE (decl);
-  if ((TREE_CODE (not_tmpl) == FUNCTION_DECL
-       || VAR_P (not_tmpl))
-      && DECL_THIS_STATIC (not_tmpl))
-    /* Internal linkage.  */
-    return;
-
   bool is_attached = (DECL_LANG_SPECIFIC (not_tmpl)
                      && DECL_MODULE_ATTACH_P (not_tmpl));
   tree *gslot = get_fixed_binding_slot