Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion flang/lib/Semantics/unparse-with-symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class SymbolDumpVisitor {
template <typename T> void Post(const parser::Statement<T> &) {
currStmt_ = std::nullopt;
}
void Post(const parser::Name &name);

bool Pre(const parser::AccClause &clause) {
currStmt_ = clause.source;
return true;
Expand All @@ -57,7 +59,6 @@ class SymbolDumpVisitor {
return true;
}
void Post(const parser::OpenMPThreadprivate &) { currStmt_ = std::nullopt; }
void Post(const parser::Name &name);

bool Pre(const parser::OpenMPDeclareMapperConstruct &x) {
currStmt_ = x.source;
Expand All @@ -67,6 +68,14 @@ class SymbolDumpVisitor {
currStmt_ = std::nullopt;
}

bool Pre(const parser::OpenMPDeclareReductionConstruct &x) {
currStmt_ = x.source;
return true;
}
void Post(const parser::OpenMPDeclareReductionConstruct &) {
currStmt_ = std::nullopt;
}

bool Pre(const parser::OpenMPDeclareTargetConstruct &x) {
currStmt_ = x.source;
return true;
Expand Down Expand Up @@ -120,6 +129,7 @@ void SymbolDumpVisitor::Indent(llvm::raw_ostream &out, int indent) const {
void SymbolDumpVisitor::Post(const parser::Name &name) {
if (const auto *symbol{name.symbol}) {
if (!symbol->has<MiscDetails>()) {
CHECK(currStmt_.has_value());
symbols_.emplace(currStmt_.value().begin(), symbol);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
!RUN: %flang_fc1 -fdebug-unparse-with-symbols -fopenmp %s | FileCheck %s

! This used to crash.

subroutine f00
!$omp declare reduction(fred : integer, real : omp_out = omp_in + omp_out)
end

!CHECK: !DEF: /f00 (Subroutine) Subprogram
!CHECK: subroutine f00
!CHECK: !$omp declare reduction (fred:integer,real:omp_out = omp_in+omp_out)
!CHECK: end subroutine