[flang-commits] [flang] [mlir] [flang][AIX] BIND(C) derived type alignment for AIX (PR #121505)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Jan 2 09:48:24 PST 2025
================
@@ -65,6 +70,60 @@ class ComputeOffsetsHelper {
equivalenceBlock_;
};
+static bool isReal8OrLarger(const Fortran::semantics::DeclTypeSpec *type) {
+ return ((type->IsNumeric(common::TypeCategory::Real) ||
+ type->IsNumeric(common::TypeCategory::Complex)) &&
+ evaluate::ToInt64(type->numericTypeSpec().kind()) > 4);
+}
+
+std::optional<size_t> ComputeOffsetsHelper::CompAlignment(const Symbol &sym) {
+ size_t max_align{0};
+ bool contain_double{false};
+ const auto derivedTypeSpec{sym.GetType()->AsDerived()};
+ DirectComponentIterator directs{*derivedTypeSpec};
+ for (auto it = directs.begin(); it != directs.end(); ++it) {
+ auto type{it->GetType()};
+ auto s{GetSizeAndAlignment(*it, true)};
+ if (isReal8OrLarger(type)) {
+ max_align = std::max(max_align, 4UL);
+ contain_double = true;
+ } else if (type->AsDerived()) {
+ if (const auto newAlgin = CompAlignment(*it)) {
----------------
klausler wrote:
braced initialization, please
https://github.com/llvm/llvm-project/pull/121505
More information about the flang-commits
mailing list