[flang-commits] [PATCH] D134504: [flang] Fix crash in semantics in error recovery

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Sep 23 17:45:59 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3bc334b31a22: [flang] Fix crash in semantics in error recovery (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134504/new/

https://reviews.llvm.org/D134504

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
@@ -2060,12 +2060,19 @@
   // If the function has a type in the prefix, process it now.
   FuncInfo *info{Top()};
   if (info && &info->scope == &scopeHandler_.currScope()) {
-    if (info->parsedType) {
+    if (info->parsedType && info->resultSymbol) {
       scopeHandler_.messageHandler().set_currStmtSource(info->source);
       if (const auto *type{
               scopeHandler_.ProcessTypeSpec(*info->parsedType, true)}) {
-        if (!scopeHandler_.context().HasError(info->resultSymbol)) {
-          info->resultSymbol->SetType(*type);
+        Symbol &symbol{*info->resultSymbol};
+        if (!scopeHandler_.context().HasError(symbol)) {
+          if (symbol.GetType()) {
+            scopeHandler_.Say(symbol.name(),
+                "Function cannot have both an explicit type prefix and a RESULT suffix"_err_en_US);
+            scopeHandler_.context().SetError(symbol);
+          } else {
+            symbol.SetType(*type);
+          }
         }
       }
       info->parsedType = nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134504.462632.patch
Type: text/x-patch
Size: 1209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220924/59877ca3/attachment-0001.bin>


More information about the flang-commits mailing list