aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cgraphunit.c9
-rw-r--r--gcc/tree.h3
3 files changed, 17 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fd015eb..c430e9d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2019-02-12 Jan Hubicka <hubicka@ucw.cz>
+
+ PR lto/88777
+ * cgraphunit.c (analyze_functions): Clear READONLY flag for external
+ types that needs constructiong.
+ * tree.h (may_be_aliased): Do not check TYPE_NEEDS_CONSTRUCTING.
+
2019-02-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/89253
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index a7c9b9a..162e004 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1226,6 +1226,15 @@ analyze_functions (bool first_time)
&& node != first_handled_var; node = next)
{
next = node->next;
+ /* For symbols declared locally we clear TREE_READONLY when emitting
+ the construtor (if one is needed). For external declarations we can
+ not safely assume that the type is readonly because we may be called
+ during its construction. */
+ if (TREE_CODE (node->decl) == VAR_DECL
+ && TYPE_P (TREE_TYPE (node->decl))
+ && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (node->decl))
+ && DECL_EXTERNAL (node->decl))
+ TREE_READONLY (node->decl) = 0;
if (!node->aux && !node->referred_to_p ())
{
if (symtab->dump_file)
diff --git a/gcc/tree.h b/gcc/tree.h
index a1c30e4..96d84d9 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5382,8 +5382,7 @@ may_be_aliased (const_tree var)
|| DECL_EXTERNAL (var)
|| TREE_ADDRESSABLE (var))
&& !((TREE_STATIC (var) || TREE_PUBLIC (var) || DECL_EXTERNAL (var))
- && ((TREE_READONLY (var)
- && !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (var)))
+ && (TREE_READONLY (var)
|| (TREE_CODE (var) == VAR_DECL
&& DECL_NONALIASED (var)))));
}