diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-11-03 22:33:53 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2019-11-03 22:33:53 +0000 |
commit | b8dd4aa14d1eca6d0f4baa5213fd8853313eef0b (patch) | |
tree | 323e8683c074f0d8205e475c626ddf1ea7ad4e96 | |
parent | 40a777e840f74dd5c19ea26c55d1248a335fd11b (diff) | |
download | gcc-b8dd4aa14d1eca6d0f4baa5213fd8853313eef0b.zip gcc-b8dd4aa14d1eca6d0f4baa5213fd8853313eef0b.tar.gz gcc-b8dd4aa14d1eca6d0f4baa5213fd8853313eef0b.tar.bz2 |
re PR fortran/92113 (r276673 causes segfault in gfortran.dg/pr51434.f90)
2019-11-03 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/92133
* trans-decl.c (gfc_get_symbol_decl): If __def_init actually
contains a value, put it into the read-only section.
From-SVN: r277760
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-decl.c | 21 |
2 files changed, 20 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 74211ce..620d8af 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-11-03 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/92133 + * trans-decl.c (gfc_get_symbol_decl): If __def_init actually + contains a value, put it into the read-only section. + 2019-11-01 Steven G. Kargl <kargl@gcc.gnu.org> * decl.c (match_byte_typespec): New function. Match BYTE type-spec. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 630682c..ffa6111 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1904,13 +1904,20 @@ gfc_get_symbol_decl (gfc_symbol * sym) if (sym->attr.associate_var) GFC_DECL_ASSOCIATE_VAR_P (decl) = 1; - /* We no longer mark __def_init as read-only so it does not take up - space in the read-only section and dan go into the BSS instead, - see PR 84487. Marking this as artificial means that OpenMP will - treat this as predetermined shared. */ - if (sym->attr.vtab - || (sym->name[0] == '_' && gfc_str_startswith (sym->name, "__def_init"))) - DECL_ARTIFICIAL (decl) = 1; + /* We only longer mark __def_init as read-only if it actually has an + initializer, it does not needlessly take up space in the + read-only section and can go into the BSS instead, see PR 84487. + Marking this as artificial means that OpenMP will treat this as + predetermined shared. */ + + bool def_init = gfc_str_startswith (sym->name, "__def_init"); + + if (sym->attr.vtab || def_init) + { + DECL_ARTIFICIAL (decl) = 1; + if (def_init && sym->value) + TREE_READONLY (decl) = 1; + } return decl; } |