aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-07-11 08:16:48 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-07-11 08:16:48 +0000
commit7352723b9e9a7f04d68aca3f09386d1a14c87f7e (patch)
treebc751dc234498dcd1192cf177d53d0f58422dcc5 /gcc/ada/gcc-interface/utils.c
parent833c1dbc609404a69b30d7f045b50935c058302b (diff)
downloadgcc-7352723b9e9a7f04d68aca3f09386d1a14c87f7e.zip
gcc-7352723b9e9a7f04d68aca3f09386d1a14c87f7e.tar.gz
gcc-7352723b9e9a7f04d68aca3f09386d1a14c87f7e.tar.bz2
trans.c (add_decl_expr): Minor tweak.
* gcc-interface/trans.c (add_decl_expr): Minor tweak. * gcc-interface/utils.c (create_var_decl): For an external variable, also clear TREE_READONLY in LTO mode if the initializer is not a valid constant and set DECL_READONLY_ONCE_ELAB instead. From-SVN: r238206
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 66c5408..3a546ff 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -2430,8 +2430,9 @@ create_var_decl (tree name, tree asm_name, tree type, tree init,
and may be used for scalars in general but not for aggregates. */
tree var_decl
= build_decl (input_location,
- (constant_p && const_decl_allowed_p
- && !AGGREGATE_TYPE_P (type)) ? CONST_DECL : VAR_DECL,
+ (constant_p
+ && const_decl_allowed_p
+ && !AGGREGATE_TYPE_P (type) ? CONST_DECL : VAR_DECL),
name, type);
/* Detect constants created by the front-end to hold 'reference to function
@@ -2456,9 +2457,20 @@ create_var_decl (tree name, tree asm_name, tree type, tree init,
constant initialization and save any variable elaborations for the
elaboration routine. If we are just annotating types, throw away the
initialization if it isn't a constant. */
- if ((extern_flag && !constant_p)
+ if ((extern_flag && init && !constant_p)
|| (type_annotate_only && init && !TREE_CONSTANT (init)))
- init = NULL_TREE;
+ {
+ init = NULL_TREE;
+
+ /* In LTO mode, also clear TREE_READONLY the same way add_decl_expr
+ would do it if the initializer was not thrown away here, as the
+ WPA phase requires a consistent view across compilation units. */
+ if (const_flag && flag_generate_lto)
+ {
+ const_flag = false;
+ DECL_READONLY_ONCE_ELAB (var_decl) = 1;
+ }
+ }
/* At the global level, a non-constant initializer generates elaboration
statements. Check that such statements are allowed, that is to say,