improved MERGE_ARRAYS

This commit is contained in:
ALEXks
2026-05-03 21:00:07 +03:00
parent 51f97e2be9
commit 5a3c936b5c
8 changed files with 77 additions and 75 deletions

View File

@@ -186,12 +186,13 @@ static bool checkCover(SgStatement* st,
return retVal;
}
static bool checkProcessPrivate(SgStatement* st,
SgStatement* attributeStatement,
const set<Symbol*>& privates,
vector<Messages>& messagesForFile)
static bool checkDeclaration(SgStatement* st,
SgStatement* attributeStatement,
const set<Symbol*>& variables,
vector<Messages>& messagesForFile)
{
// PROCESS_PRIVATE(VAR)
// MERGE_ARRAYS(ARR1, ARR2)
const int var = st->variant();
bool retVal = true;
@@ -203,12 +204,12 @@ static bool checkProcessPrivate(SgStatement* st,
set<string> varDef, varUse;
fillVarsSets(iterator, end, varDef, varUse);
for (auto& privElemS : privates)
for (auto& var : variables)
{
const string privElem = privElemS->GetOriginal()->identifier();
const string varElem = var->GetOriginal()->identifier();
bool defCond = true;
if (varDef.find(privElem) == varDef.end())
if (varDef.find(varElem) == varDef.end())
defCond = false;
if (!defCond)
@@ -1784,7 +1785,7 @@ static inline bool processStat(SgStatement *st, const string &currFile,
fillPrivatesFromComment(new Statement(attributeStatement), privates, SPF_PROCESS_PRIVATE_OP);
if (privates.size())
{
bool result = checkProcessPrivate(st, attributeStatement, privates, messagesForFile);
bool result = checkDeclaration(st, attributeStatement, privates, messagesForFile);
retVal = retVal && result;
}
@@ -1938,11 +1939,20 @@ static inline bool processStat(SgStatement *st, const string &currFile,
if (isSPF_OP(attributeStatement, SPF_MERGE_ARRAYS_OP))
{
attributeStatement->setLocalLineNumber(-1);
/*if (st->variant() != FOR_NODE)
if (!isSgDeclarationStatement(st))
{
BAD_POSITION_FULL(ERROR, "", "", "before", RR1_1, "DO statement", RR1_3, attributeStatement->lineNumber());
BAD_POSITION_FULL(ERROR, "", "", "before", RR1_1, "declataion statement", RR1_9, attributeStatement->lineNumber());
retVal = false;
}*/
}
else
{
pair<Symbol*, Symbol*> toReplacePair;
fillMergeArraysFromComment(new Statement(attributeStatement), toReplacePair);
set<Symbol*> toCheckDecl = { toReplacePair.first };
bool result = checkDeclaration(st, attributeStatement, toCheckDecl, messagesForFile);
retVal = retVal && result;
}
}
}
else if (type == SPF_CHECKPOINT_DIR)