fixed implicit none and imterfaces insertion

This commit is contained in:
ALEXks
2024-05-13 10:37:59 +03:00
parent 4a13250d1c
commit 0b6a915753
3 changed files with 26 additions and 8 deletions

View File

@@ -960,10 +960,12 @@ static string getInterfaceBlock(SgStatement* func, const FuncParam& pars)
st = copy->lexNext(); st = copy->lexNext();
while (st != last) while (st != last)
{ {
if (st->variant() == VAR_DECL const int var = st->variant();
|| st->variant() == VAR_DECL_90 if (var == VAR_DECL
|| st->variant() == DIM_STAT || var == VAR_DECL_90
|| st->variant() == INTENT_STMT) || var == DIM_STAT
|| var == INTENT_STMT
|| var == EXTERN_STAT)
{ {
bool empty = filterFromList(st, idents); bool empty = filterFromList(st, idents);
if (empty) if (empty)

View File

@@ -37,8 +37,12 @@ static void FindAllVars(SgExpression* expr, set<SgSymbol*>& allVars, set<SgSymbo
const int var = expr->variant(); const int var = expr->variant();
if (var == VAR_REF || var == ARRAY_REF || var == FUNC_CALL) if (var == VAR_REF || var == ARRAY_REF || var == FUNC_CALL)
allVars.insert(expr->symbol()); {
if (var == CONST_REF) auto s = expr->symbol();
if ((s->attributes() & EXTERNAL_BIT) == 0)
allVars.insert(s);
}
else if (var == CONST_REF)
allVarsConst.insert(expr->symbol()); allVarsConst.insert(expr->symbol());
FindAllVars(expr->lhs(), allVars, allVarsConst); FindAllVars(expr->lhs(), allVars, allVarsConst);
@@ -183,7 +187,7 @@ static map<char, SgType*> FunctionImplicitCheck(SgStatement* function, const map
set<int> skip = { EXTERN_STAT }; set<int> skip = { EXTERN_STAT };
for (auto st = function; st != endOfFunc && st->variant() != CONTAINS_STMT; st = st->lexNext()) for (auto st = function->lexNext(); st != endOfFunc && st->variant() != CONTAINS_STMT; st = st->lexNext())
{ {
if (skip.count(st->variant())) if (skip.count(st->variant()))
continue; continue;
@@ -195,6 +199,18 @@ static map<char, SgType*> FunctionImplicitCheck(SgStatement* function, const map
allVars.insert(isSgForStmt(st)->doName()); allVars.insert(isSgForStmt(st)->doName());
} }
//add parameters
auto prog = isSgProgHedrStmt(function);
if (prog)
{
for (int z = 0; z < prog->numberOfParameters(); ++z)
{
auto s = prog->parameter(z);
if ((s->attributes() & EXTERNAL_BIT) == 0)
allVars.insert(s);
}
}
varsWithoutDecl = getVars(function->symbol()->identifier(), toRename, allVars, types); varsWithoutDecl = getVars(function->symbol()->identifier(), toRename, allVars, types);
varsWithoutDeclConst = getVars(function->symbol()->identifier(), toRename, allVarsConst, types); varsWithoutDeclConst = getVars(function->symbol()->identifier(), toRename, allVarsConst, types);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2333" #define VERSION_SPF "2334"