* [PATCH] PR fortran/30792 -- Substring data-implied-do is invalid
@ 2018-02-24 1:25 Steve Kargl
2018-02-24 12:32 ` Thomas Koenig
0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2018-02-24 1:25 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 423 bytes --]
The attached patch fixes PR fortran/30792. A substring
reference is invalid for a data-implied-do. Regression
tested on x86_64-*-freebsd. OK to commit.
2018-02-23 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>
PR fortran/30792
* gfortran.dg/data_substring.f90: New test.
--
Steve
[-- Attachment #2: pr30792.diff --]
[-- Type: text/x-diff, Size: 1292 bytes --]
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 257951)
+++ gcc/fortran/decl.c (working copy)
@@ -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: gcc/testsuite/gfortran.dg/data_substring.f90
===================================================================
--- gcc/testsuite/gfortran.dg/data_substring.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/data_substring.f90 (working copy)
@@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR fortran/30792 -- Substring data-implied-do is invalid
2018-02-24 1:25 [PATCH] PR fortran/30792 -- Substring data-implied-do is invalid Steve Kargl
@ 2018-02-24 12:32 ` Thomas Koenig
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2018-02-24 12:32 UTC (permalink / raw)
To: sgk, fortran, gcc-patches
Hi Steve,
> The attached patch fixes PR fortran/30792. A substring
> reference is invalid for a data-implied-do. Regression
> tested on x86_64-*-freebsd. OK to commit.
This should be safe enough, OK for trunk.
Thanks for the patch!
Regards
Thomas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-24 12:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-24 1:25 [PATCH] PR fortran/30792 -- Substring data-implied-do is invalid Steve Kargl
2018-02-24 12:32 ` Thomas Koenig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).