PR c++/28266
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Jan 2007 16:27:21 +0000 (16:27 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Jan 2007 16:27:21 +0000 (16:27 +0000)
        * gimplify.c (gimplify_target_expr): Make sure that the TARGET_EXPR is
        expanded only once even if an error occurs.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121288 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 1ccb3c7..9e4d1c4 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 19323ae..1e99757 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 66501a9..aa9f672 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;
+}