]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/7050 (g++ segfaults on: (i ? get_string() : throw))
authorAndrew Lewycky <andrew@mxc.ca>
Wed, 12 Mar 2003 22:59:37 +0000 (22:59 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 12 Mar 2003 22:59:37 +0000 (17:59 -0500)
        PR c++/7050
        * expr.c (store_expr): Don't attempt to store void-typed trees,
        just evaluate them for side effects.
        * cp/expr.c (cxx_expand_expr): Return const0_rtx for throw
        expressions.

From-SVN: r64270

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/expr.c
gcc/expr.c

index e663fe33987170b9182a876bbf504ab4de077f1c..89c682171ec6326b85a62ff1bb67a4a54fb77dfa 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-12  Andrew Lewycky  <andrew@mxc.ca>
+
+       PR c++/7050
+       * expr.c (store_expr): Don't attempt to store void-typed trees,
+       just evaluate them for side effects.
+
 2003-03-12  Bob Wilson  <bob.wilson@acm.org>
 
        Backport from mainline:
index ea552bbe7cbd9149c598984c67e38a02b7965c1b..27697e271561d14e0fb50a37e511f5712c5fa696 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-12  Andrew Lewycky  <andrew@mxc.ca>
+
+       PR c++/7050
+       * expr.c (cxx_expand_expr): Return const0_rtx for throw
+       expressions.
+
 2003-03-10  Jason Merrill  <jason@redhat.com>
 
        PR c++/9798
index 34f779ebb97fcd3e9137b065ba5dac1dfdcba9cf..bc38fd22a823e5fd2f3f891c4d6a0993f0ee7479 100644 (file)
@@ -111,7 +111,7 @@ cplus_expand_expr (exp, target, tmode, modifier)
       
     case THROW_EXPR:
       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
-      return NULL;
+      return const0_rtx;
 
     case MUST_NOT_THROW_EXPR:
       expand_eh_region_start ();
index 2a13cd4825f6097158768e87c265b73e96135308..ba261d56912aeddc27b874e6afa61e4453c2843d 100644 (file)
@@ -3917,6 +3917,16 @@ store_expr (exp, target, want_value)
   int dont_return_target = 0;
   int dont_store_target = 0;
 
+  if (VOID_TYPE_P (TREE_TYPE (exp)))
+    {
+      /* C++ can generate ?: expressions with a throw expression in one
+        branch and an rvalue in the other. Here, we resolve attempts to
+        store the throw expression's nonexistant result. */
+      if (want_value)
+       abort ();
+      expand_expr (exp, const0_rtx, VOIDmode, 0);
+      return NULL_RTX;
+    }
   if (TREE_CODE (exp) == COMPOUND_EXPR)
     {
       /* Perform first part of compound expression, then assign from second