Skip to content

Commit 7e0e7f3

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 09df4ed commit 7e0e7f3

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
@@ -1530,6 +1530,23 @@ class OmpVisitor : public virtual DeclarationVisitor {
15301530
void Post(const parser::OpenMPDeclarativeAllocate &) {
15311531
SkipImplicitTyping(false);
15321532
}
1533+
bool Pre(const parser::OpenMPDeclarativeConstruct &x) {
1534+
AddOmpSourceRange(x.source);
1535+
return true;
1536+
}
1537+
void Post(const parser::OpenMPDeclarativeConstruct &) {
1538+
messageHandler().set_currStmtSource(std::nullopt);
1539+
}
1540+
bool Pre(const parser::OpenMPAtomicConstruct &x) {
1541+
return common::visit(common::visitors{[&](const auto &u) -> bool {
1542+
AddOmpSourceRange(u.source);
1543+
return true;
1544+
}},
1545+
x.u);
1546+
}
1547+
void Post(const parser::OpenMPAtomicConstruct &) {
1548+
messageHandler().set_currStmtSource(std::nullopt);
1549+
}
15331550
};
15341551

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

0 commit comments

Comments
 (0)