Re: [Patch, Fortran] PR 92996 – fix rank resolution EXPR_ARRAY
Tobias Burnus
tobias@codesourcery.com
Fri Dec 20 09:23:00 GMT 2019
Hi Steve,
On 12/20/19 1:26 AM, Steve Kargl wrote:
> On Thu, Dec 19, 2019 at 09:30:49PM +0100, Tobias Burnus wrote:
>> The latter could be "solved" by using %C instead of %L after
>> gfc_simplify_expr in gfc_match_stopcode.
>> [The "ref" has its own address (e->ref->u.ar->where); hence,
>> the a(1,1) error would be still fine.]
>> (Though, this potentially effects more.)
> See patch in comment #2 of PR. It regression tests cleanly,
> so it seems your parenthetical statement is not a issue.
One has the choice between
(a) Using the location where the expression was defined (in the
scoping unit) â currently done
(i.e. replacing expr->where by expr->symtree->n.sym->where)
(b) using the location where the parameter is used, i.e. keeping
expr->where despite simplification.
What I meant is that there are more locations one to change from
%L to %C if one wants to get good diagnostic and keep using the
location of the declaration (as done currently) â instead of moving
to keeping the location of the expression used (as proposed).
In my opinion (b) is the most robust version while (a) can give in
_some_ cases a better diagnostic â as mentioned in the last email
and as shown by the dg-error changed I had to do in two test cases.
I played around and found two examples where the currently shown
location is not helpful.
The current compiler shows such errors:
5 | use m
| 1
Error: âdimâ argument of âsizeâ intrinsic at (1) is not a valid dimension index
1 | complex, parameter :: x(1) = 1
| 1
Error: STOP code at (1) must be either INTEGER or CHARACTER type
Using approach (b), one gets for those:
3 | stop x(1)
| 1
Error: STOP code at (1) must be either INTEGER or CHARACTER type
6 | print size([1,2],dim=d(1))
| 1
Error: âdimâ argument of âsizeâ intrinsic at (1) is not a valid dimension index
I think the latter diagnostic is much more helpful! I have to admit that I had to
move the "e->where = p->where" further down â after the gfc_simplify_expr call
as that one again changed the location. â I also added the two examples.
OK for the trunk?
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: expr_array-v2.diff
Type: text/x-patch
Size: 9972 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20191220/2f3bfcf8/attachment.bin>
More information about the Fortran
mailing list