[cfe-commits] r132400 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/CXX/except/except.spec/p1.cpp
Douglas Gregor
dgregor at apple.com
Wed Jun 1 08:55:51 PDT 2011
Author: dgregor
Date: Wed Jun 1 10:55:51 2011
New Revision: 132400
URL: http://llvm.org/viewvc/llvm-project?rev=132400&view=rev
Log:
The expression in a noexcept exception-specification is a
constant-expression, and, therefore, an unevaluated operand. Make it
so.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/except/except.spec/p1.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=132400&r1=132399&r2=132400&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Jun 1 10:55:51 2011
@@ -2239,6 +2239,7 @@
}
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();
Modified: cfe/trunk/test/CXX/except/except.spec/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/except/except.spec/p1.cpp?rev=132400&r1=132399&r2=132400&view=diff
==============================================================================
--- cfe/trunk/test/CXX/except/except.spec/p1.cpp (original)
+++ cfe/trunk/test/CXX/except/except.spec/p1.cpp Wed Jun 1 10:55:51 2011
@@ -58,3 +58,16 @@
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);
+ }
+}
More information about the cfe-commits
mailing list