From 59463ef1a33a22113e1c577c450d7b2c70916bbc Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 16 Sep 2010 11:50:57 -0400 Subject: [PATCH] Rework CheckVariableForUnused usage --- Source/cmMakefile.cxx | 10 ++++++---- Source/cmMakefile.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 592e05e6d..df871ec41 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1771,7 +1771,7 @@ bool cmMakefile::VariableCleared(const char* var) const return false; } -bool cmMakefile::CheckForUnused(const char* reason, const char* name) +void cmMakefile::CheckForUnused(const char* reason, const char* name) const { if (this->WarnUnused && !this->VariableUsed(name)) { @@ -1786,10 +1786,8 @@ bool cmMakefile::CheckForUnused(const char* reason, const char* name) msg << file->FilePath << ":" << file->Line << ":" << " warning: (" << reason << ") unused variable \'" << name << "\'"; cmSystemTools::Message(msg.str().c_str()); - return true; } } - return false; } void cmMakefile::RemoveDefinition(const char* name) @@ -3429,7 +3427,11 @@ void cmMakefile::PopScope() for (; it != locals.end(); ++it) { init.erase(*it); - if (!this->CheckForUnused("out of scope", it->c_str())) + if (!this->VariableUsed(it->c_str())) + { + this->CheckForUnused("out of scope", it->c_str()); + } + else { usage.erase(*it); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6b0bfa26a..782690318 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -844,7 +844,7 @@ protected: void AddGlobalLinkInformation(const char* name, cmTarget& target); // Check for a an unused variable - bool CheckForUnused(const char* reason, const char* name); + void CheckForUnused(const char* reason, const char* name) const; std::string Prefix; std::vector AuxSourceDirectories; //