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.

Tested x86_64-pc-linux-gnu, applying to trunk.

gcc/cp/ChangeLog
2020-02-13  Jason Merrill  <ja...@redhat.com>

        PR c++/93713
        * name-lookup.c (matching_fn_p): A function does not match a
        template.
---
 gcc/cp/name-lookup.c                  | 6 ++++--
 gcc/testsuite/g++.dg/lookup/using62.C | 3 +++
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/lookup/using62.C

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 <class T> T bar ();
+void bar () {}
+using :: bar;

base-commit: 613c932f5e5c0cc2e4b88e21d9870fa7b1a6ce5d
-- 
2.18.1

Reply via email to