]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/29143 (address-of overloaded function does not work in function call)
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 16 Nov 2013 09:54:42 +0000 (09:54 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 16 Nov 2013 09:54:42 +0000 (09:54 +0000)
/cp
2013-11-16  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/29143
* g++.dg/overload/addr2.C: New.
* g++.old-deja/g++.other/overload11.C: Adjust.

From-SVN: r204899

gcc/cp/ChangeLog
gcc/cp/semantics.c

index 2a16220dda212cf25df57206f83368a30d1b6a3f..5f52d9047f33945ea012ae58c936b4e952cc644f 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-16  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <aldyh@redhat.com>
 
        * Make-lang.in (CXX_AND_OBJCXX_OBJS): Depend on cp/cp-cilkplus.o.
index 81394faa62671bf9bc24b4deabaa172cd89e8225..f5506d010dcdd79d20a0e760680fff9c79b8e103 100644 (file)
@@ -2184,6 +2184,11 @@ finish_call_expr (tree fn, vec<tree, va_gc> **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);