From: Paolo Carlini Date: Sat, 16 Nov 2013 09:54:42 +0000 (+0000) Subject: re PR c++/29143 (address-of overloaded function does not work in function call) X-Git-Tag: releases/gcc-4.9.0~2739 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53677b17cb887acaa488fe9b011424a657f1697c;p=thirdparty%2Fgcc.git re PR c++/29143 (address-of overloaded function does not work in function call) /cp 2013-11-16 Paolo Carlini PR c++/29143 * semantics.c (finish_call_expr): Ensure that for OVERLOADs too '(&f)(...)' is the same as '(f)(...)', per 13.3.1.1. /testsuite 2013-11-16 Paolo Carlini PR c++/29143 * g++.dg/overload/addr2.C: New. * g++.old-deja/g++.other/overload11.C: Adjust. From-SVN: r204899 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2a16220dda21..5f52d9047f33 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-11-16 Paolo Carlini + + PR c++/29143 + * semantics.c (finish_call_expr): Ensure that for OVERLOADs too + '(&f)(...)' is the same as '(f)(...)', per 13.3.1.1. + 2013-11-15 Aldy Hernandez * Make-lang.in (CXX_AND_OBJCXX_OBJS): Depend on cp/cp-cilkplus.o. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 81394faa6267..f5506d010dcd 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2184,6 +2184,11 @@ finish_call_expr (tree fn, vec **args, bool disallow_virtual, } } + /* Per 13.3.1.1, '(&f)(...)' is the same as '(f)(...)'. */ + if (TREE_CODE (fn) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (fn, 0)) == OVERLOAD) + fn = TREE_OPERAND (fn, 0); + if (is_overloaded_fn (fn)) fn = baselink_for_fns (fn);