Skip to content

Misleading parsing error message for OpenMP directives #96901

@skatrak

Description

@skatrak

Currently, the expected behavior when encountering an invalid OpenMP directive is that the parser emits an "error: expected OpenMP construct". For example:

$ cat test.f90
subroutine foo
  integer :: x = 10
  !$omp invalid_directive
  ! ...
end subroutine foo

$ flang-new -fc1 -fopenmp -fsyntax-only test.f90
error: Could not parse test.f90
./test.f90:3:10: error: expected OpenMP construct
    !$omp invalid_directive
           ^
./test.f90:3:3: in the context: specification construct
...

However, if there is an assignment operation preceding the invalid OpenMP directive, the error message becomes something else without any mention of the possibility that there is an invalid OpenMP directive. For example:

$ cat test.f90
subroutine foo
  integer :: x
  x = 10
  !$omp invalid_directive
  ! ...
end subroutine foo

$ flang-new -fc1 -fopenmp -fsyntax-only test.f90
error: Could not parse test.f90
./test.f90:4:9: error: expected 'END'
    !$omp invalid_directive
          ^
./test.f90:4:3: in the context: execution part construct
...

This makes identifying problems related to typos or to trying to use unsupported OpenMP compound constructs hard to troubleshoot on large applications.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions