diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-29 23:18:09 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-29 23:18:09 +0000 |
commit | bbd340717422bf011d56cd0164d2576601368111 (patch) | |
tree | f48622c0c79daa178eca50e4eca4121d1232dcf8 /lib/AST/Type.cpp | |
parent | 8b2f01b56209f4bb7331292225c5300753880044 (diff) |
Incomplete enum types not to be treated as integer type
when checking for integer signed/unsigned-ness. PR8694,
// rdar://8707031
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 3c9561cd44..56cd4dddb5 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -489,8 +489,12 @@ bool Type::isSignedIntegerType() const { BT->getKind() <= BuiltinType::Int128; } - if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) - return ET->getDecl()->getIntegerType()->isSignedIntegerType(); + 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. + if (ET->getDecl()->isComplete()) + return ET->getDecl()->getIntegerType()->isSignedIntegerType(); + } return false; } @@ -511,8 +515,12 @@ bool Type::isUnsignedIntegerType() const { BT->getKind() <= BuiltinType::UInt128; } - if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) - return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); + 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. + if (ET->getDecl()->isComplete()) + return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); + } return false; } |