stfc / fparser

This project maintains and develops a Fortran parser called fparser2 written purely in Python which supports Fortran 2003 and some Fortran 2008. A legacy parser fparser1 is also available but is not supported. The parsers were originally part of the f2py project by Pearu Peterson.
https://fparser.readthedocs.io
Other
64 stars 29 forks source link

Shadowed intrinsics fail in F2008 mode #316

Closed reuterbal closed 2 years ago

reuterbal commented 2 years ago

The fantastic new symbol table (many, many thanks!) resolves the problem with local declarations shadowing intrinsics. However, this seems to only work in f2003 mode and the problem persists in f2008 mode. Unfortunately, it's unclear to me what is the reason for this.

To reproduce: 1) Duplicate test_intrinsics.py using f2008_create/f2008_parser fixtures makes test_shadowed_intrinsic fail. 2) For a full example, you can use ecrad (requires commenting the optimization pragma on l.2):

> fparser2 ecrad/master/ifsrrtm/srtm_spcvrt_mcica.F90
... parses without problems ...
> fparser2 --std=f2008 ecrad/master/ifsrrtm/srtm_spcvrt_mcica.F90
Syntax error: at line 256
>>>    JL=INDEX(IC)
Intrinsic 'INDEX' expects between 2 and 4 args but found 1.
reuterbal commented 2 years ago

This took me longer to figure out than it should: Issue is that Type_Declaration_Stmt is re-implemented in Fortran2008.py but without the corresponding validation against the symbol table. Creating PR now...