Fix warnings
This commit is contained in:
@@ -1,19 +1,8 @@
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "Utils/SgUtils.h"
|
||||
#include "set_implicit_none.h"
|
||||
#include <LoopAnalyzer/loop_analyzer.h>
|
||||
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using std::multimap;
|
||||
using std::set;
|
||||
using std::make_pair;
|
||||
using std::string;
|
||||
using std::to_string;
|
||||
|
||||
map<char, SgType*> types;
|
||||
vector<SgSymbol*> allVars;
|
||||
@@ -24,9 +13,11 @@ void InitTypes();
|
||||
void FillCommonTypes();
|
||||
void FunctionImplicitCheck(SgStatement* function);
|
||||
|
||||
void ImplicitCheck(SgFile* file) {
|
||||
void ImplicitCheck(SgFile* file)
|
||||
{
|
||||
|
||||
for (int funcNum = 0; funcNum < file->numberOfFunctions(); funcNum++) {
|
||||
for (int funcNum = 0; funcNum < file->numberOfFunctions(); funcNum++)
|
||||
{
|
||||
SgStatement* function = file->functions(funcNum);
|
||||
FunctionImplicitCheck(function);
|
||||
}
|
||||
@@ -34,22 +25,27 @@ void ImplicitCheck(SgFile* file) {
|
||||
return;
|
||||
}
|
||||
|
||||
void FunctionImplicitCheck(SgStatement* function) {
|
||||
void FunctionImplicitCheck(SgStatement* function)
|
||||
{
|
||||
auto implicitNoneDeclaration = new SgStatement(IMPL_DECL);
|
||||
auto hasImplicitNone = false;
|
||||
|
||||
InitTypes();
|
||||
FillCommonTypes();
|
||||
|
||||
for (SgStatement* i = function->lexNext(); i = i->lexNext(); i != NULL) {
|
||||
|
||||
if (i->variant() == IMPL_DECL) {
|
||||
SgImplicitStmt* implicitSt = isSgImplicitStmt(i);
|
||||
if (implicitSt) {
|
||||
for (SgStatement* statement = function->lexNext(); statement = statement->lexNext(); statement != NULL)
|
||||
{
|
||||
if (statement->variant() == IMPL_DECL)
|
||||
{
|
||||
SgImplicitStmt* implicitSt = isSgImplicitStmt(statement);
|
||||
if (implicitSt)
|
||||
{
|
||||
int numberOfTypes = implicitSt->numberOfImplicitTypes();
|
||||
|
||||
if (numberOfTypes > 0) {
|
||||
for (int j = 0; j < numberOfTypes; j++) {
|
||||
if (numberOfTypes > 0)
|
||||
{
|
||||
for (int j = 0; j < numberOfTypes; j++)
|
||||
{
|
||||
SgType* type = implicitSt->implicitType(j);
|
||||
SgExpression* letters = implicitSt->implicitRangeList(j);
|
||||
|
||||
@@ -57,15 +53,22 @@ void FunctionImplicitCheck(SgStatement* function) {
|
||||
types['o'] = type;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
hasImplicitNone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (statement->variant() == CONTAINS_STMT || isSgExecutableStatement(statement) != NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (SgSymbol* symbol = function->symbol(); symbol != NULL; symbol = symbol->next()) {
|
||||
if (symbol != NULL && symbol->declaredInStmt() != NULL) {
|
||||
for (SgSymbol* symbol = function->symbol(); symbol != NULL; symbol = symbol->next())
|
||||
{
|
||||
if (symbol != NULL && symbol->declaredInStmt() != NULL)
|
||||
{
|
||||
allVars.push_back(symbol);
|
||||
}
|
||||
}
|
||||
@@ -74,36 +77,38 @@ void FunctionImplicitCheck(SgStatement* function) {
|
||||
{
|
||||
vector<SgStatement*> _;
|
||||
SgStatement* declaredIn = declaratedInStmt(var, &_, false);
|
||||
if (declaredIn == NULL) {
|
||||
if (declaredIn == NULL)
|
||||
{
|
||||
char c = var->identifier()[0];
|
||||
|
||||
if (types.find(c) != types.end())
|
||||
{
|
||||
var->setType(types[c]);
|
||||
}
|
||||
|
||||
varsWithoutDecl.push_back(var);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto var : varsWithoutDecl) {
|
||||
vector<SgSymbol*> test = { var };
|
||||
char c = var->identifier()[0];
|
||||
makeDeclaration(varsWithoutDecl, function, NULL);
|
||||
|
||||
if (types.find(c) != types.end()) {
|
||||
test[0]->setType(types[c]);
|
||||
}
|
||||
|
||||
makeDeclaration(function, test);
|
||||
}
|
||||
|
||||
if (!hasImplicitNone) {
|
||||
for (SgStatement* i = function->lexNext(); i != NULL;) {
|
||||
if (i->variant() == IMPL_DECL) {
|
||||
if (!hasImplicitNone)
|
||||
{
|
||||
for (SgStatement* i = function->lexNext(); i != NULL;)
|
||||
{
|
||||
if (i->variant() == IMPL_DECL)
|
||||
{
|
||||
auto tmp = i;
|
||||
i = i->lexNext();
|
||||
tmp->deleteStmt();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
i = i->lexNext();
|
||||
}
|
||||
}
|
||||
|
||||
auto firstRealStatementOfFile = function->lexNext();
|
||||
firstRealStatementOfFile->insertStmtBefore(*implicitNoneDeclaration, *(firstRealStatementOfFile->controlParent()));
|
||||
function->insertStmtBefore(*implicitNoneDeclaration, *function);
|
||||
}
|
||||
|
||||
printf("%s", function->unparse());
|
||||
@@ -111,21 +116,28 @@ void FunctionImplicitCheck(SgStatement* function) {
|
||||
return;
|
||||
}
|
||||
|
||||
void InitTypes() {
|
||||
for (char i = 'a'; i <= 'z'; i++) {
|
||||
void InitTypes()
|
||||
{
|
||||
for (char i = 'a'; i <= 'z'; i++)
|
||||
{
|
||||
types[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void FillCommonTypes() {
|
||||
for (char i: commonIntLetters) {
|
||||
if (types[i] == NULL) {
|
||||
void FillCommonTypes()
|
||||
{
|
||||
for (char i: commonIntLetters)
|
||||
{
|
||||
if (types[i] == NULL)
|
||||
{
|
||||
types[i] = new SgType(T_INT);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto i : types) {
|
||||
if (i.second == NULL) {
|
||||
for (auto i : types)
|
||||
{
|
||||
if (i.second == NULL)
|
||||
{
|
||||
types[i.first] = new SgType(T_FLOAT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user