[PATCH] D82096: [flang] Fix crash with alternate returns in modules

Pete Steinfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 18 09:13:41 PDT 2020


This revision was automatically updated to reflect the committed changes.
PeteSteinfeld marked an inline comment as done.
Closed by commit rG3ed2909feb34: [flang] Fix crash with alternate returns in modules (authored by PeteSteinfeld).

Changed prior to commit:
  https://reviews.llvm.org/D82096?vs=271707&id=271741#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82096

Files:
  flang/lib/Semantics/mod-file.cpp
  flang/test/Semantics/modfile04.f90


Index: flang/test/Semantics/modfile04.f90
===================================================================
--- flang/test/Semantics/modfile04.f90
+++ flang/test/Semantics/modfile04.f90
@@ -39,6 +39,15 @@
   end
 end
 
+! Module with a subroutine with alternate returns
+module m3
+contains
+  subroutine altReturn(arg1, arg2, *, *)
+    real :: arg1
+    real :: arg2
+  end subroutine
+end module m3
+
 !Expect: m1.mod
 !module m1
 !type::t
@@ -73,3 +82,12 @@
 !complex(4)::x
 !end
 !end
+
+!Expect: m3.mod
+!module m3
+!contains
+!subroutine altreturn(arg1,arg2,*,*)
+!real(4)::arg1
+!real(4)::arg2
+!end
+!end
Index: flang/lib/Semantics/mod-file.cpp
===================================================================
--- flang/lib/Semantics/mod-file.cpp
+++ flang/lib/Semantics/mod-file.cpp
@@ -322,7 +322,11 @@
     if (n++ > 0) {
       os << ',';
     }
-    os << dummy->name();
+    if (dummy) {
+      os << dummy->name();
+    } else {
+      os << "*";
+    }
   }
   os << ')';
   PutAttrs(os, bindAttrs, details.bindName(), " "s, ""s);
@@ -825,7 +829,9 @@
   const auto &details{symbol_.get<SubprogramDetails>()};
   isInterface_ = details.isInterface();
   for (const Symbol *dummyArg : details.dummyArgs()) {
-    DoSymbol(DEREF(dummyArg));
+    if (dummyArg) {
+      DoSymbol(*dummyArg);
+    }
   }
   if (details.isFunction()) {
     DoSymbol(details.result());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82096.271741.patch
Type: text/x-patch
Size: 1385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200618/fdbb51a5/attachment.bin>


More information about the llvm-commits mailing list