diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index b9e7c07901..617815d57f 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -48,7 +48,7 @@ static void extendResult( cmGeneratorExpressionParser::cmGeneratorExpressionEvaluatorVector& result, cmGeneratorExpressionParser::cmGeneratorExpressionEvaluatorVector&& contents) { - if (!result.empty() && + if (!result.empty() && !contents.empty() && (*(result.end() - 1))->GetType() == cmGeneratorExpressionEvaluator::Text && contents.front()->GetType() == cmGeneratorExpressionEvaluator::Text) { @@ -101,28 +101,19 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( commaTokens; std::vector::const_iterator colonToken; - bool emptyParamTermination = false; - if (this->it != this->Tokens.end() && this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) { colonToken = this->it; parameters.resize(parameters.size() + 1); assert(this->it != this->Tokens.end()); ++this->it; - if (this->it == this->Tokens.end()) { - emptyParamTermination = true; - } - auto handleCommaOrColon = [this, &commaTokens, ¶meters, - &emptyParamTermination]() -> void { + auto handleCommaOrColon = [this, &commaTokens, ¶meters]() -> void { if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) { commaTokens.push_back(this->it); parameters.resize(parameters.size() + 1); assert(this->it != this->Tokens.end()); ++this->it; - if (this->it == this->Tokens.end()) { - emptyParamTermination = true; - } } else if (this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) { extendText(*(parameters.end() - 1), this->it); @@ -172,9 +163,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( auto commaIt = commaTokens.begin(); assert(parameters.size() > commaTokens.size()); for (; pit != pend; ++pit, ++commaIt) { - if (!pit->empty() && !emptyParamTermination) { - extendResult(result, std::move(*pit)); - } + extendResult(result, std::move(*pit)); if (commaIt != commaTokens.end()) { extendText(result, *commaIt); } else { diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index be9a4c3706..d5439cabd6 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -146,6 +146,9 @@ add_custom_target(check-part2 ALL -Dtest_incomplete_21=$ -Dtest_incomplete_22=$<1:a>$< -Dtest_incomplete_23=$<1:a>$<1:$< + -Dtest_incomplete_24=$<1:a>$<:x + -Dtest_incomplete_25=$<1:a>$$ -Dtest_install_interface=$ -Dtest_target_name_1=$ diff --git a/Tests/GeneratorExpression/check-part2.cmake b/Tests/GeneratorExpression/check-part2.cmake index 2b92de974f..4598bc4c5c 100644 --- a/Tests/GeneratorExpression/check-part2.cmake +++ b/Tests/GeneratorExpression/check-part2.cmake @@ -24,6 +24,9 @@ check(test_incomplete_20 "$") check(test_incomplete_21 "$") check(test_incomplete_22 "a$<") check(test_incomplete_23 "a$<1:$<") +check(test_incomplete_24 "a$<:x") +check(test_incomplete_25 "a$