From c034c38f8d6becbe6d607910351acceb58b97854 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sat, 24 Feb 2018 17:22:10 +0000 Subject: [PATCH] re PR fortran/30792 (DATA implied-do substring allowed with -std=f95/f2003) 2018-02-24 Steven G. Kargl PR fortran/30792 * decl.c (gfc_match_data): Check for invalid substring in data-implied-do 2018-02-24 Steven G. Kargl PR fortran/30792 * gfortran.dg/data_substring.f90: New test. From-SVN: r257962 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 14 ++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/data_substring.f90 | 6 ++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/data_substring.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9be8a0dfe09..6e69042c896 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-24 Steven G. Kargl + + PR fortran/30792 + * decl.c (gfc_match_data): Check for invalid substring in + data-implied-do + 2018-02-23 Steven G. Kargl * intrinsic.texi: Arguments to MATMUL cannot both be rank one. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index e275be3a950..e377a213db4 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1a0bcd3a602..60d8a9e0843 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-24 Steven G. Kargl + + PR fortran/30792 + * gfortran.dg/data_substring.f90: New test. + 2018-02-24 Marek Polacek 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 index 00000000000..6d6b2c01579 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/data_substring.f90 @@ -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