[clang] [Clang][Sema] Fix type of enumerators in incomplete enumerations (PR #84068)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 8 14:37:56 PST 2024


Kupa-Martin wrote:

> not an enum compare warning in C++ because `B1` doesn't have an enumeration type due to the enumeration not being fully-defined, and is not an enum compare warning in C because `A` has type `int` (due to p15) and `B1` has type `int` (due to p12).

Yes, you are correct.

> I think we play a bit fast-and-loose with the way we treat enum constants in C in Clang, but that's outside of the scope of this patch.

There are enough differences between the C23 and C++ standards to produce different diagnostics. I've made a godbolt [snippet](https://godbolt.org/z/741W1356r) that tries to keep track of the type of different enumerators in C23 and C++; we warn when we shouldnt and we dont warn when we should. In any case, this patch didnt intend to cover C23.

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


More information about the cfe-commits mailing list