From 3617e198aa89d4aa0921343a22b96823a63f8a58 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 1 Jun 2011 15:55:51 +0000 Subject: [PATCH] The expression in a noexcept exception-specification is a constant-expression, and, therefore, an unevaluated operand. Make it so. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132400 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplateInstantiateDecl.cpp | 1 + test/CXX/except/except.spec/p1.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index adf9b2f3cb..cd08b1e3df 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2239,6 +2239,7 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, } Expr *NoexceptExpr = 0; if (Expr *OldNoexceptExpr = Proto->getNoexceptExpr()) { + EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); ExprResult E = SemaRef.SubstExpr(OldNoexceptExpr, TemplateArgs); if (E.isUsable()) NoexceptExpr = E.take(); diff --git a/test/CXX/except/except.spec/p1.cpp b/test/CXX/except/except.spec/p1.cpp index 0559285e77..86924bb49d 100644 --- a/test/CXX/except/except.spec/p1.cpp +++ b/test/CXX/except/except.spec/p1.cpp @@ -58,3 +58,16 @@ namespace noex { void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}} } + +namespace noexcept_unevaluated { + template void f(T) { + T* x = 1; + } + + template + void g(T x) noexcept((f(x), sizeof(T) == 4)) { } + + void h() { + g(1); + } +}