Skip to content

Commit df232d4

Browse files
authored
[clang-format] Don't re-annotate CaseLabelColon as ConditionalExpr (#114639)
Fixes #114627.
1 parent af6ebb7 commit df232d4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ class AnnotatingParser {
12591259

12601260
bool parseConditional() {
12611261
while (CurrentToken) {
1262-
if (CurrentToken->is(tok::colon)) {
1262+
if (CurrentToken->is(tok::colon) && CurrentToken->is(TT_Unknown)) {
12631263
CurrentToken->setType(TT_ConditionalExpr);
12641264
next();
12651265
return true;

clang/unittests/Format/FormatTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24393,6 +24393,8 @@ TEST_F(FormatTest, DisableRegions) {
2439324393
TEST_F(FormatTest, DoNotCrashOnInvalidInput) {
2439424394
format("? ) =");
2439524395
verifyNoCrash("#define a\\\n /**/}");
24396+
verifyNoCrash(" tst %o5 ! are we doing the gray case?\n"
24397+
"LY52: ! [internal]");
2439624398
}
2439724399

2439824400
TEST_F(FormatTest, FormatsTableGenCode) {

0 commit comments

Comments
 (0)