From: Jakub Jelinek Date: Tue, 29 Apr 2008 08:58:20 +0000 (+0200) Subject: re PR c++/35650 (Can't bind ref-to-function through using-decl. in namespace) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=58627576a491184e918c0e1d49966ad316b1ecd8;p=gcc.git re PR c++/35650 (Can't bind ref-to-function through using-decl. in namespace) PR c++/35650 * parser.c (cp_parser_lookup_name): Look through single function OVERLOAD. * g++.dg/init/ref17.C: New test. From-SVN: r134788 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 15aa14ca4f0..bb4c4af0b4a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2008-04-29 Jakub Jelinek + PR c++/35650 + * parser.c (cp_parser_lookup_name): Look through single function + OVERLOAD. + PR c++/35987 * typeck.c (cp_build_modify_expr) : Don't build COMPOUND_EXPR if the second argument would be error_mark_node. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 21a762dc59e..a78e124a246 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1154c105c9e..d14a2cc5dc8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2008-04-29 Jakub Jelinek + 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 index 00000000000..2c8c22b8d88 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/ref17.C @@ -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; +}