/// isComplexIntegerType() can be used to test for complex integers.
bool isIntegerType() const; // C99 6.2.5p17 (int, char, bool, enum)
bool isEnumeralType() const;
+
+ /// Determine whether this type is a scoped enumeration type.
+ bool isScopedEnumeralType() const;
bool isBooleanType() const;
bool isCharType() const;
bool isWideCharType() const;
return getAsComplexIntegerType();
}
+bool Type::isScopedEnumeralType() const {
+ if (const auto *ET = getAs<EnumType>())
+ return ET->getDecl()->isScoped();
+ return false;
+}
+
const ComplexType *Type::getAsComplexIntegerType() const {
if (const auto *Complex = getAs<ComplexType>())
if (Complex->getElementType()->isIntegerType())
; // Nothing to check.
else if (Init->isIntegerConstantExpr(Context, &Loc))
; // Ok, it's an ICE!
+ else if (Init->getType()->isScopedEnumeralType() &&
+ Init->isCXX11ConstantExpr(Context))
+ ; // Ok, it is a scoped-enum constant expression.
else if (Init->isEvaluatable(Context)) {
// If we can constant fold the initializer through heroics, accept it,
// but report this as a use of an extension for -pedantic.
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
enum class E { Foo, Bar = 97119 };
break;
}
}
+
+enum class E2;
+
+struct S {
+ static const E e = E::Foo;
+};