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

Pete Steinfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 08:38:24 PDT 2021


PeteSteinfeld added inline comments.


================
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)};
----------------
PeteSteinfeld wrote:
> klausler wrote:
> > 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.
> Thanks for the suggestion.  The code is much cleaner with these changes.
Actually, except for the elimination of `evaluate::` these changes don't work.  We only want to do the comparison if we are able to get expressions for both of the parameters, and we only want to do the comparison when both of the parameters are constants.  Also, we need to loop through all of the parameters unless we hit one where they are not equal.


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