From b581be07672e08cce4c29fa279b250d8e9c7aaba Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 26 Nov 2012 22:44:13 +0100 Subject: Genex: Don't segfault on $ Treat the comma as part of the identifier here. It will later not resolve to a generator expression and the user gets a proper error message. --- Source/cmGeneratorExpressionParser.cxx | 10 +++++++++- Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt | 9 +++++++++ Tests/RunCMake/GeneratorExpression/BadZero.cmake | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index 7a8fc51..a619cec 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -88,7 +88,15 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression && this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator) { - this->ParseContent(identifier); + if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) + { + extendText(identifier, this->it); + ++this->it; + } + else + { + this->ParseContent(identifier); + } if (this->it == this->Tokens.end()) { break; diff --git a/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt index ce04482..40db4ae 100644 --- a/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadZero-stderr.txt @@ -6,3 +6,12 @@ CMake Error at BadZero.cmake:2 \(add_custom_target\): \$<0> expression requires a parameter. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) ++ +CMake Error at BadZero.cmake:2 \(add_custom_target\): + Error evaluating generator expression: + + \$<0,> + + Expression did not evaluate to a known generator expression +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadZero.cmake b/Tests/RunCMake/GeneratorExpression/BadZero.cmake index 295ab0e..559a9fa 100644 --- a/Tests/RunCMake/GeneratorExpression/BadZero.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadZero.cmake @@ -1,4 +1,5 @@ add_custom_target(check ALL COMMAND check $<0> + $<0,> VERBATIM) -- cgit v0.12