File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -506,9 +506,18 @@ class ExprChecker {
506
506
}
507
507
508
508
bool Pre (const parser::ComponentDefStmt &) {
509
- // Already analyzed in name resolution and PDT instantiation;
510
- // do not attempt to re-analyze now without type parameters.
511
- return false ;
509
+ inComponentDefStmt_ = true ;
510
+ return true ;
511
+ }
512
+ void Post (const parser::ComponentDefStmt &) { inComponentDefStmt_ = false ; }
513
+ bool Pre (const parser::Initialization &x) {
514
+ // Default component initialization expressions (but not DATA-like ones
515
+ // as in DEC STRUCTUREs) were already analyzed in name resolution
516
+ // and PDT instantiation; do not attempt to re-analyze them without
517
+ // type parameters.
518
+ return !inComponentDefStmt_ ||
519
+ std::holds_alternative<
520
+ std::list<common::Indirection<parser::DataStmtValue>>>(x.u );
512
521
}
513
522
514
523
template <typename A> bool Pre (const parser::Scalar<A> &x) {
@@ -538,6 +547,7 @@ class ExprChecker {
538
547
SemanticsContext &context_;
539
548
evaluate::ExpressionAnalyzer exprAnalyzer_{context_};
540
549
int whereDepth_{0 }; // nesting of WHERE statements & constructs
550
+ bool inComponentDefStmt_{false };
541
551
};
542
552
} // namespace Fortran::semantics
543
553
#endif // FORTRAN_SEMANTICS_EXPRESSION_H_
Original file line number Diff line number Diff line change
1
+ ! RUN: %flang_fc1 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
2
+ ! Ensure that DATA-like default component initializers work.
3
+ ! CHECK: j (InDataStmt) size=4 offset=0: ObjectEntity type: INTEGER(4) init:123_4
4
+ type t
5
+ integer j/ 123 /
6
+ end type
7
+ end
You can’t perform that action at this time.
0 commit comments