[clang] [C23] Fix typeof handling in enum declarations (PR #146394)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 2 02:55:22 PDT 2025


================
@@ -4210,6 +4215,7 @@ class Parser : public CodeCompletionHandler {
   /// \endverbatim
   ExprResult ParseParenExpression(ParenParseOption &ExprType,
                                   bool stopIfCastExpr, bool isTypeCast,
+                                  bool ParenKnownToBeNonCast,
----------------
Sirraide wrote:

> So it doesn't mean "this is, is not, or maybe a cast expression", it means "if there's a typo, should we allow type names or not?"

Ok, I like to say I’m bad at naming, but that is actually awful. ;Þ

> How about this for a solution:
> 
> 1. Rename `TypeCastState` to `TypoCorrectionTypeBehavior`
> 2. Rename `NotTypeCast`, `IsTypeCast`, and `MaybeTypeCast` to `AllowNonTypes, `AllowTypes`, and `AllowBoth`
> 3. Add a new enumeration `TypeCastState` with members `IsTypeCast`, `IsNotTypeCast`, and `Unknown`
> 4. Change `ParseParenExpression` to take both a `TypoCorrectionTypeBehavior` and a `TypeCastState`.

I was about to suggest this so sgtm

https://github.com/llvm/llvm-project/pull/146394


More information about the cfe-commits mailing list