Removed warning for uninitialized variables in ZScript

This reverts commit 8104ef5189
This commit is contained in:
alexey.lysiuk 2017-11-06 15:37:26 +02:00
parent d4ebe51e83
commit 4beefb7007
2 changed files with 6 additions and 39 deletions

View file

@ -2692,7 +2692,6 @@ FxExpression *FxMultiAssign::Resolve(FCompileContext &ctx)
for (unsigned i = 0; i < Base.Size(); i++)
{
auto singlevar = new FxLocalVariableDeclaration(rets[i], NAME_None, nullptr, 0, ScriptPosition);
singlevar->IsInitialized = true;
LocalVarContainer->Add(singlevar);
Base[i] = Base[i]->Resolve(ctx);
ABORT(Base[i]);
@ -6032,7 +6031,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
}
else
{
auto x = new FxStackVariable(local, ScriptPosition);
auto x = new FxStackVariable(local->ValueType, local->StackOffset, ScriptPosition);
delete this;
return x->Resolve(ctx);
}
@ -6521,7 +6520,6 @@ FxLocalVariable::FxLocalVariable(FxLocalVariableDeclaration *var, const FScriptP
FxExpression *FxLocalVariable::Resolve(FCompileContext &ctx)
{
CHECKRESOLVED();
IsLocalVariable = ctx.FunctionArgs.Find(Variable) == ctx.FunctionArgs.Size();
return this;
}
@ -6555,16 +6553,7 @@ ExpEmit FxLocalVariable::Emit(VMFunctionBuilder *build)
{
ExpEmit ret(Variable->RegNum + RegOffset, Variable->ValueType->GetRegType(), false, true);
ret.RegCount = ValueType->GetRegCount();
if (AddressRequested)
{
Variable->IsInitialized = true;
ret.Target = true;
}
else if (IsLocalVariable)
{
Variable->WarnIfUninitialized(ScriptPosition);
}
if (AddressRequested) ret.Target = true;
return ret;
}
}
@ -6906,9 +6895,8 @@ ExpEmit FxCVar::Emit(VMFunctionBuilder *build)
//
//==========================================================================
FxStackVariable::FxStackVariable(FxLocalVariableDeclaration *var, const FScriptPosition &pos)
: FxMemberBase(EFX_StackVariable, Create<PField>(NAME_None, var->ValueType, 0, var->StackOffset), pos)
, Variable(var)
FxStackVariable::FxStackVariable(PType *type, int offset, const FScriptPosition &pos)
: FxMemberBase(EFX_StackVariable, Create<PField>(NAME_None, type, 0, offset), pos)
{
}
@ -6959,8 +6947,6 @@ ExpEmit FxStackVariable::Emit(VMFunctionBuilder *build)
if (AddressRequested)
{
Variable->IsInitialized = true;
if (offsetreg >= 0)
{
ExpEmit obj(build, REGT_POINTER);
@ -6972,10 +6958,6 @@ ExpEmit FxStackVariable::Emit(VMFunctionBuilder *build)
return build->FramePointer;
}
}
else
{
Variable->WarnIfUninitialized(ScriptPosition);
}
ExpEmit loc(build, membervar->Type->GetRegType(), membervar->Type->GetRegCount());
if (membervar->BitValue == -1)
@ -11421,16 +11403,6 @@ void FxLocalVariableDeclaration::Release(VMFunctionBuilder *build)
// For that all local stack variables need to live for the entire execution of a function.
}
void FxLocalVariableDeclaration::WarnIfUninitialized(const FScriptPosition &varPos) const
{
if (!IsInitialized && nullptr == Init)
{
varPos.Message(MSG_WARNING,
"Usage of uninitialized variable '%s' defined at line %i",
Name.GetChars(), ScriptPosition.ScriptLine);
}
}
FxStaticArray::FxStaticArray(PType *type, FName name, FArgumentList &args, const FScriptPosition &pos)
: FxLocalVariableDeclaration(NewArray(type, args.Size()), name, nullptr, VARF_Static|VARF_ReadOnly, pos)

View file

@ -1425,7 +1425,6 @@ class FxLocalVariable : public FxExpression
public:
FxLocalVariableDeclaration *Variable;
bool AddressRequested;
bool IsLocalVariable; // false for function parameter and true otherwise
int RegOffset;
FxLocalVariable(FxLocalVariableDeclaration*, const FScriptPosition&);
@ -1443,9 +1442,7 @@ public:
class FxStackVariable : public FxMemberBase
{
public:
FxLocalVariableDeclaration *Variable;
FxStackVariable(FxLocalVariableDeclaration*, const FScriptPosition&);
FxStackVariable(PType *type, int offset, const FScriptPosition&);
~FxStackVariable();
FxExpression *Resolve(FCompileContext&);
bool RequestAddress(FCompileContext &ctx, bool *writable);
@ -2124,7 +2121,6 @@ class FxLocalVariableDeclaration : public FxExpression
{
friend class FxCompoundStatement;
friend class FxLocalVariable;
friend class FxStackVariable;
friend class FxStaticArrayVariable;
FName Name;
@ -2134,7 +2130,6 @@ class FxLocalVariableDeclaration : public FxExpression
public:
int StackOffset = -1;
int RegNum = -1;
bool IsInitialized = false;
FxLocalVariableDeclaration(PType *type, FName name, FxExpression *initval, int varflags, const FScriptPosition &p);
~FxLocalVariableDeclaration();
@ -2142,7 +2137,7 @@ public:
ExpEmit Emit(VMFunctionBuilder *build);
void Release(VMFunctionBuilder *build);
void SetReg(ExpEmit reginfo);
void WarnIfUninitialized(const FScriptPosition &varPos) const;
};
//==========================================================================