Message ID | 66f1fd5c.050a0220.7f01c.0345@mx.google.com |
---|---|
State | New |
Headers | show |
Series | c++/modules: Implement P1815 "Translation-unit-local entities" | expand |
On 9/23/24 7:44 PM, Nathaniel Shead wrote: > I don't currently have any testcases where this changes something, but I felt > it to be a valuable cleanup. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? OK. > -- >8 -- > > 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> > --- > gcc/cp/name-lookup.cc | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc > index 50e169eca43..c0f89f98d87 100644 > --- a/gcc/cp/name-lookup.cc > +++ b/gcc/cp/name-lookup.cc > @@ -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
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 50e169eca43..c0f89f98d87 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -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
I don't currently have any testcases where this changes something, but I felt it to be a valuable cleanup. Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk? -- >8 -- 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> --- gcc/cp/name-lookup.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)