forked from OSchip/llvm-project
Update to -r337585, allow scoped enum inits in -pedantic
llvm-svn: 337738
This commit is contained in:
parent
17af5b6e20
commit
c764e9a87e
|
@ -1784,6 +1784,9 @@ public:
|
|||
/// 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;
|
||||
|
|
|
@ -481,6 +481,12 @@ bool Type::isComplexIntegerType() 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())
|
||||
|
|
|
@ -11165,6 +11165,9 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
|
|||
; // 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.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
|
||||
|
||||
enum class E { Foo, Bar = 97119 };
|
||||
|
||||
|
@ -12,3 +12,9 @@ void switch_me(E e) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum class E2;
|
||||
|
||||
struct S {
|
||||
static const E e = E::Foo;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue