[flang-commits] [flang] b6f1bad - [flang] Fixed a crash

Pete Steinfeld via flang-commits flang-commits at lists.llvm.org
Mon May 4 07:54:54 PDT 2020


Author: Pete Steinfeld
Date: 2020-05-04T07:54:23-07:00
New Revision: b6f1bad630faa86104703f40c33a7653668e6a4a

URL: https://github.com/llvm/llvm-project/commit/b6f1bad630faa86104703f40c33a7653668e6a4a
DIFF: https://github.com/llvm/llvm-project/commit/b6f1bad630faa86104703f40c33a7653668e6a4a.diff

LOG: [flang] Fixed a crash

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

Reviewers: tskeith, klausler, DavidTruby

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79282

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/type.cpp b/flang/lib/Semantics/type.cpp
index 40518ce24ba1..80f994045749 100644
--- a/flang/lib/Semantics/type.cpp
+++ b/flang/lib/Semantics/type.cpp
@@ -77,7 +77,9 @@ void DerivedTypeSpec::CookParameters(evaluate::FoldingContext &foldingContext) {
       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_,

diff  --git a/flang/test/Semantics/resolve33.f90 b/flang/test/Semantics/resolve33.f90
index 176404b9db63..3fa6bec15f2c 100644
--- a/flang/test/Semantics/resolve33.f90
+++ b/flang/test/Semantics/resolve33.f90
@@ -30,4 +30,11 @@ module m
     !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
+  type(t6(2, 10)) :: x3
 end module


        


More information about the flang-commits mailing list