Commit b0eb6a8f by Jakub Jelinek Committed by Jakub Jelinek

re PR target/33168 (GCC Boot failure, building libstc++)

	PR target/33168
	* decl.c (cp_finish_decl): Call make_rtl_for_nonlocal_decl already
	with the final TREE_READONLY flag in place.  processing_template_decl
	is known to be 0 in this part of function.

	* g++.dg/other/datasec1.C: New test.

From-SVN: r129922
parent 36b6e793
2007-11-06 Jakub Jelinek <jakub@redhat.com> 2007-11-06 Jakub Jelinek <jakub@redhat.com>
PR target/33168
* decl.c (cp_finish_decl): Call make_rtl_for_nonlocal_decl already
with the final TREE_READONLY flag in place. processing_template_decl
is known to be 0 in this part of function.
PR c++/33894 PR c++/33894
* cp-tree.h: Update comment - TYPE_LANG_FLAG_0 is not * cp-tree.h: Update comment - TYPE_LANG_FLAG_0 is not
OMP_ATOMIC_DEPENDENT_P in OMP_ATOMIC. OMP_ATOMIC_DEPENDENT_P in OMP_ATOMIC.
......
...@@ -5455,8 +5455,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, ...@@ -5455,8 +5455,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
require a guard variable, and since the mangled name of the require a guard variable, and since the mangled name of the
guard variable will depend on the mangled name of this guard variable will depend on the mangled name of this
variable. */ variable. */
if (!processing_template_decl if (DECL_FUNCTION_SCOPE_P (decl)
&& DECL_FUNCTION_SCOPE_P (decl)
&& TREE_STATIC (decl) && TREE_STATIC (decl)
&& !DECL_ARTIFICIAL (decl)) && !DECL_ARTIFICIAL (decl))
push_local_name (decl); push_local_name (decl);
...@@ -5561,6 +5560,21 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, ...@@ -5561,6 +5560,21 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
/* This needs to happen after the linkage is set. */ /* This needs to happen after the linkage is set. */
determine_visibility (decl); determine_visibility (decl);
if (var_definition_p && TREE_STATIC (decl))
{
/* If a TREE_READONLY variable needs initialization
at runtime, it is no longer readonly and we need to
avoid MEM_READONLY_P being set on RTL created for it. */
if (init)
{
if (TREE_READONLY (decl))
TREE_READONLY (decl) = 0;
was_readonly = 0;
}
else if (was_readonly)
TREE_READONLY (decl) = 1;
}
make_rtl_for_nonlocal_decl (decl, init, asmspec); make_rtl_for_nonlocal_decl (decl, init, asmspec);
/* Check for abstractness of the type. Notice that there is no /* Check for abstractness of the type. Notice that there is no
...@@ -5583,17 +5597,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, ...@@ -5583,17 +5597,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
if (init) if (init)
DECL_INITIAL (decl) = init; DECL_INITIAL (decl) = init;
} }
else
{
/* A variable definition. */ /* A variable definition. */
if (DECL_FUNCTION_SCOPE_P (decl)) else if (DECL_FUNCTION_SCOPE_P (decl) && !TREE_STATIC (decl))
{
/* Initialize the local variable. */ /* Initialize the local variable. */
if (processing_template_decl)
DECL_INITIAL (decl) = init;
else if (!TREE_STATIC (decl))
initialize_local_var (decl, init); initialize_local_var (decl, init);
}
/* If a variable is defined, and then a subsequent /* If a variable is defined, and then a subsequent
definition with external linkage is encountered, we will definition with external linkage is encountered, we will
...@@ -5603,21 +5610,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, ...@@ -5603,21 +5610,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
expand_static_init only when we actually process the expand_static_init only when we actually process the
initializer. It is not legal to redeclare a static data initializer. It is not legal to redeclare a static data
member, so this issue does not arise in that case. */ member, so this issue does not arise in that case. */
if (var_definition_p && TREE_STATIC (decl)) else if (var_definition_p && TREE_STATIC (decl))
{
/* If a TREE_READONLY variable needs initialization
at runtime, it is no longer readonly and we need to
avoid MEM_READONLY_P being set on RTL created for it. */
if (init)
{
if (TREE_READONLY (decl))
TREE_READONLY (decl) = 0;
was_readonly = 0;
}
expand_static_init (decl, init); expand_static_init (decl, init);
} }
}
}
/* If a CLEANUP_STMT was created to destroy a temporary bound to a /* If a CLEANUP_STMT was created to destroy a temporary bound to a
reference, insert it in the statement-tree now. */ reference, insert it in the statement-tree now. */
......
2007-11-06 Jakub Jelinek <jakub@redhat.com> 2007-11-06 Jakub Jelinek <jakub@redhat.com>
PR target/33168
* g++.dg/other/datasec1.C: New test.
PR tree-optimization/33458 PR tree-optimization/33458
* g++.dg/opt/inline12.C: New test. * g++.dg/opt/inline12.C: New test.
// PR target/33168
// { dg-do compile }
// { dg-options "-O2 -fdata-sections" }
extern const int& foo;
namespace
{
const int bar = 16;
}
const int &foo = bar;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment