Skip to content

Commit 04376a9

Browse files
authored
Merge pull request #991 from flang-compiler/jpr-add-lines-in-error
Add line information to some fatal errors to help debugging
2 parents 7001237 + ec8d2a8 commit 04376a9

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

flang/lib/Lower/ConvertExpr.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,15 +1680,11 @@ class ScalarExprLowering {
16801680
// Explicitly map statement function host associated symbols to their
16811681
// parent scope lowered symbol box.
16821682
for (const Fortran::semantics::SymbolRef &sym :
1683-
Fortran::evaluate::CollectSymbols(*details.stmtFunction())) {
1683+
Fortran::evaluate::CollectSymbols(*details.stmtFunction()))
16841684
if (const auto *details =
1685-
sym->detailsIf<Fortran::semantics::HostAssocDetails>()) {
1686-
if (!symMap.lookupSymbol(*sym)) {
1687-
symMap.addSymbol(
1688-
*sym, symMap.lookupSymbol(details->symbol()).toExtendedValue());
1689-
}
1690-
}
1691-
}
1685+
sym->detailsIf<Fortran::semantics::HostAssocDetails>())
1686+
if (!symMap.lookupSymbol(*sym))
1687+
symMap.addSymbol(*sym, gen(details->symbol()));
16921688

16931689
auto result = genval(details.stmtFunction().value());
16941690
LLVM_DEBUG(llvm::dbgs() << "stmt-function: " << result << '\n');

flang/lib/Optimizer/CodeGen/CodeGen.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,15 +2248,17 @@ struct CoordinateOpConversion
22482248
}
22492249

22502250
int64_t getIntValue(mlir::Value val) const {
2251-
if (val)
2251+
if (val) {
22522252
if (auto defop = val.getDefiningOp()) {
22532253
if (auto constOp = dyn_cast<mlir::ConstantIntOp>(defop))
22542254
return constOp.getValue();
22552255
else if (auto llConstOp = dyn_cast<mlir::LLVM::ConstantOp>(defop))
22562256
if (auto attr = llConstOp.value().dyn_cast<mlir::IntegerAttr>())
22572257
return attr.getValue().getSExtValue();
22582258
}
2259-
llvm_unreachable("must be a constant");
2259+
fir::emitFatalError(val.getLoc(), "must be a constant");
2260+
}
2261+
llvm_unreachable("must not be null value");
22602262
}
22612263
}; // namespace
22622264

0 commit comments

Comments
 (0)