cmGeneratorExpressionParser: Fix crash on "$<" at end of input

When a previous expression in the input has already been closed,
parsing continued to the next `$<`, and when that's at the end, it
stepped past.
This commit is contained in:
Tyler Yankee committed 2026-10-26 15:48:49 -04:00
1 parent b7f4d4b5dd
commit 2f0da06e90
3 files changed
+9

No files matched your search

+5
View File
@@ -224,6 +224,11 @@ void cmGeneratorExpressionParser::ParseContent(
case cmGeneratorExpressionToken::BeginExpression:
assert(this->it != this->Tokens.end());
++this->it;
if (this->it == this->Tokens.end()) {
// A '$<' at the end of the input is plain text.
extendText(result, this->it - 1);
return;
}
this->ParseGeneratorExpression(result);
return;
case cmGeneratorExpressionToken::EndExpression:
+2
View File
@@ -144,6 +144,8 @@ add_custom_target(check-part2 ALL
-Dtest_incomplete_19=$<1:some,thing$<ANGLE-R>
-Dtest_incomplete_20=$<CONFIGURATION$<ANGLE-R>
-Dtest_incomplete_21=$<BOOL:something$<ANGLE-R>
-Dtest_incomplete_22=$<1:a>$<
-Dtest_incomplete_23=$<1:a>$<1:$<
-Dtest_build_interface=$<BUILD_INTERFACE:build>
-Dtest_install_interface=$<INSTALL_INTERFACE:install>
-Dtest_target_name_1=$<TARGET_NAME:tgt,ok>
@@ -22,6 +22,8 @@ check(test_incomplete_18 "$<1:some,thing")
check(test_incomplete_19 "$<1:some,thing>")
check(test_incomplete_20 "$<CONFIGURATION>")
check(test_incomplete_21 "$<BOOL:something>")
check(test_incomplete_22 "a$<")
check(test_incomplete_23 "a$<1:$<")
check(test_build_interface "build")
check(test_install_interface "")
check(test_target_name_1 "tgt,ok")