[GCC-3.3.4] Fix for C++/14802
Gabriel Dos Reis
gdr@integrable-solutions.net
Mon May 17 00:30:00 GMT 2004
This is a backport from part of Mark's
http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01568.html
to fix PR C++/14082. The audit trail of that PR contains also a
proposed patch which is identical to Mark's.
Bootstrapped and regtested on an i686-pc-linux-gnu.
-- Gaby
Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.3076.2.269
diff -p -r1.3076.2.269 ChangeLog
*** cp/ChangeLog 8 May 2004 21:52:42 -0000 1.3076.2.269
--- cp/ChangeLog 16 May 2004 22:49:57 -0000
***************
*** 1,3 ****
--- 1,11 ----
+ 2004-05-16 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ Backport from mainline:
+ 2004-03-18 Mark Mitchell <mark@codesourcery.com>
+ * call.c (build_conditional_expr): Do not call force_rvalue for
+ operands of void_type when the conditional expression itself has
+ void type.
+
2004-05-08 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Make-lang.in (cp/init.o): Depend on diagnostic.h.
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.341.2.41
diff -p -r1.341.2.41 call.c
*** cp/call.c 13 Mar 2004 02:00:56 -0000 1.341.2.41
--- cp/call.c 16 May 2004 22:50:00 -0000
*************** build_conditional_expr (arg1, arg2, arg3
*** 3242,3259 ****
type of the other and is an rvalue.
--Both the second and the third operands have type void; the
! result is of type void and is an rvalue. */
if (TREE_CODE (arg2) == THROW_EXPR
&& TREE_CODE (arg3) != THROW_EXPR)
{
! arg3 = force_rvalue (arg3);
arg3_type = TREE_TYPE (arg3);
result_type = arg3_type;
}
else if (TREE_CODE (arg2) != THROW_EXPR
&& TREE_CODE (arg3) == THROW_EXPR)
{
! arg2 = force_rvalue (arg2);
arg2_type = TREE_TYPE (arg2);
result_type = arg2_type;
}
--- 3242,3265 ----
type of the other and is an rvalue.
--Both the second and the third operands have type void; the
! result is of type void and is an rvalue.
!
! We must avoid calling force_rvalue for expressions of type
! "void" because it will complain that their value is being
! used. */
if (TREE_CODE (arg2) == THROW_EXPR
&& TREE_CODE (arg3) != THROW_EXPR)
{
! if (!VOID_TYPE_P (arg3_type))
! arg3 = force_rvalue (arg3);
arg3_type = TREE_TYPE (arg3);
result_type = arg3_type;
}
else if (TREE_CODE (arg2) != THROW_EXPR
&& TREE_CODE (arg3) == THROW_EXPR)
{
! if (!VOID_TYPE_P (arg2_type))
! arg2 = force_rvalue (arg2);
arg2_type = TREE_TYPE (arg2);
result_type = arg2_type;
}
Index: testsuite/g++.dg/expr/cond5.C
===================================================================
RCS file: testsuite/g++.dg/expr/cond5.C
diff -N testsuite/g++.dg/expr/cond5.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/expr/cond5.C 16 May 2004 22:50:01 -0000
***************
*** 0 ****
--- 1,3 ----
+ void f() {
+ true ? throw 1 : (void)7;
+ }
More information about the Gcc-patches
mailing list