Skip to content

Commit 92e91b3

Browse files
[Flang][Semantics] Add source range to the threadprivate,
and Atomic constructs This patch fixes #82943, which used to crash when the threadprivate directive appears as the first directive without the program statement. Fix: Adding a source range from the current statement to the threadprivate and atomic will take care of the crash. See: https://reviews.llvm.org/D153634 for more details
1 parent aedf9d9 commit 92e91b3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,23 @@ class OmpVisitor : public virtual DeclarationVisitor {
15051505
void Post(const parser::OmpEndCriticalDirective &) {
15061506
messageHandler().set_currStmtSource(std::nullopt);
15071507
}
1508+
bool Pre(const parser::OpenMPDeclarativeConstruct &x) {
1509+
AddOmpSourceRange(x.source);
1510+
return true;
1511+
}
1512+
void Post(const parser::OpenMPDeclarativeConstruct &) {
1513+
messageHandler().set_currStmtSource(std::nullopt);
1514+
}
1515+
bool Pre(const parser::OpenMPAtomicConstruct &x) {
1516+
return common::visit(common::visitors{[&](const auto &u) -> bool {
1517+
AddOmpSourceRange(u.source);
1518+
return true;
1519+
}},
1520+
x.u);
1521+
}
1522+
void Post(const parser::OpenMPAtomicConstruct &) {
1523+
messageHandler().set_currStmtSource(std::nullopt);
1524+
}
15081525
};
15091526

15101527
bool OmpVisitor::NeedsScope(const parser::OpenMPBlockConstruct &x) {

0 commit comments

Comments
 (0)