Browse Source

Merge topic 'fix-double-warn-uninitialized-in-script-mode'

53a5aec899 CMP0053: Fix double warning on uninitialized variables in -P mode
f92f93467e cmMakefile: Rename SuppressWatches to SuppressSideEffects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2565
pull/324/head
Brad King 7 years ago
committed by Kitware Robot
parent
commit
cf78a7df95
  1. 10
      Source/cmMakefile.cxx
  2. 2
      Source/cmMakefile.h
  3. 4
      Tests/RunCMake/CommandLine/RunCMakeTest.cmake
  4. 5
      Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt
  5. 1
      Tests/RunCMake/CommandLine/warn-uninitialized.cmake

10
Source/cmMakefile.cxx

@ -67,7 +67,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused(); this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
this->SuppressWatches = false;
this->SuppressSideEffects = false;
// Setup the default include complaint regular expression (match nothing). // Setup the default include complaint regular expression (match nothing).
this->ComplainFileRegularExpression = "^$"; this->ComplainFileRegularExpression = "^$";
@ -2421,7 +2421,7 @@ const std::string* cmMakefile::GetDef(const std::string& name) const
} }
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch(); cmVariableWatch* vv = this->GetVariableWatch();
if (vv && !this->SuppressWatches) {
if (vv && !this->SuppressSideEffects) {
bool const watch_function_executed = bool const watch_function_executed =
vv->VariableAccessed(name, vv->VariableAccessed(name,
def ? cmVariableWatch::VARIABLE_READ_ACCESS def ? cmVariableWatch::VARIABLE_READ_ACCESS
@ -2508,11 +2508,11 @@ const std::string& cmMakefile::ExpandVariablesInString(
compareResults = true; compareResults = true;
// Suppress variable watches to avoid calling hooks twice. Suppress new // Suppress variable watches to avoid calling hooks twice. Suppress new
// dereferences since the OLD behavior is still what is actually used. // dereferences since the OLD behavior is still what is actually used.
this->SuppressWatches = true;
this->SuppressSideEffects = true;
newError = ExpandVariablesInStringNew( newError = ExpandVariablesInStringNew(
newErrorstr, newResult, escapeQuotes, noEscapes, atOnly, filename, newErrorstr, newResult, escapeQuotes, noEscapes, atOnly, filename,
line, removeEmpty, replaceAt); line, removeEmpty, replaceAt);
this->SuppressWatches = false;
this->SuppressSideEffects = false;
CM_FALLTHROUGH; CM_FALLTHROUGH;
} }
case cmPolicies::OLD: case cmPolicies::OLD:
@ -2766,7 +2766,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
} else { } else {
varresult = value; varresult = value;
} }
} else if (!removeEmpty) {
} else if (!removeEmpty && !this->SuppressSideEffects) {
// check to see if we need to print a warning // check to see if we need to print a warning
// if strict mode is on and the variable has // if strict mode is on and the variable has
// not been "cleared"/initialized with a set(foo ) call // not been "cleared"/initialized with a set(foo ) call

2
Source/cmMakefile.h

@ -1025,7 +1025,7 @@ private:
bool CheckCMP0000; bool CheckCMP0000;
std::set<std::string> WarnedCMP0074; std::set<std::string> WarnedCMP0074;
bool IsSourceFileTryCompile; bool IsSourceFileTryCompile;
mutable bool SuppressWatches;
mutable bool SuppressSideEffects;
}; };
#endif #endif

4
Tests/RunCMake/CommandLine/RunCMakeTest.cmake

@ -348,6 +348,10 @@ set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized)
run_cmake(trace-expand-warn-uninitialized) run_cmake(trace-expand-warn-uninitialized)
unset(RunCMake_TEST_OPTIONS) unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --warn-uninitialized)
run_cmake(warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake) set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake)
run_cmake(trace-source) run_cmake(trace-source)
unset(RunCMake_TEST_OPTIONS) unset(RunCMake_TEST_OPTIONS)

5
Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt

@ -0,0 +1,5 @@
^CMake Warning \(dev\) at warn-uninitialized.cmake:1 \(set\):
uninitialized variable 'WARN_FROM_NORMAL_CMAKE_FILE'
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$

1
Tests/RunCMake/CommandLine/warn-uninitialized.cmake

@ -0,0 +1 @@
set(FOO "${WARN_FROM_NORMAL_CMAKE_FILE}")
Loading…
Cancel
Save