From: Steven G. Kargl Date: Sat, 9 Jun 2018 15:39:29 +0000 (+0000) Subject: re PR fortran/78278 (ICE in gfc_wide_memset, at fortran/scanner.c:153) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4ea0af1da0cfa9c55e739808d4b405b982985ad5;p=gcc.git re PR fortran/78278 (ICE in gfc_wide_memset, at fortran/scanner.c:153) 2018-06-09 Steven G. Kargl PR fortran/78278 * data.c (gfc_assign_data_value): Re-arrange code to allow for an error for double initialization of CHARACTER entities. 2018-06-09 Steven G. Kargl PR fortran/78278 * gfortran.dg/data_bounds_1.f90: Add -std=gnu option. * gfortran.dg/data_char_1.f90: Ditto. * gfortran.dg/pr78571.f90: Ditto. * gfortran.dg/pr78278.f90: New test. From-SVN: r261361 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5f1ed3bc75d..52fdc46a887 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-06-09 Steven G. Kargl + + PR fortran/78278 + * data.c (gfc_assign_data_value): Re-arrange code to allow for + an error for double initialization of CHARACTER entities. + 2018-06-09 Steven G. Kargl PR fortran/63514 diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c index d837e15ee28..0d1f83040e9 100644 --- a/gcc/fortran/data.c +++ b/gcc/fortran/data.c @@ -483,6 +483,21 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index, mpz_clear (offset); gcc_assert (repeat == NULL); + /* Overwriting an existing initializer is non-standard but usually only + provokes a warning from other compilers. */ + if (init != NULL && init->where.lb && rvalue->where.lb) + { + /* Order in which the expressions arrive here depends on whether + they are from data statements or F95 style declarations. + Therefore, check which is the most recent. */ + expr = (LOCATION_LINE (init->where.lb->location) + > LOCATION_LINE (rvalue->where.lb->location)) + ? init : rvalue; + if (gfc_notify_std (GFC_STD_GNU, "re-initialization of %qs at %L", + symbol->name, &expr->where) == false) + return false; + } + if (ref || last_ts->type == BT_CHARACTER) { /* An initializer has to be constant. */ @@ -503,22 +518,6 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index, return false; } - /* Overwriting an existing initializer is non-standard but usually only - provokes a warning from other compilers. */ - if (init != NULL) - { - /* Order in which the expressions arrive here depends on whether - they are from data statements or F95 style declarations. - Therefore, check which is the most recent. */ - expr = (LOCATION_LINE (init->where.lb->location) - > LOCATION_LINE (rvalue->where.lb->location)) - ? init : rvalue; - if (gfc_notify_std (GFC_STD_GNU, - "re-initialization of %qs at %L", - symbol->name, &expr->where) == false) - return false; - } - expr = gfc_copy_expr (rvalue); if (!gfc_compare_types (&lvalue->ts, &expr->ts)) gfc_convert_type (expr, &lvalue->ts, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 36135a88521..8e90b1f4723 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-06-09 Steven G. Kargl + + PR fortran/78278 + * gfortran.dg/data_bounds_1.f90: Add -std=gnu option. + * gfortran.dg/data_char_1.f90: Ditto. + * gfortran.dg/pr78571.f90: Ditto. + * gfortran.dg/pr78278.f90: New test. + 2018-06-09 Steven G. Kargl PR fortran/63514 diff --git a/gcc/testsuite/gfortran.dg/data_bounds_1.f90 b/gcc/testsuite/gfortran.dg/data_bounds_1.f90 index b20aa415b8a..24cdc7c9815 100644 --- a/gcc/testsuite/gfortran.dg/data_bounds_1.f90 +++ b/gcc/testsuite/gfortran.dg/data_bounds_1.f90 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-std=gnu" } ! Checks the fix for PR32315, in which the bounds checks below were not being done. ! ! Contributed by Tobias Burnus diff --git a/gcc/testsuite/gfortran.dg/data_char_1.f90 b/gcc/testsuite/gfortran.dg/data_char_1.f90 index 95ca51d891c..0611e637591 100644 --- a/gcc/testsuite/gfortran.dg/data_char_1.f90 +++ b/gcc/testsuite/gfortran.dg/data_char_1.f90 @@ -1,4 +1,5 @@ ! { dg-do run } +! { dg-options "-std=gnu" } ! Test character variables in data statements ! Also substrings of character variables. ! PR14976 PR16228 diff --git a/gcc/testsuite/gfortran.dg/pr78278.f90 b/gcc/testsuite/gfortran.dg/pr78278.f90 new file mode 100644 index 00000000000..fd50e3e1c18 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78278.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! PR fortran/78278 +program p + character, pointer :: x => null() + data x /null()/ ! { dg-error "GNU Extension: re-initialization" } + print *, associated(x) +end + +subroutine foo + real :: x = 42 + data x /0/ ! { dg-error "GNU Extension: re-initialization" } + print *, x +end subroutine foo diff --git a/gcc/testsuite/gfortran.dg/pr78571.f90 b/gcc/testsuite/gfortran.dg/pr78571.f90 index 16b07abd273..8e377567eec 100644 --- a/gcc/testsuite/gfortran.dg/pr78571.f90 +++ b/gcc/testsuite/gfortran.dg/pr78571.f90 @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-std=gnu" } ! PR fortran/78571 program p type t