================ @@ -8623,6 +8624,13 @@ inline bool Type::isIntegralOrEnumerationType() const { inline bool Type::isBooleanType() const { if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) return BT->getKind() == BuiltinType::Bool; + if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) { + // Incomplete enum types are not treated as integer types. + // FIXME: In C++, enum types are never integer types. + return IsEnumDeclComplete(ET->getDecl()) && + !IsEnumDeclScoped(ET->getDecl()) && ---------------- michele-scandale wrote:
> C specifies that "enumerated types" are integer types, and C++ does not, and > `isIntegerType` is trying to honor that as best it can. It's one of those > situations where we need to ask what callers actually want, because in most > cases it's probably not this language-specific formal property. If > `hasIntegerRepresentation` is really a question about the representation of > the type, it should be ignoring scoped-ness of enums. But it seems to be used > in Sema in ways that should definitely exclude scoped enums, like the > semantic analysis of `__builtin_shuffle_vector` and vector math. The check on scoped enum comes from: ``` commit 21673c4e7ec08457b53798b9879b7cc9a5909eb8 Author: Douglas Gregor <dgre...@apple.com> Date: Thu May 5 16:13:52 2011 +0000 Scoped enumerations should not be treated as integer types (in the C sense). Fixes <rdar://problem/9366066> by eliminating an inconsistency between C++ overloading (which handled scoped enumerations correctly) and C binary operator type-checking (which didn't). llvm-svn: 130924 ``` > `isBooleanType` should probably continue to check only for `bool`. Ok. > It seems reasonable for `hasBooleanRepresentation` to look through enums, > though, and it should probably ignore the scoped-ness of the enum. I can do that, but I'm not super happy about the inconsistency. https://github.com/llvm/llvm-project/pull/136038 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits