]> granicus.if.org Git - clang/commitdiff
The expression in a noexcept exception-specification is a
authorDouglas Gregor <dgregor@apple.com>
Wed, 1 Jun 2011 15:55:51 +0000 (15:55 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 1 Jun 2011 15:55:51 +0000 (15:55 +0000)
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
test/CXX/except/except.spec/p1.cpp

index adf9b2f3cb1635c33b62e6bb862d79b2d1ea78aa..cd08b1e3df047bd7b171a7069ccfec7f263af50d 100644 (file)
@@ -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();
index 0559285e77a91c711c8a743b77a6b4648bd4744a..86924bb49d75098b69eed5e62e2173d622154274 100644 (file)
@@ -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);
+  }
+}