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.
This commit is contained in:
parent
59ce04d4f8
commit
59f6f383e9
|
@ -3388,14 +3388,20 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef)
|
||||||
// Now update the definition in the parent scope.
|
// Now update the definition in the parent scope.
|
||||||
up->Set(var, varDef);
|
up->Set(var, varDef);
|
||||||
}
|
}
|
||||||
else if(cmMakefile* parent =
|
else if(cmLocalGenerator* plg = this->LocalGenerator->GetParent())
|
||||||
this->LocalGenerator->GetParent()->GetMakefile())
|
|
||||||
{
|
{
|
||||||
// Update the definition in the parent directory top scope. This
|
// Update the definition in the parent directory top scope. This
|
||||||
// directory's scope was initialized by the closure of the parent
|
// directory's scope was initialized by the closure of the parent
|
||||||
// scope, so we do not need to localize the definition first.
|
// scope, so we do not need to localize the definition first.
|
||||||
|
cmMakefile* parent = plg->GetMakefile();
|
||||||
parent->Internal->VarStack.top().Set(var, varDef);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue