[flang-commits] [flang] e7cb677 - [flang] Enforce F'2023 C7125
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Jul 21 13:39:36 PDT 2023
Author: Peter Klausler
Date: 2023-07-21T13:39:28-07:00
New Revision: e7cb6778000bdc915508cbe06ff23d976a1e6a51
URL: https://github.com/llvm/llvm-project/commit/e7cb6778000bdc915508cbe06ff23d976a1e6a51
DIFF: https://github.com/llvm/llvm-project/commit/e7cb6778000bdc915508cbe06ff23d976a1e6a51.diff
LOG: [flang] Enforce F'2023 C7125
An item whose declared type is ABSTRACT may not appear in an
array constructor.
Differential Revision: https://reviews.llvm.org/D155969
Added:
Modified:
flang/lib/Semantics/expression.cpp
flang/test/Semantics/array-constr-values.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 777ef3b20b2324..0f07fe0b202c60 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -1600,6 +1600,14 @@ void ArrayConstructorContext::Push(MaybeExpr &&x) {
messageDisplayedSet_ |= 8;
}
return;
+ } else if (dyType->category() == TypeCategory::Derived &&
+ dyType->GetDerivedTypeSpec().typeSymbol().attrs().test(
+ semantics::Attr::ABSTRACT)) { // F'2023 C7125
+ if (!(messageDisplayedSet_ & 0x200)) {
+ exprAnalyzer_.Say(
+ "An item whose declared type is ABSTRACT may not appear in an array constructor"_err_en_US);
+ messageDisplayedSet_ |= 0x200;
+ }
}
DynamicTypeWithLength xType{dyType.value()};
if (Expr<SomeCharacter> * charExpr{UnwrapExpr<Expr<SomeCharacter>>(*x)}) {
diff --git a/flang/test/Semantics/array-constr-values.f90 b/flang/test/Semantics/array-constr-values.f90
index 860a3a3d98b324..b93f774e0b0d0a 100644
--- a/flang/test/Semantics/array-constr-values.f90
+++ b/flang/test/Semantics/array-constr-values.f90
@@ -44,9 +44,10 @@ subroutine arrayconstructorvalues()
!ERROR: Cannot have an unlimited polymorphic value in an array constructor
intarray = (/ unlim_polymorphic, 2, 3, 4, 5/)
- ! C7114
+ ! C7114, F'2023 C7125
!ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types INTEGER(4) and TYPE(base_type)
!ERROR: ABSTRACT derived type 'base_type' may not be used in a structure constructor
+ !ERROR: An item whose declared type is ABSTRACT may not appear in an array constructor
!ERROR: Values in array constructor must have the same declared type when no explicit type appears
intarray = (/ base_type(10), 2, 3, 4, 5 /)
More information about the flang-commits
mailing list