Skip to content

Commit 9016c60

Browse files
authored
[clang] Call ActOnCaseExpr even if the 'case' is missing (#166326)
This otherwise happens in ParseCaseExpression. If we don't call this, we don't perform the usual arithmetic conversions, etc.
1 parent 66f52ca commit 9016c60

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/Parse/ParseStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ StmtResult Parser::ParseCaseStatement(ParsedStmtContext StmtCtx,
813813
return StmtError();
814814
}
815815
} else {
816-
LHS = Expr;
816+
LHS = Actions.ActOnCaseExpr(CaseLoc, Expr);
817817
MissingCase = false;
818818
}
819819

clang/test/SemaCXX/constant-expression-cxx14.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,3 +1450,9 @@ namespace GH149500 {
14501450
unsigned int * p = &(*(unsigned int *)0x400);
14511451
static const void *q = &(*(const struct sysrq_key_op *)0);
14521452
}
1453+
1454+
constexpr bool missingCase() {
1455+
switch (1) {
1456+
1u: return false; // expected-error {{expected 'case' keyword before expression}}
1457+
}
1458+
}

0 commit comments

Comments
 (0)