[PATCH] D79282: [flang] Fixed a crash

Pete Steinfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 20:54:06 PDT 2020


PeteSteinfeld created this revision.
PeteSteinfeld added reviewers: tskeith, klausler.
Herald added a reviewer: DavidTruby.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

I found a small test case that caused a crash when derived type
definitions have parameters without definitions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79282

Files:
  flang/lib/Semantics/type.cpp
  flang/test/Semantics/resolve33.f90


Index: flang/test/Semantics/resolve33.f90
===================================================================
--- flang/test/Semantics/resolve33.f90
+++ flang/test/Semantics/resolve33.f90
@@ -30,4 +30,10 @@
     !ERROR: Type parameter, component, or procedure binding 'a' already defined in this type
     integer, len :: a
   end type
+  !ERROR: No definition found for type parameter 'k'
+  !ERROR: No definition found for type parameter 'l'
+  type :: t6(k, l)
+    !ERROR: Must be a constant value
+    character(kind=k, len=l) :: d3
+  end type
 end module
Index: flang/lib/Semantics/type.cpp
===================================================================
--- flang/lib/Semantics/type.cpp
+++ flang/lib/Semantics/type.cpp
@@ -77,7 +77,9 @@
       name = *nextNameIter++;
       auto it{std::find_if(parameterDecls.begin(), parameterDecls.end(),
           [&](const Symbol &symbol) { return symbol.name() == name; })};
-      CHECK(it != parameterDecls.end());
+      if (it == parameterDecls.end()) {
+        break;
+      }
       attr = it->get().get<TypeParamDetails>().attr();
     } else {
       messages.Say(name_,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79282.261612.patch
Type: text/x-patch
Size: 1134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/c21f582e/attachment.bin>


More information about the llvm-commits mailing list