[flang-commits] [PATCH] D127429: [flang] Fix crash on USE error
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Mon Jun 13 16:20:52 PDT 2022
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8eebf4696454: [flang] Fix crash on USE error (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127429/new/
https://reviews.llvm.org/D127429
Files:
flang/lib/Semantics/resolve-names.cpp
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -2698,15 +2698,23 @@
// symbol must be either a Use or a Generic formed by merging two uses.
// Convert it to a UseError with this additional location.
-static void ConvertToUseError(
+static bool ConvertToUseError(
Symbol &symbol, const SourceName &location, const Scope &module) {
const auto *useDetails{symbol.detailsIf<UseDetails>()};
if (!useDetails) {
- auto &genericDetails{symbol.get<GenericDetails>()};
- useDetails = &genericDetails.uses().at(0)->get<UseDetails>();
+ if (auto *genericDetails{symbol.detailsIf<GenericDetails>()}) {
+ if (!genericDetails->uses().empty()) {
+ useDetails = &genericDetails->uses().at(0)->get<UseDetails>();
+ }
+ }
+ }
+ if (useDetails) {
+ symbol.set_details(
+ UseErrorDetails{*useDetails}.add_occurrence(location, module));
+ return true;
+ } else {
+ return false;
}
- symbol.set_details(
- UseErrorDetails{*useDetails}.add_occurrence(location, module));
}
// If a symbol has previously been USE-associated and did not appear in a USE
@@ -2807,9 +2815,7 @@
}
}
if (!combine) {
- if (localSymbol.has<UseDetails>() || localSymbol.has<GenericDetails>()) {
- ConvertToUseError(localSymbol, location, *useModuleScope_);
- } else {
+ if (!ConvertToUseError(localSymbol, location, *useModuleScope_)) {
Say(location,
"Cannot use-associate '%s'; it is already declared in this scope"_err_en_US,
localName)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127429.436600.patch
Type: text/x-patch
Size: 1672 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220613/243ef864/attachment.bin>
More information about the flang-commits
mailing list