[clang] [C23] Accept an _Atomic underlying type (PR #147802)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 10 06:28:20 PDT 2025


================
@@ -17563,6 +17573,16 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
                                           UPPC_FixedUnderlyingType))
         EnumUnderlying = Context.IntTy.getTypePtr();
 
+      // If the underlying type is atomic, we need to adjust the type before
+      // continuing. This only happens in the case we stored a TypeSourceInfo
+      // into EnumUnderlying because the other cases are error recovery up to
+      // this point. But because it's not possible to gin up a TypeSourceInfo
+      // for a non-atomic type from an atomic one, we'll store into the Type
+      // field instead.
+      if (TypeSourceInfo *TI = dyn_cast<TypeSourceInfo *>(EnumUnderlying);
+          TI && TI->getType()->isAtomicType())
+        EnumUnderlying = TI->getType().getAtomicUnqualifiedType().getTypePtr();
----------------
erichkeane wrote:

Ah, gross... but yeah, I guess so.  Can I have a 'fixme' on it?  Something like, "we COOOOULD just unconditionally strip this but it loses the TypeSourceInfo... someday figure out how to do that"

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


More information about the cfe-commits mailing list