diff options
Diffstat (limited to 'test/CXX/expr')
-rw-r--r-- | test/CXX/expr/expr.const/p2-0x.cpp | 25 | ||||
-rw-r--r-- | test/CXX/expr/expr.post/expr.call/p7-0x.cpp | 17 | ||||
-rw-r--r-- | test/CXX/expr/expr.prim/p12-0x.cpp | 12 | ||||
-rw-r--r-- | test/CXX/expr/expr.prim/p4-0x.cpp | 10 | ||||
-rw-r--r-- | test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp | 13 |
5 files changed, 77 insertions, 0 deletions
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp new file mode 100644 index 0000000..1b38cf1 --- /dev/null +++ b/test/CXX/expr/expr.const/p2-0x.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +// PR9999 +template<bool v> +class bitWidthHolding { +public: + static const + unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1); +}; + +static const int width=bitWidthHolding<255>::width; + +template<bool b> +struct always_false { + static const bool value = false; +}; + +template<bool b> +struct and_or { + static const bool and_value = b && and_or<always_false<b>::value>::and_value; + static const bool or_value = !b || and_or<always_false<b>::value>::or_value; +}; + +static const bool and_value = and_or<true>::and_value; +static const bool or_value = and_or<true>::or_value; diff --git a/test/CXX/expr/expr.post/expr.call/p7-0x.cpp b/test/CXX/expr/expr.post/expr.call/p7-0x.cpp new file mode 100644 index 0000000..bb4726d --- /dev/null +++ b/test/CXX/expr/expr.post/expr.call/p7-0x.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +struct X1 { + X1(); +}; + +struct X2 { + X2(); + ~X2(); +}; + +void vararg(...); + +void f(X1 x1, X2 x2) { + vararg(x1); // okay + vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}} +} diff --git a/test/CXX/expr/expr.prim/p12-0x.cpp b/test/CXX/expr/expr.prim/p12-0x.cpp new file mode 100644 index 0000000..0ff29a1 --- /dev/null +++ b/test/CXX/expr/expr.prim/p12-0x.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +struct S { + int *j = &nonexistent; // expected-error {{use of undeclared identifier 'nonexistent'}} + int *m = &n; // ok + + int n = f(); // ok + int f(); +}; + +int i = sizeof(S::m); // ok +int j = sizeof(S::m + 42); // ok diff --git a/test/CXX/expr/expr.prim/p4-0x.cpp b/test/CXX/expr/expr.prim/p4-0x.cpp new file mode 100644 index 0000000..13735fa --- /dev/null +++ b/test/CXX/expr/expr.prim/p4-0x.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +struct S { + S *p = this; // ok + decltype(this) q; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} \ + expected-error {{C++ requires a type specifier for all declarations}} + + int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} + int sz = sizeof(this); // ok +}; 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 28ed62c..6d1e523 100644 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp +++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp @@ -97,6 +97,8 @@ struct Bad2 { void operator delete(void*) throw(int); }; +typedef int X; + void implicits() { N(new int); P(new (0) int); @@ -113,6 +115,7 @@ void implicits() { N(static_cast<int>(s)); P(static_cast<float>(s)); N(Bad1()); + P(X().~X()); } struct V { @@ -155,12 +158,16 @@ void gencon() { N(G3()); } +template <class T> void f(T&&) noexcept; template <typename T, bool b> void late() { B(b, typeid(*(T*)0)); B(b, T(1)); B(b, static_cast<T>(S2(0, 0))); B(b, S1() + T()); + P(f(T())); + P(new (0) T); + P(delete (T*)0); } struct S3 { virtual ~S3() throw(); @@ -168,9 +175,15 @@ struct S3 { explicit S3(int); S3(const S2&); }; +template <class T> T&& f2() noexcept; +template <typename T> +void late2() { + P(dynamic_cast<S3&>(f2<T&>())); +} void operator +(const S1&, float) throw(); void operator +(const S1&, const S3&); void tlate() { late<float, true>(); late<S3, false>(); + late2<S3>(); } |