[PATCH] D100989: [flang] Fix checking of argument passing for parameterized derived types

Peter Klausler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 12:35:14 PDT 2021


klausler added inline comments.


================
Comment at: flang/lib/Evaluate/tools.cpp:1181
+// Used to check assignment statements and argument passing.  See 15.5.2.4(4)
+bool AreTypeParamCompatible(const semantics::DerivedTypeSpec &type1,
+    const semantics::DerivedTypeSpec &type2) {
----------------
I'm not sure that this is behaviorally identical with AreKindCompatible(), which only compares KIND type parameters and ignores LEN type parameters.


================
Comment at: flang/lib/Evaluate/tools.cpp:1185
+    if (semantics::MaybeIntExpr paramExpr1{param1.GetExplicit()}) {
+      if (evaluate::IsConstantExpr(*paramExpr1)) {
+        const semantics::ParamValue *param2{type2.FindParameter(name)};
----------------
You don't need to check that the expressions are "constant expressions" in the Fortran standard's sense if you're going to be extracting their actual integer constant values later with ToInt64().  I know that you didn't write this (at least not for this patch), but while you're moving this code we might as well simplify it.

const auto param2{type2.FindParameter(name)};
return !param2 || ToInt64(param1.GetExplicit()) == ToInt64(param2->GetExplicit();

The "evaluate::" namespace name isn't needed now that this code is in that namespace.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100989/new/

https://reviews.llvm.org/D100989



More information about the llvm-commits mailing list