aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-05-17 20:39:18 +0200
committerHarald Anlauf <anlauf@gmx.de>2023-05-17 21:53:00 +0200
commit7bafe652dba9167b65e7b5ef24e77eceb49709ba (patch)
tree834fe18af7ddf2aaa4fd78ca28ced9b9b1b0d22b /gcc/fortran
parent883f1e25dc7907c9bb37f480b900336a050218f1 (diff)
downloadgcc-7bafe652dba9167b65e7b5ef24e77eceb49709ba.zip
gcc-7bafe652dba9167b65e7b5ef24e77eceb49709ba.tar.gz
gcc-7bafe652dba9167b65e7b5ef24e77eceb49709ba.tar.bz2
Fortran: set shape of initializers of zero-sized arrays [PR95374,PR104352]
gcc/fortran/ChangeLog: PR fortran/95374 PR fortran/104352 * decl.cc (add_init_expr_to_sym): Set shape of initializer also for zero-sized arrays, so that bounds violations can be detected later. gcc/testsuite/ChangeLog: PR fortran/95374 PR fortran/104352 * gfortran.dg/zero_sized_13.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/decl.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 9c4b40d..4c578d0 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -2239,8 +2239,7 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
&& gfc_is_constant_expr (init)
&& (init->expr_type == EXPR_CONSTANT
|| init->expr_type == EXPR_STRUCTURE)
- && spec_size (sym->as, &size)
- && mpz_cmp_si (size, 0) > 0)
+ && spec_size (sym->as, &size))
{
array = gfc_get_array_expr (init->ts.type, init->ts.kind,
&init->where);