re PR c++/30158 (ICE with invalid statement-expressions)
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Fri, 16 Feb 2007 01:23:35 +0000 (01:23 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Fri, 16 Feb 2007 01:23:35 +0000 (17:23 -0800)
2007-02-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/30158
        * semantics.c (finish_stmt_expr_expr): Set TREE_TYPE of the
        statement expression if we had an error mark node.
2007-02-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/30158
        * g++.dg/ext/stmtexpr10.C: New testcase.

From-SVN: r122028

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/stmtexpr10.C [new file with mode: 0644]

index 16df0f7da4fee1f80e86807b00b245f25aa7487f..6e7f84fe72b1cd53f45c6c225c2aaf770a2c8ce9 100644 (file)
@@ -1,3 +1,9 @@
+2007-02-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/30158
+       * semantics.c (finish_stmt_expr_expr): Set TREE_TYPE of the 
+       statement expression if we had an error mark node.
+               
 2007-02-15  Sandra Loosemore  <sandra@codesourcery.com>
            Brooks Moses  <brooks.moses@codesourcery.com>
            Lee Millward  <lee.millward@codesourcery.com>
index 3df045e733d8aa7a27b35289210aeda5c7376f93..c4cdd954982c9aabd5d9c4166463346caccfea4d 100644 (file)
@@ -1631,7 +1631,12 @@ tree
 finish_stmt_expr_expr (tree expr, tree stmt_expr)
 {
   if (error_operand_p (expr))
-    return error_mark_node;
+    {
+      /* The type of the statement-expression is the type of the last
+         expression.  */
+      TREE_TYPE (stmt_expr) = error_mark_node;
+      return error_mark_node;
+    }
 
   /* If the last statement does not have "void" type, then the value
      of the last statement is the value of the entire expression.  */
index 20c55913da0e75a43b8372d9c9c7d1185cc86020..c0fc66a9f32ba4541de846bcd0032b1fa12779a9 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/30158
+       * g++.dg/ext/stmtexpr10.C: New testcase.
+
 2007-02-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        PR middle-end/30729
diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr10.C b/gcc/testsuite/g++.dg/ext/stmtexpr10.C
new file mode 100644 (file)
index 0000000..f7c5f8f
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } " */
+/* { dg-options "" } */
+
+void foo(int i)
+{
+  (i ? 1 : 2) = ({ X; }); /* { dg-error "" } */
+}
+
+struct A
+{
+  ~A ();
+  void foo()
+  {
+    delete this = ({ X; }); /* { dg-error "" } */
+  }
+};