Enable constant evaluation of implicit calls to constexpr conversion operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148333 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Richard Smith 2012-01-17 21:17:26 +00:00
Родитель a8398ea850
Коммит 7d580a4e9e
2 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -2280,6 +2280,7 @@ public:
case CK_AtomicToNonAtomic:
case CK_NonAtomicToAtomic:
case CK_NoOp:
case CK_UserDefinedConversion:
return StmtVisitorTy::Visit(E->getSubExpr());
case CK_LValueToRValue: {
@ -4525,13 +4526,13 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
case CK_BitCast:
case CK_Dependent:
case CK_LValueBitCast:
case CK_UserDefinedConversion:
case CK_ARCProduceObject:
case CK_ARCConsumeObject:
case CK_ARCReclaimReturnedObject:
case CK_ARCExtendBlockObject:
return Error(E);
case CK_UserDefinedConversion:
case CK_LValueToRValue:
case CK_AtomicToNonAtomic:
case CK_NonAtomicToAtomic:

Просмотреть файл

@ -687,6 +687,28 @@ static_assert((Bottom*)nullB == 0, "");
static_assert((Derived*)nullB == 0, "");
static_assert((void*)(Bottom*)nullB == (void*)(Derived*)nullB, "");
namespace ConversionOperators {
struct T {
constexpr T(int n) : k(5*n - 3) {}
constexpr operator int() { return k; }
int k;
};
struct S {
constexpr S(int n) : k(2*n + 1) {}
constexpr operator int() { return k; }
constexpr operator T() { return T(k); }
int k;
};
constexpr bool check(T a, T b) { return a == b.k; }
static_assert(S(5) == 11, "");
static_assert(check(S(5), 11), "");
}
}
namespace Temporaries {