mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 04:17:17 +08:00
[flang][OpenMP] Fix crash on DECLARE REDUCTION in unparse-with-symbols (#157871)
This commit is contained in:
committed by
GitHub
parent
fa0bb6a20e
commit
fc9fe0f7b7
@@ -37,6 +37,8 @@ public:
|
||||
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;
|
||||
@@ -57,7 +59,6 @@ public:
|
||||
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;
|
||||
@@ -67,6 +68,14 @@ public:
|
||||
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;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user