diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2c524230fe43..0b3adaf7391b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-07-03 Jakub Jelinek + + PR c++/53812 + * semantics.c (finish_goto_stmt): Surround computed goto argument + with CLEANUP_POINT_EXPR if needed. + 2012-07-02 Jason Merrill PR c++/53619 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8e37ebb7e162..0cacf7494798 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -571,6 +571,9 @@ finish_goto_stmt (tree destination) tf_warning_or_error); if (error_operand_p (destination)) return NULL_TREE; + destination + = fold_build_cleanup_point_expr (TREE_TYPE (destination), + destination); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3d51a0c574fa..42366fa0ecb8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-07-03 Jakub Jelinek + + PR c++/53812 + * g++.dg/ext/label14.C: New test. + 2012-07-03 Uros Bizjak PR target/53811 diff --git a/gcc/testsuite/g++.dg/ext/label14.C b/gcc/testsuite/g++.dg/ext/label14.C new file mode 100644 index 000000000000..d1a8b0d5299a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/label14.C @@ -0,0 +1,17 @@ +// PR c++/53812 +// { dg-do compile } +// { dg-options "" } + +struct T { T () : t(0) {}; int t; ~T (); }; +struct S { void *operator [] (T); }; +void bar (S &, void *, void *); + +void +foo (S &x, T &y) +{ + bar (x, &&l1, &&l2); +l1: + goto *x[y]; +l2: + bar (x, &&l1, &&l2); +}