forked from OSchip/llvm-project
Compute the promoted integer type of fixed-width enums correctly. Found by inspection.
llvm-svn: 143021
This commit is contained in:
parent
8fae82a196
commit
64d9504b8f
|
@ -9702,7 +9702,11 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
|
|||
Packed = true;
|
||||
|
||||
if (Enum->isFixed()) {
|
||||
BestType = BestPromotionType = Enum->getIntegerType();
|
||||
BestType = Enum->getIntegerType();
|
||||
if (BestType->isPromotableIntegerType())
|
||||
BestPromotionType = Context.getPromotedIntegerType(BestType);
|
||||
else
|
||||
BestPromotionType = BestType;
|
||||
// We don't need to set BestWidth, because BestType is going to be the type
|
||||
// of the enumerators, but we do anyway because otherwise some compilers
|
||||
// warn that it might be used uninitialized.
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
|
||||
|
||||
enum X : short { A, B };
|
||||
extern decltype(+A) x;
|
||||
extern int x;
|
||||
|
||||
enum Y : long { C, D };
|
||||
extern decltype(+C) y;
|
||||
extern long y;
|
Loading…
Reference in New Issue