@@ -263,6 +263,20 @@ struct TypeBuilder {
263
263
return ty;
264
264
}
265
265
266
+ // / Does \p component has non deferred lower bounds that are not compile time
267
+ // / constant 1.
268
+ static bool componentHasNonDefaultLowerBounds (
269
+ const Fortran::semantics::Symbol &component) {
270
+ if (const auto *objDetails =
271
+ component.detailsIf <Fortran::semantics::ObjectEntityDetails>())
272
+ for (const auto &bounds : objDetails->shape ())
273
+ if (auto lb = bounds.lbound ().GetExplicit ())
274
+ if (auto constant = Fortran::evaluate::ToInt64 (*lb))
275
+ if (!constant || *constant != 1 )
276
+ return true ;
277
+ return false ;
278
+ }
279
+
266
280
mlir::Type genDerivedType (const Fortran::semantics::DerivedTypeSpec &tySpec) {
267
281
std::vector<std::pair<std::string, mlir::Type>> ps;
268
282
std::vector<std::pair<std::string, mlir::Type>> cs;
@@ -278,6 +292,11 @@ struct TypeBuilder {
278
292
// (1) The data components.
279
293
for (const auto &field :
280
294
Fortran::semantics::OrderedComponentIterator (tySpec)) {
295
+ // Lowering is assuming non deferred component lower bounds are always 1.
296
+ // Catch any situations where this is not true for now.
297
+ if (componentHasNonDefaultLowerBounds (field))
298
+ TODO (converter.genLocation (field.name ()),
299
+ " lowering derived type components with non default lower bounds" );
281
300
auto ty = genSymbolType (field);
282
301
// Do not add the parent component (component of the parents are
283
302
// added and should be sufficient, the parent component would
0 commit comments