Skip to content

Program without program-statement misclassification during parsing #1075

Open
@ivan-pi

Description

@ivan-pi

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions