fixed CalculateInteger usage

This commit is contained in:
ALEXks
2024-04-09 11:51:21 +03:00
parent 0a2e187d26
commit 1b4eb0c5c4
7 changed files with 13 additions and 13 deletions

View File

@@ -328,7 +328,7 @@ static void processActualParams(SgExpression *parList, const map<string, vector<
currParams.parametersT[num] = parf; currParams.parametersT[num] = parf;
if (parf == SCALAR_INT_T) if (parf == SCALAR_INT_T)
{ {
SgExpression* result = CalculateInteger(ex->lhs()); SgExpression* result = CalculateInteger(ex->lhs()->copyPtr());
if (result != ex->lhs()) if (result != ex->lhs())
{ {
currParams.parameters[num] = new int[1]; currParams.parameters[num] = new int[1];

View File

@@ -2320,20 +2320,20 @@ static void createDeclarations(const map<SgStatement*, set<SgSymbol*>>& newSymbs
if (t->selector()) if (t->selector())
{ {
if (t->selector()->variant() == CONST_REF) if (t->selector()->variant() == CONST_REF)
t->setSelector(CalculateInteger(t->selector())); t->setSelector(CalculateInteger(t->selector()->copyPtr()));
} }
if (t->length()) if (t->length())
{ {
if (t->length()->variant() == CONST_REF) if (t->length()->variant() == CONST_REF)
{ {
auto result = CalculateInteger(t->length()); auto result = CalculateInteger(t->length()->copyPtr());
if (result->variant() == INT_VAL) if (result->variant() == INT_VAL)
t->setLength(result); t->setLength(result);
} }
} }
} }
auto result = CalculateInteger(list->lhs()); auto result = CalculateInteger(list->lhs()->copyPtr());
list->setLhs(result); list->setLhs(result);
} }
list = list->rhs(); list = list->rhs();

View File

@@ -2559,9 +2559,9 @@ SgExpression* getTypeLengthExpr(SgType *t)
if (!len && !selector) //the number of bytes is not specified in type declaration statement if (!len && !selector) //the number of bytes is not specified in type declaration statement
return (new SgValueExp(getIntrinsicTypeSize(t))); return (new SgValueExp(getIntrinsicTypeSize(t)));
else if (len && !selector) //INTEGER*2,REAL*8,CHARACTER*(N+1) else if (len && !selector) //INTEGER*2,REAL*8,CHARACTER*(N+1)
return CalculateInteger(len); return CalculateInteger(len->copyPtr());
else else
return CalculateInteger(getLengthOfKindExpr(t, selector, len)); //specified kind or/and len return CalculateInteger(getLengthOfKindExpr(t, selector, len)->copyPtr()); //specified kind or/and len
} }
int getSizeOfType(SgType *t) int getSizeOfType(SgType *t)

View File

@@ -631,7 +631,7 @@ int printParalleRegions(const char *fileName, vector<ParallelRegion*> &regions)
static int getIntVal(SgExpression *ex) static int getIntVal(SgExpression *ex)
{ {
SgExpression* calc = CalculateInteger(ex); SgExpression* calc = CalculateInteger(ex->copyPtr());
if (calc->variant() == INT_VAL) if (calc->variant() == INT_VAL)
return calc->valueInteger(); return calc->valueInteger();
else else

View File

@@ -114,7 +114,7 @@ static string getStringDeclaration(SgSymbol *symb)
if (SgFile::switchToFile(symb->getFile()->filename()) != -1) if (SgFile::switchToFile(symb->getFile()->filename()) != -1)
{ {
auto stat = symb->makeVarDeclStmt(); auto stat = symb->makeVarDeclStmt();
auto res = CalculateInteger(stat->expr(0)); auto res = CalculateInteger(stat->expr(0)->copyPtr());
stat->setExpression(0, res); stat->setExpression(0, res);
decl = stat->unparse(); decl = stat->unparse();
} }

View File

@@ -131,13 +131,13 @@ static bool isEqExpressions(SgExpression* exp1, SgExpression* exp2)
if (exp1 != NULL) if (exp1 != NULL)
{ {
exp1 = CalculateInteger(exp1); exp1 = CalculateInteger(exp1->copyPtr());
str1 = exp1->unparse(); str1 = exp1->unparse();
} }
if (exp2 != NULL) if (exp2 != NULL)
{ {
exp2 = CalculateInteger(exp2); exp2 = CalculateInteger(exp2->copyPtr());
str2 = exp2->unparse(); str2 = exp2->unparse();
} }
@@ -150,8 +150,8 @@ static bool isOppositeExpressions(SgExpression* exp1, SgExpression* exp2)
if (exp1 == NULL || exp2 == NULL) if (exp1 == NULL || exp2 == NULL)
return false; return false;
exp1 = CalculateInteger(exp1); exp1 = CalculateInteger(exp1->copyPtr());
exp2 = CalculateInteger(exp2); exp2 = CalculateInteger(exp2->copyPtr());
if (exp1->variant() == MINUS_OP) if (exp1->variant() == MINUS_OP)
return isEqExpressions(exp1->lhs(), exp2); return isEqExpressions(exp1->lhs(), exp2);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION_SPF "2307" #define VERSION_SPF "2308"