From 821f91d6ab668bbfcfc645a872acf91f71f76ff1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 5 Jul 2015 19:28:45 +0200 Subject: cmMakefile: Create a scoped context for parsing listfiles. Update the Syntax tests to check for updated/improved backtraces. --- Source/cmMakefile.cxx | 30 ++++++++++++++++++++++++ Source/cmMakefile.h | 1 + Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt | 4 +++- Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt | 4 +++- Tests/RunCMake/Syntax/ParenInENV-stderr.txt | 4 +++- Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt | 12 +++++++--- Tests/RunCMake/Syntax/StringNoSpace-stderr.txt | 8 +++++-- 15 files changed, 79 insertions(+), 16 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 08df655..0d48cbc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -547,6 +547,26 @@ void cmMakefile::IncludeScope::EnforceCMP0011() } } +class cmParseFileScope +{ +public: + cmParseFileScope(cmMakefile* mf) + : Makefile(mf) + { + this->Context.FilePath = this->Makefile->GetExecutionFilePath(); + this->Makefile->ContextStack.push_back(&this->Context); + } + + ~cmParseFileScope() + { + this->Makefile->ContextStack.pop_back(); + } + +private: + cmMakefile* Makefile; + cmListFileContext Context; +}; + bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", @@ -558,10 +578,14 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope) IncludeScope incScope(this, filenametoread, noPolicyScope); cmListFile listFile; + { + cmParseFileScope pfs(this); if (!listFile.ParseFile(filenametoread.c_str(), false, this)) { return false; } + } + this->ReadListFile(listFile, filenametoread); if(cmSystemTools::GetFatalErrorOccured()) { @@ -619,10 +643,13 @@ bool cmMakefile::ReadListFile(const char* filename) ListFileScope scope(this, filenametoread); cmListFile listFile; + { + cmParseFileScope pfs(this); if (!listFile.ParseFile(filenametoread.c_str(), false, this)) { return false; } + } this->ReadListFile(listFile, filenametoread); if(cmSystemTools::GetFatalErrorOccured()) @@ -1738,11 +1765,14 @@ void cmMakefile::Configure() this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str()); cmListFile listFile; + { + cmParseFileScope pfs(this); if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), this)) { this->SetConfigured(); return; } + } this->ReadListFile(listFile, currentStart); if(cmSystemTools::GetFatalErrorOccured()) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 01c9e8c..03b9c04 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -940,6 +940,7 @@ private: std::vector ContextStack; std::vector ExecutionStatusStack; friend class cmMakefileCall; + friend class cmParseFileScope; std::vector ImportedTargetsOwned; TargetMap ImportedTargets; diff --git a/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt index b3f1e47..a845ffb 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-16-BE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-16-BE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt index c08c902..cc4244b 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-16-LE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-16-LE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt index 5dde4e3..5f851bf 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-32-BE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-32-BE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt index eb054ec..d8fafd0 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-32-LE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-32-LE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt index afd91f9..a288280 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace0.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace0.cmake:1:27 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt index 826e511..391e11b 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace1.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace1.cmake:1:24 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt index 23ecdcd..acaf7fe 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace2.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace2.cmake:1:44 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt index 906d6fc..f12b2e5 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace3.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace3.cmake:1:45 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt index a461e93..7157763 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace4.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace4.cmake:1:44 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt index ff8bf1c..c13969d 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace5.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace5.cmake:1:45 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt index 7ecfe11..37c5d6e 100644 --- a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt +++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt @@ -1,9 +1,11 @@ -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in ParenInENV.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error at ParenInENV.cmake:2 \(message\): diff --git a/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt b/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt index 64ef8b1..45b2e6a 100644 --- a/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt +++ b/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt @@ -1,22 +1,28 @@ -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in ParenNoSpace1.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:1:26 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in ParenNoSpace1.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:2:26 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in ParenNoSpace1.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:3:29 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt b/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt index 89c2d2a..a4ec6e7 100644 --- a/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt +++ b/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt @@ -1,17 +1,21 @@ -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in StringNoSpace.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/StringNoSpace.cmake:2:28 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in StringNoSpace.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/StringNoSpace.cmake:2:31 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. \[1 \${var} \\n 4\] -- cgit v0.12