aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-06-01 15:55:51 +0000
committerDouglas Gregor <dgregor@apple.com>2011-06-01 15:55:51 +0000
commit3617e198aa89d4aa0921343a22b96823a63f8a58 (patch)
tree573eb5adae2109861deeeaf665772cf2b8d34248
parent17e37c7959d60d8bfcbc8cb5630d3101ae583be5 (diff)
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
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp1
-rw-r--r--test/CXX/except/except.spec/p1.cpp13
2 files changed, 14 insertions, 0 deletions
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<typename T> void f(T) {
+ T* x = 1;
+ }
+
+ template<typename T>
+ void g(T x) noexcept((f(x), sizeof(T) == 4)) { }
+
+ void h() {
+ g(1);
+ }
+}