* [Patch, fortran] PR80657 - [7/8/9 Regression] Loop in character function declaration
@ 2018-05-19 10:39 Paul Richard Thomas
0 siblings, 0 replies; only message in thread
From: Paul Richard Thomas @ 2018-05-19 10:39 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 576 bytes --]
I intend to commit this as 'obvious' once the patches for PR82923 and
82275 are out of the way.
Paul
2018-05-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/80657
* resolve.c (flag_fn_result_spec): Use the 'sym' argument to
test for self refs to the function result in the character len
expression. If a self reference is found, emit an error and
return true.
(resolve_fntype): Use the function symbol in the calls to the
above.
2018-05-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/80657
* gfortran.dg/char_result_18.f90: New test.
[-- Attachment #2: submit.diff --]
[-- Type: text/x-patch, Size: 1917 bytes --]
Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c (revision 260389)
--- gcc/fortran/resolve.c (working copy)
*************** resolve_equivalence (gfc_equiv *eq)
*** 16217,16223 ****
static bool
flag_fn_result_spec (gfc_expr *expr,
! gfc_symbol *sym ATTRIBUTE_UNUSED,
int *f ATTRIBUTE_UNUSED)
{
gfc_namespace *ns;
--- 16217,16223 ----
static bool
flag_fn_result_spec (gfc_expr *expr,
! gfc_symbol *sym,
int *f ATTRIBUTE_UNUSED)
{
gfc_namespace *ns;
*************** flag_fn_result_spec (gfc_expr *expr,
*** 16230,16235 ****
--- 16230,16242 ----
if (!ns->parent)
break;
+ if (sym == s)
+ {
+ gfc_error ("Self reference in character length expression "
+ "for %qs at %L", sym->name, &expr->where);
+ return true;
+ }
+
if (!s->fn_result_spec
&& s->attr.flavor == FL_PARAMETER)
{
*************** resolve_fntype (gfc_namespace *ns)
*** 16312,16318 ****
}
if (sym->ts.type == BT_CHARACTER)
! gfc_traverse_expr (sym->ts.u.cl->length, NULL, flag_fn_result_spec, 0);
}
--- 16319,16325 ----
}
if (sym->ts.type == BT_CHARACTER)
! gfc_traverse_expr (sym->ts.u.cl->length, sym, flag_fn_result_spec, 0);
}
Index: gcc/testsuite/gfortran.dg/char_result_18.f90
===================================================================
*** gcc/testsuite/gfortran.dg/char_result_18.f90 (nonexistent)
--- gcc/testsuite/gfortran.dg/char_result_18.f90 (working copy)
***************
*** 0 ****
--- 1,10 ----
+ ! { dg-do compile }
+ !
+ ! Tests the fix for PR80657.
+ !
+ ! Contributed by Vittorio Zecca <zeccav@gmail.com>
+ !
+ function f(x)
+ implicit character(len(f)) (x) ! { dg-error "Self reference in character length" }
+ character(len(x)) f
+ end
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-19 10:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-19 10:39 [Patch, fortran] PR80657 - [7/8/9 Regression] Loop in character function declaration Paul Richard Thomas
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).