Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program without program-statement misclassification during parsing #1075

Open
ivan-pi opened this issue Sep 22, 2024 · 1 comment
Open

Program without program-statement misclassification during parsing #1075

ivan-pi opened this issue Sep 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ivan-pi
Copy link
Member

ivan-pi commented Sep 22, 2024

Description

fpm doesn't classify correctly the source type of program units without a program-statement, such as:

print *, "Hello World"
end

or

print *, "Hello World"
end program

which are allowed according to the standard.

Currently, parse_f_source will return FPM_UNIT_SUBPROGRAM (=4)` for these two cases.

Expected Behaviour

The expected source unit type should be FPM_UNIT_PROGRAM (=1).

Version of fpm

0.8.1, alpha

Platform and Architecture

MacOS (Intel)

Additional Information

The culprit is the parsing logic, which relies on detecting the program statement at front:

! Detect if contains a program
! (no modules allowed after program def)
if (index(file_lines_lower(i)%s,'program ') == 1) then
temp_string = split_n(file_lines_lower(i)%s,n=2,delims=' ',stat=stat)
if (stat == 0) then
if (scan(temp_string,'=(')>0 ) then
! Ignore:
! program =*
! program (i) =*
cycle
end if
end if
f_source%unit_type = FPM_UNIT_PROGRAM
cycle
end if

Instead it should probably rely on the end program statement which is mandatory per the standard. (J3/24-007, 14.1)

@ivan-pi ivan-pi added the bug Something isn't working label Sep 22, 2024
@ivan-pi
Copy link
Member Author

ivan-pi commented Sep 22, 2024

I suppose that from the build perspective, a program unit is not very different to an external procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant