@@ -973,7 +973,8 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::Name &n) {
973
973
}
974
974
}
975
975
if (!isWholeAssumedSizeArrayOk_ &&
976
- semantics::IsAssumedSizeArray (*n.symbol )) { // C1002, C1014, C1231
976
+ semantics::IsAssumedSizeArray (
977
+ ResolveAssociations (*n.symbol ))) { // C1002, C1014, C1231
977
978
AttachDeclaration (
978
979
SayAt (n,
979
980
" Whole assumed-size array '%s' may not appear here without subscripts" _err_en_US,
@@ -1329,15 +1330,29 @@ std::optional<Component> ExpressionAnalyzer::CreateComponent(DataRef &&base,
1329
1330
1330
1331
// Derived type component references and type parameter inquiries
1331
1332
MaybeExpr ExpressionAnalyzer::Analyze (const parser::StructureComponent &sc) {
1332
- MaybeExpr base{Analyze (sc.base )};
1333
1333
Symbol *sym{sc.component .symbol };
1334
- if (!base || !sym || context_.HasError (sym)) {
1334
+ if (context_.HasError (sym)) {
1335
+ return std::nullopt;
1336
+ }
1337
+ const auto *misc{sym->detailsIf <semantics::MiscDetails>()};
1338
+ bool isTypeParamInquiry{sym->has <semantics::TypeParamDetails>() ||
1339
+ (misc &&
1340
+ (misc->kind () == semantics::MiscDetails::Kind::KindParamInquiry ||
1341
+ misc->kind () == semantics::MiscDetails::Kind::LenParamInquiry))};
1342
+ MaybeExpr base;
1343
+ if (isTypeParamInquiry) {
1344
+ auto restorer{AllowWholeAssumedSizeArray ()};
1345
+ base = Analyze (sc.base );
1346
+ } else {
1347
+ base = Analyze (sc.base );
1348
+ }
1349
+ if (!base) {
1335
1350
return std::nullopt;
1336
1351
}
1337
1352
const auto &name{sc.component .source };
1338
1353
if (auto *dtExpr{UnwrapExpr<Expr<SomeDerived>>(*base)}) {
1339
1354
const auto *dtSpec{GetDerivedTypeSpec (dtExpr->GetType ())};
1340
- if (sym-> detailsIf <semantics::TypeParamDetails>() ) {
1355
+ if (isTypeParamInquiry ) {
1341
1356
if (auto *designator{UnwrapExpr<Designator<SomeDerived>>(*dtExpr)}) {
1342
1357
if (std::optional<DynamicType> dyType{DynamicType::From (*sym)}) {
1343
1358
if (dyType->category () == TypeCategory::Integer) {
@@ -1350,8 +1365,7 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::StructureComponent &sc) {
1350
1365
Say (name, " Type parameter is not INTEGER" _err_en_US);
1351
1366
} else {
1352
1367
Say (name,
1353
- " A type parameter inquiry must be applied to "
1354
- " a designator" _err_en_US);
1368
+ " A type parameter inquiry must be applied to a designator" _err_en_US);
1355
1369
}
1356
1370
} else if (!dtSpec || !dtSpec->scope ()) {
1357
1371
CHECK (context_.AnyFatalError () || !foldingContext_.messages ().empty ());
@@ -1393,8 +1407,7 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::StructureComponent &sc) {
1393
1407
return AsGenericExpr (std::move (realExpr));
1394
1408
}
1395
1409
}
1396
- } else if (kind == MiscKind::KindParamInquiry ||
1397
- kind == MiscKind::LenParamInquiry) {
1410
+ } else if (isTypeParamInquiry) { // %kind or %len
1398
1411
ActualArgument arg{std::move (*base)};
1399
1412
SetArgSourceLocation (arg, name);
1400
1413
return MakeFunctionRef (name, ActualArguments{std::move (arg)});
@@ -3743,9 +3756,12 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::Selector &selector) {
3743
3756
}
3744
3757
}
3745
3758
}
3759
+ // Not a Variable -> FunctionReference
3760
+ auto restorer{AllowWholeAssumedSizeArray ()};
3761
+ return Analyze (selector.u );
3762
+ } else { // Expr
3763
+ return Analyze (selector.u );
3746
3764
}
3747
- // Not a Variable -> FunctionReference; handle normally as Variable or Expr
3748
- return Analyze (selector.u );
3749
3765
}
3750
3766
3751
3767
MaybeExpr ExpressionAnalyzer::Analyze (const parser::DataStmtConstant &x) {
@@ -4001,6 +4017,7 @@ void ArgumentAnalyzer::Analyze(
4001
4017
const parser::ActualArgSpec &arg, bool isSubroutine) {
4002
4018
// TODO: C1534: Don't allow a "restricted" specific intrinsic to be passed.
4003
4019
std::optional<ActualArgument> actual;
4020
+ auto restorer{context_.AllowWholeAssumedSizeArray ()};
4004
4021
common::visit (
4005
4022
common::visitors{
4006
4023
[&](const common::Indirection<parser::Expr> &x) {
0 commit comments