]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/78278 (ICE in gfc_wide_memset, at fortran/scanner.c:153)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 9 Jun 2018 19:57:29 +0000 (19:57 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 9 Jun 2018 19:57:29 +0000 (19:57 +0000)
2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>

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  <kargl@gcc.gnu.org>

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: r261374

gcc/fortran/ChangeLog
gcc/fortran/data.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/data_bounds_1.f90
gcc/testsuite/gfortran.dg/data_char_1.f90
gcc/testsuite/gfortran.dg/pr78278.f90 [new file with mode: 0644]

index 8ba1206d5b3e684d96a1d153f78d8da7f5fbfa8e..d1355c85bba56eb1f94b6454ad444d4ddedbf06f 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       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  <kargl@gcc.gnu.org>
 
        PR fortran/86059
index c24e6f3e6e48b053cc9bab2f3b37d4f11865b603..5d1d38042f497d446f89e4db42cc651c8dbc14c4 100644 (file)
@@ -481,6 +481,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.  */
@@ -501,22 +516,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);
index 301b1555af9b406db8d266e4f564d4da70270f29..0751cf324116d9fd525cfbdb67730d68edbe1f75 100644 (file)
@@ -1,3 +1,11 @@
+2018-06-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       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  <kargl@gcc.gnu.org>
 
        PR fortran/86059
index b20aa415b8a2bce5f981f74a16f16f8aceb3aa09..24cdc7c98156d1beed73b425bf55fd4f6b510106 100644 (file)
@@ -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 <burnus@gcc.gnu.org>
index 96db4fd30eb7b9cbea8f28ea48b21d5602ade8d7..24785b636fa636add094322b25baef879cc2a136 100644 (file)
@@ -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 (file)
index 0000000..fd50e3e
--- /dev/null
@@ -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