[flang-dev] How to check when a Derived type is being defined inside resolve-names.cc

Kiran Chandramohan via flang-dev flang-dev at lists.llvm.org
Thu Jan 9 04:57:31 PST 2020


Hi,



"I would like to check when inside BlockData if a symbol is a derived type being defined."

Can you use the declaration visitor for DerivedTypeDef and check if the scope is BlockData?
bool DeclarationVisitor::Pre(const parser::DerivedTypeDef &x) {



"I can see there is a method:

void ConstructVisitor::Post(const parser::TypeGuardStmt::Guard &x)

Is this one checking when a derived type is being defined?"

This function in resolve-name.cc is creating a symbol and adding some type information for each type guard statement in a select type construct if there is an association. Hence I believe this is not checking for a derived type definition.

--Kiran

________________________________
From: flang-dev <flang-dev-bounces at lists.llvm.org> on behalf of Caroline Concatto via flang-dev <flang-dev at lists.llvm.org>
Sent: 20 December 2019 11:22
To: flang-dev at lists.llvm.org <flang-dev at lists.llvm.org>; tkeith at nvidia.com <tkeith at nvidia.com>
Subject: [flang-dev] How to check when a Derived type is being defined inside resolve-names.cc


Hey you all,



Me again, this time I have problem to check when a derived type is being defined.



I would like to check when inside BlockData if a symbol is a derived type being defined.



The function CheckDerivedTypeDefinition should check if a new declaration type is being defined.



void ResolveNamesVisitor::CheckDerivedTypeDefinition() {

  for (auto &pair : currScope()) {

    auto &symbol{*pair.second};

    if (currScope().kind() == Scope::Kind::BlockData){

      if (symbol.has<AssocEntityDetails>() || GetDeclTypeSpec()){

           Say(symbol.name(),

            "'%s' is declaration type definition"_err_en_US);

       }

    }

  }

}



I image these ones only check if the type is a derived type or if it has a type defined

currScope().IsDerivedType() || symbol.GetType()

but not a derived type declaration



I can see there is a method:

void ConstructVisitor::Post(const parser::TypeGuardStmt::Guard &x)

Is this one checking when a derived type is being defined?



I believe this is allowed inside BlockData:



block data bdderivedtype

type mytype

   integer:: i

end type mytype



  type (mytype)  var

end block data



PS.: I’ve created the Scope::Kind::BlockData, as it was not defined yet and I needed to make the semantic checks.



Thank you,



Carol




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20200109/8d0ffda8/attachment.html>


More information about the flang-dev mailing list