[patch, fortran] Fix PR 44960, accepts invalid reference on function
Steve Kargl
sgk@troutmask.apl.washington.edu
Sat Jan 18 00:06:00 GMT 2020
On Fri, Jan 17, 2020 at 11:20:06PM +0100, Thomas Koenig wrote:
> Am 17.01.20 um 15:42 schrieb Steve Kargl:
> > Gfortran probably should not try to guess what the user
> > thought s/he wanted. The generic "Syntax error" would
> > seem to apply here. To me, foo(1)%a looks much more like
> > an array reference rather than a function reference.
>
> OK, so here's a patch which does just that.
>
> The error message low looks like
>
> function_reference_1.f90:9:8:
>
> 9 | print *, foo(1)%a ! { dg-error "Syntax error" }
> | 1
> Error: Syntax error in expression at (1)
>
> The location information is a bit off, but in the absence of location
> information for the reference (which we do not collect), I think this
> is the best I can do.
>
> So, OK for trunk (with the old ChangeLog)?
>
It's fine with me. May want to give Tobias a chance to comment.
> + if (expr->ref)
> + {
> + gfc_error ("Syntax error in expression at %L", &expr->where);
I assume that %C puts the locus at the end of the line. I haven't
spent to much time trying to understand expressions in an output IO
list, but as you state, it seems that gfortran loose the locus.
--
Steve
More information about the Gcc-patches
mailing list