// them are not permitted.
const VarDecl *VD = dyn_cast<VarDecl>(D);
QualType VT = VD->getType();
- if (!VD)
+ if (!VD || VD->isInvalidDecl())
return false;
if (!isa<ParmVarDecl>(VD)) {
if (!IsConstNonVolatile(VT))
return false;
- if (!VT->isIntegralOrEnumerationType() && !VT->isRealFloatingType())
+ // FIXME: Allow folding of values of any literal type in all languages.
+ if (!VT->isIntegralOrEnumerationType() && !VT->isRealFloatingType() &&
+ !VD->isConstexpr())
return false;
}
if (!EvaluateVarDeclInit(Info, VD, Frame, RVal))
}
-#if 0
namespace Pointers {
constexpr int f(int n, const int *a, const int *b, const int *c) {
static_assert_fold(1 + Apply(Select(4), 5) + Apply(Select(3), 7) == 42, "");
- constexpr int Invalid = Apply(Select(0), 0); // xpected-error {{must be initialized by a constant expression}}
+ constexpr int Invalid = Apply(Select(0), 0); // expected-error {{must be initialized by a constant expression}}
}
-#endif
namespace PointerComparison {
static_assert_fold(&x < &x, "false"); // expected-error {{false}}
static_assert_fold(&x > &x, "false"); // expected-error {{false}}
-#if 0
constexpr S* sptr = &s;
// FIXME: This is not a constant expression; check we reject this and move this
// test elsewhere.
constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr);
-#endif
extern char externalvar[];
// FIXME: This is not a constant expression; check we reject this and move this