diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-02-18 07:58:40 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2005-02-18 07:58:40 +0100 |
commit | 3a96c3b9d8cb8983c666c367fd7f9e5c278315df (patch) | |
tree | 903f1b0c94ccf13fa933a9fe9d234462b5b67614 | |
parent | 9fd64c63156c891794eb1cfb7ad7b043c04569c8 (diff) | |
download | gcc-3a96c3b9d8cb8983c666c367fd7f9e5c278315df.zip gcc-3a96c3b9d8cb8983c666c367fd7f9e5c278315df.tar.gz gcc-3a96c3b9d8cb8983c666c367fd7f9e5c278315df.tar.bz2 |
re PR c++/19813 (wrong code with -finline-limit)
PR c++/19813
* emit-rtl.c (set_mem_attributes_minus_bitpos): Add assertion
that ref to be marked MEM_READONLY_P doesn't have base that needs
constructing.
* decl.c (start_decl_1): Clear TREE_READONLY flag if
its type has TYPE_NEEDS_CONSTRUCTING.
(complete_vars): Likewise.
From-SVN: r95217
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 15 | ||||
-rw-r--r-- | gcc/emit-rtl.c | 7 |
4 files changed, 35 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1d83533..0433f2f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-02-18 Jakub Jelinek <jakub@redhat.com> + + PR c++/19813 + * emit-rtl.c (set_mem_attributes_minus_bitpos): Add assertion + that ref to be marked MEM_READONLY_P doesn't have base that needs + constructing. + 2005-02-18 Joseph S. Myers <joseph@codesourcery.com> * genautomata.c (output_get_cpu_unit_code_func, diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cdbbfa5..61cd670 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2005-02-18 Jakub Jelinek <jakub@redhat.com> + + PR c++/19813 + * decl.c (start_decl_1): Clear TREE_READONLY flag if + its type has TYPE_NEEDS_CONSTRUCTING. + (complete_vars): Likewise. + 2005-02-17 Alexandre Oliva <aoliva@redhat.com> PR c++/20028 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 48f8d8c..4f1aa1f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3823,6 +3823,14 @@ start_decl_1 (tree decl) instantiation has occurred that TYPE_HAS_NONTRIVIAL_DESTRUCTOR will be set correctly. */ maybe_push_cleanup_level (type); + + /* An object declared 'const' is only readonly after it is + initialized. We don't have any way of expressing this currently, + so we need to be conservative and unset TREE_READONLY for types + with constructors. Otherwise aliasing code will ignore stores in + an inline constructor. */ + if (TYPE_NEEDS_CONSTRUCTING (type)) + TREE_READONLY (decl) = 0; } /* Handle initialization of references. DECL, TYPE, and INIT have the @@ -10913,6 +10921,13 @@ complete_vars (tree type) /* Complete the type of the variable. The VAR_DECL itself will be laid out in expand_expr. */ complete_type (TREE_TYPE (var)); + /* An object declared 'const' is only readonly after it is + initialized. We don't have any way of expressing this currently, + so we need to be conservative and unset TREE_READONLY for types + with constructors. Otherwise aliasing code will ignore stores in + an inline constructor. */ + if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (var))) + TREE_READONLY (var) = 0; /* Remove this entry from the list. */ *list = TREE_CHAIN (*list); } diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 46d9183..37bd665 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1533,7 +1533,12 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp, if (base && DECL_P (base) && TREE_READONLY (base) && (TREE_STATIC (base) || DECL_EXTERNAL (base))) - MEM_READONLY_P (ref) = 1; + { + tree base_type = TREE_TYPE (base); + gcc_assert (!(base_type && TYPE_NEEDS_CONSTRUCTING (base_type)) + || DECL_ARTIFICIAL (base)); + MEM_READONLY_P (ref) = 1; + } if (TREE_THIS_VOLATILE (t)) MEM_VOLATILE_P (ref) = 1; |