[clang] [Clang] treat fixed-underlying enum constants as the enumerated type in C23 to follow the spec (PR #172211)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 6 09:49:52 PST 2026


================
@@ -20822,10 +20822,12 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange,
       NewSign = true;
     } else if (ECD->getType() == BestType) {
       // Already the right type!
-      if (getLangOpts().CPlusPlus)
+      if (getLangOpts().CPlusPlus || (getLangOpts().C23 && Enum->isFixed()))
         // C++ [dcl.enum]p4: Following the closing brace of an
         // enum-specifier, each enumerator has the type of its
         // enumeration.
+        // C23 6.7.2.2p15: For an enumerated type with fixed underlying type,
+        // the enumeration member type is the enumerated type.
----------------
AaronBallman wrote:

```suggestion
        // C23 6.7.3.3p16: The enumeration member type for an enumerated type with fixed
        // underlying type is the enumerated type.
```

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


More information about the cfe-commits mailing list