From: Jason Merrill Date: Thu, 13 Feb 2020 15:56:08 +0000 (+0100) Subject: c++: Fix useless using-declaration. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9a0c4f5b373e236cb4af5491f50862d41fd8775a;p=gcc.git c++: Fix useless using-declaration. Here reintroducing the same declarations into the global namespace via using-declaration is useless but OK. And a function and a function template with the same parameters do not conflict. gcc/cp/ChangeLog 2020-02-13 Jason Merrill PR c++/93713 * name-lookup.c (matching_fn_p): A function does not match a template. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8d7d91ce719..793e4afffcb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2020-02-13 Jason Merrill + PR c++/93713 + * name-lookup.c (matching_fn_p): A function does not match a + template. + PR c++/93643 PR c++/91476 * tree.c (decl_linkage): Always lk_none for locals. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 2a9bae53162..e5638d2df91 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -2321,12 +2321,14 @@ update_local_overload (cxx_binding *binding, tree newval) static bool matching_fn_p (tree one, tree two) { + if (TREE_CODE (one) != TREE_CODE (two)) + return false; + if (!compparms (TYPE_ARG_TYPES (TREE_TYPE (one)), TYPE_ARG_TYPES (TREE_TYPE (two)))) return false; - if (TREE_CODE (one) == TEMPLATE_DECL - && TREE_CODE (two) == TEMPLATE_DECL) + if (TREE_CODE (one) == TEMPLATE_DECL) { /* Compare template parms. */ if (!comp_template_parms (DECL_TEMPLATE_PARMS (one), diff --git a/gcc/testsuite/g++.dg/lookup/using62.C b/gcc/testsuite/g++.dg/lookup/using62.C new file mode 100644 index 00000000000..e7a952ace08 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using62.C @@ -0,0 +1,3 @@ +template T bar (); +void bar () {} +using :: bar;