From e2d141d47410ad17ba2b63fd32a61cead8a50606 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 12 Oct 2012 16:51:16 +0200 Subject: GenEx: Parse colon after arguments separator colon specially. The rationale is similar to that in commit b3d8f5da (GenEx: Parse comma after colon tokens specially, 2012-10-04), in that colon tokens should not be parsed as identifier-argument delimiters after the first colon. --- Source/cmGeneratorExpressionParser.cxx | 11 +++++++++-- Tests/GeneratorExpression/CMakeLists.txt | 5 +++++ Tests/GeneratorExpression/check.cmake | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index d95e1cc2eb..d09e412e5b 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -14,6 +14,8 @@ #include "cmGeneratorExpressionEvaluator.h" +#include "assert.h" + //---------------------------------------------------------------------------- cmGeneratorExpressionParser::cmGeneratorExpressionParser( const std::vector &tokens) @@ -124,6 +126,11 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( parameters.resize(parameters.size() + 1); ++this->it; } + while (this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) + { + extendText(*(parameters.end() - 1), this->it); + ++this->it; + } while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression) { this->ParseContent(*(parameters.end() - 1)); @@ -133,7 +140,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( parameters.resize(parameters.size() + 1); ++this->it; } - if (this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) + while (this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) { extendText(*(parameters.end() - 1), this->it); ++this->it; @@ -233,7 +240,7 @@ void cmGeneratorExpressionParser::ParseContent( } else { - // TODO: Unreachable. Assert? + assert(!"Got unexpected syntax token."); } ++this->it; return; diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 8bc4f32dff..4967ac0a77 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -44,6 +44,11 @@ add_custom_target(check ALL -Dtest_strequal_one_empty=$ -Dtest_angle_r=$ -Dtest_comma=$ + -Dtest_colons_1=$<1::> + -Dtest_colons_2=$<1:::> + -Dtest_colons_3=$<1:Qt5::Core> + -Dtest_colons_4=$<1:C:\\CMake> + -Dtest_colons_5=$<1:C:/CMake> -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done" VERBATIM diff --git a/Tests/GeneratorExpression/check.cmake b/Tests/GeneratorExpression/check.cmake index ec1f130eca..e46c1c1bb8 100644 --- a/Tests/GeneratorExpression/check.cmake +++ b/Tests/GeneratorExpression/check.cmake @@ -45,3 +45,8 @@ check(test_strequal_both_empty "1") check(test_strequal_one_empty "0") check(test_angle_r ">") check(test_comma ",") +check(test_colons_1 ":") +check(test_colons_2 "::") +check(test_colons_3 "Qt5::Core") +check(test_colons_4 "C:\\\\CMake") +check(test_colons_5 "C:/CMake") -- cgit v1.2.1