diff --git a/flang/lib/Evaluate/type.cpp b/flang/lib/Evaluate/type.cpp --- a/flang/lib/Evaluate/type.cpp +++ b/flang/lib/Evaluate/type.cpp @@ -157,7 +157,7 @@ } break; case TypeCategory::Derived: - if (derived_ && derived_->scope()) { + if (!IsPolymorphic() && derived_ && derived_->scope()) { auto size{derived_->scope()->size()}; auto align{aligned ? derived_->scope()->alignment().value_or(0) : 0}; auto alignedSize{align > 0 ? ((size + align - 1) / align) * align : size}; diff --git a/flang/test/Evaluate/errors01.f90 b/flang/test/Evaluate/errors01.f90 --- a/flang/test/Evaluate/errors01.f90 +++ b/flang/test/Evaluate/errors01.f90 @@ -2,6 +2,9 @@ ! Check errors found in folding ! TODO: test others emitted from flang/lib/Evaluate module m + type t + real x + end type t contains subroutine s1(a,b) real :: a(*), b(:) @@ -100,6 +103,14 @@ !CHECK: error: DIM=4 argument to SPREAD must be between 1 and 3 integer, parameter :: bad3 = spread(matrix, 4, 1) end subroutine + subroutine s12(x,y) + class(t), intent(in) :: x + class(*), intent(in) :: y + !CHERK: error: Must be a constant value + integer, parameter :: bad1 = storage_size(x) + !CHERK: error: Must be a constant value + integer, parameter :: bad2 = storage_size(y) + end subroutine subroutine warnings real, parameter :: ok1 = scale(0.0, 99999) ! 0.0 real, parameter :: ok2 = scale(1.0, -99999) ! 0.0