Fix detection of unused variables when setting

This commit is contained in:
Ben Boeckel 2010-09-16 13:53:41 -04:00
parent f7438ca7ac
commit ca90f673a0
1 changed files with 3 additions and 3 deletions

View File

@ -1648,7 +1648,7 @@ void cmMakefile::AddDefinition(const char* name, const char* value)
#endif #endif
this->Internal->VarStack.top().Set(name, value); this->Internal->VarStack.top().Set(name, value);
if ((this->Internal->VarUsageStack.size() > 1) && if (this->Internal->VarUsageStack.size() &&
this->VariableInitialized(name)) this->VariableInitialized(name))
{ {
this->CheckForUnused("changing definition", name); this->CheckForUnused("changing definition", name);
@ -1719,7 +1719,7 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value,
void cmMakefile::AddDefinition(const char* name, bool value) void cmMakefile::AddDefinition(const char* name, bool value)
{ {
this->Internal->VarStack.top().Set(name, value? "ON" : "OFF"); this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
if ((this->Internal->VarUsageStack.size() > 1) && if (this->Internal->VarUsageStack.size() &&
this->VariableInitialized(name)) this->VariableInitialized(name))
{ {
this->CheckForUnused("changing definition", name); this->CheckForUnused("changing definition", name);
@ -1763,7 +1763,7 @@ bool cmMakefile::VariableUsed(const char* var) const
void cmMakefile::CheckForUnused(const char* reason, const char* name) const void cmMakefile::CheckForUnused(const char* reason, const char* name) const
{ {
if (this->WarnUnused && !this->VariableUsed(name)) if (this->WarnUnused && !this->VariableUsed(name) && this->CallStack.size())
{ {
const cmListFileContext* file = this->CallStack.back().Context; const cmListFileContext* file = this->CallStack.back().Context;
if (this->CheckSystemVars || if (this->CheckSystemVars ||