summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-11-02 16:56:17 (GMT)
committerBrad King <brad.king@kitware.com>2009-11-02 16:56:17 (GMT)
commit59f6f383e9f87ee39f8cef7984b2993204fbd214 (patch)
tree5480cbbc1cdf54faff168c9bbc171ec687ddb401 /Source/cmMakefile.cxx
parent59ce04d4f8014ea96f9cca6618606ea30761c9b9 (diff)
downloadCMake-59f6f383e9f87ee39f8cef7984b2993204fbd214.zip
CMake-59f6f383e9f87ee39f8cef7984b2993204fbd214.tar.gz
CMake-59f6f383e9f87ee39f8cef7984b2993204fbd214.tar.bz2
Warn on set(PARENT_SCOPE) at top scope
Previously we silently ignored such calls and set nothing. The commit "Initialize directory scope with closure of parent" inroduced a bad test for the top scope. This commit fixes the test to avoid dereferencing a null pointer, and adds a warning when the case is encountered.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 88c8c7b..d09188a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3388,14 +3388,20 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef)
// Now update the definition in the parent scope.
up->Set(var, varDef);
}
- else if(cmMakefile* parent =
- this->LocalGenerator->GetParent()->GetMakefile())
+ else if(cmLocalGenerator* plg = this->LocalGenerator->GetParent())
{
// Update the definition in the parent directory top scope. This
// directory's scope was initialized by the closure of the parent
// scope, so we do not need to localize the definition first.
+ cmMakefile* parent = plg->GetMakefile();
parent->Internal->VarStack.top().Set(var, varDef);
}
+ else
+ {
+ cmOStringStream m;
+ m << "Cannot set \"" << var << "\": current scope has no parent.";
+ this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+ }
}