re PR c++/35650 (Can't bind ref-to-function through using-decl. in namespace)
authorJakub Jelinek <jakub@redhat.com>
Tue, 29 Apr 2008 08:58:20 +0000 (10:58 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 29 Apr 2008 08:58:20 +0000 (10:58 +0200)
PR c++/35650
* parser.c (cp_parser_lookup_name): Look through single function
OVERLOAD.

* g++.dg/init/ref17.C: New test.

From-SVN: r134788

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/ref17.C [new file with mode: 0644]

index 15aa14ca4f057ca8cc536b8e5df8b6fea4d6cacd..bb4c4af0b4a5838acbdd4774e8accc14c0f5c364 100644 (file)
@@ -1,5 +1,9 @@
 2008-04-29  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/35650
+       * parser.c (cp_parser_lookup_name): Look through single function
+       OVERLOAD.
+
        PR c++/35987
        * typeck.c (cp_build_modify_expr) <case PREINCREMENT_EXPR>: Don't build
        COMPOUND_EXPR if the second argument would be error_mark_node.
index 21a762dc59ef7ae5d6d63cfaa03e1b99c2624bfb..a78e124a246aa0716f1d2046cdfec691570aa3e2 100644 (file)
@@ -16447,6 +16447,13 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
          decl = lookup_qualified_name (parser->scope, name,
                                        tag_type != none_type,
                                        /*complain=*/true);
+
+         /* If we have a single function from a using decl, pull it out.  */
+         if (decl
+             && TREE_CODE (decl) == OVERLOAD
+             && !really_overloaded_fn (decl))
+           decl = OVL_FUNCTION (decl);
+
          if (pushed_scope)
            pop_scope (pushed_scope);
        }
index 1154c105c9e68db3e024e980198764bdd446c1f5..d14a2cc5dc89e9d1e0d7788228be31d91c4ab1f6 100644 (file)
@@ -1,5 +1,8 @@
 2008-04-29  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/35650
+       * g++.dg/init/ref17.C: New test.
+
        PR c++/35987
        * g++.dg/other/error28.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/init/ref17.C b/gcc/testsuite/g++.dg/init/ref17.C
new file mode 100644 (file)
index 0000000..2c8c22b
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/35650
+// { dg-do compile }
+
+void f1 ();
+
+namespace N
+{
+  using::f1;
+  void f2 ();
+  void f3 ();
+}
+
+using N::f3;
+
+void
+test ()
+{
+  void (&a) () = f1;
+  void (&b) () = N::f1;
+  void (&c) () = N::f2;
+  void (&d) () = f3;
+  void (&e) () = ::f3;
+}