summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-16 22:52:19 +0000
committergdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>2004-05-16 22:52:19 +0000
commitacf493c029d9edf25004643ece9599ee5e834f3e (patch)
tree0768c968ac32eea0d4c4762dd84425d338eaf235
parent16ac26e3bfbbf8b8a97ee2a61b341b95ae8bd859 (diff)
downloadgcc-acf493c029d9edf25004643ece9599ee5e834f3e.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_3-branch@81927 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/call.c12
-rw-r--r--gcc/testsuite/g++.dg/expr/cond5.C3
3 files changed, 20 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 85adf271e05..b508b2fe522 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index e45d5aaee0c..313460b6984 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3242,18 +3242,24 @@ build_conditional_expr (arg1, arg2, arg3)
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. */
+ 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)
{
- arg3 = force_rvalue (arg3);
+ 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)
{
- arg2 = force_rvalue (arg2);
+ if (!VOID_TYPE_P (arg2_type))
+ arg2 = force_rvalue (arg2);
arg2_type = TREE_TYPE (arg2);
result_type = arg2_type;
}
diff --git a/gcc/testsuite/g++.dg/expr/cond5.C b/gcc/testsuite/g++.dg/expr/cond5.C
new file mode 100644
index 00000000000..cb62dd1cfa4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/cond5.C
@@ -0,0 +1,3 @@
+void f() {
+ true ? throw 1 : (void)7;
+}