mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Removed warning for uninitialized variables in ZScript
This reverts commit 8104ef5189
This commit is contained in:
parent
d4ebe51e83
commit
4beefb7007
2 changed files with 6 additions and 39 deletions
|
@ -2692,7 +2692,6 @@ FxExpression *FxMultiAssign::Resolve(FCompileContext &ctx)
|
||||||
for (unsigned i = 0; i < Base.Size(); i++)
|
for (unsigned i = 0; i < Base.Size(); i++)
|
||||||
{
|
{
|
||||||
auto singlevar = new FxLocalVariableDeclaration(rets[i], NAME_None, nullptr, 0, ScriptPosition);
|
auto singlevar = new FxLocalVariableDeclaration(rets[i], NAME_None, nullptr, 0, ScriptPosition);
|
||||||
singlevar->IsInitialized = true;
|
|
||||||
LocalVarContainer->Add(singlevar);
|
LocalVarContainer->Add(singlevar);
|
||||||
Base[i] = Base[i]->Resolve(ctx);
|
Base[i] = Base[i]->Resolve(ctx);
|
||||||
ABORT(Base[i]);
|
ABORT(Base[i]);
|
||||||
|
@ -6032,7 +6031,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto x = new FxStackVariable(local, ScriptPosition);
|
auto x = new FxStackVariable(local->ValueType, local->StackOffset, ScriptPosition);
|
||||||
delete this;
|
delete this;
|
||||||
return x->Resolve(ctx);
|
return x->Resolve(ctx);
|
||||||
}
|
}
|
||||||
|
@ -6521,7 +6520,6 @@ FxLocalVariable::FxLocalVariable(FxLocalVariableDeclaration *var, const FScriptP
|
||||||
FxExpression *FxLocalVariable::Resolve(FCompileContext &ctx)
|
FxExpression *FxLocalVariable::Resolve(FCompileContext &ctx)
|
||||||
{
|
{
|
||||||
CHECKRESOLVED();
|
CHECKRESOLVED();
|
||||||
IsLocalVariable = ctx.FunctionArgs.Find(Variable) == ctx.FunctionArgs.Size();
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6555,16 +6553,7 @@ ExpEmit FxLocalVariable::Emit(VMFunctionBuilder *build)
|
||||||
{
|
{
|
||||||
ExpEmit ret(Variable->RegNum + RegOffset, Variable->ValueType->GetRegType(), false, true);
|
ExpEmit ret(Variable->RegNum + RegOffset, Variable->ValueType->GetRegType(), false, true);
|
||||||
ret.RegCount = ValueType->GetRegCount();
|
ret.RegCount = ValueType->GetRegCount();
|
||||||
if (AddressRequested)
|
if (AddressRequested) ret.Target = true;
|
||||||
{
|
|
||||||
Variable->IsInitialized = true;
|
|
||||||
ret.Target = true;
|
|
||||||
}
|
|
||||||
else if (IsLocalVariable)
|
|
||||||
{
|
|
||||||
Variable->WarnIfUninitialized(ScriptPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6906,9 +6895,8 @@ ExpEmit FxCVar::Emit(VMFunctionBuilder *build)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FxStackVariable::FxStackVariable(FxLocalVariableDeclaration *var, const FScriptPosition &pos)
|
FxStackVariable::FxStackVariable(PType *type, int offset, const FScriptPosition &pos)
|
||||||
: FxMemberBase(EFX_StackVariable, Create<PField>(NAME_None, var->ValueType, 0, var->StackOffset), pos)
|
: FxMemberBase(EFX_StackVariable, Create<PField>(NAME_None, type, 0, offset), pos)
|
||||||
, Variable(var)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6959,8 +6947,6 @@ ExpEmit FxStackVariable::Emit(VMFunctionBuilder *build)
|
||||||
|
|
||||||
if (AddressRequested)
|
if (AddressRequested)
|
||||||
{
|
{
|
||||||
Variable->IsInitialized = true;
|
|
||||||
|
|
||||||
if (offsetreg >= 0)
|
if (offsetreg >= 0)
|
||||||
{
|
{
|
||||||
ExpEmit obj(build, REGT_POINTER);
|
ExpEmit obj(build, REGT_POINTER);
|
||||||
|
@ -6972,10 +6958,6 @@ ExpEmit FxStackVariable::Emit(VMFunctionBuilder *build)
|
||||||
return build->FramePointer;
|
return build->FramePointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Variable->WarnIfUninitialized(ScriptPosition);
|
|
||||||
}
|
|
||||||
ExpEmit loc(build, membervar->Type->GetRegType(), membervar->Type->GetRegCount());
|
ExpEmit loc(build, membervar->Type->GetRegType(), membervar->Type->GetRegCount());
|
||||||
|
|
||||||
if (membervar->BitValue == -1)
|
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.
|
// 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)
|
FxStaticArray::FxStaticArray(PType *type, FName name, FArgumentList &args, const FScriptPosition &pos)
|
||||||
: FxLocalVariableDeclaration(NewArray(type, args.Size()), name, nullptr, VARF_Static|VARF_ReadOnly, pos)
|
: FxLocalVariableDeclaration(NewArray(type, args.Size()), name, nullptr, VARF_Static|VARF_ReadOnly, pos)
|
||||||
|
|
|
@ -1425,7 +1425,6 @@ class FxLocalVariable : public FxExpression
|
||||||
public:
|
public:
|
||||||
FxLocalVariableDeclaration *Variable;
|
FxLocalVariableDeclaration *Variable;
|
||||||
bool AddressRequested;
|
bool AddressRequested;
|
||||||
bool IsLocalVariable; // false for function parameter and true otherwise
|
|
||||||
int RegOffset;
|
int RegOffset;
|
||||||
|
|
||||||
FxLocalVariable(FxLocalVariableDeclaration*, const FScriptPosition&);
|
FxLocalVariable(FxLocalVariableDeclaration*, const FScriptPosition&);
|
||||||
|
@ -1443,9 +1442,7 @@ public:
|
||||||
class FxStackVariable : public FxMemberBase
|
class FxStackVariable : public FxMemberBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FxLocalVariableDeclaration *Variable;
|
FxStackVariable(PType *type, int offset, const FScriptPosition&);
|
||||||
|
|
||||||
FxStackVariable(FxLocalVariableDeclaration*, const FScriptPosition&);
|
|
||||||
~FxStackVariable();
|
~FxStackVariable();
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
bool RequestAddress(FCompileContext &ctx, bool *writable);
|
bool RequestAddress(FCompileContext &ctx, bool *writable);
|
||||||
|
@ -2124,7 +2121,6 @@ class FxLocalVariableDeclaration : public FxExpression
|
||||||
{
|
{
|
||||||
friend class FxCompoundStatement;
|
friend class FxCompoundStatement;
|
||||||
friend class FxLocalVariable;
|
friend class FxLocalVariable;
|
||||||
friend class FxStackVariable;
|
|
||||||
friend class FxStaticArrayVariable;
|
friend class FxStaticArrayVariable;
|
||||||
|
|
||||||
FName Name;
|
FName Name;
|
||||||
|
@ -2134,7 +2130,6 @@ class FxLocalVariableDeclaration : public FxExpression
|
||||||
public:
|
public:
|
||||||
int StackOffset = -1;
|
int StackOffset = -1;
|
||||||
int RegNum = -1;
|
int RegNum = -1;
|
||||||
bool IsInitialized = false;
|
|
||||||
|
|
||||||
FxLocalVariableDeclaration(PType *type, FName name, FxExpression *initval, int varflags, const FScriptPosition &p);
|
FxLocalVariableDeclaration(PType *type, FName name, FxExpression *initval, int varflags, const FScriptPosition &p);
|
||||||
~FxLocalVariableDeclaration();
|
~FxLocalVariableDeclaration();
|
||||||
|
@ -2142,7 +2137,7 @@ public:
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
void Release(VMFunctionBuilder *build);
|
void Release(VMFunctionBuilder *build);
|
||||||
void SetReg(ExpEmit reginfo);
|
void SetReg(ExpEmit reginfo);
|
||||||
void WarnIfUninitialized(const FScriptPosition &varPos) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue