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() || 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

Hi Carol,

While I cannot help you with any of this, sorry!, I would kindly ask you
and others to write up the things that need clarification afterwards in
code comments and method (doxygen) documentation, if applicable of
course.

Happy holidays!

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