diff options
author | Jim Wilson <wilson@gcc.gnu.org> | 1994-03-18 15:31:17 -0800 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 1994-03-18 15:31:17 -0800 |
commit | 07aeab22c0aa102a34c5fdd1b435964135271618 (patch) | |
tree | 87ab8ec3694d85c65b7e7774bee251a3bec11712 /gcc | |
parent | bdfd4e3106f5623ff3afdde1cd51d41879bd4dd3 (diff) | |
download | gcc-07aeab22c0aa102a34c5fdd1b435964135271618.zip gcc-07aeab22c0aa102a34c5fdd1b435964135271618.tar.gz gcc-07aeab22c0aa102a34c5fdd1b435964135271618.tar.bz2 |
(assemble_variable): Likewise.
From-SVN: r6819
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/varasm.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index b127de3..17117c0 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1142,11 +1142,22 @@ assemble_variable (decl, top_level, at_end, dont_output_data) named_section (TREE_STRING_POINTER (DECL_SECTION_NAME (decl))); else { + /* C++ can have const variables that get initialized from constructors, + and thus can not be in a readonly section. We prevent this by + verifying that the initial value is constant for objects put in a + readonly section. + + error_mark_node is used by the C front end to indicate that the + initializer has not been seen yet. In this case, we assume that + the initializer must be constant. */ #ifdef SELECT_SECTION SELECT_SECTION (decl, reloc); #else if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) + && DECL_INITIAL (decl) + && (DECL_INITIAL (decl) == error_mark_node + || TREE_CONSTANT (DECL_INITIAL (decl))) && ! (flag_pic && reloc)) readonly_data_section (); else @@ -1194,6 +1205,9 @@ assemble_variable (decl, top_level, at_end, dont_output_data) #else if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) + && DECL_INITIAL (decl) + && (DECL_INITIAL (decl) == error_mark_node + || TREE_CONSTANT (DECL_INITIAL (decl))) && ! (flag_pic && reloc)) readonly_data_section (); else @@ -1289,6 +1303,9 @@ assemble_variable (decl, top_level, at_end, dont_output_data) #else if (TREE_READONLY (decl) && ! TREE_THIS_VOLATILE (decl) + && DECL_INITIAL (decl) + && (DECL_INITIAL (decl) == error_mark_node + || TREE_CONSTANT (DECL_INITIAL (decl))) && ! (flag_pic && reloc)) readonly_data_section (); else |