re PR c++/28266 (ICE on invalid default variable)
authorSimon Martin <simartin@users.sourceforge.net>
Mon, 29 Jan 2007 16:27:21 +0000 (16:27 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 29 Jan 2007 16:27:21 +0000 (11:27 -0500)
        PR c++/28266
        * gimplify.c (gimplify_target_expr): Make sure that the TARGET_EXPR is
        expanded only once even if an error occurs.

From-SVN: r121288

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/defarg12.C [new file with mode: 0644]

index 1ccb3c7bf37a8d0809f0f75a75b42096a5699b8e..9e4d1c43e7ac8fbc2e421162c59990821219d09a 100644 (file)
@@ -1,3 +1,9 @@
+2007-01-29  Simon Martin  <simartin@users.sourceforge.net>
+
+       PR c++/28266
+       * gimplify.c (gimplify_target_expr): Make sure that the TARGET_EXPR is
+       expanded only once even if an error occurs.
+
 2007-01-29  Ben Elliston  <bje@au.ibm.com>
 
        * gcov-io.h (__gcov_indirect_call_profiler): Declare.
index 19323ae59c3a347238c9f09c9192acd65d8493fc..1e9975777a3af68afa88e1e9069b432d01b18de5 100644 (file)
@@ -4300,7 +4300,11 @@ gimplify_target_expr (tree *expr_p, tree *pre_p, tree *post_p)
                               fb_none);
        }
       if (ret == GS_ERROR)
-       return GS_ERROR;
+       {
+         /* PR c++/28266 Make sure this is expanded only once. */
+         TARGET_EXPR_INITIAL (targ) = NULL_TREE;
+         return GS_ERROR;
+       }
       append_to_statement_list (init, pre_p);
 
       /* If needed, push the cleanup for the temp.  */
index 66501a914bced9e719b95f42f50d69d95a9be33e..aa9f672331eb6a05e22601a2003c9e97ca7fd058 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-29  Simon Martin  <simartin@users.sourceforge.net>
+
+       PR c++/28266
+       * g++.dg/parse/defarg12.C: New test.
+
 2007-01-29  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/30554
diff --git a/gcc/testsuite/g++.dg/parse/defarg12.C b/gcc/testsuite/g++.dg/parse/defarg12.C
new file mode 100644 (file)
index 0000000..3717ad5
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR28266 This used to ICE in gimple_add_tmp_var */
+/* { dg-do "compile" } */
+
+struct A
+{
+  int i;
+  A(int = X); /* { dg-error "was not declared in this scope" }*/
+};
+
+void foo()
+{
+  A().i;
+}