[flang-commits] [PATCH] D155969: [flang] Enforce F'2023 C7125

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Jul 21 13:39:39 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7cb6778000b: [flang] Enforce F'2023 C7125 (authored by klausler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155969

Files:
  flang/lib/Semantics/expression.cpp
  flang/test/Semantics/array-constr-values.f90


Index: flang/test/Semantics/array-constr-values.f90
===================================================================
--- flang/test/Semantics/array-constr-values.f90
+++ flang/test/Semantics/array-constr-values.f90
@@ -44,9 +44,10 @@
   !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 /)
 
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -1600,6 +1600,14 @@
       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)}) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155969.543046.patch
Type: text/x-patch
Size: 1633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230721/cd853720/attachment-0001.bin>


More information about the flang-commits mailing list