[flang-commits] [PATCH] D152183: [flang] Fix crash from bug#63099 (gfortran/regression/oldstyle_3.f90)
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jun 5 11:36:58 PDT 2023
klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added subscribers: sunshaoce, jdoerfert.
Herald added a project: All.
klausler requested review of this revision.
In InitElement() in flang/lib/Semantics/data-to-inits.cpp, don't
assume that values_.Location() can be called until after it has been
verified that values_.IsAtEnd() is not true.
Fixes https://github.com/llvm/llvm-project/issues/63099.
https://reviews.llvm.org/D152183
Files:
flang/lib/Semantics/data-to-inits.cpp
Index: flang/lib/Semantics/data-to-inits.cpp
===================================================================
--- flang/lib/Semantics/data-to-inits.cpp
+++ flang/lib/Semantics/data-to-inits.cpp
@@ -320,9 +320,6 @@
bool isPointer{lastSymbol && IsPointer(*lastSymbol)};
bool isProcPointer{lastSymbol && IsProcedurePointer(*lastSymbol)};
evaluate::FoldingContext &context{exprAnalyzer_.GetFoldingContext()};
- auto &messages{context.messages()};
- auto restorer{
- messages.SetLocation(values_.LocateSource().value_or(messages.at()))};
const auto DescribeElement{[&]() {
if (auto badDesignator{
@@ -365,6 +362,9 @@
return false;
}
+ auto &messages{context.messages()};
+ auto restorer{
+ messages.SetLocation(values_.LocateSource().value_or(messages.at()))};
const SomeExpr *expr{*values_};
if (!expr) {
CHECK(exprAnalyzer_.context().AnyFatalError());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152183.528532.patch
Type: text/x-patch
Size: 906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230605/eb399811/attachment.bin>
More information about the flang-commits
mailing list