This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to convert_to_void for c++/28996
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 09 Sep 2006 18:26:38 -0400
- Subject: C++ PATCH to convert_to_void for c++/28996
My fix for 26696 only dealt with COMPONENT_REFs of method type which had
no side-effects. This finishes the job.
Tested x86_64-pc-linux-gnu, applied to trunk.
2006-09-09 Jason Merrill <jason@redhat.com>
PR c++/28996
* cvt.c (convert_to_void): Strip COMPONENT_REF to functions.
Index: cp/cvt.c
===================================================================
*** cp/cvt.c (revision 116788)
--- cp/cvt.c (working copy)
*************** convert_to_void (tree expr, const char *
*** 927,935 ****
expr = void_zero_node;
}
else if (implicit && probe == expr && is_overloaded_fn (probe))
! /* Only warn when there is no &. */
! warning (0, "%s is a reference, not call, to function %qE",
! implicit, expr);
}
if (expr != error_mark_node && !VOID_TYPE_P (TREE_TYPE (expr)))
--- 927,939 ----
expr = void_zero_node;
}
else if (implicit && probe == expr && is_overloaded_fn (probe))
! {
! /* Only warn when there is no &. */
! warning (0, "%s is a reference, not call, to function %qE",
! implicit, expr);
! if (TREE_CODE (expr) == COMPONENT_REF)
! expr = TREE_OPERAND (expr, 0);
! }
}
if (expr != error_mark_node && !VOID_TYPE_P (TREE_TYPE (expr)))
Index: testsuite/g++.dg/warn/noeffect8.C
===================================================================
*** testsuite/g++.dg/warn/noeffect8.C (revision 116788)
--- testsuite/g++.dg/warn/noeffect8.C (working copy)
***************
*** 1,4 ****
! // PR c++/26696
struct A
{
--- 1,4 ----
! // PR c++/26696, 28996
struct A
{
*************** int main()
*** 9,12 ****
--- 9,13 ----
{
A a;
a.f; // { dg-warning "not call" }
+ A().f; // { dg-warning "not call" }
}