@@ -98,8 +98,6 @@ class Component {
98
98
99
99
// A NamedEntity is either a whole Symbol or a component in an instance
100
100
// of a derived type. It may be a descriptor.
101
- // TODO: this is basically a symbol with an optional DataRef base;
102
- // could be used to replace Component.
103
101
class NamedEntity {
104
102
public:
105
103
CLASS_BOILERPLATE (NamedEntity)
@@ -239,28 +237,16 @@ class ArrayRef {
239
237
std::vector<Subscript> subscript_;
240
238
};
241
239
242
- // R914 coindexed-named-object
243
- // R924 image-selector, R926 image-selector-spec.
244
- // C825 severely limits the usage of derived types with coarray ultimate
245
- // components: they can't be pointers, allocatables, arrays, coarrays, or
246
- // function results. They can be components of other derived types.
247
- // Although the F'2018 Standard never prohibits multiple image-selectors
248
- // per se in the same data-ref or designator, nor the presence of an
249
- // image-selector after a part-ref with rank, the constraints on the
250
- // derived types that would have be involved make it impossible to declare
251
- // an object that could be referenced in these ways (esp. C748 & C825).
252
- // C930 precludes having both TEAM= and TEAM_NUMBER=.
253
- // TODO C931 prohibits the use of a coindexed object as a stat-variable.
240
+ // A coindexed data-ref. The base is represented as a general
241
+ // DataRef, but the base may not contain a CoarrayRef and may
242
+ // have rank > 0 only in an uppermost ArrayRef.
254
243
class CoarrayRef {
255
244
public:
256
245
CLASS_BOILERPLATE (CoarrayRef)
257
- CoarrayRef (SymbolVector &&, std::vector<Subscript> &&,
258
- std::vector<Expr<SubscriptInteger>> &&);
246
+ CoarrayRef (DataRef &&, std::vector<Expr<SubscriptInteger>> &&);
259
247
260
- const SymbolVector &base () const { return base_; }
261
- SymbolVector &base () { return base_; }
262
- const std::vector<Subscript> &subscript () const { return subscript_; }
263
- std::vector<Subscript> &subscript () { return subscript_; }
248
+ const DataRef &base () const { return base_.value (); }
249
+ DataRef &base () { return base_.value (); }
264
250
const std::vector<Expr<SubscriptInteger>> &cosubscript () const {
265
251
return cosubscript_;
266
252
}
@@ -270,25 +256,24 @@ class CoarrayRef {
270
256
// (i.e., Designator or pointer-valued FunctionRef).
271
257
std::optional<Expr<SomeInteger>> stat () const ;
272
258
CoarrayRef &set_stat (Expr<SomeInteger> &&);
273
- std::optional<Expr<SomeInteger>> team () const ;
274
- bool teamIsTeamNumber () const { return teamIsTeamNumber_; }
275
- CoarrayRef &set_team (Expr<SomeInteger> &&, bool isTeamNumber = false );
259
+ // When team() is Expr<SomeInteger>, it's TEAM_NUMBER=; otherwise,
260
+ // it's TEAM=.
261
+ std::optional<Expr<SomeType>> team () const ;
262
+ CoarrayRef &set_team (Expr<SomeType> &&);
276
263
277
264
int Rank () const ;
278
265
int Corank () const { return 0 ; }
279
266
const Symbol &GetFirstSymbol () const ;
280
267
const Symbol &GetLastSymbol () const ;
281
- NamedEntity GetBase () const ;
282
268
std::optional<Expr<SubscriptInteger>> LEN () const ;
283
269
bool operator ==(const CoarrayRef &) const ;
284
270
llvm::raw_ostream &AsFortran (llvm::raw_ostream &) const ;
285
271
286
272
private:
287
- SymbolVector base_;
288
- std::vector<Subscript> subscript_;
273
+ common::CopyableIndirection<DataRef> base_;
289
274
std::vector<Expr<SubscriptInteger>> cosubscript_;
290
- std::optional<common::CopyableIndirection<Expr<SomeInteger>>> stat_, team_ ;
291
- bool teamIsTeamNumber_{ false }; // false: TEAM=, true: TEAM_NUMBER=
275
+ std::optional<common::CopyableIndirection<Expr<SomeInteger>>> stat_;
276
+ std::optional<common::CopyableIndirection<Expr<SomeType>>> team_;
292
277
};
293
278
294
279
// R911 data-ref is defined syntactically as a series of part-refs, which
0 commit comments