re PR fortran/30792 (DATA implied-do substring allowed with -std=f95/f2003)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 24 Feb 2018 17:22:10 +0000 (17:22 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 24 Feb 2018 17:22:10 +0000 (17:22 +0000)
2018-02-24  Steven G. Kargl <kargl@gcc.gnu.org>

PR fortran/30792
* decl.c (gfc_match_data): Check for invalid substring in
data-implied-do

2018-02-24  Steven G. Kargl <kargl@gcc.gnu.org>

PR fortran/30792
* gfortran.dg/data_substring.f90: New test.

From-SVN: r257962

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/data_substring.f90 [new file with mode: 0644]

index 9be8a0dfe09dd8f4c2cc71928efca4f5ff54d216..6e69042c89677c67981f0e3b7cc1e6254d84857b 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-24  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/30792
+       * decl.c (gfc_match_data): Check for invalid substring in
+       data-implied-do
+
 2018-02-23  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        * intrinsic.texi: Arguments to MATMUL cannot both be rank one.
index e275be3a95092f7f1a9c004063175a361907a33e..e377a213db49ff1217dc3d4b61ec37c9260945e7 100644 (file)
@@ -585,6 +585,20 @@ gfc_match_data (void)
       if (m != MATCH_YES)
        goto cleanup;
 
+      if (new_data->var->iter.var
+         && new_data->var->iter.var->ts.type == BT_INTEGER
+         && new_data->var->iter.var->symtree->n.sym->attr.implied_index == 1
+         && new_data->var->list
+         && new_data->var->list->expr
+         && new_data->var->list->expr->ts.type == BT_CHARACTER
+         && new_data->var->list->expr->ref
+         && new_data->var->list->expr->ref->type == REF_SUBSTRING)
+       {
+         gfc_error ("Invalid substring in data-implied-do at %L in DATA "
+                    "statement", &new_data->var->list->expr->where);
+         goto cleanup;
+       }
+
       m = top_val_list (new_data);
       if (m != MATCH_YES)
        goto cleanup;
index 1a0bcd3a602504db95679f2cf56adc05dc684db9..60d8a9e0843ff5802157c927874d152358063537 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-24  Steven G. Kargl <kargl@gcc.gnu.org>
+
+       PR fortran/30792
+       * gfortran.dg/data_substring.f90: New test.
+
 2018-02-24  Marek Polacek  <polacek@redhat.com>
 
        PR c++/83692
diff --git a/gcc/testsuite/gfortran.dg/data_substring.f90 b/gcc/testsuite/gfortran.dg/data_substring.f90
new file mode 100644 (file)
index 0000000..6d6b2c0
--- /dev/null
@@ -0,0 +1,6 @@
+! { dg-do compile }
+! PR fortran/30792
+character string*1025
+integer i
+data (string(i:i),i=1,1025)/1025*'?'/  ! { dg-error "Invalid substring" }
+end