[PATCH] D84290: [Flang] Fix for the scenario when type guard has intrinsic type specification and Selector is NOT unlimited Polymorphic.

sameeran joshi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 27 22:53:30 PDT 2020


sameeranjoshi added inline comments.


================
Comment at: flang/lib/Semantics/check-select-type.cpp:77
+    const parser::TypeGuardStmt &typeGuardStmt{stmt.statement};
+    const auto &guard{std::get<parser::TypeGuardStmt::Guard>(typeGuardStmt.t)};
     return std::visit(
----------------
inderjeet-hcl wrote:
> inderjeet-hcl wrote:
> > sameeranjoshi wrote:
> > > Can you please use `GetGuardFromStmt` here? 
> > ok, I will update source code.
> GetGuardFromStmt is defined in struct TypeCase and can not be called from PassesChecksOnGuard as we do not have object of class TypeCase in function PassesChecksOnGuard.
> Kindly suggest if I should pass object of class TypeCase as a parameter to PassesChecksOnGuard or we can keep above modifications without calling GetGuardFromStmt.
Ok, please revert with the older way.


================
Comment at: flang/lib/Semantics/check-select-type.cpp:103
+              } else {
+                const DerivedTypeSpec *derived{spec->AsDerived()};
+                typeSpecRetVal = PassesDerivedTypeChecks(
----------------
inderjeet-hcl wrote:
> sameeranjoshi wrote:
> > `DeclTypeSpec::AsDerived` might return `nullptr`. Please wrap it in some conditional statement.
> I have added  CHECK(spec); and CHECK(spec->AsIntrinsic() || spec->AsDerived()); at the start considering if code in block "[&](const parser::TypeSpec &typeSpec)" is executed then spec will always be one of intrinsic or derived type and one of AsIntrinsic() or AsDerived() will return non NULL value.
> Considering above description, I think AsDerived() will not return NULL at this location as this code is present in 'else' of AsIntrinsic().
> Kindly suggest.
Sorry, I missed it.
Your point seems correct.


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

https://reviews.llvm.org/D84290



More information about the llvm-commits mailing list