// Keep track of whether all elements have type int.
bool AllElementsInt = true;
+ QualType EnumType = Context.getTypeDeclType(Enum);
EnumConstantDecl *EltList = 0;
for (unsigned i = 0; i != NumElements; ++i) {
EnumConstantDecl *ECD =
llvm::APSInt IV = ECD->getInitVal();
IV.setIsSigned(true);
ECD->setInitVal(IV);
+
+ if (getLangOptions().CPlusPlus)
+ // C++ [dcl.enum]p4: Following the closing brace of an
+ // enum-specifier, each enumerator has the type of its
+ // enumeration.
+ ECD->setType(EnumType);
continue; // Already int type.
}
NewSign = true;
} else if (ECD->getType() == BestType) {
// Already the right type!
+ if (getLangOptions().CPlusPlus)
+ // C++ [dcl.enum]p4: Following the closing brace of an
+ // enum-specifier, each enumerator has the type of its
+ // enumeration.
+ ECD->setType(EnumType);
continue;
} else {
NewTy = BestType;
// Adjust the Expr initializer and type.
ECD->setInitExpr(new ImplicitCastExpr(NewTy, ECD->getInitExpr(),
/*isLvalue=*/false));
- ECD->setType(NewTy);
+ if (getLangOptions().CPlusPlus)
+ // C++ [dcl.enum]p4: Following the closing brace of an
+ // enum-specifier, each enumerator has the type of its
+ // enumeration.
+ ECD->setType(EnumType);
+ else
+ ECD->setType(NewTy);
}
Enum->completeDefinition(Context, BestType);
// The types we'll try to promote to, in the appropriate
// order. Try each of these types.
- QualType PromoteTypes[4] = {
+ QualType PromoteTypes[6] = {
Context.IntTy, Context.UnsignedIntTy,
- Context.LongTy, Context.UnsignedLongTy
+ Context.LongTy, Context.UnsignedLongTy ,
+ Context.LongLongTy, Context.UnsignedLongLongTy
};
- for (int Idx = 0; Idx < 4; ++Idx) {
+ for (int Idx = 0; Idx < 6; ++Idx) {
uint64_t ToSize = Context.getTypeSize(PromoteTypes[Idx]);
if (FromSize < ToSize ||
(FromSize == ToSize &&
CandidateSet.push_back(OverloadCandidate());
OverloadCandidate& Candidate = CandidateSet.back();
Candidate.Function = 0;
+ Candidate.IsSurrogate = false;
Candidate.BuiltinTypes.ResultTy = ResultTy;
for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx)
Candidate.BuiltinTypes.ParamTypes[ArgIdx] = ParamTys[ArgIdx];
-// RUN: clang -fsyntax-only -pedantic -verify %s
+// RUN: clang -fsyntax-only -pedantic -verify %s
int* f(int) { return 0; }
float* f(float) { return 0; }
void f();
}
enum PromotesToInt {
- PromotesToIntValue = 1
+ PromotesToIntValue = -1
};
enum PromotesToUnsignedInt {
- PromotesToUnsignedIntValue = (unsigned int)-1
+ PromotesToUnsignedIntValue = 1u
};
int* o(int);