diff options
author | Mark Mitchell <mark@codesourcery.com> | 2006-07-19 22:49:20 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2006-07-19 22:49:20 +0000 |
commit | d23f3d60929d0df378cc61593933db9d85add5a5 (patch) | |
tree | 8d9d28ecf559ae39bd12c309d61d6dcf79d51d85 /gcc | |
parent | 7eb314dc4ba66b79de1a170c127cd0eee10f8fb5 (diff) | |
download | gcc-d23f3d60929d0df378cc61593933db9d85add5a5.zip gcc-d23f3d60929d0df378cc61593933db9d85add5a5.tar.gz gcc-d23f3d60929d0df378cc61593933db9d85add5a5.tar.bz2 |
re PR c++/28338 (ICE/rejects-valid with references)
PR c++/28338
* decl.c (layout_var_decl): Don't call push_local_name here.
(initialize_artificial_var): Assert artificiality.
(cp_finish_decl): Call push_local_name here.
PR c++/28338
* g++.dg/init/ref13.C: New test.
From-SVN: r115600
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/ref13.C | 7 |
4 files changed, 31 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 24731c4..da9ab49 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2006-07-19 Mark Mitchell <mark@codesourcery.com> + + PR c++/28338 + * decl.c (layout_var_decl): Don't call push_local_name here. + (initialize_artificial_var): Assert artificiality. + (cp_finish_decl): Call push_local_name here. + 2006-07-18 Mark Mitchell <mark@codesourcery.com> PR c++/28337 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6165a2f..124e044 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4190,12 +4190,6 @@ layout_var_decl (tree decl) { tree type; - if (TREE_STATIC (decl) - && !DECL_ARTIFICIAL (decl) - && current_function_decl - && DECL_CONTEXT (decl) == current_function_decl) - push_local_name (decl); - type = TREE_TYPE (decl); if (type == error_mark_node) return; @@ -5003,6 +4997,7 @@ initialize_local_var (tree decl, tree init) void initialize_artificial_var (tree decl, tree init) { + gcc_assert (DECL_ARTIFICIAL (decl)); if (TREE_CODE (init) == TREE_LIST) init = build_constructor_from_list (NULL_TREE, init); gcc_assert (TREE_CODE (init) == CONSTRUCTOR); @@ -5144,6 +5139,17 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, if (DECL_THREAD_LOCAL_P (decl) && !pod_type_p (TREE_TYPE (decl))) error ("%qD cannot be thread-local because it has non-POD type %qT", decl, TREE_TYPE (decl)); + /* If this is a local variable that will need a mangled name, + register it now. We must do this before processing the + initializer for the variable, since the initialization might + require a guard variable, and since the mangled name of the + guard variable will depend on the mangled name of this + variable. */ + if (!processing_template_decl + && DECL_FUNCTION_SCOPE_P (decl) + && TREE_STATIC (decl) + && !DECL_ARTIFICIAL (decl)) + push_local_name (decl); /* Convert the initializer to the type of DECL, if we have not already initialized DECL. */ if (!DECL_INITIALIZED_P (decl) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e335856..f6ca4c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-07-19 Mark Mitchell <mark@codesourcery.com> + + PR c++/28338 + * g++.dg/init/ref13.C: New test. + 2006-07-19 Volker Reichelt <reichelt@igpm.rwth-aachen.de> PR obj-c++/28434 diff --git a/gcc/testsuite/g++.dg/init/ref13.C b/gcc/testsuite/g++.dg/init/ref13.C new file mode 100644 index 0000000..6be57aa --- /dev/null +++ b/gcc/testsuite/g++.dg/init/ref13.C @@ -0,0 +1,7 @@ +// PR c++/28338 + +void foo() +{ + { static const int& i = 0; } + { static const int& i = 0; } +} |