Skip to content

Commit 27498e9

Browse files
authored
[Flang][OpenMP] Prevent ICE for certain constructs in unnamed programs (#73938)
This patch fixes #72748 by modifying the processing of program units to search for a symbol to which OpenMP REQUIRES clauses can bind to. Rather than picking up the first PFT node with a source reference and getting its associated scope, it picks up the last one. This avoids using the source from the first specification construct of a nameless program, which can sometimes not be associated to any scope, causing an ICE due to an invalid source location.
1 parent cf8fc53 commit 27498e9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
template <typename T>
2727
static Fortran::semantics::Scope *GetScope(
2828
Fortran::semantics::SemanticsContext &context, const T &x) {
29-
std::optional<Fortran::parser::CharBlock> source{GetSource(x)};
29+
std::optional<Fortran::parser::CharBlock> source{GetLastSource(x)};
3030
return source ? &context.FindScope(*source) : nullptr;
3131
}
3232

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2+
! Check OpenMP compatibility with the DEC STRUCTURE extension
3+
4+
structure /s/
5+
end structure
6+
7+
end

0 commit comments

Comments
 (0)