From: Sebastian Redl Date: Fri, 10 Sep 2010 20:55:50 +0000 (+0000) Subject: Tests for noexcept in templates. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a822c0c554a7b82ea2cb0f7545e4ed1062f29fc;p=clang Tests for noexcept in templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113625 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp index c1865fc4ff..e4025d9e2f 100644 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp +++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp @@ -2,6 +2,7 @@ #define P(e) static_assert(noexcept(e), "expected nothrow") #define N(e) static_assert(!noexcept(e), "expected throw") +#define B(b, e) static_assert(b == noexcept(e), "expectation failed") void simple() { P(0); @@ -126,3 +127,33 @@ void uneval() { P(sizeof(typeid(*(V*)0))); P(typeid(typeid(*(V*)0))); } + +struct G1 {}; +struct G2 { int i; }; +struct G3 { S2 s; }; + +void gencon() { + P(G1()); + P(G2()); + N(G3()); +} + +template +void late() { + B(b, typeid(*(T*)0)); + B(b, T(1)); + B(b, static_cast(S2(0, 0))); + B(b, S1() + T()); +} +struct S3 { + virtual ~S3() throw(); + S3() throw(); + explicit S3(int); + S3(const S2&); +}; +void operator +(const S1&, float) throw(); +void operator +(const S1&, const S3&); +void tlate() { + late(); + late(); +}