Changing some strange code into an assert; NFC

This code was added in b65b1f322b, but it
was not noticed that the [[fallthrough]] behavior was very wrong. In C
mode, we would set the ParenExprType to CompoundLiteral and then
promptly overwrite that information by falling through.

After some investigation, I convinced myself that it is not possible to
hit this code path in C, only in C++. I've switched it to be an
assertion; I don't expect to hit it, but if we do hit it, that will at
least give us a code example we can use to reason about the intent of
the original code.
This commit is contained in:
Aaron Ballman 2022-09-21 14:51:17 -04:00
parent efd97c716b
commit 1ae5310ebb
1 changed files with 1 additions and 2 deletions

View File

@ -943,8 +943,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
ParenParseOption ParenExprType;
switch (ParseKind) {
case CastParseKind::UnaryExprOnly:
if (!getLangOpts().CPlusPlus)
ParenExprType = CompoundLiteral;
assert(getLangOpts().CPlusPlus && "not possible to get here in C");
[[fallthrough]];
case CastParseKind::AnyCastExpr:
ParenExprType = ParenParseOption::CastExpr;