================
@@ -19797,6 +19797,19 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl
*Enum,
// - If an initializer is specified for an enumerator, the
// initializing value has the same type as the expression.
EltTy = Val->getType();
+ } else if (getLangOpts().C23) {
+ // C23 6.7.2.2p11 b4
+ // int, if given explicitly with = and the value of the
+ // integer constant expression is representable by an int
+ //
+ // C23 6.7.2.2p11 b5
+ // the type of the integer constant expression, if given
+ // explicitly with = and if the value of the integer
+ // constant expression is not representable by int;
+ if (isRepresentableIntegerValue(Context, EnumVal, Context.IntTy)) {
+ Val = ImpCastExprToType(Val, Context.IntTy, CK_IntegralCast).get();
+ }
----------------
AaronBallman wrote:
```suggestion
if (isRepresentableIntegerValue(Context, EnumVal, Context.IntTy))
Val = ImpCastExprToType(Val, Context.IntTy, CK_IntegralCast).get();
```
Per our odd coding standard.
https://github.com/llvm/llvm-project/pull/78742
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits