EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
ExprResult E = SemaRef.SubstExpr(OldNoexceptExpr, TemplateArgs);
if (E.isUsable())
+ E = SemaRef.CheckBooleanCondition(E.get(), E.get()->getLocStart());
+
+ if (E.isUsable()) {
+ SourceLocation ErrLoc;
+ llvm::APSInt NoexceptVal;
NoexceptExpr = E.take();
+ if (!NoexceptExpr->isTypeDependent() &&
+ !NoexceptExpr->isValueDependent() &&
+ !NoexceptExpr->isIntegerConstantExpr(NoexceptVal, SemaRef.Context,
+ &ErrLoc, /*evaluated=*/false)){
+ SemaRef.Diag(ErrLoc, diag::err_noexcept_needs_constant_expression)
+ << NoexceptExpr->getSourceRange();
+ NoexceptExpr = 0;
+ }
+ }
}
// Rebuild the function type
}
namespace noexcept_unevaluated {
- template<typename T> void f(T) {
+ template<typename T> bool f(T) {
T* x = 1;
}
template<typename T>
- void g(T x) noexcept((f(x), sizeof(T) == 4)) { }
+ void g(T x) noexcept((sizeof(T) == sizeof(int)) || f(x)) { }
void h() {
g(1);
}
}
+
+namespace PR11084 {
+ template<int X> struct A {
+ static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}}
+ };
+
+ void g() { A<0>::f(); } // expected-note{{in instantiation of template class 'PR11084::A<0>' requested here}}
+}