aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-11-04 23:28:05 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-11-04 23:28:05 -0400
commit8dc1dc7975a3d8dd3ffdfd6fcc992419cc358af7 (patch)
treeca470eace191fef9bebca636e8607224204fd3ba /gcc/cp
parent1bb6f778233848318cd8290380d77c515669545a (diff)
downloadgcc-8dc1dc7975a3d8dd3ffdfd6fcc992419cc358af7.zip
gcc-8dc1dc7975a3d8dd3ffdfd6fcc992419cc358af7.tar.gz
gcc-8dc1dc7975a3d8dd3ffdfd6fcc992419cc358af7.tar.bz2
re PR c++/48370 (G++ fails to extend reference temporary lifetime in some situations)
PR c++/48370 * decl.c (cp_finish_decl): Run cleanups in the right order. From-SVN: r181001
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c12
2 files changed, 10 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ffb085c..6c68d87 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-04 Jason Merrill <jason@redhat.com>
+
+ PR c++/48370
+ * decl.c (cp_finish_decl): Run cleanups in the right order.
+
2011-11-04 Eric Botcazou <ebotcazou@adacore.com>
PR c++/50608
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 50c45de..65413df 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5907,7 +5907,8 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
tree asmspec_tree, int flags)
{
tree type;
- VEC(tree,gc) *cleanups = NULL;
+ VEC(tree,gc) *cleanups = make_tree_vector ();
+ unsigned i; tree t;
const char *asmspec = NULL;
int was_readonly = 0;
bool var_definition_p = false;
@@ -6315,12 +6316,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
/* If a CLEANUP_STMT was created to destroy a temporary bound to a
reference, insert it in the statement-tree now. */
- if (cleanups)
- {
- unsigned i; tree t;
- FOR_EACH_VEC_ELT_REVERSE (tree, cleanups, i, t)
- push_cleanup (decl, t, false);
- }
+ FOR_EACH_VEC_ELT (tree, cleanups, i, t)
+ push_cleanup (decl, t, false);
+ release_tree_vector (cleanups);
if (was_readonly)
TREE_READONLY (decl) = 1;