]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: call.c (build_conditional_expr): Do not call force_rvalue for operands...
authorGabriel Dos Reis <gdr@integrable-solutions.net>
Sun, 16 May 2004 22:52:19 +0000 (22:52 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Sun, 16 May 2004 22:52:19 +0000 (22:52 +0000)
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.

From-SVN: r81927

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/expr/cond5.C [new file with mode: 0644]

index 85adf271e05039c34ed8d9a027ab0eaf6c71ede0..b508b2fe522883bfda513632fd0bc46d343975ed 100644 (file)
@@ -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 e45d5aaee0cca689ddab316906bae436d209bbde..313460b69845ac6d21b3575a11a7649a6edd85d0 100644 (file)
@@ -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 (file)
index 0000000..cb62dd1
--- /dev/null
@@ -0,0 +1,3 @@
+void f() {
+  true ? throw 1 : (void)7;
+}