diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x')
787 files changed, 27896 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/__func__.C b/gcc/testsuite/g++.dg/cpp0x/__func__.C new file mode 100644 index 000000000..1ac906515 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/__func__.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x -pedantic" } + +const char* foo() +{ + return __func__; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/access01.C b/gcc/testsuite/g++.dg/cpp0x/access01.C new file mode 100644 index 000000000..43e5e8637 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/access01.C @@ -0,0 +1,15 @@ +// PR c++/49042 +// { dg-options -std=c++0x } + +template <class T> +class A +{ + T p; +public: + template <class U> auto f() -> decltype(+p) { } +}; + +int main() +{ + A<int>().f<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/alignof.C b/gcc/testsuite/g++.dg/cpp0x/alignof.C new file mode 100644 index 000000000..8e8f715cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignof.C @@ -0,0 +1,5 @@ +// { dg-options "-std=c++0x" } +int main(void) +{ + static_assert(alignof(int) == __alignof(int), "alignof(int) does not equal __alignof(int)"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/alignof2.C b/gcc/testsuite/g++.dg/cpp0x/alignof2.C new file mode 100644 index 000000000..7c5aad3de --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alignof2.C @@ -0,0 +1,7 @@ +// { dg-do compile } +// { dg-options "-std=c++0x -pedantic" } +int main(void) +{ + alignof(int); //ok with a type but not with an expression + alignof(3); // { dg-warning "alignof" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto1.C b/gcc/testsuite/g++.dg/cpp0x/auto1.C new file mode 100644 index 000000000..9e274b622 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto1.C @@ -0,0 +1,8 @@ +// { dg-options "-std=c++98 -Wc++0x-compat" } + +// Test warning for use of auto in C++98 mode with C++0x +// compatibility warnings +void f() +{ + auto int x = 5; // { dg-warning "will change meaning" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto10.C b/gcc/testsuite/g++.dg/cpp0x/auto10.C new file mode 100644 index 000000000..9b89291d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto10.C @@ -0,0 +1,22 @@ +// Positive test for auto +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <typeinfo> +extern "C" void abort(); + +int main() +{ + if (auto i = 42L) + { + if (typeid (i) != typeid (long int)) + abort (); + } + + while (auto i = 1) + { + if (typeid (i) != typeid (int)) + abort (); + break; + } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto11.C b/gcc/testsuite/g++.dg/cpp0x/auto11.C new file mode 100644 index 000000000..bd21daef0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto11.C @@ -0,0 +1,12 @@ +// PR c++/38256 +// { dg-options "-std=c++0x" } + +template<int> struct A +{ + template<typename T> operator T(); +}; + +void foo() +{ + A<0>().operator auto(); // { dg-error "auto.*conversion" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto14.C b/gcc/testsuite/g++.dg/cpp0x/auto14.C new file mode 100644 index 000000000..cb2c4e035 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto14.C @@ -0,0 +1,29 @@ +// PR c++/40306, c++/40307 +// { dg-options "-std=c++0x" } +// { dg-do run } + +template< typename T > +struct test { + test run() { + auto tmp = *this; + return tmp; + } + test run_pass() { + test tmp( *this ); + return tmp; + } + + test run_fail() { + auto tmp( *this ); + return tmp; + } +}; + +int main() +{ + test<int> x; + x.run(); + x.run_pass(); + x.run_fail(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto15.C b/gcc/testsuite/g++.dg/cpp0x/auto15.C new file mode 100644 index 000000000..b23e1e2fd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto15.C @@ -0,0 +1,13 @@ +// { dg-options "-std=c++0x" } + +template< typename Fn > struct function; + +template< typename Result, typename ... ArgTypes > +struct function< auto (ArgTypes...)->Result > { +}; + +int main() +{ + function< auto(double)->int > y; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto16.C b/gcc/testsuite/g++.dg/cpp0x/auto16.C new file mode 100644 index 000000000..1b4ae8f82 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto16.C @@ -0,0 +1,7 @@ +// PR c++/40619 +// { dg-options "-std=c++0x" } + +template<typename U> struct X {}; + +template<typename T> auto f(T t) -> X<decltype(t+1)> {} +template<typename T> auto g(T t) -> X<decltype(t+1)> {} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto17.C b/gcc/testsuite/g++.dg/cpp0x/auto17.C new file mode 100644 index 000000000..03608d33a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto17.C @@ -0,0 +1,10 @@ +// PR c++/42567 +// { dg-options "-std=c++0x" } + +template<typename B> +struct A { + template<typename C> + void fn(C c) { + auto& key = *c; + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto18.C b/gcc/testsuite/g++.dg/cpp0x/auto18.C new file mode 100644 index 000000000..17f7f9959 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto18.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x" } + +void f() +{ + auto val = val; // { dg-error "auto. type used in its own initializer" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto19.C b/gcc/testsuite/g++.dg/cpp0x/auto19.C new file mode 100644 index 000000000..f70990287 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto19.C @@ -0,0 +1,8 @@ +// { dg-options -std=c++0x } + +struct Explicit { + Explicit() = default; // Line 2 + explicit Explicit(const Explicit&){} +} ex; + +auto ex2(ex); // Line 6 diff --git a/gcc/testsuite/g++.dg/cpp0x/auto2.C b/gcc/testsuite/g++.dg/cpp0x/auto2.C new file mode 100644 index 000000000..626e9e245 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto2.C @@ -0,0 +1,74 @@ +// Positive test for auto +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <typeinfo> +extern "C" void abort(); + +int f() {} + +struct A +{ + int i; + int f() {} + A operator+(A a) { return a; } +}; + +template <class T> +void g(T t) +{ + auto x = t+t; + if (typeid(x) != typeid(t+t)) + abort(); + + auto p = new auto(&t); + if (typeid(p) != typeid(T**)) + abort(); +} + +int main() +{ + auto i = 42; + if (typeid (i) != typeid (int)) + abort(); + + auto *p = &i; + if (typeid (p) != typeid (int*)) + abort(); + + auto *p2 = &p; + if (typeid (p2) != typeid (int**)) + abort(); + + auto (*fp)() = f; + if (typeid (fp) != typeid (int (*)())) + abort(); + + auto A::* pm = &A::i; + if (typeid (pm) != typeid (int A::*)) + abort(); + + auto (A::*pmf)() = &A::f; + if (typeid (pmf) != typeid (int (A::*)())) + abort(); + + g(42); + g(10.f); + g(A()); + + auto *p3 = new auto (i); + if (typeid (p3) != typeid (int*)) + abort(); + + for (auto idx = i; idx != 0; idx = 0); + while (auto idx = 0); + if (auto idx = 1); + + switch (auto s = i) + { + case 42: + break; + } + + auto j = 42, k = 24; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto20.C b/gcc/testsuite/g++.dg/cpp0x/auto20.C new file mode 100644 index 000000000..90f875114 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto20.C @@ -0,0 +1,20 @@ +// Test for proper non-deduced context handling of the initializer +// for an auto declaration/new. +// { dg-options -std=c++0x } + +struct with_apply +{ + template <unsigned> + void apply(const double&){} +}; + +auto p = &with_apply::apply<0>; +auto pp = new auto(&with_apply::apply<0>); + +template <class T> +void f() +{ + auto p = &T::template apply<0>; +} + +template void f<with_apply>(); diff --git a/gcc/testsuite/g++.dg/cpp0x/auto21.C b/gcc/testsuite/g++.dg/cpp0x/auto21.C new file mode 100644 index 000000000..1cbcac58d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto21.C @@ -0,0 +1,5 @@ +// Origin PR c++/47208 +// { dg-options "-std=c++0x" } + +constexpr auto list = { }; // { dg-error "deducing from brace-enclosed initializer list requires #include <initializer_list>" } +static const int l = list.size(); diff --git a/gcc/testsuite/g++.dg/cpp0x/auto22.C b/gcc/testsuite/g++.dg/cpp0x/auto22.C new file mode 100644 index 000000000..66630e536 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto22.C @@ -0,0 +1,21 @@ +// PR c++/47999 +// { dg-options -std=c++0x } + +int& identity(int& i) +{ + return i; +} + +// In a function template, auto type deduction works incorrectly. +template <typename = void> +void f() +{ + int i = 0; + auto&& x = identity(i); // Type of x should be `int&`, but it is `int&&`. +} + +int main (int argc, char* argv[]) +{ + f(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto23.C b/gcc/testsuite/g++.dg/cpp0x/auto23.C new file mode 100644 index 000000000..49b5a0eb9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto23.C @@ -0,0 +1,4 @@ +// PR c++/46245 +// { dg-options -std=c++0x } + +template<auto f()->int> struct A { }; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto3.C b/gcc/testsuite/g++.dg/cpp0x/auto3.C new file mode 100644 index 000000000..860790d7d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto3.C @@ -0,0 +1,27 @@ +// Negative test for auto +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +auto x; // { dg-error "auto" } + +// If the type deduced for the template parameter U is not the same in each +// deduction, the program is ill-formed. +auto i = 42, j = 42.0; // { dg-error "auto" } + +// New CWG issue +auto a[2] = { 1, 2 }; // { dg-error "initializer_list" } + +template<class T> +struct A { }; + +A<int> A1; +// CWG issue 625 +A<auto> A2 = A1; // { dg-error "" } + +auto foo() { } // { dg-error "auto" } + +void bar(auto i) // { dg-error "incomplete|auto" } +{ + (void)i; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto31.C b/gcc/testsuite/g++.dg/cpp0x/auto31.C new file mode 100644 index 000000000..2c74b72df --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto31.C @@ -0,0 +1,12 @@ +// PR c++/51416 +// { dg-options "-std=c++0x" } + +template<typename T, typename... U> void foo(T, U... u) +{ + auto foo(u...); // { dg-error "auto" } +} + +void bar() +{ + foo(0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto4.C b/gcc/testsuite/g++.dg/cpp0x/auto4.C new file mode 100644 index 000000000..d47bca436 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto4.C @@ -0,0 +1,28 @@ +// Testcase for deduction of std::initializer_list for auto. +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <typeinfo> +#include <initializer_list> +extern "C" void abort(); + +template <class T> +void f (T t) +{ + auto ilt = { &t, &t }; + if (typeid(ilt) != typeid(std::initializer_list<T*>)) + abort(); + + auto il = { 1, 2, 3 }; + if (typeid(il) != typeid(std::initializer_list<int>)) + abort(); +} + +int main() +{ + auto il = { 1, 2, 3 }; + if (typeid(il) != typeid(std::initializer_list<int>)) + abort(); + + f('c'); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto5.C b/gcc/testsuite/g++.dg/cpp0x/auto5.C new file mode 100644 index 000000000..ebe2df22e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto5.C @@ -0,0 +1,22 @@ +// Testcase for non-dependent auto in templates +// { dg-options "-std=c++0x" } + +struct A +{ + template<class> void f(); +} a; + +template <class T> +void g() +{ + auto aa = a; + aa.f<int>(); + + auto p = new auto (a); + p->f<int>(); +} + +int main() +{ + g<double>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/auto7.C b/gcc/testsuite/g++.dg/cpp0x/auto7.C new file mode 100644 index 000000000..9ef5a80eb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto7.C @@ -0,0 +1,13 @@ +// PR c++/37965 +// Negative test for auto +// { dg-options "-std=c++0x" } + +auto i = 6; +auto j; // { dg-error "has no initializer" } + +template<int> struct A +{ + static auto k = 7; + static auto l; // { dg-error "has no initializer" } + auto m; // { dg-error "has no initializer" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto9.C b/gcc/testsuite/g++.dg/cpp0x/auto9.C new file mode 100644 index 000000000..190bfa6e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto9.C @@ -0,0 +1,124 @@ +// PR c++/37962 +// Negative test for auto +// { dg-do compile } +// { dg-options "-std=c++0x" } + +#include <typeinfo> +#include <stdarg.h> +#include <stddef.h> + +int i = *(auto *) 0; // { dg-error "auto" } +struct A *p = (auto *) 0; // { dg-error "auto" } +int *q = static_cast <auto *>(0); // { dg-error "auto" } +const int *r = const_cast <auto *>(q); // { dg-error "auto" } +const std::type_info &t1 = typeid (auto); // { dg-error "auto" } +const std::type_info &t2 = typeid (auto *); // { dg-error "auto" } + +struct A +{ + operator auto (); // { dg-error "auto" } + operator auto *(); // { dg-error "auto" } +}; + +struct A2 +{ + operator auto () -> int; // { dg-error "invalid use of" } + operator auto *() -> int; // { dg-error "auto" } +}; + +template <typename> struct B +{ + enum { e }; +}; + +template <typename T> struct C +{ + C () : i () {} + int i; +}; + +bool d = (auto (A::*)()) 0; // { dg-error "auto" } + +void +foo () +{ + (auto) { 0 }; // { dg-error "auto" } + C<int> c; + dynamic_cast<auto> (c); // { dg-error "auto" } + reinterpret_cast<auto> (c); // { dg-error "auto" } + int i = auto (0); // { dg-error "auto" } + auto p1 = new (auto); // { dg-error "auto" } + auto p2 = new (auto) (42); // { dg-error "invalid use of|deduce" } + offsetof (auto, fld); // { dg-error "auto" } + offsetof (auto *, fld); // { dg-error "auto" } + sizeof (auto); // { dg-error "auto" } + sizeof (auto *); // { dg-error "auto" } +} + +void +foo2 (void) +{ + __alignof__ (auto); // { dg-error "auto" } + __alignof__ (auto *); // { dg-error "auto" } + __typeof__ (auto) v1; // { dg-error "auto" } + __typeof__ (auto *) v2; // { dg-error "auto" } + __is_class (auto); // { dg-error "auto|expected" } + __is_pod (auto *); // { dg-error "auto|expected" } + __is_base_of (int, auto); // { dg-error "auto|expected" } + __is_base_of (auto, int); // { dg-error "auto|expected" } + __is_base_of (auto, auto *); // { dg-error "auto|expected" } +} + +B<auto> b; // { dg-error "auto|invalid" } +C<auto> c; // { dg-error "auto|invalid" } +C<auto *> c2; // { dg-error "auto|invalid" } + +enum : auto { EE = 0 }; // { dg-error "must be an integral type" } +enum struct D : auto * { FF = 0 }; // { dg-error "must be an integral type|declar|expected" } + +void +bar () +{ + try { } catch (auto i) { } // { dg-error "parameter declared" } + try { } catch (auto) { } // { dg-error "parameter declared" } + try { } catch (auto *i) { } // { dg-error "parameter declared" } + try { } catch (auto *) { } // { dg-error "parameter declared" } +} + +void +baz (int i, ...) +{ + va_list ap; + va_start (ap, i); + va_arg (ap, auto); // { dg-error "invalid use of" } + va_arg (ap, auto *); // { dg-error "invalid use of|expected" } + va_arg (ap, auto &); // { dg-error "invalid use of|expected" } + va_end (ap); +} + +template <typename T = auto> struct E {}; // { dg-error "invalid use of" } +template <class T = auto *> struct F {}; // { dg-error "invalid use of|expected" } + +auto fnlate () -> auto; // { dg-error "invalid use of" } +auto fnlate2 () -> auto *; // { dg-error "invalid use of|expected" } + +void +badthrow () throw (auto) // { dg-error "invalid use of" } +{ +} + +void +badthrow2 () throw (auto &) // { dg-error "invalid use of|expected" } +{ +} + +template <auto V = 4> struct G {}; // { dg-error "auto" } + +template <typename T> struct H { H (); ~H (); }; +H<auto> h; // { dg-error "invalid" } + +void qq (auto); // { dg-error "auto" } +void qr (auto*); // { dg-error "auto" } + +// PR c++/46145 +typedef auto autot; // { dg-error "auto" } diff --git a/gcc/testsuite/g++.dg/cpp0x/bind.C b/gcc/testsuite/g++.dg/cpp0x/bind.C new file mode 100644 index 000000000..42a2ac203 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/bind.C @@ -0,0 +1,8 @@ +// { dg-options "--std=c++0x" } +struct S{}; +void f(S&&); + +int main() +{ + f(S()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/bracket1.C b/gcc/testsuite/g++.dg/cpp0x/bracket1.C new file mode 100644 index 000000000..dfb5bf4ea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/bracket1.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename T> +struct list {}; + +template<typename T> +struct vector { + operator T() const; +}; + +void f() +{ + vector<vector<int>> v; + const vector<int> vi = static_cast<vector<int>>(v); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/bracket2.C b/gcc/testsuite/g++.dg/cpp0x/bracket2.C new file mode 100644 index 000000000..300015d01 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/bracket2.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<int i> class X { /* ... */ }; +X< 1>2 > x1; // // { dg-error "numeric constant" } +X<(1>2)> x2; // Okay. + +template<class T> class Y { /* ... */ }; +Y<X<1>> x3; // Okay, same as "Y<X<1> > x3;". +Y<X<6>>1>> x4; // { dg-error "numeric constant" } +Y<X<(6>>1)>> x5; // Okay diff --git a/gcc/testsuite/g++.dg/cpp0x/bracket3.C b/gcc/testsuite/g++.dg/cpp0x/bracket3.C new file mode 100644 index 000000000..4ef7a0e9d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/bracket3.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++98 -Wc++0x-compat" } + +template<int N> struct X {}; + +X<1 >> 2> x; // { dg-warning "will be treated as|suggest parentheses" } + +// From cp/parser.c +typedef int Y; +template <int V> struct Foo {}; +Foo<Y () >> 5> r; // { dg-warning "will be treated as|suggest parentheses" } diff --git a/gcc/testsuite/g++.dg/cpp0x/bracket4.C b/gcc/testsuite/g++.dg/cpp0x/bracket4.C new file mode 100644 index 000000000..0e1985cef --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/bracket4.C @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +template<typename T> +struct vector { +}; + +struct X { + template<typename T> + struct tmpl { + operator T() const; + }; +}; + +template<typename T> +void g() +{ + T::template tmpl<vector<int>>() + 2; +} + +template<typename T> +void operator+(vector<T>, int); + +void f() +{ + vector<vector<int>>() + 2; +} + +// PR c++/36460 +template <class a> +class A {}; +template <class b> +class B {}; + +A<B<void()>> x; + diff --git a/gcc/testsuite/g++.dg/cpp0x/cast-bug.C b/gcc/testsuite/g++.dg/cpp0x/cast-bug.C new file mode 100644 index 000000000..211f88b2b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/cast-bug.C @@ -0,0 +1,14 @@ +// { dg-options "--std=c++0x" } +struct S +{ + S(); + S(S &&); +private: + S(S &); +}; + +S f() +{ + S s; + return static_cast<S&&>(s); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/cast.C b/gcc/testsuite/g++.dg/cpp0x/cast.C new file mode 100644 index 000000000..9162d09f3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/cast.C @@ -0,0 +1,30 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test cast from lvalue to rvalue + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; + +struct A {}; + +one foo(const A&) {return one();} +two foo(A&&) {return two();} + +int test1() +{ + A a; + sa<sizeof(foo(a)) == 1 * sizeof(long)> t1; + sa<sizeof(foo(static_cast<A&&>(a))) == 2 * sizeof(long)> t2; + return 0; +} + +int main() +{ + return test1(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/collapse-bug.C b/gcc/testsuite/g++.dg/cpp0x/collapse-bug.C new file mode 100644 index 000000000..02a59cd1d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/collapse-bug.C @@ -0,0 +1,16 @@ +// { dg-options "--std=c++0x" } +template<typename T, typename U> struct same_type; +template<typename T> struct same_type<T, T> {}; + +template <typename T> +struct S +{ + typedef T const (&type)(); +}; + +void f() +{ + // initial implementation didn't ignore const qualifier on + // reference, resulting in a typedef of 'const int& (&)()' + same_type<S<int &>::type, int&(&)()>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/collapse.C b/gcc/testsuite/g++.dg/cpp0x/collapse.C new file mode 100644 index 000000000..96c327324 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/collapse.C @@ -0,0 +1,38 @@ +// { dg-options "--std=c++0x" } +template<typename T, typename U> struct same_type; +template<typename T> struct same_type<T, T> {}; + +typedef int & lref; +typedef int const & clref; +typedef int && rref; +typedef int const && crref; + +template<typename T> +struct S +{ + typedef T & lref; + typedef T const & clref; + typedef T && rref; + typedef T const && crref; +}; + +void f() +{ + same_type<lref &, int &>(); + same_type<lref &&, int &>(); + same_type<rref &, int &>(); + same_type<rref &&, int &&>(); + + same_type<rref const &, int &>(); + same_type<crref volatile &&, int const &&>(); + same_type<clref const &&, int const &>(); + + same_type<S<int &>::lref &, int &>(); + same_type<S<int &&>::lref &&, int &>(); + same_type<S<int &>::rref &, int &>(); + same_type<S<int &&>::rref &&, int &&>(); + + same_type<S<int const &>::rref, int const &>(); + same_type<S<int volatile &&>::crref, int volatile &&>(); + same_type<S<int const &&>::clref, int const &>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-46420.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-46420.C new file mode 100644 index 000000000..757a6e315 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-46420.C @@ -0,0 +1,13 @@ +// PR c++/46420 +// { dg-options -std=c++0x } + +template<typename> class vector { }; +struct A{}; +template <class T1> +void complete_test(vector<T1> data1){ + A drop=A(); +} +int main(){ + vector<double> vect1; + complete_test(vect1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-47570.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-47570.C new file mode 100644 index 000000000..c60ba8658 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-47570.C @@ -0,0 +1,25 @@ +// PR c++/47570 +// { dg-options -std=c++0x } + +unsigned int constexpr one() +{ return 1; } + +int constexpr one_B() +{ return 1; } + +int main() +{ + // FAIL TO COMPILE: + static bool constexpr SC_huh1 = ((unsigned int)one()) >= ((unsigned int)0); + static bool constexpr SC_huh2 = one() >= ((unsigned int)0); + static bool constexpr SC_huh3 = one() >= 0; + + // COMPILE OK: + static bool constexpr SC_huh4 = ((one() == 0) || (one() > 0)); + static bool constexpr SC_huh5 = one() == 0; + static bool constexpr SC_huh6 = one() > 0; + static bool constexpr SC_huh7 = one_B() >= 0; + static bool constexpr SC_huh8 = one() >= 1; + + return SC_huh3; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C new file mode 100644 index 000000000..5124f7c7f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-48089.C @@ -0,0 +1,50 @@ +// PR c++/48089 +// { dg-options -std=c++0x } + +// bang is ill-formed (diagnostic required) because its initializer is +// non-constant, because it uses the value of an uninitialized object. + +// s() is ill-formed (no diagnostic required) because there is no set of +// arguments that would produce a constant expression. + +// R() is well-formed because i is initialized before j. + +struct s { + constexpr s() : v(v) { } // { dg-message "" } + int v; +}; + +constexpr s bang; // { dg-error "" } + +struct R { + int i,j; + constexpr R() : i(42),j(i) { } // { dg-bogus "" "" { xfail *-*-* } } +}; + +constexpr R r; // { dg-bogus "" "" { xfail *-*-* } } + +// Ill-formed (no diagnostic required) +struct T { + int i; + constexpr int f() { return i; } + constexpr T(): i(0) { } + constexpr T(const T& t) : i(f()) { } // { dg-message "" } +}; + +constexpr T t1; +// Ill-formed (diagnostic required) +constexpr T t2(t1); // { dg-error "" } + +// Well-formed +struct U { + int i, j; + constexpr int f(int _i) { return _i; } + constexpr int g() { return i; } + constexpr U(): i(0), j(0) { } + constexpr U(const U& t) : i(f(t.i)),j(0) { } // { dg-bogus "" "" { xfail *-*-* } } + constexpr U(int _i) : i(_i),j(g()) { } // { dg-bogus "" "" { xfail *-*-* } } +}; + +constexpr U u1; +constexpr U u2(u1); // { dg-bogus "" "" { xfail *-*-* } } +constexpr U u3(1); // { dg-bogus "" "" { xfail *-*-* } } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-98.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-98.C new file mode 100644 index 000000000..4ae3944c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-98.C @@ -0,0 +1,4 @@ +// { dg-options "-std=c++98" } + +constexpr int i = 42; // { dg-message "std=c\\+\\+0x" } +// { dg-error "constexpr" "" { target *-*-* } 3 } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-access.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-access.C new file mode 100644 index 000000000..ee5fc9854 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-access.C @@ -0,0 +1,14 @@ +// { dg-options -std=c++0x } + +class base +{ +protected: + constexpr base() { } +}; + +struct A : base { }; + +int main() +{ + A a; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr.C new file mode 100644 index 000000000..36939e1af --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr.C @@ -0,0 +1,15 @@ +// { dg-options -std=c++0x } + +template<class T> +constexpr T do_get(T* x, int n) { + return x[n - 1]; +} + +template<class T, int N> +constexpr T get(T (&x)[N]) { + return do_get(x, N); +} + +constexpr int arr_i[] = {1}; +constexpr auto var = get(arr_i); // #2 +static_assert(var == arr_i[0], "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr2.C new file mode 100644 index 000000000..7cf733445 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr2.C @@ -0,0 +1,21 @@ +// { dg-options -std=c++0x } + +template<class T> +struct IsNegative { + int dummy; // Workaround for empty class problem + constexpr IsNegative() : dummy(0) {} + constexpr bool operator()(const T& x) { + return x < T(0); + } +}; + +template<class T, int N, class Pred> +constexpr bool has_neg(T (&x)[N], Pred p) { + return p(x[0]) || p(x[1]); +} + +constexpr int a[] = {1, -2}; + +constexpr auto answer = has_neg(a, IsNegative<int>{}); // #1 + +static_assert(answer, "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr3.C new file mode 100644 index 000000000..f84cb5257 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr3.C @@ -0,0 +1,19 @@ +// { dg-options -std=c++0x } + +constexpr bool is_negative(int x) { + return x < 0; +}; + +constexpr bool do_has_neg(const int* x, bool(*p)(int)) { + return p(x[0]) || p(x[1]); // Line 6 +} + +constexpr bool has_neg(const int (&x)[2], bool(*p)(int)) { + return do_has_neg(x, p); // Line 10 +} + +constexpr int a[] = {1, -2}; + +constexpr auto answer = has_neg(a, is_negative); // Line 15 + +static_assert(answer, "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr4.C new file mode 100644 index 000000000..697d2d9f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr4.C @@ -0,0 +1,23 @@ +// { dg-options -std=c++0x } + +constexpr const int do_last(const int* x, int n) { + return x[n - 1]; +} + +struct IsNegative { + constexpr bool operator()(const int& x) { + return x < 0; + } +}; + +template<int N, class Pred> +constexpr bool has_neg(const int (&x)[N], Pred p) { + return p(do_last(x, N)); // Line 13 +} + +constexpr int a[] = {1, -2}; + +constexpr auto answer = has_neg(a, IsNegative{}); // Line 18 + +static_assert(answer, "Error"); + diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr5.C new file mode 100644 index 000000000..d58f254f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr5.C @@ -0,0 +1,32 @@ +// { dg-options -std=c++0x } + +template<class T> +constexpr T do_last(T* x, int n) { + return x[n - 1]; // +} + +template<class T, int N> +constexpr T last(T (&x)[N]) { + return do_last(x, N); +} + +constexpr bool is_negative(int x) { return x < 0; } + +template<class T> +struct IsNegative { + constexpr bool operator()(const T& x) { + return x < T(0); + } +}; + +template<class T, int N, class Pred> +constexpr bool has_neg(T (&x)[N], Pred p) { + return p(last(x)); // Line 22 +} + +constexpr int a[] = {1, -2}; + +constexpr auto answer1 = has_neg(a, IsNegative<int>{}); // Line 27 +constexpr auto answer2 = has_neg(a, is_negative); + +static_assert(answer2 == answer1, "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr6.C new file mode 100644 index 000000000..17dd6e50b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-ptr6.C @@ -0,0 +1,18 @@ +// { dg-options "-std=c++0x" } + +typedef decltype(sizeof(char)) size_type; + +template<class T, size_type N> +constexpr size_type size(T (&)[N]) { return N; } + +double array_double[] = { 1.0, 2.0, 3.0 }; + +constexpr auto sz_d = size(array_double); + +static_assert(sz_d == 3, "Array size failure"); + +void f(bool (¶m)[2]) { + static_assert(size(param) == 2, "Array size failure"); // Line 13 + short data[] = {-1, 2, -45, 6, 88, 99, -345}; + static_assert(size(data) == 7, "Array size failure"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array-tparm.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-tparm.C new file mode 100644 index 000000000..c17090cc3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array-tparm.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +template <const int I[2]> struct A { int ir[I[0]]; }; +extern constexpr int ar[2] = { 1, 2 }; +A<ar> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array.C new file mode 100644 index 000000000..e37400a8b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array.C @@ -0,0 +1,15 @@ +// { dg-options -std=c++0x } +// { dg-final { scan-assembler-not "static_initialization" } } + +struct A +{ + int i; + constexpr A(): i(0) { } +}; + +struct B +{ + A a[4]; +}; + +extern const B b{}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array2.C new file mode 100644 index 000000000..9577f75d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array2.C @@ -0,0 +1,19 @@ +// PR c++/46348 +// { dg-options -std=c++0x } + +template<__SIZE_TYPE__ _Nw> + struct _Base + { + typedef unsigned long _WordT; + + _WordT _M_w[_Nw]; + + constexpr + _Base() + : _M_w() { } + }; + +int main() +{ + _Base<256> bs; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C new file mode 100644 index 000000000..145a4307e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array3.C @@ -0,0 +1,14 @@ +// PR c++/48132 +// { dg-options -std=c++0x } + +struct C +{ + constexpr C (int x) : c (x) {} + int c; +}; + +void +foo () +{ + C a[] = { C (0) }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array4.C new file mode 100644 index 000000000..9aeb75d6b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array4.C @@ -0,0 +1,14 @@ +// PR c++/49924 +// { dg-options -std=c++0x } + +struct A { constexpr A() { } }; + +struct B { + A array[1]; //non-static member array of a literal type w constexpr ctor + constexpr B() : array{} { } // here is the problem +}; + +int main() +{ + constexpr B b{}; // won't compile +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C new file mode 100644 index 000000000..ac85c076d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute.C @@ -0,0 +1,63 @@ +// { dg-options -std=c++0x } + +//A few constexpr's +constexpr int foo() { return __alignof__(int); } + +template<typename T> +constexpr int fooT() { return __alignof__(T); } + +template<int N> +constexpr int fooN() { return N; } + +//Now the attributes + +//with normal variables, +int a __attribute__((aligned(foo()))); +int b __attribute__((aligned(fooT<int>()))); +int c __attribute__((aligned(fooN<__alignof__(int)>()))); + +//with variables inside a template, +template <typename T> +void fun() +{ + T a __attribute__((aligned(foo()))); + T b __attribute__((aligned(fooT<T>()))); + T c __attribute__((aligned(fooN<__alignof__(T)>()))); + T d __attribute__((aligned(fooT<int>()))); + T e __attribute__((aligned(fooN<__alignof__(int)>()))); +} + +//instantiate it, +void bar() +{ + fun<int>(); +} + +//with classes +struct __attribute__((aligned(foo()))) S0 +{ + char dummy; +}; +S0 s0; + +struct __attribute__((aligned(fooT<int>()))) S1 +{ + char dummy; +}; +S1 s1; + +//and class templates +template <typename T> +struct __attribute__((aligned(foo()))) S2 +{ + char dummy; +}; + +S2<int> s2; + +template <typename T> +struct __attribute__((aligned(fooT<T>()))) S3 +{ + char dummy; +}; +S3<int> s3; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-auto.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-auto.C new file mode 100644 index 000000000..ddf0da0b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-auto.C @@ -0,0 +1,2 @@ +// { dg-options -std=c++0x } +constexpr auto value = 0; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base.C new file mode 100644 index 000000000..774df318a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-base.C @@ -0,0 +1,17 @@ +// Test base/member class and static_assert with constexpr +// { dg-options -std=c++0x } + +struct A { + int i; + constexpr A(int _i): i(_i) { } +}; +struct B: A { + A a; + int j; + constexpr B(int _ib, int _ia, int _j): A(_ib), a(_ia), j(_j) { } +}; + +constexpr B b (12, 24, 36); + +#define SA(X) static_assert (X, #X) +SA(b.i==12 && b.a.i==24 && b.j==36); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base2.C new file mode 100644 index 000000000..3ea75432a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-base2.C @@ -0,0 +1,19 @@ +// PR c++/46293 +// { dg-options -std=c++0x } + +struct A +{ +}; + +struct C +{ + int i; + constexpr C(int i): i(i) {} +}; + +struct B: A, C +{ + constexpr B(): A(), C(42) { } +}; + +constexpr B b{}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C new file mode 100644 index 000000000..cffe9ea24 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C @@ -0,0 +1,27 @@ +// PR c++/46526 +// { dg-do run } +// { dg-options "-std=c++0x" } + +struct Base +{ + virtual int getid () = 0; +}; + +struct A : public Base +{ + virtual int getid () { return 1; } +}; + +struct B : public Base +{ + virtual int getid () { throw "here"; } +}; + +int +main () +{ + A a; + B b; + Base& ar = a; + ar.getid (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C new file mode 100644 index 000000000..ce23cb9dd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-base4.C @@ -0,0 +1,28 @@ +// PR c++/46626 +// { dg-do run } +// { dg-options "-std=c++0x" } + +struct A +{ + virtual void f () = 0; + virtual ~A () { } +}; + +struct B : A +{ + virtual void f () { } +}; + +static void +foo (A *a) +{ + a->f (); +} + +int +main () +{ + B b; + foo (&b); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield.C new file mode 100644 index 000000000..7eba49833 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield.C @@ -0,0 +1,10 @@ +// PR c++/46369 +// { dg-options -std=c++0x } + +struct A +{ + unsigned i : 1; +}; + +constexpr A f() { return { 1 }; } +constexpr bool b = (f().i == 1); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield2.C new file mode 100644 index 000000000..531bf31fc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield2.C @@ -0,0 +1,19 @@ +// PR c++/49136 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct day +{ + unsigned d : 5; + unsigned n : 3; + constexpr explicit day (int dd) : d(dd), n(7) {} +}; + +struct date { + int d; + constexpr date (day dd) : d(dd.n != 7 ? 7 : dd.d) {} +}; + +constexpr day d(0); +constexpr date dt(d); +static_assert (dt.d == 0, "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield3.C new file mode 100644 index 000000000..b0ecbfb9a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-bitfield3.C @@ -0,0 +1,33 @@ +// PR c++/49136 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct S +{ + unsigned : 1; unsigned s : 27; unsigned : 4; + constexpr S (unsigned int x) : s(x) {} +}; + +template <typename S> +struct T +{ + unsigned int t; + constexpr T (S s) : t(s.s != 7 ? 0 : s.s) {} + constexpr T (S s, S s2) : t(s.s != s2.s ? 0 : s.s) {} +}; + +constexpr S s (7), s2 (7); +constexpr T<S> t (s), t2 (s, s2); +static_assert (t.t == 7, "Error"); +static_assert (t2.t == 7, "Error"); + +struct U +{ + int a : 1; int s : 1; + constexpr U (int x, int y) : a (x), s (y) {} +}; + +constexpr U u (0, -1), u2 (-1, -1); +constexpr T<U> t3 (u), t4 (u, u2); +static_assert (t3.t == 0, "Error"); +static_assert (t4.t == -1, "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C new file mode 100644 index 000000000..de17f3ddb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } + +struct A +{ + int i; + ~A(); +}; + +constexpr int i = A().i; // { dg-error "non-literal" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-complex.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex.C new file mode 100644 index 000000000..fbaae5dcd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex.C @@ -0,0 +1,17 @@ +// Make sure C99 complex works with constexpr +// { dg-options -std=c++0x } + +struct complex +{ + typedef float value_type; + typedef __complex__ float _ComplexT; + + constexpr complex(_ComplexT __z) : _M_value(__z) { } + + constexpr complex(float __r = 0.0f, float __i = 0.0f) + : _M_value(__r + __i * 1.0fi) { } + +private: + _ComplexT _M_value; +}; +constexpr complex c1; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C new file mode 100644 index 000000000..e2328fcc5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-condition.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } +// Core DR 948 + +constexpr int something() { return 3; } + +int main() { + if (constexpr long v = something()) {} + if (static long v = something()) { } // { dg-error "decl-specifier invalid" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-condition2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-condition2.C new file mode 100644 index 000000000..243409669 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-condition2.C @@ -0,0 +1,18 @@ +// PR c++/48909 +// { dg-options -std=c++0x } + +#define SA(X) static_assert((X),#X) + +constexpr int const * is_sorted_until(int const * first, int const * last) +{ + return first == last || first + 1 == last ? last + : (*(first + 1) < *first) != false ? first + 1 + : is_sorted_until(first + 1, last); +} + +int main() +{ + static constexpr int array[2] = {0, 1}; + constexpr int const * last = is_sorted_until(array, array + 2); + SA(last==array+2); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor.C new file mode 100644 index 000000000..91c489db2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } + +struct A +{ + int i; + constexpr A() { } // { dg-error "uninitialized member .A::i" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor2.C new file mode 100644 index 000000000..5280b131b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor2.C @@ -0,0 +1,11 @@ +// { dg-options -std=c++0x } + +struct A +{ + A(); +}; + +struct B : A +{ + constexpr B(): A() { } // { dg-error "A::A" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor3.C new file mode 100644 index 000000000..d5bfbad3d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor3.C @@ -0,0 +1,10 @@ +// PR c++/46348 +// { dg-options -std=c++0x } + +struct A +{ + int arr[1]; + + constexpr A() + : arr() { } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor4.C new file mode 100644 index 000000000..397b4b054 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor4.C @@ -0,0 +1,15 @@ +// PR c++/46873 +// { dg-options -std=c++0x } + +struct S +{ + int i:1; +}; + +struct T +{ + const S s; + constexpr T (S a = S ()) : s (a) { } +}; + +T t; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor5.C new file mode 100644 index 000000000..36b01785f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor5.C @@ -0,0 +1,30 @@ +// PR c++/46877 +// { dg-options -std=c++0x } + +struct new_allocator +{ + constexpr new_allocator (); +}; + +struct string +{ + constexpr string () + { + } + new_allocator a; +}; + +struct pair +{ + const string first; + constexpr pair () + { + } +}; + +constexpr +new_allocator::new_allocator () +{ +} + +pair p; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor6.C new file mode 100644 index 000000000..4f86f73a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor6.C @@ -0,0 +1,9 @@ +// PR c++/47041 +// { dg-options "-std=c++0x -fno-elide-constructors" } + +struct S +{ + int i; +}; + +S s = S (); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor7.C new file mode 100644 index 000000000..8338bf1f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor7.C @@ -0,0 +1,17 @@ +// PR c++/47199 +// { dg-options "-std=c++0x -fno-elide-constructors" } + +template < int > struct S +{ + constexpr S (int r):rr (r) + { + } + S (const S &) = default; + static constexpr S s () + { + return -1; + } + int rr; +}; + +static const int d = S < 0 >::s ().rr; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor8.C new file mode 100644 index 000000000..81fc83737 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor8.C @@ -0,0 +1,6 @@ +// PR c++/46466 +// { dg-options "-std=c++0x -fno-elide-constructors" } + +struct S { bool b; }; +constexpr S f() { return S{true}; } +static_assert(f().b, ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor9.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor9.C new file mode 100644 index 000000000..b7693f1e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor9.C @@ -0,0 +1,19 @@ +// PR c++/47774 +// { dg-options -std=c++0x } + +struct A +{ + A() {} +}; + +template <typename T> +struct array +{ + constexpr array() : mem() {} + T mem[7]; +}; + +int main() +{ + array<A> ar; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-data1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-data1.C new file mode 100644 index 000000000..0943fa422 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-data1.C @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// From N2235 + +// 1 +struct A2 +{ + static const int eights = 888; + static constexpr int nines = 999; +}; + +A2 a; + +// 2 +struct pixel +{ + int x, y; +}; +constexpr pixel ur = { 1294, 1024 }; // OK + +// p4 +struct Length +{ + explicit constexpr Length(int i = 0) : val(i) { } +private: + int val; +}; + +constexpr int myabs(int x) +{ return x < 0 ? -x : x; } // OK + +Length l(myabs(-97)); // OK + +// p6 +class debug_flag +{ +public: + explicit debug_flag(bool); + constexpr bool is_on(); // { dg-error "enclosing class .* not a literal type" } +private: + bool flag; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C new file mode 100644 index 000000000..2d614ec32 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename _Tp, _Tp v> + struct A3 + { + typedef _Tp value_type; + typedef A3<value_type,v> type; + + static constexpr value_type value = v; + + constexpr operator value_type() { return value; } + }; + +// Partial specialization. +template<typename _Tp, _Tp v> + struct A3<_Tp*, v> + { + typedef _Tp* value_type; + typedef A3<value_type,v> type; + + static constexpr value_type value = v; + + constexpr operator value_type() { return value; } + }; + +// Explicit specialization. +template<> + struct A3<unsigned short, 0> + { + typedef unsigned short value_type; + typedef A3<value_type, 0> type; + + static constexpr value_type value = 0; + + constexpr operator value_type() { return value; } + }; + +// Explicitly instantiate. +template struct A3<int, 415>; + +// Extern explicitly instantiate. +extern template struct A3<int, 510>; + +// Use. +A3<int, 1111> a31; +A3<char, 9999> a32; // { dg-warning "overflow" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-decl.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-decl.C new file mode 100644 index 000000000..0a3fcb656 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-decl.C @@ -0,0 +1,10 @@ +// PR c++/46930 +// { dg-options -std=c++0x } + +struct S { + static constexpr int size; // { dg-error "must have an initializer" } + // { dg-error "previous declaration" "" { target *-*-* } 5 } +}; + +const int limit = 2 * S::size; +constexpr int S::size = 256; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C new file mode 100644 index 000000000..1413b24bd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg.C @@ -0,0 +1,12 @@ +// PR c++/46335 +// { dg-options -std=c++0x } + +struct T { }; +struct A { + A(const T &tr =T()) {} +}; +struct B { + A k; +}; +B kk_; +A fk_; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg2.C new file mode 100644 index 000000000..faa8a3603 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-defarg2.C @@ -0,0 +1,44 @@ +// PR c++/46368 +// { dg-options "-std=c++0x" } + +class A; + +class B +{ + A foo (); + A bar (); +}; + +class C +{ +}; + +struct D +{ + D (C); +}; + +struct A : D +{ + A (const C & n) : D (n) {} +}; + +A baz (const char *, A = C ()); + +A +B::foo () +{ + try + { + baz ("foo"); + } + catch (...) + { + } +} + +A +B::bar () +{ + baz ("bar"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-delete.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-delete.C new file mode 100644 index 000000000..67c950302 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-delete.C @@ -0,0 +1,3 @@ +// { dg-options -std=c++0x } + +constexpr bool never() = delete; // useless, but OK diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-deref.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-deref.C new file mode 100644 index 000000000..7363e98ec --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-deref.C @@ -0,0 +1,16 @@ +// { dg-options -std=c++0x } + +struct A +{ + const int *p[2]; +}; + +constexpr const int * f(const int *p) { return p; } + +int main() +{ + constexpr int i = 42; + constexpr int j = *&i; // OK + constexpr int k = *A{{&i}}.p[0]; // OK + constexpr int l = *f(&i); // OK +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C new file mode 100644 index 000000000..183d3f768 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C @@ -0,0 +1,20 @@ +// Test that we explain why a template instantiation isn't constexpr +// { dg-options -std=c++0x } + +template <class T> +struct A +{ + T t; + constexpr int f() { return 42; } // { dg-error "enclosing class" } +}; + +struct B { B(); operator int(); }; + +constexpr A<int> ai = { 42 }; +constexpr int i = ai.f(); + +constexpr int b = A<B>().f(); // { dg-error "not a constexpr function" } + +template <class T> +constexpr int f (T t) { return 42; } // { dg-error "parameter" } +constexpr int x = f(B()); // { dg-error "constexpr function" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag2.C new file mode 100644 index 000000000..c78416ec1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag2.C @@ -0,0 +1,5 @@ +// PR c++/47207 +// { dg-options -std=c++0x } + +constexpr int X (X); // { dg-error "not usable" } +// { dg-message "own initializer" "" { target *-*-* } 4 } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-eh-spec.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-eh-spec.C new file mode 100644 index 000000000..6d231fafa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-eh-spec.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } +template<class T> class my_limits { +public: + static constexpr T min() throw() { return T(); } + static constexpr T max() noexcept { return T(); } +}; + +constexpr double var_min = my_limits<double>::min(); // #1 OK +constexpr double var_max = my_limits<double>::max(); // #2 Error diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ellipsis.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ellipsis.C new file mode 100644 index 000000000..5d090b541 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ellipsis.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } +constexpr int ellipsis(...) { return 1; } + +constexpr int ellipsis_c = ellipsis(); // OK +constexpr int ellipsis_c2 = ellipsis(42); // Internal error diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ellipsis2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ellipsis2.C new file mode 100644 index 000000000..0bb690406 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ellipsis2.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } + +struct A +{ + A(); + A(const A&); + bool empty(); +}; + +constexpr int ellipsis(...) { return 1; } + +static_assert(ellipsis(A().empty()), "Error"); // { dg-error "non-constant condition|empty" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty.C new file mode 100644 index 000000000..a9fc4388a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } + +struct Empty {}; + +constexpr bool f(Empty) { return true; } + +constexpr bool x(f(Empty{})); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty2.C new file mode 100644 index 000000000..ef2121194 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty2.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } + +struct IsLiteral {}; + +constexpr IsLiteral bar(IsLiteral x) { return x; } + +constexpr auto xy = bar(IsLiteral()); // #1 Error, but should be OK diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty3.C new file mode 100644 index 000000000..e0026fcc7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty3.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } + +struct IsLiteral {}; + +constexpr auto ab = IsLiteral(); + +constexpr IsLiteral bar(IsLiteral x) { return x; } + +constexpr auto xy = bar(ab); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty4.C new file mode 100644 index 000000000..b07f92464 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty4.C @@ -0,0 +1,34 @@ +// { dg-options -std=c++0x } + +typedef decltype(sizeof(char)) size_type; + +template<class T, size_type N, class Pred> +constexpr size_type do_find_if_or_stop(T (&x)[N], size_type i, Pred p); + +template<class T, size_type N, class Pred> +constexpr size_type do_find_if(T (&x)[N], size_type i, Pred p) { + return p(x[i]) ? i : do_find_if_or_stop(x, i + 1, p); // line 8 +} + +template<class T, size_type N, class Pred> +constexpr size_type do_find_if_or_stop(T (&x)[N], size_type i, Pred p) { + return i == N ? N : do_find_if(x, i, p); +} // Line 14 + +template<class T, size_type N, class Pred> +constexpr size_type find_if(T (&x)[N], Pred p) { + return do_find_if(x, 0, p); // Line 18 +} + +constexpr long items_long[] = {1, 2, 3, 4, -5, 6, -7, 8}; + +template<class T> +struct IsNegative { + constexpr bool operator()(const T& x) { + return x < T(0); + } +}; + +constexpr auto pos1 = find_if(items_long, IsNegative<long>{}); // Line 30 + +static_assert(pos1 == 4, "find_if failure"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-empty5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty5.C new file mode 100644 index 000000000..9bd9aa583 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-empty5.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } + +struct A { }; +struct B: A { }; + +constexpr B b { }; +constexpr A a = b; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C new file mode 100644 index 000000000..4ab467780 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex1.C @@ -0,0 +1,94 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// From N2235 + +// 4.1 constant-expression functions +// 1 examples + + + + + +// 2 defined before first use +// NOTE: this is only needed in contexts that require a constant-expression +struct S { + constexpr int twice(); + constexpr int t(); // { dg-message "used but never defined" } +private: + static constexpr int val = 7; // constexpr variable +}; + +constexpr int S::twice() { return val + val; } +constexpr S s = { }; +int x1 = s.twice(); // ok +int x2 = s.t(); // error: S::t() not defined +constexpr int x2a = s.t(); // { dg-error "S::t" } error: S::t() not defined +constexpr int ff(); // ok +constexpr int gg(); // ok +int x3 = ff(); // error: ff() not defined +constexpr int x3a = ff(); // { dg-error "ff" } error: ff() not defined +constexpr int ff() { return 1; } // too late +constexpr int gg() { return 2; } +int x4 = gg(); // ok + + +// 4.2 const-expression data + +// 2 +// storage not allocated untill address taken +constexpr double x = 9484.748; +const double* p = &x; // the &x forces x into memory + +// 4.3 constant-expression constructors + +// 1 +struct complex { + constexpr complex(double r, double i) : re(r), im(i) { } + constexpr double real() { return re; } + constexpr double imag() { return im; } +private: + double re; + double im; +}; +constexpr complex I(0, 1); // OK -- literal complex + + +// 2 invoked with non-const args +double x5 = 1.0; // { dg-message "not declared .constexpr" } +constexpr complex unit(x5, 0); // { dg-error "x5|argument" } error: x5 non-constant +const complex one(x5, 0); // OK, ‘‘ordinary const’’ -- dynamic + // initialization +constexpr double xx = I.real(); // OK +complex z(2, 4); // OK -- ordinary variable + +// 3 +constexpr complex v[] = { + complex(0, 0), complex(1, 1), complex(2, 2) +}; +constexpr double x6 = v[2].real(); // OK + +// 4 + constexpr int i = 98; + typedef __INTPTR_TYPE__ intptr_t; + constexpr intptr_t ip = (intptr_t) &i; // { dg-error "constant" } + +// 4.3.2 copy-constructor +constexpr complex operator+(complex z, complex w) +{ + return complex(z.real() + w.real(), z.imag() + w.imag()); // fine +} +constexpr complex I2 = I + I; // OK +struct resource { + int id; + constexpr resource(int i) : id(i) { } // fine + resource(const resource& r) : id(r.id) // oops, not constexpr + { + //cout << id << " copied" << endl; + } +}; +constexpr resource f(resource d) +{ return d; } // { dg-error "not .constexpr" } +constexpr resource d = f(9); // { dg-error "resource" } + +// 4.4 floating-point constant expressions diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C new file mode 100644 index 000000000..29e835c4b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex2.C @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// From N2235 + +// 4.5.3 constant expressions + +// p 4 +struct A { + constexpr A(int i) : val(i) { } + constexpr operator int() { return val; } + constexpr operator long() { return -1; } +private: + int val; +}; + +template<int I> struct X { static const int i = I; }; +constexpr A a = 42; + +X<a> x; // OK: unique conversion to int +int ar[X<a>::i]; // also OK +int ary[a]; // { dg-error "ambiguous|conversion|array" } ambiguous conversion + diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C new file mode 100644 index 000000000..08552cd7d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex3.C @@ -0,0 +1,30 @@ +// { dg-options "-std=c++0x" } + +#define SA(X) static_assert (X, #X) + +struct A +{ + int i; + constexpr A(int _i) { i = _i; } // { dg-error "empty body|uninitialized member" } +}; + +template <class T> +struct B +{ + T t; + constexpr B(T _t): t(_t) { } +}; + +B<int> b(1); // { dg-message "not declared .constexpr" } +SA(b.t==1); // { dg-error "non-constant condition|'b'" } +constexpr B<int> b2(1); +SA(b2.t==1); + +template <class T> +constexpr T f(T a, T b) +{ + typedef T myT; + return a + b; +} + +SA(f(1,2)==3); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ex4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex4.C new file mode 100644 index 000000000..4214f5c52 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ex4.C @@ -0,0 +1,16 @@ +// { dg-options "-std=c++0x" } + +struct A +{ + constexpr A(int) { } + constexpr operator int() { return 1; }; +}; + +template <class T> +struct B +{ + static constexpr A a = A(1); + int ar[a]; +}; + +B<int> b; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-expinst.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-expinst.C new file mode 100644 index 000000000..208987369 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-expinst.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } +// Error: Explicit instantiation of a function template shall not use the +// inline or constexpr specifiers +template<class T> constexpr inline T bar(T x) { return x; } +template constexpr inline float bar(float x); // { dg-error "specifier" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-explicit-inst.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-explicit-inst.C new file mode 100644 index 000000000..8f0da0af0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-explicit-inst.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } + +template<class T> constexpr inline T bar(T x) { return x; } + +template short bar(short x); // #EI + +constexpr auto yz = bar(0); // OK +constexpr auto ab = bar(short()); // #1 Error, but should be OK +constexpr auto mn = bar(short{}); // #2 Error, but should be OK diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-fnptr.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-fnptr.C new file mode 100644 index 000000000..4c84d827f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-fnptr.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } + +constexpr bool is_negative(int x) { return x < 0; } + +constexpr bool check(int x, bool (*p)(int)) { return p(x); } // #1 + +static_assert(check(-2, is_negative), "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C new file mode 100644 index 000000000..f1d9ccee7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend.C @@ -0,0 +1,23 @@ +// PR c++/48948 +// { dg-options -std=c++0x } + +struct A { A(); }; + +struct B { + friend constexpr int f(B) { return 0; } // OK + friend constexpr int f(A) { return 0; } // { dg-error "constexpr" } +}; + +template <class T> +struct C +{ + friend constexpr int f(C) { return 0; } + friend constexpr int g(C, A) { return 0; } // { dg-error "double" } + constexpr int m(C) { return 0; } + constexpr int m(A) { return 0; } // { dg-error "double" } +}; + +constexpr int i = f(C<int>()); +constexpr int j = C<int>().m(C<int>()); +constexpr int k = C<double>().m(A()); // { dg-error "not a constexpr function" } +constexpr int l = g(C<double>(),A()); // { dg-error "not a constexpr function" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-function1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-function1.C new file mode 100644 index 000000000..c708b040f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-function1.C @@ -0,0 +1,10 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// From N2235 + +constexpr int veryabs(int x) { return x < 0 ? -x : x; } + +constexpr long long_max() { return 2147483647; } + +constexpr int verysquare(int x) { return x * x; } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C new file mode 100644 index 000000000..5a2ec76e3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C @@ -0,0 +1,50 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// From N2235 + +// Mess with the builtin by redeclaring. +constexpr int abs(int x) { return x < 0 ? -x : x; } + +extern "C" +{ + constexpr float + squaref(float x) { return x * x; } +} + +// implicitly inline, already: warn? +inline constexpr double +squared(double x) { return x * x; } + +constexpr int squarei(int x) { return x * x; } +extern const int side; // { dg-message "not initialized with a constant expression" } +constexpr int area = squarei(side); // { dg-error "side|argument" } +// error: squarei(side) is not a constant expression + +int next(constexpr int x) // { dg-error "parameter" } +{ return x + 1; } + +constexpr void f(int x) // { dg-error "return type .void" } +{ /* ... */ } + +constexpr int prev(int x) +{ return --x; } // { dg-error "--" } + +constexpr int g(int x, int n) // error: body not just ‘‘return expr’’ +{ + int r = 1; + while (--n > 0) r *= x; + return r; +} // { dg-error "not a return-statement" } + +constexpr int +bar(int x, int y) { return x + y + x * y; } // { dg-error "previously" } + +int bar(int x, int y) // { dg-error "redefinition" } +{ return x * 2 + 3 * y; } + +constexpr int twice(int x); // { dg-message "never defined" } +enum { bufsz = twice(256) }; // { dg-error "" } twice() isn’t (yet) defined + +constexpr int fac(int x) +{ return x > 2 ? x * fac(x - 1) : 1; } // OK diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C new file mode 100644 index 000000000..e8ca7bc68 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-function3.C @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// From N2235 + +// function template 1 +template<typename T> + constexpr int bytesize(T t) + { return sizeof (t); } // OK + +char buf[bytesize(0)]; // OK -- not C99 VLA + + +// function template 2 +template<typename _Tp> + constexpr _Tp + square(_Tp x) { return x; } + +// Explicit specialization +template<> + constexpr unsigned long + square(unsigned long x) { return x * x; } + +// Explicit instantiation +template int square(int); + +class A { }; +template A square(A); + +template long square(long); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice.C new file mode 100644 index 000000000..3b72484a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice.C @@ -0,0 +1,11 @@ +// We used to crash on this instead of giving a decent error. +// { dg-options -std=c++0x } + +struct A { int i; }; + +struct B { + const A *a; + constexpr B(const A& a): a(&a) { } +}; + +constexpr B b{A{42}}; // { dg-error "constant|expansion" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice2.C new file mode 100644 index 000000000..35643b990 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice2.C @@ -0,0 +1,3 @@ +// { dg-options -std=c++0x } +int x; +constexpr int& rx = x; // { dg-error "int&" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C new file mode 100644 index 000000000..23903bca7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ice3.C @@ -0,0 +1,13 @@ +// PR c++/46289 +// { dg-options -std=c++0x } + +struct A +{ + int i; +}; + +struct B +{ + A a; + constexpr B(): a({1,2}) { } // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C new file mode 100644 index 000000000..71372d226 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete1.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } + +struct A +{ + static constexpr A a = 1; // { dg-error "incomplete|literal" } + constexpr A(int i) { } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete2.C new file mode 100644 index 000000000..dc0b7429d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete2.C @@ -0,0 +1,31 @@ +// A constructor that might or might not be constexpr still makes +// its class literal. +// { dg-options -std=c++0x } + +template <class T> +struct B +{ + constexpr B(T) { } + constexpr B() {} +}; + +struct A +{ + B<A> b; +}; + +constexpr A a {}; + +template <class T> +struct C +{ + constexpr C(T) { } + C() {} +}; + +struct D +{ + C<D> c; +}; + +constexpr D d {}; // { dg-error "not a constexpr function" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete3.C new file mode 100644 index 000000000..81822b07e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-incomplete3.C @@ -0,0 +1,12 @@ +// PR c++/49015 +// { dg-options -std=c++0x } + +class A; + +class B { + friend constexpr B f(A); // Line 5 +}; + +class A {}; + +constexpr B f(A) { return B(); } // Line 10 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist.C new file mode 100644 index 000000000..6854e7341 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist.C @@ -0,0 +1,65 @@ +// { dg-options -std=c++0x } +// { dg-do run } + +namespace xstd { + +typedef decltype(sizeof(char)) size_t; + +template<class E> +class initializer_list { +private: + size_t sz; + const E* start; + +public: + typedef E value_type; + typedef const E& reference; + typedef const E& const_reference; + typedef size_t size_type; + typedef const E* iterator; + typedef const E* const_iterator; + + constexpr initializer_list() : sz(), start(nullptr) {} + + template<size_t N> + constexpr initializer_list(const E(&array)[N]) : sz(N), start(array) {} + + constexpr size_t size() { return sz; } + + constexpr const E* begin() { return start; } + + constexpr const E* end() { return start + sz; } +}; + +template<class E, size_t N> +constexpr initializer_list<E> make_list(const E(&array)[N]) { + return initializer_list<E>(array); +} + +template<class E> +E min(initializer_list<E> list) +{ + // static_assert(list.size() > 0, "Invalid list"); + auto it = list.begin(); + E result = *it; + for (++it; it != list.end(); ++it) { + if (*it < result) { + result = *it; + } + } + return result; +} + +} + +constexpr int global_i[] = {2, 4, -5, 6, 10}; +constexpr xstd::initializer_list<int> list(global_i); +#define SA(X) static_assert(X, #X) +SA(list.size() == 5); +SA(list.begin()[2] == -5); +SA(list.end()[-1] == 10); + +int main() { + if (xstd::min(xstd::make_list(global_i)) != -5) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist2.C new file mode 100644 index 000000000..f34b98016 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist2.C @@ -0,0 +1,10 @@ +// { dg-options -std=c++0x } + +#include <initializer_list> + +constexpr auto list = { 1, 2, 3, 4 }; + +#define SA(X) static_assert(X, #X) +SA(list.size() == 4); +SA(list.begin()[2] == 3); +SA(list.end()[-1] == 4); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist3.C new file mode 100644 index 000000000..7620e6b2c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist3.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } + +#include <initializer_list> +#define SA(X) static_assert(X,#X) + +constexpr int f(std::initializer_list<int> l) { return l.begin()[0]; } + +int main() +{ + constexpr int i = f({42}); + SA(i==42); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist5.C new file mode 100644 index 000000000..97f039998 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist5.C @@ -0,0 +1,15 @@ +// PR c++/50024 +// { dg-options -std=c++0x } + +template< class T > +struct Container +{ + Container(){ + int* ptr = new int{}; + } +}; + +int main() { + Container< int > c; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-is_literal.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-is_literal.C new file mode 100644 index 000000000..d1b95437d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-is_literal.C @@ -0,0 +1,38 @@ +// { dg-options -std=c++0x } + +#include <type_traits> + +#define IS_LIT(T) (std::is_literal_type<T>::value) +#define SA(X) static_assert (X, #X) +#define YES(T) SA(IS_LIT(T)) +#define NO(T) SA(!IS_LIT(T)) + +enum E1 { }; +enum class E2 { }; +struct Literal {}; + +struct NotLiteral { + ~NotLiteral(); +}; + +YES(int); +YES(int[]); +YES(int[3]); +YES(double); +YES(void *); +YES(decltype (nullptr)); +YES(int Literal::*); +YES(void (Literal::*)()); +YES(E1); +YES(E2); +YES(Literal); +NO (NotLiteral); +YES(NotLiteral *); +YES(NotLiteral NotLiteral::*); +YES(NotLiteral (NotLiteral::*)(NotLiteral)); + +struct A { + A(const A&) = default; +}; + +NO(A); // no constexpr ctor other than copy diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-memfn1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-memfn1.C new file mode 100644 index 000000000..ef7ac6b48 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-memfn1.C @@ -0,0 +1,18 @@ +// PR c++/48296 +// { dg-options -std=c++0x } + +struct X +{ + constexpr X() { } + constexpr X f(X x) { return x; } + constexpr X g(X x); +}; + +constexpr X X::g(X x) { return x; } + +struct Y +{ + Y() { } + constexpr Y f(Y y); // { dg-error "not a literal type" } + static constexpr Y g(Y y) {} // { dg-error "constexpr" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-missing.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-missing.C new file mode 100644 index 000000000..547f552e3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-missing.C @@ -0,0 +1,39 @@ +// PR c++/48911 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +#define SA(X) static_assert((X),#X) + +struct A +{ + constexpr A () : a (6) {} + int a; +}; + +int +main () +{ + constexpr int a[2] = { 42 }; + constexpr int i = a[1]; + SA(i==0); + constexpr int b[1] = { }; + constexpr int j = b[0]; + SA(j==0); + constexpr char c[2] = "a"; + constexpr char k = c[1]; + SA(k==0); + constexpr char d[2] = ""; + constexpr char l = d[1]; + SA(l==0); + constexpr wchar_t e[2] = L"a"; + constexpr wchar_t m = e[1]; + SA(m==0); + constexpr wchar_t f[2] = L""; + constexpr wchar_t n = f[1]; + SA(n==0); + constexpr A g[2] = { A () }; + constexpr A o = g[0]; + SA(o.a == 6); + constexpr A p = g[1]; + SA(p.a == 6); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C new file mode 100644 index 000000000..8294afa98 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C @@ -0,0 +1,69 @@ +// Negative examples from N3092 (FCD) +// { dg-options -std=c++0x } + +// OK: declaration +constexpr int square(int x); // { dg-message "never defined" } + +// error: pixel is a type +constexpr struct pixel { + int x; + int y; + // OK: declaration + constexpr pixel(int); +}; // { dg-error "constexpr" } +constexpr pixel::pixel(int a) +// OK: definition + : x(square(a)), y(square(a)) // { dg-error "square" } +{ } + +// error: square not defined, so small(2) not constant (5.19), so constexpr +// not satisfied +constexpr pixel small(2); // { dg-message "in constexpr expansion" } + +// error: not for parameters +int next(constexpr int x) { // { dg-error "parameter" } + return x + 1; +} + +// error: not a definition +extern constexpr int memsz; // { dg-error "definition" } + +// error: return type is void +constexpr void f(int x) // { dg-error "void" } +{ /* ... */ } +// error: use of decrement +constexpr int prev(int x) +{ return --x; } // { dg-error "-- x" } + +// error: body not just return expr +constexpr int g(int x, int n) { + int r = 1; + while (--n > 0) r *= x; + return r; +} // { dg-error "body of constexpr function" } + +class debug_flag { +public: + explicit debug_flag(bool); + constexpr bool is_on(); // { dg-error "not a literal type" } debug_flag not literal type +private: + bool flag; +}; +// OK +constexpr int bar(int x, int y) // { dg-error "previously defined here" } +{ return x + y + x*y; } +// ... +// error: redefinition of bar +int bar(int x, int y) // { dg-error "redefinition" } +{ return x * 2 + 3 * y; } + +struct pixel2 { // { dg-message "no user-provided default constructor" } + int x, y; +}; +constexpr pixel2 ur = { 1294, 1024 };// OK +constexpr pixel2 origin; // { dg-error "uninitialized const" } + +constexpr const int* addr(const int& ir) { return &ir; } // OK + +// error, initializer for constexpr variable not a constant +extern constexpr const int* tp = addr(5); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept.C new file mode 100644 index 000000000..0476f9096 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept.C @@ -0,0 +1,13 @@ +// { dg-options -std=c++0x } + +template<class T> +struct is_funny { + static constexpr bool value = false; +}; + +template<class T> +constexpr T value(T t) noexcept(is_funny<T>::value) { return t; } // Line 7 + +constexpr bool ok = noexcept(value(42)); + +static_assert(ok, "Assertion failure"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept2.C new file mode 100644 index 000000000..95a1443fa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept2.C @@ -0,0 +1,14 @@ +// { dg-options -std=c++0x } + +template<class T> +constexpr T value(T t) { return t; } + +template<class T> +struct is_funny { + static constexpr bool value = false; +}; + +template<class T> +void eval() noexcept(value(is_funny<T>::value)) {} + +constexpr bool ok = noexcept(eval<int>()); // line 12 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept3.C new file mode 100644 index 000000000..6e76ea8fa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept3.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } + +constexpr int f(int i) { return i; } +#define SA(X) static_assert (X, #X) +SA(noexcept(f(42))); +int j; +SA(!noexcept(f(j))); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept4.C new file mode 100644 index 000000000..119d4e167 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept4.C @@ -0,0 +1,14 @@ +// { dg-options -std=c++0x } +// A call is noexcept if it is a valid subexpression of a constant +// expression, even if it is not itself a constant expression. + +#define SA(X) static_assert(X,#X) + +constexpr const int* f(const int *p) { return p; } + +int main() +{ + constexpr int i = 42; + SA(noexcept(*f(&i))); + SA(noexcept(f(&i))); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept5.C new file mode 100644 index 000000000..7bf961b3c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-noexcept5.C @@ -0,0 +1,15 @@ +// { dg-options -std=c++0x } + +struct booleable { + bool data; + constexpr explicit operator bool() { return data; } +}; + +constexpr booleable truthy_func() { return {true}; } + +void funky() noexcept(truthy_func()) {} + +int main() { + funky(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg.C new file mode 100644 index 000000000..7637c0a05 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg.C @@ -0,0 +1,24 @@ +// Example from issue 1125 drafting; D() and v were well-formed with the +// wording approved in Rapperswil, now seems they should be ill-formed. +// { dg-options "-std=c++0x -pedantic-errors" } + +struct B { + constexpr B(int x) : i(0) { } // "x" is unused + int i; +}; + +int global; // { dg-message "not const" } + +struct D : B { + constexpr D() : B(global) { } // { dg-error "global|argument" } +}; + +struct A2 { + constexpr A2(bool b, int x) : m(b ? 42 : x) { } + int m; +}; + +// ok, constructor call initializes m with the value 42 after substitution +constexpr int v = A2(true, global).m; // { dg-error "global" } +// error: initializer for m is "x", which is non-constant +constexpr int w = A2(false, global).m; // { dg-error "global" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg2.C new file mode 100644 index 000000000..20e05c3c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg2.C @@ -0,0 +1,16 @@ +// PR c++/47200 +// { dg-options "-std=c++0x -w" } + +template < int > struct duration +{ + constexpr int count (); + static constexpr duration min (); +}; + +constexpr int +f (duration < 0 > d, duration < 0 > ) +{ + return d.count (); +} + +static_assert (f (duration < 0 >::min (), duration < 0 > ()), ""); // { dg-error "non-constant|before its definition" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg3.C new file mode 100644 index 000000000..581be6d15 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-non-const-arg3.C @@ -0,0 +1,23 @@ +// PR c++/49988 +// { dg-options -std=c++0x } +// { dg-do run } + +template<int ... I> struct X { }; + +struct A { + char data[3]; + template<int ... I> + constexpr + A(const char (&s)[3], X<I...> x) : data{ s[I]...} { } +}; +struct B { + A a; + B(const char (&s)[3]) : a{s,X<0,1,2>{}} { } +}; + +int main() +{ + B b{"12"}; + if (b.a.data[0] != '1') + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit.C new file mode 100644 index 000000000..9104c8afa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit.C @@ -0,0 +1,13 @@ +// FIXME this is currently invalid, but seems like it should be OK +// { dg-options -std=c++0x } + +struct A { A() { } }; + +template<class T> +constexpr bool ignore(T&&) { return true; } + +static_assert(ignore(10), "Error"); // OK + +A s; + +static_assert(ignore(s), "Error"); // Currently an error diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C new file mode 100644 index 000000000..21e8bd509 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonlit2.C @@ -0,0 +1,19 @@ +// { dg-options -std=c++0x } + +struct A +{ + ~A(); +}; + +template<class T> +struct W { + T t; + template<class U> + constexpr W(U&& u) : t(u) {} +}; + +template <class T> +constexpr W<T> make_w(T& w) { return W<T>(w); } + +A a; +constexpr auto w = make_w(a); // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-nonstatic.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonstatic.C new file mode 100644 index 000000000..3951fbdb1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-nonstatic.C @@ -0,0 +1,6 @@ +// { dg-options -std=c++0x } + +struct A +{ + constexpr int i; // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C new file mode 100644 index 000000000..7ac53db48 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr.C @@ -0,0 +1,6 @@ +// { dg-options -std=c++0x } + +constexpr int zero() { return 0; } + +void* ptr1 = zero(); // #1 +constexpr void* ptr2 = zero(); // #2 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C new file mode 100644 index 000000000..4ff398bf1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-object1.C @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// From N2235 + +// 4.5.2 semantics + +// p 1 constexpr specifier +// objects, static const data +struct A1 { int i; }; // { dg-message "no user-provided default constructor" } + +constexpr int i1 = 1024; +constexpr A1 a1 = A1(); + +// error: not a definition +extern constexpr int i2; // { dg-error "definition" } + +// error: missing initializer +constexpr A1 a2; // { dg-error "uninitialized const" } + +// error: duplicate cv +const constexpr A1 a3 = A1(); // { dg-error "both .const. and .constexpr. cannot" } + +volatile constexpr A1 a4 = A1(); // { dg-error "both .volatile. and .constexpr. cannot" } + +// error: on type declaration +constexpr struct pixel +{ + int x; + int y; +}; // { dg-error "cannot be used for type declarations" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C new file mode 100644 index 000000000..a038970f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-object2.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +constexpr int verysquare(int x) { return x * x; } + +const double mass = 9.8; +constexpr double energy = mass * verysquare(56.6); // { dg-error "mass" "" { xfail *-*-* } } + +int arr[(int)mass]; // { dg-error "mass" "" { xfail *-*-* } } + +float array[verysquare(9)]; // OK -- not C99 VLA + +extern const int medium; +const int high = verysquare(medium); // OK -- dynamic initialization + +enum { Max = verysquare(7) }; // OK diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow.C new file mode 100644 index 000000000..9b3b1fa0e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x -w" } + +#include <limits.h> +extern constexpr int max_s = INT_MAX + 1; // { dg-error "" } +extern constexpr unsigned max_u = UINT_MAX + 1u; // OK +extern constexpr int abs_s = -INT_MIN; // { dg-error "" } overflows on 2's complement machines diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow2.C new file mode 100644 index 000000000..5d5749ce2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-overflow2.C @@ -0,0 +1,8 @@ +// PR c++/47504 +// { dg-options -std=c++0x } + +char constexpr sub(char arg) +{ return char(arg - char(1)); } + +int main() +{ static char constexpr m = sub(-1); } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-pedantic.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-pedantic.C new file mode 100644 index 000000000..dc393d759 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-pedantic.C @@ -0,0 +1,16 @@ +// The FCD doesn't allow typedefs and static_assert in constexpr functions, +// but it should. +// { dg-options "-std=c++0x -pedantic" } + +template <class T> +constexpr T f(T t) +{ + typedef T T2; // { dg-warning "constexpr" "" { xfail *-*-* } } + static_assert (T2(0) == T(0), ""); // { dg-warning "constexpr" "" { xfail *-*-* } } + return t; +} + +int main() +{ + constexpr int i = f(42); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-pos1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-pos1.C new file mode 100644 index 000000000..775080acc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-pos1.C @@ -0,0 +1,60 @@ +// Positive examples from N3092 (FCD) +// { dg-options -std=c++0x } + +#define SA(X) static_assert(X, #X) + +constexpr int bufsz = 1024; // OK: definition +SA (bufsz == 1024); + +constexpr int square(int x); // OK: declaration + +struct pixel { + int x; + int y; + // OK: declaration + constexpr pixel(int); +}; +constexpr pixel::pixel(int a) // OK: definition + : x(square(a)), y(square(a)) +{ } + +constexpr int square(int x) // OK: definition +{ return x * x; } + +constexpr pixel large(4); // OK: square defined +SA(large.x == 16 && large.y==16); + +constexpr long long_max() // OK +{ return 2147483647; } + +SA(long_max() == 2147483647); + +constexpr int abs(int x) // OK +{ return x < 0 ? -x : x; } + +SA(abs(-1) == 1); +SA(abs(24) == 24); + +struct Length { + explicit constexpr Length(int i = 0) : val(i) { } +private: + int val; +}; + +constexpr Length l1; +constexpr Length l2(12); + +struct pixel2 { + int x, y; +}; +constexpr pixel2 ur = { 1294, 1024 };// OK + +SA(ur.x == 1294 && ur.y == 1024); + +constexpr const int* addr(const int& ir) { return &ir; } // OK +static const int x = 5; +extern constexpr const int* xp = addr(x); // OK: (const int*)&(const int&)x + // is an address contant expression +SA(xp == &x); +extern constexpr int x2 = *addr(5); +SA(x2 == 5); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-potential1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-potential1.C new file mode 100644 index 000000000..e933506b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-potential1.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } +// We decided in Rapperswil that it's OK if any value of decide can produce +// a constant expression. + +constexpr int may_throw(bool decide) { + return decide ? 42 : throw -1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem.C new file mode 100644 index 000000000..f6ed2f40a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ptrmem.C @@ -0,0 +1,20 @@ +// { dg-options -std=c++0x } + +struct C { // literal type + int m; + int n; + constexpr C(int m) : m(m), n(-m) {} + constexpr bool is_neg() { return m < 0; } +}; + +constexpr bool check1(const C& c, int C:: *pm) { return c.*pm < 0; } // #1 + +constexpr bool check2(const C* pc, bool (C::*pm)() const) { return +(pc->*pm)(); } // #2 + +constexpr C c(-1); + +static_assert(!check1(c, &C::n), "Error"); +static_assert(check1(c, &C::m), "Error"); + +static_assert(check2(&c, &C::is_neg), "Error"); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-pure.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-pure.C new file mode 100644 index 000000000..e17e02a42 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-pure.C @@ -0,0 +1,13 @@ +// { dg-options -std=c++0x } + +struct A +{ + virtual void f() = 0; +}; + +struct B: A +{ + void f() { } +}; + +B b; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-recursion.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-recursion.C new file mode 100644 index 000000000..2f9b4887d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-recursion.C @@ -0,0 +1,5 @@ +// Test that we catch excessive recursion. +// { dg-options "-std=c++0x -fconstexpr-depth=5" } +// { dg-prune-output "in constexpr expansion" } +constexpr int f (int i) { return f (i-1); } +constexpr int i = f(42); // { dg-error "constexpr evaluation depth" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-sassert.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-sassert.C new file mode 100644 index 000000000..3e08fb0ef --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-sassert.C @@ -0,0 +1,13 @@ +// Allow static_assert in constexpr constructors, too. +// { dg-options -std=c++0x } + +template<typename T> +struct A +{ + int i; + + constexpr A(int i) : i(i) + { + static_assert(sizeof(T) == 1, ""); + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static.C new file mode 100644 index 000000000..8ed2b5e82 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static.C @@ -0,0 +1,24 @@ +// Test for constant initialization of non-literal class (e.g. mutex) +// { dg-options "-std=c++0x -save-temps" } +// { dg-do run } + +struct A +{ + int i; + constexpr A(int _i): i(_i) { } + A(const A&); // non-trivial copy ctor makes A non-literal +}; + +A a(42); // constexpr constructor allows constant initialization +A ar[3] = { { 1 }, { 2 }, { 3 } }; +// { dg-final { scan-assembler-not "static_initialization" } } +// { dg-final cleanup-saved-temps } + +int main() +{ + if (a.i != 42 + || ar[0].i != 1 + || ar[1].i != 2 + || ar[2].i != 3) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static2.C new file mode 100644 index 000000000..67c353080 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static2.C @@ -0,0 +1,11 @@ +// { dg-options -std=c++0x } +struct IsLiteral {}; + +struct ShouldBeLiteral { + constexpr ShouldBeLiteral(int){} +}; + +struct StaticDataMember { + static constexpr IsLiteral one = IsLiteral(); // #1 + static constexpr ShouldBeLiteral two= ShouldBeLiteral(-1); // #2 +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static3.C new file mode 100644 index 000000000..dccdc854b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static3.C @@ -0,0 +1,18 @@ +// Test for constant initialization of class with vtable +// { dg-options "-std=c++0x -save-temps" } +// { dg-final { scan-assembler-not "static_initialization" } } +// { dg-final cleanup-saved-temps } +// { dg-do run } + +int r = 1; +// implicit default constructor for A and B is constexpr +struct A { virtual void f() {} }; +struct B: A { virtual void f() { r = 0; } }; + +B b; + +int main() +{ + b.f(); + return r; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static4.C new file mode 100644 index 000000000..8189fc5de --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static4.C @@ -0,0 +1,20 @@ +// { dg-options -std=c++0x } +// { dg-do run } + +extern "C" void abort (); +extern int ar[2]; + +int f() +{ + if (ar[0] != 42 || ar[1] != 0) + abort (); + return 1; +} + +int i = f(); + +int ar[2] = { 42, i }; + +int main() +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static5.C new file mode 100644 index 000000000..a401cc0b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static5.C @@ -0,0 +1,17 @@ +// { dg-options -std=c++0x } + +template <class T> +struct A +{ + constexpr static T t = T(); // { dg-error "literal" } +}; +template <class T> +constexpr T A<T>::t; + +struct B +{ + ~B(); +}; + +B b = A<B>::t; + diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static6.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static6.C new file mode 100644 index 000000000..a34704d83 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static6.C @@ -0,0 +1,21 @@ +// { dg-options -std=c++0x } + +struct B +{ + constexpr operator int() { return 4; } +}; + +template <int I> +struct C; + +template<> +struct C<4> { typedef int TP; }; + +template <class T> +struct A +{ + constexpr static B t = B(); + C<t>::TP tp; +}; + +A<B> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C new file mode 100644 index 000000000..ba4a25184 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static7.C @@ -0,0 +1,8 @@ +// PR c++/48945 +// { dg-options -std=c++0x } + +struct A { + static constexpr bool is(); +}; + +constexpr bool A::is() { return true; } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-stmtexpr.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-stmtexpr.C new file mode 100644 index 000000000..40e0c2d65 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-stmtexpr.C @@ -0,0 +1,8 @@ +// PR c++/46977 +// { dg-options "-std=c++0x" } + +template < typename > void +foo () +{ + ({int i;}), 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-string.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-string.C new file mode 100644 index 000000000..e76d00d7e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-string.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +constexpr char c1 = "hi"[1]; +constexpr char c2 = "hi"[2]; +constexpr char c3 = "hi"[3]; // { dg-error "out of bound" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-switch.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-switch.C new file mode 100644 index 000000000..d229304e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-switch.C @@ -0,0 +1,13 @@ +// { dg-options -std=c++0x } + +template<class T> +constexpr T value(T t = T()) { return t; } + +enum us_enum { us_item = value<short>() }; // OK + +void func(us_enum n) { + switch (n) { + case value(us_item): ; // #1 Error + default: ; + } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-switch2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-switch2.C new file mode 100644 index 000000000..55cf2ad7c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-switch2.C @@ -0,0 +1,23 @@ +// Test for constexpr conversion in case context +// { dg-options -std=c++0x } + +enum class E { e1, e2 }; + +struct A +{ + E e; + constexpr operator E() { return e; } + constexpr A(E e): e(e) { } +}; + +E e; + +int main() +{ + switch (e) + { + case A(E::e1): + case A(E::e2): + ; + } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-synth1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-synth1.C new file mode 100644 index 000000000..983093980 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-synth1.C @@ -0,0 +1,14 @@ +// PR c++/46472 +// { dg-options -std=c++0x } + +template<class T> struct A { + T t; + constexpr A(){} +}; + +struct B +{ + A<int> a; +}; + +B b; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C new file mode 100644 index 000000000..0c8c73d2e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ.C @@ -0,0 +1,13 @@ +// { dg-options -std=c++0x } + +struct A +{ + constexpr operator double() { return 1.0; } +}; + +template <int I> +struct B +{ }; + +constexpr A a { }; +B<a> b; // { dg-error "template argument|invalid type" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-throw.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-throw.C new file mode 100644 index 000000000..f1ef9dc7d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-throw.C @@ -0,0 +1,8 @@ +// { dg-options -std=c++0x } + +constexpr int may_throw(bool decide) { + return decide ? 42 : throw -1; // { dg-error "throw" } +} + +constexpr int x = may_throw(false); // { dg-message "may_throw" } +constexpr int y = may_throw(true); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-typedef1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-typedef1.C new file mode 100644 index 000000000..2719e3aea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-typedef1.C @@ -0,0 +1,11 @@ +// PR c++/50508 +// { dg-options -std=c++0x } + +template <class T> + struct integral_constant { + typedef T value_type; + constexpr operator value_type() { return true; } + }; + +static constexpr bool value = integral_constant<bool>() + && true; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-typeid.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-typeid.C new file mode 100644 index 000000000..b523bb38c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-typeid.C @@ -0,0 +1,10 @@ +// { dg-options -std=c++0x } + +#include <typeinfo> + +struct A { virtual void f(); }; + +extern constexpr const std::type_info* p1 = &typeid(int); +extern constexpr const std::type_info* p2 = &typeid(A); +// typeid-expression whose operand is of a polymorphic class type +extern constexpr const std::type_info* p3 = &typeid((A())); // { dg-error "" "" { xfail *-*-* } } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-union.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-union.C new file mode 100644 index 000000000..b4613058e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-union.C @@ -0,0 +1,16 @@ +// Test that we don't have to deal with type punning +// FIXME Mike Miller thinks it should work +// { dg-options -std=c++0x } + +union U +{ + float f; + unsigned char ca[sizeof(float)]; +}; + +constexpr U u = { 1.0 }; +constexpr float f = u.f; +constexpr unsigned char c = u.ca[0]; // { dg-error "U::ca" } + +constexpr double d = 1.0; +constexpr unsigned char c2 = (unsigned char&)d; // { dg-error "char. glvalue" } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-value.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-value.C new file mode 100644 index 000000000..85799d90b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-value.C @@ -0,0 +1,10 @@ +// { dg-options -std=c++0x } + +struct HopefullyLiteral { + HopefullyLiteral() = default; // Should be a constexpr c'tor as of 12.1/6 and 8.4.2/4 +}; + +constexpr HopefullyLiteral var1{}; // OK +constexpr HopefullyLiteral var2 = HopefullyLiteral{}; // #1 +constexpr HopefullyLiteral var3 = HopefullyLiteral(); // #2 +constexpr HopefullyLiteral var4 = HopefullyLiteral(var3); // #3 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-value2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-value2.C new file mode 100644 index 000000000..1b0e28f16 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-value2.C @@ -0,0 +1,19 @@ +// { dg-options -std=c++0x } + +template<class T> +constexpr T value_init() { return T(); } + +template<class T> +constexpr inline T bar(T x) { return x; } + +union EmptyUnion {}; +union Union1 { int i; }; +union Union3 { double d; int i; char* c; }; + +constexpr auto u1 = value_init<EmptyUnion>(); +constexpr auto u2 = value_init<Union1>(); +constexpr auto u3 = value_init<Union3>(); +constexpr auto u4 = bar(EmptyUnion{}); +constexpr auto u5 = bar(Union1{}); +constexpr auto u6 = bar(Union3{}); +constexpr auto u7 = bar(u1); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-value3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-value3.C new file mode 100644 index 000000000..38d89936e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-value3.C @@ -0,0 +1,10 @@ +// PR c++/50234 +// { dg-options -std=c++0x } + +#define SA(X) static_assert((X),#X) + +struct A { int i; }; + +constexpr int f(A a) { return a.i; } + +SA(f({}) == 0); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-variadic.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-variadic.C new file mode 100644 index 000000000..5d0ad0594 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-variadic.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } +template<class... T> +constexpr bool variadics(T&&...) { return true; } + +struct IsLiteral {}; + +constexpr bool variadic_var = variadics(0, true, 1.2, IsLiteral{}); // Error, so below + +int main() {} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-virtual.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-virtual.C new file mode 100644 index 000000000..448ecb1dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-virtual.C @@ -0,0 +1,14 @@ +// PR c++/47067 +// { dg-options -std=c++0x } + +struct X { + virtual void x(); + virtual ~X(); +}; + +struct Y { + virtual void y(); + virtual ~Y(); +}; + +struct Z: X, Y {} z; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-wstring1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-wstring1.C new file mode 100644 index 000000000..059977bff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-wstring1.C @@ -0,0 +1,34 @@ +// PR c++/48570 +// { dg-do run } +// { dg-options "-std=c++0x" } + +extern "C" void abort (); +constexpr wchar_t foo (int i) { return L"0123"[i]; } +constexpr char16_t bar (int i) { return u"0123"[i]; } +constexpr char32_t baz (int i) { return U"0123"[i]; } +const wchar_t foo0 = foo (0); +const wchar_t foo1 = foo (1); +const wchar_t foo2 = foo (2); +const wchar_t foo3 = foo (3); +const wchar_t foo4 = foo (4); +const char16_t bar0 = bar (0); +const char16_t bar1 = bar (1); +const char16_t bar2 = bar (2); +const char16_t bar3 = bar (3); +const char16_t bar4 = bar (4); +const char32_t baz0 = baz (0); +const char32_t baz1 = baz (1); +const char32_t baz2 = baz (2); +const char32_t baz3 = baz (3); +const char32_t baz4 = baz (4); + +int +main () +{ + if (foo0 != L'0' || foo1 != L'1' || foo2 != L'2' || foo3 != L'3' || foo4 != L'\0') + abort (); + if (bar0 != u'0' || bar1 != u'1' || bar2 != u'2' || bar3 != u'3' || bar4 != u'\0') + abort (); + if (baz0 != U'0' || baz1 != U'1' || baz2 != U'2' || baz3 != U'3' || baz4 != U'\0') + abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-wstring2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-wstring2.C new file mode 100644 index 000000000..4fc8980ef --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-wstring2.C @@ -0,0 +1,7 @@ +// PR c++/48570 +// { dg-do compile } +// { dg-options -std=c++0x } + +constexpr wchar_t c1 = L"hi"[3]; // { dg-error "out of bound" } +constexpr char16_t c2 = u"hi"[3]; // { dg-error "out of bound" } +constexpr char32_t c3 = U"hi"[3]; // { dg-error "out of bound" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-33837.C b/gcc/testsuite/g++.dg/cpp0x/decltype-33837.C new file mode 100644 index 000000000..2c263dd0a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-33837.C @@ -0,0 +1,7 @@ +// { dg-options -std=c++0x } +// PR c++/33837 +void foo() +{ + __decltype (A::foo()); // { dg-error "was not declared|expected" } + __decltype (B); // { dg-error "was not declared" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-33838.C b/gcc/testsuite/g++.dg/cpp0x/decltype-33838.C new file mode 100644 index 000000000..260a0d1cf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-33838.C @@ -0,0 +1,6 @@ +// { dg-options -std=c++0x } +// PR c++/33838 +template<typename T> struct A +{ + __decltype (T* foo()); // { dg-error "expected|no arguments|accept" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-38655.C b/gcc/testsuite/g++.dg/cpp0x/decltype-38655.C new file mode 100644 index 000000000..3b8455bc1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-38655.C @@ -0,0 +1,4 @@ +// PR c++/38655 +// { dg-options "" } + +__decltype(0r)* p = 1; // { dg-error "not supported|invalid" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-refbug.C b/gcc/testsuite/g++.dg/cpp0x/decltype-refbug.C new file mode 100644 index 000000000..8e3c82407 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-refbug.C @@ -0,0 +1,17 @@ +// { dg-options "-std=c++0x" } +// PR c++/33045 +int && f (); + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +static_assert(is_same<decltype(f()), int&&>::value, "decltype of rvalue reference"); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype1.C b/gcc/testsuite/g++.dg/cpp0x/decltype1.C new file mode 100644 index 000000000..d1288e07d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype1.C @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +const int& foo(); +int i; +struct A { double x; }; +const A* a = new A(); + +static_assert(is_same<decltype(foo()), const int&>::value, + "type should be const int&"); +static_assert(is_same<decltype(i), int>::value, + "type should be int"); +static_assert(is_same<decltype(a->x), double>::value, + "type should be double"); +static_assert(is_same<decltype((a->x)), const double&>::value, + "type should be const double&"); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype10.C b/gcc/testsuite/g++.dg/cpp0x/decltype10.C new file mode 100644 index 000000000..6c488998c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype10.C @@ -0,0 +1,10 @@ +// PR c++/34271 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<int> struct A +{ + static int i; +}; + +template<int N> int A<N>::i(decltype (A::i; // { dg-error "expected primary-expression before" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype11.C b/gcc/testsuite/g++.dg/cpp0x/decltype11.C new file mode 100644 index 000000000..ac32d349a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype11.C @@ -0,0 +1,12 @@ +// PR c++/35316 +// { dg-options "-std=c++0x" } + +template<int> struct A +{ + int i : 2; + + void foo() + { + decltype(i) j; + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype12.C b/gcc/testsuite/g++.dg/cpp0x/decltype12.C new file mode 100644 index 000000000..77c794bcf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype12.C @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +int&& f(const int&) {} +int&& (*fp)(const int&) = f; +int&& (&fr)(const int&) = f; + +struct X { int&& f(const int&); }; + +int&& (X::*mfp)(const int&) = &X::f; + +void g(X& xr, X* xp) +{ + int i; + static_assert(is_same<decltype(f(i)), int&&>::value, "direct call"); + static_assert(is_same<decltype(fp(i)), int&&>::value, "pointer"); + static_assert(is_same<decltype((*fp)(i)), int&&>::value, + "dereferenced pointer"); + static_assert(is_same<decltype(fr(i)), int&&>::value, + "reference"); + static_assert(is_same<decltype(xr.f(i)), int&&>::value, + "member function call"); + static_assert(is_same<decltype((xr.*mfp)(i)), int&&>::value, + "member function pointer with .*"); + static_assert(is_same<decltype((xp->*mfp)(i)), int&&>::value, + "member function pointer with ->*"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype13.C b/gcc/testsuite/g++.dg/cpp0x/decltype13.C new file mode 100644 index 000000000..8e6c6d2bf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype13.C @@ -0,0 +1,38 @@ +// PR c++/34269 +// { dg-do compile } + +void +f1 () +{ + __decltype; // { dg-error "expected" } +} + +void +f2 () +{ + __decltype (; // { dg-error "expected" } +} + +void +f3 () +{ + __decltype (); // { dg-error "expected" } +} + +void +f4 () +{ + __typeof__; // { dg-error "expected" } +} + +void +f5 () +{ + __typeof__ (; // { dg-error "expected" } +} + +void +f6 () +{ + __typeof__ (); // { dg-error "expected" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype14.C b/gcc/testsuite/g++.dg/cpp0x/decltype14.C new file mode 100644 index 000000000..9484173cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype14.C @@ -0,0 +1,17 @@ +// PR c++/37540 + +struct A +{ + int g() {return 0;} +}; + +template <typename T_> +void f(A a) +{ + __decltype(a.g()) i; +} + +int main() +{ + f<int>(A()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype15.C b/gcc/testsuite/g++.dg/cpp0x/decltype15.C new file mode 100644 index 000000000..5c2d445de --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype15.C @@ -0,0 +1,13 @@ +// PR c++/38640 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<int N> void foo (decltype (N)); +template<long int N> void foo (decltype (N)); + +void +bar (void) +{ + foo<5> (6); + foo<5L> (6L); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype16.C b/gcc/testsuite/g++.dg/cpp0x/decltype16.C new file mode 100644 index 000000000..2002458b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype16.C @@ -0,0 +1,10 @@ +// PR c++/39070 +// { dg-options "-std=c++0x" } + +template<typename X> struct junk { + template<typename Z> static Z y(); + template<typename Y> static int test(...); + template<typename Y> static char test(decltype(y<Y>())*); + static int const value=sizeof(test<X>(0)); +}; +typedef char type[junk<int>::value==sizeof(char) ? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype17.C b/gcc/testsuite/g++.dg/cpp0x/decltype17.C new file mode 100644 index 000000000..3c98105fc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype17.C @@ -0,0 +1,29 @@ +// PR c++/36628 +// { dg-options "-std=c++0x" } +// { dg-do run } + +#include <typeinfo> +#include <string.h> + +int rvalue(); +int& lvalueref(); +int&& rvalueref(); + +decltype(true ? rvalue() : rvalue()) f() +{} + +decltype(true ? lvalueref() : lvalueref()) g() +{} + +decltype(true ? rvalueref() : rvalueref()) h() +{} + +int main() +{ + if (strcmp (typeid(f).name(), "FivE") != 0) + return 1; + if (strcmp (typeid(g).name(), "FRivE") != 0) + return 2; + if (strcmp (typeid(h).name(), "FivE") != 0) + return 3; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype18.C b/gcc/testsuite/g++.dg/cpp0x/decltype18.C new file mode 100644 index 000000000..0d44586e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype18.C @@ -0,0 +1,5 @@ +// PR c++/37875 +// { dg-options "-std=c++0x" } + +template <typename> struct X {}; +X<decltype(1 > 2)> x; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype19.C b/gcc/testsuite/g++.dg/cpp0x/decltype19.C new file mode 100644 index 000000000..41d602f34 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype19.C @@ -0,0 +1,24 @@ +// PR c++/42013 + +template<typename _Tp> + _Tp +__attribute ((const)) declval(); + +template<typename _Tp, typename _Up> + struct common_type + { + typedef __decltype(true ? declval<_Tp>() : declval<_Up>()) typet; + typedef __decltype(false ? declval<_Tp>() : declval<_Up>()) typef; + }; + +template<typename, typename> struct is_same; + +template<typename _Tp> struct is_same<_Tp, _Tp> { typedef _Tp type; }; + +void f() +{ + typedef common_type<int, const int>::typet typet; + typedef common_type<int, const int>::typef typef; + + typedef is_same<typet, typef>::type type; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype2.C b/gcc/testsuite/g++.dg/cpp0x/decltype2.C new file mode 100644 index 000000000..186d75b72 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype2.C @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +#define CHECK_DECLTYPE(DECLTYPE,RESULT) \ + static_assert(is_same< DECLTYPE , RESULT >::value, #RESULT) + +struct A {}; + +int a; +int& b = a; +const int& c = a; +const int d = 5; +const A e = A(); +CHECK_DECLTYPE(decltype(a), int); +CHECK_DECLTYPE(decltype(b), int&); +CHECK_DECLTYPE(decltype(c), const int&); +CHECK_DECLTYPE(decltype(d), const int); +CHECK_DECLTYPE(decltype(e), const A); + +CHECK_DECLTYPE(decltype(a), int); +CHECK_DECLTYPE(decltype((a)), int&); + +void foo_check(int a, int& b, float& c, int* d) +{ + CHECK_DECLTYPE(decltype(a), int); + CHECK_DECLTYPE(decltype(b), int&); + CHECK_DECLTYPE(decltype(c), float&); + CHECK_DECLTYPE(decltype(d), int*); +} + +int foo(char); +int bar(char); +int bar(int); +CHECK_DECLTYPE(decltype(foo), int(char)); + +decltype(bar) z; // { dg-error "overload" } +// { dg-error "invalid type" "" { target *-*-* } 48 } + +CHECK_DECLTYPE(decltype(&foo), int(*)(char)); +CHECK_DECLTYPE(decltype(*&foo), int(&)(char)); + +void array_types() +{ + int a[10]; + CHECK_DECLTYPE(decltype(a), int[10]); +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype20.C b/gcc/testsuite/g++.dg/cpp0x/decltype20.C new file mode 100644 index 000000000..3155cdcf8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype20.C @@ -0,0 +1,10 @@ +// PR c++/42277 +// { dg-options -std=c++0x } + +struct S { int s; }; +template <int N> +void foo () +{ + S s; + decltype (s.s) i; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype22.C b/gcc/testsuite/g++.dg/cpp0x/decltype22.C new file mode 100644 index 000000000..74811cfe7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype22.C @@ -0,0 +1,13 @@ +// PR c++/42761 +// { dg-options "-std=c++0x" } + +template<typename _Tp> _Tp* fn(); + +template <class T> struct A +{ + template <class U, + class S = decltype(fn<T>())> + struct B { }; +}; + +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype23.C b/gcc/testsuite/g++.dg/cpp0x/decltype23.C new file mode 100644 index 000000000..78eb89d8e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype23.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +int x, &&y = static_cast<int &&>(x); +typedef decltype((y)) myInt; // `y' is a parenthesized id-expression of type int that is an lvalue +typedef int &myInt; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype24.C b/gcc/testsuite/g++.dg/cpp0x/decltype24.C new file mode 100644 index 000000000..16d0736d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype24.C @@ -0,0 +1,7 @@ +// PR c++/47068 +// { dg-options -std=c++0x } + +template <class T> struct broken { + int member; + typedef decltype(~ member) gcc_crashes_here; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype25.C b/gcc/testsuite/g++.dg/cpp0x/decltype25.C new file mode 100644 index 000000000..c9559f151 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype25.C @@ -0,0 +1,20 @@ +// PR c++/47851 +// { dg-options -std=c++0x } + +struct Type { + void display_type(); + void display_type() const { } +}; + +typedef Type const ConstType; + +struct ConvertibleToType { + operator Type&() { return *reinterpret_cast<Type*>(this); } +}; + +int main () +{ + // Both lines should call the const variant. + (true ? ConvertibleToType() : ConstType()).display_type(); + decltype((true ? ConvertibleToType() : ConstType()))().display_type(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype27.C b/gcc/testsuite/g++.dg/cpp0x/decltype27.C new file mode 100644 index 000000000..cb962ada5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype27.C @@ -0,0 +1,9 @@ +// PR c++/48617 +// { dg-options -std=c++0x } + +template<class T, decltype(T())> // # +struct A {}; + +A<int, 0> a; + +int main() {} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype3.C b/gcc/testsuite/g++.dg/cpp0x/decltype3.C new file mode 100644 index 000000000..aeacfae09 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype3.C @@ -0,0 +1,72 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +#define CHECK_DECLTYPE(DECLTYPE,RESULT) \ + static_assert(is_same< DECLTYPE , RESULT >::value, #DECLTYPE " should be " #RESULT) + +class A { +public: + int a; + int& b; + static int c; + + A(int& b) : b(b) { } + + void foo() { + CHECK_DECLTYPE(decltype(a), int); + CHECK_DECLTYPE(decltype(this->a), int); + CHECK_DECLTYPE(decltype((*this).a), int); + CHECK_DECLTYPE(decltype(b), int&); + CHECK_DECLTYPE(decltype(c), int); + } + void bar() const { + CHECK_DECLTYPE(decltype(a), int); + CHECK_DECLTYPE(decltype(b), int&); + CHECK_DECLTYPE(decltype(c), int); + } +}; + +int b; +A aa(b); +const A& caa = aa; +CHECK_DECLTYPE(decltype(aa.a), int); +CHECK_DECLTYPE(decltype(aa.b), int&); +CHECK_DECLTYPE(decltype(caa.a), int); + +class B { +public: + int a; + enum B_enum { b }; + decltype(a) c; + decltype(a) foo() { } + decltype(b) enums_are_in_scope() { return b; } // ok +}; + +CHECK_DECLTYPE(decltype(aa.*&A::a), int&); +decltype(aa.*&A::b) zz; // { dg-error "cannot create pointer to reference member" } +// { dg-error "invalid type" "" { target *-*-* } 58 } +CHECK_DECLTYPE(decltype(caa.*&A::a), const int&); + +class X { + void foo() { + CHECK_DECLTYPE(decltype(this), X*); + CHECK_DECLTYPE(decltype(*this), X&); + } + void bar() const { + CHECK_DECLTYPE(decltype(this), const X*); + CHECK_DECLTYPE(decltype(*this), const X&); + } +}; + diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype30.C b/gcc/testsuite/g++.dg/cpp0x/decltype30.C new file mode 100644 index 000000000..b23c9a94d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype30.C @@ -0,0 +1,17 @@ +// PR c++/49369 +// { dg-options -std=c++0x } + +template <class,class> struct assert_same; +template <class T> struct assert_same<T,T> {}; + +struct B { + int member; +}; + +struct C: B { + void method() const; +}; + +void C::method() const { + assert_same<decltype((B::member)), const int&> a; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype31.C b/gcc/testsuite/g++.dg/cpp0x/decltype31.C new file mode 100644 index 000000000..b9817eb9e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype31.C @@ -0,0 +1,13 @@ +// PR c++/49921 +// { dg-options -std=c++0x } + +struct Local +{ + void f(); +}; + +Local *l; +void (Local::*ptr)(); +decltype((l->*ptr)) i; // { dg-error "member function" } + +// { dg-prune-output "invalid type in declaration" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype35.C b/gcc/testsuite/g++.dg/cpp0x/decltype35.C new file mode 100644 index 000000000..d1fd47638 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype35.C @@ -0,0 +1,15 @@ +// PR c++/50870 +// { dg-options -std=c++0x } + +template <class V> + struct impl + { + template <class T> static T create(); + }; + +template <class T, class U, class V, class + = decltype(impl<V>::template create<T>() + -> impl<V>::template create<U>())> +struct tester { }; + +tester<impl<float>*, int, float> ti; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype36.C b/gcc/testsuite/g++.dg/cpp0x/decltype36.C new file mode 100644 index 000000000..f3dfed992 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype36.C @@ -0,0 +1,21 @@ +// PR c++/51265 +// { dg-options -std=c++0x } + +struct Funny +{ + int print(int); +}; + +template<typename X> +void c(); + +template<typename X, X ff> +void xx() +{ + c<decltype(ff)>(); +} + +int main() +{ + xx<int(Funny::*)(int), &Funny::print>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype4.C b/gcc/testsuite/g++.dg/cpp0x/decltype4.C new file mode 100644 index 000000000..cd715cb28 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype4.C @@ -0,0 +1,83 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +#define CHECK_DECLTYPE(DECLTYPE,RESULT) \ + static_assert(is_same< DECLTYPE , RESULT >::value, #DECLTYPE " should be " #RESULT) + +struct A { + int x; + int& y; + int foo(char); + int& bar() const; +}; + +CHECK_DECLTYPE(decltype(&A::x), int A::*); +decltype(&A::y) Ay; // { dg-error "cannot create pointer to reference member|invalid type" } +CHECK_DECLTYPE(decltype(&A::foo), int (A::*) (char)); +CHECK_DECLTYPE(decltype(&A::bar), int& (A::*) () const); + +CHECK_DECLTYPE(decltype("decltype"), const char(&)[9]); +CHECK_DECLTYPE(decltype(1), int); + +int an_int = 5; +int& i = an_int; +const int j = an_int; + +CHECK_DECLTYPE(decltype(i)&, int&); +CHECK_DECLTYPE(const decltype(j), const int); + +int foo(); +CHECK_DECLTYPE(decltype(foo()), int); +float& bar(int); +CHECK_DECLTYPE(decltype (bar(1)), float&); +const A bar(); +CHECK_DECLTYPE(decltype (bar()), const A); +const A& bar2(); +CHECK_DECLTYPE(decltype (bar2()), const A&); + +void wibble() { + CHECK_DECLTYPE(decltype(1+2), int); + int* p; + CHECK_DECLTYPE(decltype(*p), int&); + int a[10]; + CHECK_DECLTYPE(decltype(a[3]), int&); + int i; int& j = i; + CHECK_DECLTYPE(decltype (i = 5), int&); + CHECK_DECLTYPE(decltype (j = 5), int&); + + CHECK_DECLTYPE(decltype (++i), int&); + CHECK_DECLTYPE(decltype (i++), int); +} + +struct B { + B () : bit(), cbit() {} + int bit : 2; + const int cbit : 3; + + void foo() + { + CHECK_DECLTYPE(decltype(bit), int); + CHECK_DECLTYPE(decltype((bit)), int&); + CHECK_DECLTYPE(decltype(cbit), const int); + CHECK_DECLTYPE(decltype((cbit)), const int&); + } +}; + +B b; +const B& bc = b; +CHECK_DECLTYPE(decltype(b.bit), int); +CHECK_DECLTYPE(decltype(bc.bit), int); +CHECK_DECLTYPE(decltype((b.bit)), int&); +CHECK_DECLTYPE(decltype((bc.bit)), const int&); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype5.C b/gcc/testsuite/g++.dg/cpp0x/decltype5.C new file mode 100644 index 000000000..139153987 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype5.C @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +#define CHECK_DECLTYPE(DECLTYPE,RESULT) \ + static_assert(is_same< DECLTYPE , RESULT >::value, #RESULT) + +template<typename F> F create_a(); + +template<typename F, typename T1> +decltype(create_a<F&>()(create_a<const T1&>())) forward(F f, const T1& a1) +{ + return f(a1); +} + +struct identity { + template<typename T> + const T& operator()(const T& x) { return x; } +}; + + +identity id; +int i; +float f; + +CHECK_DECLTYPE(decltype(forward(id, i)), const int&); +CHECK_DECLTYPE(decltype(forward(id, f)), const float&); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype6.C b/gcc/testsuite/g++.dg/cpp0x/decltype6.C new file mode 100644 index 000000000..7aa8e1505 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype6.C @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +template<typename T> const T& foo(); + + +int i; + +template<typename T> +struct A +{ + double x; +}; + +const A<double>* a = new A<double>(); + +static_assert(is_same<decltype(foo<int>()), const int&>::value, + "type should be const int&"); +static_assert(is_same<decltype(i), int>::value, + "type should be int"); +static_assert(is_same<decltype(a->x), double>::value, + "type should be double"); +static_assert(is_same<decltype((a->x)), const double&>::value, + "type should be const double&"); diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype7.C b/gcc/testsuite/g++.dg/cpp0x/decltype7.C new file mode 100644 index 000000000..f757c9e10 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype7.C @@ -0,0 +1,14 @@ +// PR c++/34268 +// { dg-do compile } + +struct A +{ + __decltype (A); // { dg-error "must be an expression" } + __decltype (~A); // { dg-error "must be an expression" } +}; + +struct B +{ + __typeof__ (B); + __typeof__ (~B); // { dg-error "expected primary-expression" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype8.C b/gcc/testsuite/g++.dg/cpp0x/decltype8.C new file mode 100644 index 000000000..368068926 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype8.C @@ -0,0 +1,12 @@ +// PR c++/34267 +// { dg-do compile } + +struct A {}; +__decltype (A); // { dg-error "must be an expression" } +template<int> struct B +{ + __decltype (A); // { dg-error "must be an expression" } + __decltype (~A); // { dg-error "must be an expression" } + __decltype (B); // { dg-error "must be an expression" } + __decltype (~B); // { dg-error "must be an expression" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype9.C b/gcc/testsuite/g++.dg/cpp0x/decltype9.C new file mode 100644 index 000000000..4cd150ea6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype9.C @@ -0,0 +1,10 @@ +// PR c++/34271 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<int> struct A +{ + static int i; +}; + +template<int N> int A<N>::i(decltype (A::i)); // { dg-error "member function|must be an expression" } diff --git a/gcc/testsuite/g++.dg/cpp0x/deduce.C b/gcc/testsuite/g++.dg/cpp0x/deduce.C new file mode 100644 index 000000000..635228cca --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/deduce.C @@ -0,0 +1,36 @@ +// { dg-options "--std=c++0x" } +template<typename T, typename U> struct same_type; +template<typename T> struct same_type<T, T> {}; + +int lval_int; +int rval_int(); +int const lval_const_int=0; +int const&& rval_const_int(); + +template <typename T> void deduce_lval_int(T && t) +{ + same_type<T, int &>(); +} + +template <typename T> void deduce_rval_int(T && t) +{ + same_type<T, int>(); +} + +template <typename T> void deduce_lval_const_int(T && t) +{ + same_type<T, const int &>(); +} + +template <typename T> void deduce_rval_const_int(T && t) +{ + same_type<T, const int>(); +} + +void f() +{ + deduce_lval_int(lval_int); + deduce_rval_int(rval_int()); + deduce_lval_const_int(lval_const_int); + deduce_rval_const_int(rval_const_int()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted1.C b/gcc/testsuite/g++.dg/cpp0x/defaulted1.C new file mode 100644 index 000000000..e8fe37eb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted1.C @@ -0,0 +1,43 @@ +// Positive test for defaulted/deleted fns +// { dg-do run } +// { dg-options "-std=c++0x" } + +struct A +{ + int i; + A() = default; + A(const A&) = delete; + A& operator=(const A&) = default; + ~A(); +}; + +A::~A() = default; + +void f() = delete; + +struct B +{ + int i; + B() = default; +}; + +int main() +{ + A a1, a2; + B b = {1}; + a1 = a2; +} + +// fns defaulted in class defn are trivial +struct C +{ + C() = default; + C(const C&) = default; + C& operator=(const C&) = default; + ~C() = default; +}; + +union U +{ + C c; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted10.C b/gcc/testsuite/g++.dg/cpp0x/defaulted10.C new file mode 100644 index 000000000..64fa5f019 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted10.C @@ -0,0 +1,14 @@ +// PR c++/40381 +// { dg-options "-std=gnu++0x" } + +struct A +{ + template<typename T> void foo(T) = delete; // { dg-error "previously|declared" } +}; + +template<typename T> void A::foo(T) {} // { dg-error "redefinition" } + +void bar() +{ + A().foo(0); // { dg-error "use" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted11.C b/gcc/testsuite/g++.dg/cpp0x/defaulted11.C new file mode 100644 index 000000000..b9bed7e00 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted11.C @@ -0,0 +1,15 @@ +// Core issue 901 +// { dg-options "-std=c++0x" } + +struct A +{ + A(); ~A(); + void operator delete (void *) = delete; + void operator delete[] (void *) = delete; +}; + +int main() +{ + A* ap = new A; + ap = new A[2]; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted13.C b/gcc/testsuite/g++.dg/cpp0x/defaulted13.C new file mode 100644 index 000000000..8b2357921 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted13.C @@ -0,0 +1,29 @@ +// { dg-options -std=c++0x } + +template<typename T> +struct NonCopyable { + NonCopyable() = default; + NonCopyable(NonCopyable const&); +}; + +template<> +NonCopyable<int>::NonCopyable(NonCopyable<int> const&) = delete; // { dg-error "declared" } + +template<typename T> +NonCopyable<T>::NonCopyable(NonCopyable<T> const&) = default; + +template<> +NonCopyable<double>::NonCopyable(NonCopyable<double> const&) = delete; // { dg-error "declared" } + + +int main() +{ + NonCopyable<double> nc_dbl; + NonCopyable<double> nc_dbl_cpy(nc_dbl); // { dg-error "use" } + + NonCopyable<int> nc_int; + NonCopyable<int> nc_int_cpy(nc_int); // { dg-error "use" } + + NonCopyable<char> nc_char; + NonCopyable<char> nc_char_cpy(nc_char); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted14.C b/gcc/testsuite/g++.dg/cpp0x/defaulted14.C new file mode 100644 index 000000000..e476d576c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted14.C @@ -0,0 +1,20 @@ +// PR c++/39866 +// { dg-options "-std=c++0x" } + +struct A { + A& operator=(const A&) = delete; // { dg-bogus "" } + + void operator=(int) {} // { dg-message "" } + void operator=(char) {} // { dg-message "" } +}; + +struct B {}; + +int main() +{ + A a; + a = B(); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } + a = 1.0; // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 18 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted15.C b/gcc/testsuite/g++.dg/cpp0x/defaulted15.C new file mode 100644 index 000000000..4c5b11c9e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted15.C @@ -0,0 +1,58 @@ +// PR c++/38796 +// { dg-options -std=c++0x } + +#define SA(X) static_assert ((X), #X) + +struct A +{ + A (int); + A (const A& = 1) = default; // { dg-error "default argument" } + void operator= (const A&) = default; // { dg-error "defaulted|match" } +}; + +struct B +{ +private: + B() = default; +}; + +SA(__has_trivial_constructor(B)); + +struct C +{ +protected: + ~C() = default; +}; + +SA(__has_trivial_destructor(C)); + +struct D +{ +private: + D& operator= (const D&) = default; +}; + +SA(__has_trivial_assign(D)); + +struct E +{ + explicit E (const E&) = default; +}; + +SA(__has_trivial_copy(E)); + +struct F +{ + F(F&) = default; // { dg-error "non-const" } +}; + +struct G: public F +{ + // Can't be const because F copy ctor isn't. + G(const G&) = default; // { dg-error "const" } +}; + +struct H +{ + virtual ~H() = default; // { dg-error "declared virtual" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted16.C b/gcc/testsuite/g++.dg/cpp0x/defaulted16.C new file mode 100644 index 000000000..741b43de2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted16.C @@ -0,0 +1,13 @@ +// Test that non-inline default causes the function to be defined even if +// it isn't used. + +// { dg-options -std=c++0x } +// { dg-final { scan-assembler "_ZN1AC1Ev" } } + +struct A +{ + A(); +}; + +A::A() = default; + diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted17.C b/gcc/testsuite/g++.dg/cpp0x/defaulted17.C new file mode 100644 index 000000000..79e91a0eb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted17.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } + +struct A // { dg-error "const|operator=" } +{ + const int i; +}; + +int main() +{ + A a = { 0 }; + a = a; // { dg-error "deleted" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted18.C b/gcc/testsuite/g++.dg/cpp0x/defaulted18.C new file mode 100644 index 000000000..559dfde48 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted18.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++0x" } + +void f(char i, int j) = delete; // { dg-message "<deleted>" } +void f(int i, ...); // { dg-message "void f" } + +int main() +{ + f(1,1); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 8 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted19.C b/gcc/testsuite/g++.dg/cpp0x/defaulted19.C new file mode 100644 index 000000000..ea33df398 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted19.C @@ -0,0 +1,21 @@ +// We allocate a cookie to help us run the destructor even if it's deleted. +// { dg-options -std=c++0x } +// { dg-do run } + +struct A +{ + ~A() = delete; +}; + +void *p = 0; +void *operator new[](__SIZE_TYPE__ t) +{ + p = ::operator new (t); + return p; +} + +int main() +{ + A* ap = new A[5]; + return ap == p; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted2.C b/gcc/testsuite/g++.dg/cpp0x/defaulted2.C new file mode 100644 index 000000000..e3aac8f1a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted2.C @@ -0,0 +1,69 @@ +// Negative test for defaulted/deleted fns. +// { dg-options "-std=c++0x" } + +void f(); // { dg-error "previous" } +void f() = delete; // { dg-error "deleted" } + +struct A +{ + A() { } // { dg-error "previous" } + void f() = default; // { dg-error "default" } +}; + +A::A() = default; // { dg-error "redefinition" } + +void g() {} // { dg-error "previous" } +void g() = delete; // { dg-error "redefinition" } + +struct B // { dg-message "user-provided default constructor" } +{ + int i; + B() = default; // { dg-message "not user-provided" } +}; + +const B b; // { dg-error "uninitialized const" } + +struct C +{ + virtual void f() = delete; // { dg-error "overriding deleted" } +}; + +struct D: public C +{ + virtual void f(); // { dg-error "non-deleted function" } +}; + +struct E +{ + const B b; + E() { } // { dg-error "uninitialized" } +}; + +struct F +{ + F() = default; + F(const F&) = delete; // { dg-error "declared" } +}; + +struct G +{ + G(); +}; + +// ctor defaulted after class defn is not trivial +G::G() = default; + +union U +{ + G g; // { dg-error "union member.*non-trivial" } +}; + +int main() +{ + F f; + F f2(f); // { dg-error "use" } + B* b = new const B; // { dg-error "uninitialized const" } + U u; // { dg-error "deleted" } +} + +// { dg-prune-output "implicitly deleted because" } diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted20.C b/gcc/testsuite/g++.dg/cpp0x/defaulted20.C new file mode 100644 index 000000000..5d536a97e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted20.C @@ -0,0 +1,20 @@ +// PR c++/46497 +// { dg-options -std=c++0x } + +struct A { + A(A&&) = default; // { dg-message "A::A|no known conversion" } +}; +struct B { + const A a; + B(const B&) = default; + B(B&&) = default; // { dg-error "implicitly deleted|no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 10 } +}; + +void g(B); // { dg-error "argument 1" } +B&& f(); + +int main() +{ + g(f()); // { dg-error "deleted" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted21.C b/gcc/testsuite/g++.dg/cpp0x/defaulted21.C new file mode 100644 index 000000000..3e740331d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted21.C @@ -0,0 +1,20 @@ +// PR c++/46736 +// { dg-options -std=c++0x } + +struct U { + U(); + U(U const&); +}; + +struct X { + U const u; + X(); + X(X&&); +}; + +X::X(X&&)=default; // { dg-error "implicitly deleted" } +// { dg-error "does not have a move constructor" "" { target *-*-* } 15 } + +X f() { + return X(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted24.C b/gcc/testsuite/g++.dg/cpp0x/defaulted24.C new file mode 100644 index 000000000..307bf94ab --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted24.C @@ -0,0 +1,6 @@ +// PR c++/48280 +// { dg-options -std=c++0x } + +struct S { + template < typename > S (const S &) = default; // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted26.C b/gcc/testsuite/g++.dg/cpp0x/defaulted26.C new file mode 100644 index 000000000..69bd0accb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted26.C @@ -0,0 +1,7 @@ +// PR c++/49066 +// { dg-options -std=c++0x } + +void foo() = delete; // { dg-error "declared here" } +void foo(); + +int main() { foo(); } // { dg-error "deleted" } diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted27.C b/gcc/testsuite/g++.dg/cpp0x/defaulted27.C new file mode 100644 index 000000000..7d9139d23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted27.C @@ -0,0 +1,19 @@ +// PR c++/47544 +// { dg-options -std=c++0x } +// { dg-final { scan-assembler "_ZN1sIiEC2Ev" } } +// { dg-final { scan-assembler-not "_ZN1sIiED2Ev" } } + +template <typename T> +struct s { + s(); + ~s() = default; +}; + +extern template struct s<int>; + +template <typename T> +s<T>::s() = default; + +template struct s<int>; + +s<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted29.C b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C new file mode 100644 index 000000000..5fcf5b0c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted29.C @@ -0,0 +1,20 @@ +// PR c++/46696 +// { dg-options -std=c++0x } + +struct A +{ + A& operator= (A const&); +}; + +struct B +{ + A ar[1]; + B& operator= (B const&) = default; +}; + +int main() +{ + B x; + B y; + y = x; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted3.C b/gcc/testsuite/g++.dg/cpp0x/defaulted3.C new file mode 100644 index 000000000..5e2116b53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted3.C @@ -0,0 +1,16 @@ +// PR c++/37006 +// { dg-options "-std=c++0x" } + +template<class T> +struct A { + template<class U> + bool operator==(const A<U>&) = delete; // { dg-error "declared" } + operator bool () { return true; } +}; + +int main() +{ + A<int> a1; + A<void> a2; + if(a1 == a2) {} // { dg-error "use" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted30.C b/gcc/testsuite/g++.dg/cpp0x/defaulted30.C new file mode 100644 index 000000000..0bf4425b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted30.C @@ -0,0 +1,16 @@ +// PR c++/49507 +// { dg-options -std=c++0x } + +template<typename T> +struct ConcretePoolKey +{ + virtual ~ConcretePoolKey(); +}; + +template<typename T> +ConcretePoolKey<T>::~ConcretePoolKey() = default; + +int main() +{ + ConcretePoolKey<int> foo; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted32.C b/gcc/testsuite/g++.dg/cpp0x/defaulted32.C new file mode 100644 index 000000000..351cdae11 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted32.C @@ -0,0 +1,21 @@ +// PR c++/50531 +// { dg-options -std=c++0x } + +template <typename T> +class DataFilter +{ + public: + inline virtual ~DataFilter(); +}; + +template<typename T> +inline DataFilter<T>::~DataFilter() = default; + +class ARCalculator : public DataFilter<ARCalculator> +{ + public: + virtual void dataStart(int, int); +}; + +void ARCalculator::dataStart(int, int) +{} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted4.C b/gcc/testsuite/g++.dg/cpp0x/defaulted4.C new file mode 100644 index 000000000..56053840b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted4.C @@ -0,0 +1,26 @@ +// PR c++/37208: SFINAE and deleted functions. + +// { dg-options "-std=c++0x" } +// { dg-do compile } +template<int> struct A { }; + +template<typename T> +int& int_if_addable(A<sizeof((*(T*)0) + (*(T*)0))>*); + +template<typename T> +float& int_if_addable(...); + +struct X { }; + +struct Y { }; +Y operator+(Y, Y); + +struct Z { }; +Z operator+(Z, Z) = delete; + +void f() +{ + float& x = int_if_addable<X>(0); + int& y = int_if_addable<Y>(0); + float& z = int_if_addable<Z>(0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted5.C b/gcc/testsuite/g++.dg/cpp0x/defaulted5.C new file mode 100644 index 000000000..b7bd16b40 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted5.C @@ -0,0 +1,20 @@ +// PR c++/37234 +// { dg-do link } +// { dg-options "-std=c++0x" } + +template <typename T> +class foo { + public: + foo() =default; + ~foo(); +}; + +template <typename T> +foo<T>::~foo() =default; + +int main() { + + foo<int> fi; + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted6.C b/gcc/testsuite/g++.dg/cpp0x/defaulted6.C new file mode 100644 index 000000000..c33d57292 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted6.C @@ -0,0 +1,13 @@ +// PR c++/37906 +// { dg-options "-std=c++0x" } + +struct b +{ + b() = default; + b(const b&) = delete; +}; + +void test01() +{ + static_assert(__has_trivial_constructor(b), "default ctor not trivial"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted7.C b/gcc/testsuite/g++.dg/cpp0x/defaulted7.C new file mode 100644 index 000000000..97c29258e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted7.C @@ -0,0 +1,12 @@ +// PR c++/38701, 38702 +// { dg-options "-std=c++0x" } + +void foo() = default; // { dg-error "cannot be defaulted" } +namespace +{ + void bar() = default; // { dg-error "cannot be defaulted" } +} + +enum E { e }; + +E& operator |= (E&, const E&) = default; // { dg-error "cannot be defaulted" } diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted8.C b/gcc/testsuite/g++.dg/cpp0x/defaulted8.C new file mode 100644 index 000000000..f446f8156 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted8.C @@ -0,0 +1,8 @@ +// PR c++/38649 +// { dg-options "-std=c++0x" } + +struct A +{ + A(...) = default; // { dg-error "cannot be defaulted" } + A(const A&, ...) = default; // { dg-error "cannot be defaulted" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted9.C b/gcc/testsuite/g++.dg/cpp0x/defaulted9.C new file mode 100644 index 000000000..1e5e2cbf9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted9.C @@ -0,0 +1,20 @@ +// PR c++/39153 +// { dg-options "-std=c++0x -fno-inline" } + +struct _Impl_base +{ + _Impl_base() = default; + virtual ~_Impl_base(); +}; + +inline _Impl_base::~_Impl_base() = default; + +template<typename _Tp> +class _Impl : public _Impl_base +{ }; + +int main() +{ + _Impl<int> i; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/dependent1.C b/gcc/testsuite/g++.dg/cpp0x/dependent1.C new file mode 100644 index 000000000..1ceeeafd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/dependent1.C @@ -0,0 +1,25 @@ +// PR c++/48319 +// { dg-options -std=c++0x } +// We were failing to recognize declval<_Args1> as dependent. + +template<typename Tp> Tp declval() noexcept; + +template<typename _Tp> +class __is_constructible_helper +{ + typedef char __one; + typedef struct { char __arr[2]; } __two; + + template<typename _Tp1, typename... _Args1> + static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int); + + template<typename, typename...> + static __two __test(...); + +public: + static const bool __value = sizeof(__test<_Tp>(0)) == 1; +}; + +int main() { + return __is_constructible_helper<int>::__value; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/elision.C b/gcc/testsuite/g++.dg/cpp0x/elision.C new file mode 100644 index 000000000..35d5e4b02 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/elision.C @@ -0,0 +1,76 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test: Implicit cast to rvalue when eliding copy + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; + +class move_only +{ + move_only(const move_only&); + move_only& operator=(const move_only&); +public: + move_only() {} + move_only(move_only&&) {} + move_only& operator=(move_only&&) {return *this;} +}; + +move_only +test1() +{ + return move_only(); +} + +move_only +test2() +{ + move_only x; + return x; +} + +move_only +test3(bool b) +{ + move_only x1; + if (b) + { + move_only x2; + return x2; + } + return x1; +} + +void +test4(bool b) +{ + if (!b) + throw move_only(); +} + +void +test5(bool b) +{ + move_only x; + if (!b) + throw x; +} + +extern bool b; + +int main() +{ + move_only t1 = test1(); + move_only t2 = test2(); + move_only t3 = test3(b); + test4(b); + test5(b); + return 0; +} + +bool b = true; diff --git a/gcc/testsuite/g++.dg/cpp0x/elision2.C b/gcc/testsuite/g++.dg/cpp0x/elision2.C new file mode 100644 index 000000000..216b1b59d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/elision2.C @@ -0,0 +1,13 @@ +// Core 1148: should be able to move from value parameter on return +// { dg-options -std=c++0x } + +struct A +{ + A(const A&) = delete; + A(A&&); +}; + +A f (A a) +{ + return a; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/elision_neg.C b/gcc/testsuite/g++.dg/cpp0x/elision_neg.C new file mode 100644 index 000000000..78feac72a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/elision_neg.C @@ -0,0 +1,44 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test: Implicit cast to rvalue when eliding copy + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; + +class move_only +{ + move_only(const move_only&); // { dg-error "is private" } + move_only& operator=(const move_only&); +public: + move_only() {} + move_only(move_only&&) {} + move_only& operator=(move_only&&) {return *this;} +}; + +move_only +test1() +{ + static move_only x; + return x; // { dg-error "within this context" } +} + +move_only +test2(move_only&& x) +{ + return x; // { dg-error "within this context" } +} + +int main() +{ + move_only t1 = test1(); + move_only t2 = test2(move_only()); + return 0; +} + +bool b = true; diff --git a/gcc/testsuite/g++.dg/cpp0x/elision_weak.C b/gcc/testsuite/g++.dg/cpp0x/elision_weak.C new file mode 100644 index 000000000..e8ba7551d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/elision_weak.C @@ -0,0 +1,19 @@ +// { dg-do compile } + +struct S +{ + S() {} + S(S&) {} +}; + +S f() +{ + S s; + return s; +} + +void g() +{ + S s; + throw s; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum1.C b/gcc/testsuite/g++.dg/cpp0x/enum1.C new file mode 100644 index 000000000..fb03692fa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum1.C @@ -0,0 +1,6 @@ +// PR c++/38021 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +enum : { }; // { dg-error "expected" } +enum : 3 { }; // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum10.C b/gcc/testsuite/g++.dg/cpp0x/enum10.C new file mode 100644 index 000000000..55a1ab46b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum10.C @@ -0,0 +1,9 @@ +// PR c++/48534 +// { dg-options -std=c++0x } + +enum class OpSE : bool; + +int main() +{ + return static_cast<bool>(OpSE()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum13.C b/gcc/testsuite/g++.dg/cpp0x/enum13.C new file mode 100644 index 000000000..ec02d3bf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum13.C @@ -0,0 +1,20 @@ +// PR c++/48780 +// { dg-options "-std=c++0x -fabi-version=5 -Wabi" } + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +enum struct A : short { X }; + +void foo(int x, ...) { + va_list vl; + __builtin_va_start(vl, x); + enum A t = __builtin_va_arg(vl, enum A); // { dg-warning "promote" } + __builtin_va_end(vl); +} + +int main() { + foo(0, A::X); // { dg-warning "will not promote" } +} + +// { dg-prune-output "note" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum15.C b/gcc/testsuite/g++.dg/cpp0x/enum15.C new file mode 100644 index 000000000..d65321649 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum15.C @@ -0,0 +1,20 @@ +// PR c++/44311 +// { dg-options -std=c++0x } + +enum class A { Val0, Val1 }; + +void foo (A a, int i) +{ + switch (a) + { + case A::Val0: break; + case 1: break; // { dg-error "" } + } + + switch (i) + { + case A::Val0: break; // { dg-error "" } + case 1: break; + case 2.0: break; + } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum16.C b/gcc/testsuite/g++.dg/cpp0x/enum16.C new file mode 100644 index 000000000..ebb48688b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum16.C @@ -0,0 +1,6 @@ +// PR c++/48935 +// { dg-options -std=c++0x } + +enum class ENUM { a }; + +ENUM::Type func() { return ENUM::a; } // { dg-error "does not name a type" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum18.C b/gcc/testsuite/g++.dg/cpp0x/enum18.C new file mode 100644 index 000000000..5575ca6ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum18.C @@ -0,0 +1,8 @@ +// PR c++/47277 +// { dg-options -std=c++0x } + +int main(void) { + enum e {}; + e ev; + ev.e::~e_u(); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum19.C b/gcc/testsuite/g++.dg/cpp0x/enum19.C new file mode 100644 index 000000000..acdd86c0b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum19.C @@ -0,0 +1,12 @@ +// We shouldn't give an ABI warning about promotion in switch. +// { dg-options "-std=c++0x -fabi-version=5 -Wabi" } + +enum class Foo { X }; +void test(Foo val) +{ + switch(val) + { + case Foo::X: + break; + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/enum2.C b/gcc/testsuite/g++.dg/cpp0x/enum2.C new file mode 100644 index 000000000..21c265a92 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum2.C @@ -0,0 +1,5 @@ +// PR c++/38637 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<int> enum E : int { e }; // { dg-error "declaration|expected" } diff --git a/gcc/testsuite/g++.dg/cpp0x/enum3.C b/gcc/testsuite/g++.dg/cpp0x/enum3.C new file mode 100644 index 000000000..5ae5e1a9d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum3.C @@ -0,0 +1,27 @@ +// PR c++/38064 +// { dg-options "-std=c++0x" } +// { dg-do run } + +enum class E { elem }; + +template <class T> +void f (T t); + +bool f (bool b) { return b; } + +int main() +{ + E e = E::elem; + if (!f (e == E::elem)) + return 1; + if (!f (e <= E::elem)) + return 1; + if (!f (e >= E::elem)) + return 1; + if (f (e < E::elem)) + return 1; + if (f (e > E::elem)) + return 1; + if (f (e != E::elem)) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum4.C b/gcc/testsuite/g++.dg/cpp0x/enum4.C new file mode 100644 index 000000000..002edf092 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum4.C @@ -0,0 +1,8 @@ +// PR c++/40633 +// { dg-options "-std=c++0x" } + +template< typename T > +struct wrap { + enum class E { val }; +}; + diff --git a/gcc/testsuite/g++.dg/cpp0x/enum5.C b/gcc/testsuite/g++.dg/cpp0x/enum5.C new file mode 100644 index 000000000..c4ceebed7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum5.C @@ -0,0 +1,20 @@ +// PR c++/40639 +// { dg-options "-std=c++0x" } + +template< typename T > +struct wrap { + enum E : T { val }; +}; + +template< typename T > +struct dependant { + enum E : typename T::type { val }; +}; + +template<typename T> +struct identity { + typedef T type; +}; + +wrap<int> x; +dependant<identity<int>> y; diff --git a/gcc/testsuite/g++.dg/cpp0x/enum6.C b/gcc/testsuite/g++.dg/cpp0x/enum6.C new file mode 100644 index 000000000..e06398471 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum6.C @@ -0,0 +1,15 @@ +// PR c++/37946 +// { dg-options "-std=c++0x" } + +enum class E : char +{ + e1, + e2 +}; + +inline E operator| (E a1, E a2) +{ + char ret = static_cast<char> (a1) + | static_cast<char> (a2); + return static_cast<E>(ret); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum7.C b/gcc/testsuite/g++.dg/cpp0x/enum7.C new file mode 100644 index 000000000..407672a47 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum7.C @@ -0,0 +1,11 @@ +// PR c++/37816 +// { dg-options "-std=c++0x" } + +class A +{ + enum class Color { Red, Orange, Yellow, Green, Blue, Violet }; + enum class Alert { Green, Yellow, Red }; + static const Color x = Red; // { dg-error "" } + static const Color y = Color::Red; + static const Alert z = Alert::Red; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/enum8.C b/gcc/testsuite/g++.dg/cpp0x/enum8.C new file mode 100644 index 000000000..0075e2daa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum8.C @@ -0,0 +1,10 @@ +// PR c++/47704 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +void +foo () +{ + enum class E { A, B }; + new E; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum9.C b/gcc/testsuite/g++.dg/cpp0x/enum9.C new file mode 100644 index 000000000..10e510bcd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum9.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +enum class E { }; +E f(); +bool b2 = static_cast<bool>(f()); diff --git a/gcc/testsuite/g++.dg/cpp0x/enum_base.C b/gcc/testsuite/g++.dg/cpp0x/enum_base.C new file mode 100644 index 000000000..5607961f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum_base.C @@ -0,0 +1,25 @@ +// { dg-options "-std=c++0x" } + +typedef unsigned volatile long long uvlonglong; + +enum E1 : char { }; +enum E2 : signed const short { }; +enum E3 : uvlonglong { }; +enum E4 : char { + val = 500 // { dg-error "too large" } +}; + +enum class E5 { + val = (unsigned long long)-1 // { dg-error "too large" } +}; + +typedef float Float; + +enum class E6 : Float { }; // { dg-error "must be an integral type" } + +static_assert (sizeof(E1) == sizeof(char), "char-sized enum"); +static_assert (sizeof(E2) == sizeof(signed short), "short-sized enum"); +static_assert (sizeof(E3) == sizeof(unsigned long long), + "long long-sized enum"); +static_assert (sizeof(E4) == sizeof(char), "char-sized enum"); +static_assert (sizeof(E5) == sizeof(int), "scoped enum with int size"); diff --git a/gcc/testsuite/g++.dg/cpp0x/enum_base_warn.C b/gcc/testsuite/g++.dg/cpp0x/enum_base_warn.C new file mode 100644 index 000000000..4b14cf65e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum_base_warn.C @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-O2 -Wtype-limits -std=c++0x" } +extern void link_error (void); + +enum Alpha : unsigned char { + ZERO = 0, ONE, TWO, THREE +}; + +Alpha a2; + +int m1 = -1; +int GetM1() { + return m1; +} + +int main() { + a2 = static_cast<Alpha>(GetM1()); + if (a2 == -1) { // { dg-warning "always false due" } + link_error (); + } + if (-1 == a2) { // { dg-warning "always false due" } + link_error (); + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/error1.C b/gcc/testsuite/g++.dg/cpp0x/error1.C new file mode 100644 index 000000000..751b3b75e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/error1.C @@ -0,0 +1,11 @@ +// PR c++/34395 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<int... N> void foo (int... x[N]) // { dg-error "int \\\[N\\\]\\.\\.\\. x" } +{ + struct A + { + A () { x; } // { dg-error "use of parameter from containing function" } + }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/error2.C b/gcc/testsuite/g++.dg/cpp0x/error2.C new file mode 100644 index 000000000..ca681eb2f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/error2.C @@ -0,0 +1,9 @@ +// PR c++/38656 +// { dg-options "-std=c++0x" } + +template<int> int foo(); + +template<typename F> void bar(F f) +{ + f((foo<0>()=0)...); // { dg-error "pattern '\\(foo\\<0\\>\\)\\(\\)=0'" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/error3.C b/gcc/testsuite/g++.dg/cpp0x/error3.C new file mode 100644 index 000000000..e7da96195 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/error3.C @@ -0,0 +1,24 @@ +// PR c++/47336 +// { dg-options -std=c++0x } + +template <typename T> +void g(T t) +{ + t+1; // { dg-error "no match" } +} + +template <typename S> +class C +{ + struct D {} d; +public: + decltype(g(d)) h() + { + return g(d); + } +}; + +int main() +{ + C<int>().h(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/error4.C b/gcc/testsuite/g++.dg/cpp0x/error4.C new file mode 100644 index 000000000..29a1cddab --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/error4.C @@ -0,0 +1,22 @@ +// PR c++/49156 +// { dg-options -std=c++0x } + +template<typename T> T declval(); + +template<typename T> +struct S { + + template<typename U> + static U get(const volatile T&); + + template<typename U> + static decltype(*declval<U>()) get(...); + + typedef decltype(get<T>(declval<T>())) type; // { dg-error "no match" } +}; + +struct X { }; + +S<X>::type x; + +// { dg-prune-output "note" } diff --git a/gcc/testsuite/g++.dg/cpp0x/error6.C b/gcc/testsuite/g++.dg/cpp0x/error6.C new file mode 100644 index 000000000..35156520b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/error6.C @@ -0,0 +1,8 @@ +// PR c++/48284 +// { dg-options -std=c++0x } + +template<typename C> +auto g(C& c) -> decltype (c.f()) { return c.f(); } // { dg-error "decltype .c\\.f" } + +template<typename C> +auto g(C& c) -> decltype (c.f()) { return c.f(); } // { dg-error "decltype .c\\.f" } diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit1.C b/gcc/testsuite/g++.dg/cpp0x/explicit1.C new file mode 100644 index 000000000..fe164fc8c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit1.C @@ -0,0 +1,58 @@ +// Test for explicit conversion ops from N2437. +// { dg-options "-std=c++0x" } + +class U; class V; +class T +{ +public: + T( U const & ); + //implicit converting ctor + explicit T( V const & ); + // explicit ctor +}; +class U +{ +}; +class V +{ +}; +class W +{ +public: + operator T() const; +}; +class X +{ +public: + explicit operator T() const; // theoretical +}; +int main() +{ + U u; V v; W w; X x; + // Direct initialization: + T t1( u ); + T t2( v ); + T t3( w ); + T t4( x ); + // Copy initialization: + T t5 = u; + T t6 = v; // { dg-error "" } + T t7 = w; + T t8 = x; // { dg-error "" } + // Cast notation: + T t9 = (T) u; + T t10 = (T) v; + T t11 = (T) w; + T t12 = (T) x; + // Static cast: + T t13 = static_cast<T>( u ); + T t14 = static_cast<T>( v ); + T t15 = static_cast<T>( w ); + T t16 = static_cast<T>( x ); + // Function-style cast: + T t17 = T( u ); + T t18 = T( v ); + T t19 = T( w ); + T t20 = T( x ); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit2.C b/gcc/testsuite/g++.dg/cpp0x/explicit2.C new file mode 100644 index 000000000..c2327c140 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit2.C @@ -0,0 +1,29 @@ +// Test for explicit conversion ops in various conversion situations. +// { dg-options "-std=c++0x" } + +typedef void (*pfn)(); + +struct A +{ + explicit operator int() const; + explicit operator pfn() const; +}; + +int main() +{ + A a; + int i = a; // { dg-error "" } + const int &ir = a; // { dg-error "" } + a(); // { dg-error "" } + a + 1; // { dg-message "" } (error and note on same line) + + int j (a); + (int)a; + static_cast<int>(a); +} + +struct B +{ + int i; + B(const A& a): i(a) { } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit3.C b/gcc/testsuite/g++.dg/cpp0x/explicit3.C new file mode 100644 index 000000000..be0a14e7a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit3.C @@ -0,0 +1,51 @@ +// Test for "contextually converted to bool" +// { dg-options "-std=c++0x" } + +struct A +{ + explicit operator bool(); +}; + +void f (bool); + +struct B +{ + bool b; +}; + +struct C +{ + operator int(); +}; + +struct D +{ + operator int(); +}; + +int main() +{ + A a; C c; D d; + // These contexts use an explicit bool conversion. + if (a) {} + for (; a; ) {} + do {} while (a); + while (a) {} + a ? 1 : 0; + a || true; + a && true; + !a; + + a ? c : 1; + a ? c : d; + + // These do not. + switch (a); // { dg-error "" } + bool b = a; // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 44 } + f(a); // { dg-error "" } + B b2 = { a }; // { dg-error "" } + a + true; // { dg-message "" } + b ? a : true; // { dg-message "" } + a ? a : true; // { dg-message "" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit4.C b/gcc/testsuite/g++.dg/cpp0x/explicit4.C new file mode 100644 index 000000000..0f3bc623a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit4.C @@ -0,0 +1,18 @@ +// Negative explicit conv test. +// { dg-options "-std=c++0x" } + +struct A { + A(const A&, int = 0); // { dg-message "note" } +}; +struct B +{ + explicit operator A(); +}; + +int main() +{ + B b; + (A(b)); // OK + (A(b,1)); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/explicit5.C b/gcc/testsuite/g++.dg/cpp0x/explicit5.C new file mode 100644 index 000000000..88a47071d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/explicit5.C @@ -0,0 +1,25 @@ +// test for extension of DR 899 to handle template ctors +// { dg-options "-std=c++0x" } +// { dg-do run } + +int r = 1; + +struct C { + C() { } + template <class T = int> C(C&, T = 0) { r = 0; } +}; + +C c; + +struct A +{ + explicit operator C&() const { return c; } +}; + +int main() +{ + A a; + C c2 (a); + + return r; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/extern_template-1.C b/gcc/testsuite/g++.dg/cpp0x/extern_template-1.C new file mode 100644 index 000000000..ec2cb784e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/extern_template-1.C @@ -0,0 +1,4 @@ +// { dg-options "-std=c++0x -pedantic" } + +template <typename> void f() {} +extern template void f<int>(); diff --git a/gcc/testsuite/g++.dg/cpp0x/extern_template-2.C b/gcc/testsuite/g++.dg/cpp0x/extern_template-2.C new file mode 100644 index 000000000..89a9ceb5a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/extern_template-2.C @@ -0,0 +1,4 @@ +// { dg-options "-std=c++0x -pedantic" } + +template <typename> class S {}; +extern template class S<int>; diff --git a/gcc/testsuite/g++.dg/cpp0x/extern_template-3.C b/gcc/testsuite/g++.dg/cpp0x/extern_template-3.C new file mode 100644 index 000000000..1b7ad0e01 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/extern_template-3.C @@ -0,0 +1,16 @@ +// PR c++/37256 +// { dg-options "-O" } + +template <typename T_> +struct B +{ + T_ f(); +}; + +extern template class B<int>; + +void f() +{ + B<int> t; + t.f(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C new file mode 100644 index 000000000..25192ad86 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C @@ -0,0 +1,7 @@ +// PR c++/37766 +// { dg-options -std=c++0x } + +int a = 1; +template<int& b = a> void f() { + f<>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C new file mode 100644 index 000000000..12cc83659 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C @@ -0,0 +1,14 @@ +// PR c++/46831 +// { dg-options -std=c++0x } + +struct B { }; +struct D : B { }; +struct A { + template<typename T = void> operator D&(); + operator long(); +}; + +void f(long); +void f(B&); + +int main() { f(A()); } diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum1.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum1.C new file mode 100644 index 000000000..2817ae595 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum1.C @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// opaque enum declarations +enum class E1; +enum class E2 : int; +enum class E3 : short; +enum E4 : int; +enum E5 : short; + +// can be repeated +enum class E1; +enum class E2 : int; +enum class E3 : short; +enum E4 : int; +enum E5 : short; + +// are complete so we can declare variables +E1 b1; +E2 b2; +E3 b3; +E4 b4; +E5 b5; + +//even with elaborated-type-specifiers +enum E1 a1; +enum E2 a2; +enum E3 a3; +enum E4 a4; +enum E5 a5; + +// and the list can be added later +enum class E1 { e11, e12 }; +enum class E2 : int { e21, e22 }; +enum class E3 : short {e31, e32 }; +enum E4 : int { e41, e42 }; +enum E5 : short { e51, e52 }; + +// more repetitions allowed +enum class E1; +enum class E2 : int; +enum class E3 : short; +enum E4 : int; +enum E5 : short; + diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum2.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum2.C new file mode 100644 index 000000000..b6ad87148 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum2.C @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct S1 +{ + struct S2 + { + // opaque enum declarations + enum class E1; + enum class E2 : int; + enum class E3 : short; + enum E4 : int; + enum E5 : short; + + // can be repeated + enum class E1; + enum class E2 : int; + enum class E3 : short; + enum E4 : int; + enum E5 : short; + }; +}; + +// are complete so we can declare variables +S1::S2::E1 b1; +S1::S2::E2 b2; +S1::S2::E3 b3; +S1::S2::E4 b4; +S1::S2::E5 b5; + +//even with elaborated-type-specifiers +enum S1::S2::E1 a1; +enum S1::S2::E2 a2; +enum S1::S2::E3 a3; +enum S1::S2::E4 a4; +enum S1::S2::E5 a5; + +// and the list can be added later +enum class S1::S2::E1 { e11, e12 }; +enum class S1::S2::E2 : int { e21, e22 }; +enum class S1::S2::E3 : short {e31, e32 }; +enum S1::S2::E4 : int { e41, e42 }; +enum S1::S2::E5 : short { e51, e52 }; + diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum3.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum3.C new file mode 100644 index 000000000..4a7e9f98d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum3.C @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +namespace S1 +{ + namespace S2 + { + // opaque enum declarations + enum class E1; + enum class E2 : int; + enum class E3 : short; + enum E4 : int; + enum E5 : short; + + // can be repeated + enum class E1; + enum class E2 : int; + enum class E3 : short; + enum E4 : int; + enum E5 : short; + } +} + +// are complete so we can declare variables +S1::S2::E1 b1; +S1::S2::E2 b2; +S1::S2::E3 b3; +S1::S2::E4 b4; +S1::S2::E5 b5; + +//even with elaborated-type-specifiers +enum S1::S2::E1 a1; +enum S1::S2::E2 a2; +enum S1::S2::E3 a3; +enum S1::S2::E4 a4; +enum S1::S2::E5 a5; + +// and the list can be added later +enum class S1::S2::E1 { e11, e12 }; +enum class S1::S2::E2 : int { e21, e22 }; +enum class S1::S2::E3 : short {e31, e32 }; +enum S1::S2::E4 : int { e41, e42 }; +enum S1::S2::E5 : short { e51, e52 }; + diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum4.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum4.C new file mode 100644 index 000000000..0fcc3bde0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum4.C @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename T> struct S1 +{ + struct S2 + { + // opaque enum declarations + enum class E1; + enum class E2 : T; + enum class E3 : short; + enum E4 : T; + enum E5 : short; + + // can be repeated + enum class E1; + enum class E2 : T; + enum class E3 : short; + enum E4 : T; + enum E5 : short; + }; + + // are complete so we can declare variables + typename S2::E1 b1; + typename S2::E2 b2; + typename S2::E3 b3; + typename S2::E4 b4; + typename S2::E5 b5; + + //even with elaborated-type-specifiers + enum S1::S2::E1 a1; + enum S1::S2::E2 a2; + enum S1::S2::E3 a3; + enum S1::S2::E4 a4; + enum S1::S2::E5 a5; + + // and the list can be added later + enum class S1::S2::E1 { e11, e12 }; + enum class S1::S2::E2 : T { e21, e22 }; + enum class S1::S2::E3 : short {e31, e32 }; + enum S1::S2::E4 : T { e41, e42 }; + enum S1::S2::E5 : short { e51, e52 }; +}; + +template struct S1<int>; diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum5.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum5.C new file mode 100644 index 000000000..a2edfa763 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum5.C @@ -0,0 +1,63 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +namespace one +{ + struct S + { + enum { A = 1, B = 2 }; + struct T + { + enum { B = 102 }; + + enum class E1; + enum E2 : int; + }; + }; + + enum class S::T::E1 { A1 = A, B1 = B, C1 }; + enum S::T::E2 : int { A1 = A, B1 = B, C1 }; + + static_assert(int(S::T::E1::A1) == 1, "error"); + static_assert(int(S::T::E1::B1) == 102, "error"); + static_assert(int(S::T::E1::C1) == 103, "error"); + + static_assert(int(S::T::E2::A1) == 1, "error"); + static_assert(int(S::T::E2::B1) == 102, "error"); + static_assert(int(S::T::E2::C1) == 103, "error"); + static_assert(int(S::T::A1) == 1, "error"); + static_assert(int(S::T::B1) == 102, "error"); + static_assert(int(S::T::C1) == 103, "error"); +} + + +namespace two +{ + namespace S + { + enum { A = 1, B = 2 }; + namespace T + { + enum { B = 102 }; + + enum class E1; + enum E2 : int; + } + } + + enum class S::T::E1 { A1 = A, B1 = B, C1 }; + enum S::T::E2 : int { A1 = A, B1 = B, C1 }; + + static_assert(int(S::T::E1::A1) == 1, "error"); + static_assert(int(S::T::E1::B1) == 102, "error"); + static_assert(int(S::T::E1::C1) == 103, "error"); + + static_assert(int(S::T::E2::A1) == 1, "error"); + static_assert(int(S::T::E2::B1) == 102, "error"); + static_assert(int(S::T::E2::C1) == 103, "error"); + static_assert(int(S::T::A1) == 1, "error"); + static_assert(int(S::T::B1) == 102, "error"); + static_assert(int(S::T::C1) == 103, "error"); +} + + diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum6.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum6.C new file mode 100644 index 000000000..51ef6e43e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum6.C @@ -0,0 +1,74 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +enum class E1 : int; // { dg-error "previous definition" } +enum E1 : int; // { dg-error "scoped/unscoped mismatch" } + +enum E2 : int; // { dg-error "previous definition" } +enum class E2 : int; // { dg-error "scoped/unscoped mismatch" } + +enum struct E3 : int; +enum class E3 : int; //ok + +enum class E4 : int; // { dg-error "previous definition" } +enum class E4 : long; // { dg-error "different underlying type" } + +enum E5 : int; // { dg-error "previous definition" } +enum E5 : long; // { dg-error "different underlying type" } + +enum E6 : int; +enum E6 : int; //ok + +enum class E7; +enum class E7 : int; //ok + +enum class E3 e3; // { dg-warning "scoped enum must not use" } +enum struct E3 e4; // { dg-warning "scoped enum must not use" } +enum E5 : int e5; // { dg-error "expected|invalid type" } + +enum E6 : int { a, b, c }; // { dg-error "previous definition" } +enum E6 : int { a, b, c }; // { dg-error "multiple definition" } + +enum class E7 { }; // { dg-error "previous definition" } +enum class E7 { a, b, c }; // { dg-error "multiple definition" } + +namespace N1 +{ + struct D; + enum class E6; + enum E7 : int; +} + +enum class N1::E6; // { dg-error "must use a simple identifier" } +enum N1::E6 e6_1; //ok +enum ::N1::E6 e6_2; //ok + +namespace N2 +{ + enum class N1::E6 { e1, e2, e3 }; // { dg-error "does not enclose" } + enum N1::E7 : int { e1, e2, e3 }; // { dg-error "does not enclose" } +}; + +enum class N1::E6 { e1, e2, e3 }; +enum N1::E7 : int { e1, e2, e3 }; + +struct S1 +{ + struct D; + enum class E6; + enum E7 : int; +}; + +enum class S1::E6; // { dg-error "must use a simple identifier" } +enum S1::E6 e6_3; //ok +enum ::S1::E6 e6_4; //ok + +struct S2 +{ + enum class S1::E6 { e1, e2, e3 }; // { dg-error "does not enclose" } + enum S1::E7 : int { e1, e2, e3 }; // { dg-error "does not enclose" } +}; + +enum class S1::E6 { e1, e2, e3 }; +enum S1::E7 : int { e1, e2, e3 }; + diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum7.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum7.C new file mode 100644 index 000000000..62e445c70 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum7.C @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename T> struct S1 +{ + enum E1 : int; + enum E1 : T; + enum class E2 : int; + enum class E2 : T; +}; + +template<typename T> enum S1<T>::E1 : int { e1 }; +template<typename T> enum class S1<T>::E2 : T { e2 }; + +S1<int>::E1 x1 = S1<int>::e1; +S1<int>::E1 x11 = S1<int>::E1::e1; +S1<int>::E2 x2 = S1<int>::E2::e2; + +enum S1<int>::E1 ex1 = S1<int>::e1; +enum S1<int>::E1 ex11 = S1<int>::E1::e1; +enum S1<int>::E2 ex2 = S1<int>::E2::e2; diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum8.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum8.C new file mode 100644 index 000000000..c87aa5bf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum8.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +//This instatiation is ok +template<typename T> struct S1 +{ + enum E : int; + enum E : T; +}; +template struct S1<int>; //ok + +//This error is diagnosed at instantiation time +template<typename T> struct S2 +{ + enum E : int; // { dg-error "previous definition" } + enum E : T; // { dg-error "different underlying type" } +}; +template struct S2<short>; // { dg-message "instantiated from here" } + +//This error is diagnosed at compilation time +template<typename T> struct S3 +{ + enum E : int; // { dg-error "previous definition" } + enum E : short; // { dg-error "different underlying type" } +}; + diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum9.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum9.C new file mode 100644 index 000000000..da8cde27b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum9.C @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename T> struct S1 +{ + enum E1 : int; + enum class E2 : int; +}; + +template<typename T> enum S1<T>::E1 : int { e1 }; +template<typename T> enum class S1<T>::E2 : T { e2 }; + +template<> enum S1<int>::E1 : int { i1 }; +template<> enum class S1<int>::E2 : int { i2 }; + +S1<char>::E1 xci = S1<char>::e1; +S1<int>::E1 xi1 = S1<int>::i1; + +S1<char>::E2 xc2 = S1<char>::E2::e2; +S1<int>::E2 xi2 = S1<int>::E2::i2; + diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit-copy.C b/gcc/testsuite/g++.dg/cpp0x/implicit-copy.C new file mode 100644 index 000000000..861fe201f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit-copy.C @@ -0,0 +1,15 @@ +// { dg-options "--std=c++0x" } +struct S +{ + S(); +private: + S(S const &&); // { dg-error "" } + S & operator=(S const &&); // { dg-error "" } +}; + +void f() +{ + S a; + S b(a); // { dg-error "" } + a = b; // { dg-error "" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit-trivial1.C b/gcc/testsuite/g++.dg/cpp0x/implicit-trivial1.C new file mode 100644 index 000000000..64084c148 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit-trivial1.C @@ -0,0 +1,23 @@ +// PR c++/46807 +// { dg-options -std=c++0x } +// In C++98/03, B::B(const B&) is trivial because A::A(const A&) is trivial, +// even though doing overload resolution would mean calling the template +// constructor. In C++0x, we do overload resolution to determine triviality. + +struct A +{ + A() {} +private: + template <class T> A(T&); // { dg-error "private" } +}; + +struct B // { dg-error "implicitly deleted|this context" } +{ + mutable A a; +}; + +int main() +{ + B b; + B b2(b); // { dg-error "deleted" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit1.C b/gcc/testsuite/g++.dg/cpp0x/implicit1.C new file mode 100644 index 000000000..2efbde6a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit1.C @@ -0,0 +1,26 @@ +// Test for implicitly deleted destructors. +// { dg-options "-std=c++0x" } +// { dg-prune-output "default definition would be ill-formed" } +// { dg-prune-output "within this context" } + +class C +{ + void operator delete (void *); // { dg-error "private" } +public: + virtual ~C(); // { dg-error "overriding" } +}; + +struct D: C { }; // { dg-error "deleted" } +D d; // { dg-error "deleted" } + +struct E +{ + ~E() = delete; // { dg-error "declared here" } +}; + +struct F +{ + virtual ~F(); // { dg-error "overriding" } +}; + +struct G: E, F { }; // { dg-error "deleted" } diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit10.C b/gcc/testsuite/g++.dg/cpp0x/implicit10.C new file mode 100644 index 000000000..721a93dd5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit10.C @@ -0,0 +1,19 @@ +// PR c++/46103 +// { dg-options -std=c++0x } + +struct MoveOnly { + MoveOnly(const MoveOnly&) = delete; + MoveOnly(MoveOnly&&) { } + MoveOnly() = default; +}; + +struct A { + MoveOnly mo[1]; + A() = default; + A(A&&) = default; +}; + +int main() { + A a; + A aa = static_cast<A&&>(a); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit2.C b/gcc/testsuite/g++.dg/cpp0x/implicit2.C new file mode 100644 index 000000000..f24a78838 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit2.C @@ -0,0 +1,33 @@ +// Test that the synthesized C copy constructor calls the A template +// constructor and has the appropriate exception specification. +// { dg-options -std=c++0x } +// { dg-do run } + +int r = 1; + +struct A +{ + A() {} + A(const A&) throw () { } + template <class T> + A(T& t) { r = 0; } +}; + +struct B +{ + B() {} + B(B&) throw () { } +}; + +struct C: A, B { }; + +#define SA(E) static_assert(E, #E) + +C c; +SA (!noexcept(C(c))); + +int main() +{ + (C(c)); + return r; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit3.C b/gcc/testsuite/g++.dg/cpp0x/implicit3.C new file mode 100644 index 000000000..a43eca708 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit3.C @@ -0,0 +1,56 @@ +// Basic runtime test for implicit move constructor +// { dg-do run } +// { dg-options -std=c++0x } + +int m; + +struct A +{ + A() = default; + A(A&&) { ++m; } + A& operator=(A&&) { ++m; return *this; } +}; + +struct B +{ + B() = default; + B(const B&); + B(B&&) { ++m; } + B& operator=(const B&); + B& operator=(B&&) { ++m; return *this; } +}; + +struct C +{ + C() = default; + C(C&); + C(C&&) { ++m; } + C& operator=(C&); + C& operator=(C&&) { ++m; return *this; } +}; + +struct D: public A, public B +{ + C c; + int i; +}; + +struct E: public A, public B +{ + C c; + int i; + E() = default; + E(E&&) = default; + E& operator=(E&&) = default; +}; + +int main() +{ + D d1; + D d2 (static_cast<D&&>(d1)); + d1 = static_cast<D&&>(d2); + E e1; + E e2 (static_cast<E&&>(e1)); + e1 = static_cast<E&&>(e2); + return m != 12; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit4.C b/gcc/testsuite/g++.dg/cpp0x/implicit4.C new file mode 100644 index 000000000..f97eb7549 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit4.C @@ -0,0 +1,21 @@ +// Test that a base with only a move constructor causes the implicit copy +// constructor to be deleted. +// { dg-options "-std=c++0x" } + +struct A +{ + A(); // { dg-message "A::A|candidate expects" } + A(A&&); // { dg-message "A::A|no known conversion" } +}; + +struct B: A // { dg-error "implicit|no match" } +// { dg-message "candidate" "candidate note" { target *-*-* } 11 } +{ +}; + +int main() +{ + B b1; + B b2(b1); // { dg-error "deleted function .B::B.const" } + B b3(static_cast<B&&>(b1)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit5.C b/gcc/testsuite/g++.dg/cpp0x/implicit5.C new file mode 100644 index 000000000..f25c08530 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit5.C @@ -0,0 +1,19 @@ +// Test that the default B copy constructor calls the A member template +// constructor. +// { dg-options -std=c++0x } + +struct A +{ + A() = default; + A(A&&) = default; + template <class T> + A(const T& t) { t.i; } // { dg-error "no member" } +}; + +struct B: A { }; + +int main() +{ + B b; + B b2(b); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit6.C b/gcc/testsuite/g++.dg/cpp0x/implicit6.C new file mode 100644 index 000000000..c7902969d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit6.C @@ -0,0 +1,23 @@ +// Circular implicit declarations were causing errors +// { dg-options -std=c++0x } + +struct Ray; + +struct Vector +{ + virtual void f(); // make non-trivially-copyable + Vector(const Ray &) ; +}; + +struct array +{ + Vector v; +}; + +struct Ray +{ + array a; +}; + +extern Ray r1; +Ray r2=r1; diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit7.C b/gcc/testsuite/g++.dg/cpp0x/implicit7.C new file mode 100644 index 000000000..f29e5009f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit7.C @@ -0,0 +1,37 @@ +// PR c++/44909 +// { dg-options -std=c++0x } +// Declaring A<D<E>>'s copy ctor means choosing a ctor to initialize D<E>, +// which means choosing a ctor for C<B<E>>, which meant considering +// C(const B<E>&) which means choosing a ctor for B<E>, which means choosing +// a ctor for A<D<E>>. Cycle. + +template<typename T> +struct A +{ + T t; +}; + +template <typename T> +struct B +{ + typename T::U u; +}; + +template <typename T> +struct C +{ + C(const T&); +}; + +template <typename T> +struct D +{ + C<B<T> > v; +}; + +struct E { + typedef A<D<E> > U; +}; + +extern A<D<E> > a; +A<D<E> > a2(a); diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit8.C b/gcc/testsuite/g++.dg/cpp0x/implicit8.C new file mode 100644 index 000000000..2f3febae8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit8.C @@ -0,0 +1,34 @@ +// The hack for PR c++/44909 breaks this testcase. We need feedback +// from the C++ committee to know how to proceed. +// { dg-options -std=c++0x } +// { dg-prune-output "implicitly deleted" } +// { dg-prune-output "cannot bind" } +// { dg-prune-output "initializing argument" } + +struct A +{ + A(); + A(A&); +}; + +struct B; +struct BP +{ + BP(const B&); +}; + +struct B +{ + B(); + B(B&&); + B(const BP&); +}; + +// If B(B&&) suppresses the B copy constructor, then copying the B +// subobject of C should use B(const BP&). But we ignore that constructor +// in order to break the cycle in 44909. Perhaps the move ctor shouldn't +// suppress the copy ctor? +struct C: A, B { }; + +C c; +C c2(c); // { dg-bogus "deleted" "" { xfail *-*-* } } diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit9.C b/gcc/testsuite/g++.dg/cpp0x/implicit9.C new file mode 100644 index 000000000..3a6dbc558 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/implicit9.C @@ -0,0 +1,12 @@ +// Test that private base dtor makes derived ctor deleted +// { dg-options -std=c++0x } + +struct A +{ + A(); +private: + ~A(); // { dg-error "private" } +}; + +struct B: A { }; // { dg-error "implicitly deleted|context" } +B * b = new B; // { dg-error "deleted" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-49216.C b/gcc/testsuite/g++.dg/cpp0x/initlist-49216.C new file mode 100644 index 000000000..4bf608229 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-49216.C @@ -0,0 +1,6 @@ +// PR c++/49216 +// { dg-options -std=c++0x } + +int main() { + new int[1]{}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array2.C new file mode 100644 index 000000000..19eec33ac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array2.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } + +typedef int IA[2]; +typedef double DA[2]; + +void f(const IA&) { } +void f(const DA&); + +int main() +{ + f({1,2}); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C new file mode 100644 index 000000000..25113d770 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-arrray1.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +typedef int IRT[2]; + +const IRT& ir = IRT{1,2}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C b/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C new file mode 100644 index 000000000..e422132af --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C @@ -0,0 +1,26 @@ +// Test for deduction of T as std::initializer_list. This isn't currently +// supported by the working draft, but is necessary for perfect forwarding +// of initializer-lists to things that can take a std::initializer_list. + +// { dg-options -std=c++0x } +// { dg-do run } + +#include <initializer_list> + +struct A +{ + A(std::initializer_list<int>) { } +}; + +void f (A a) { } + +template <class T> +auto g (T&& t) -> decltype (f(t)) // { dg-warning "call" } +{ + return f(t); +} + +int main() +{ + g({1}); // { dg-warning "deduc" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C b/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C new file mode 100644 index 000000000..d17cda3f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C @@ -0,0 +1,19 @@ +// PR c++/41997 +// { dg-options "-std=c++0x -O2 -fdump-tree-optimized" } +// { dg-final { scan-tree-dump-not "_0" "optimized" } } +// { dg-final { cleanup-tree-dump "optimized" } } + +#include <initializer_list> + +inline int max_val(std::initializer_list<int> il) +{ + int i = *(il.begin()); + int j = *(il.begin() + 1); + return (i > j ? i : j); +} + +int main(void) +{ + return max_val({1,2}); +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist1.C b/gcc/testsuite/g++.dg/cpp0x/initlist1.C new file mode 100644 index 000000000..ff45f7176 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist1.C @@ -0,0 +1,72 @@ +// Basic uses of initializer lists +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +extern "C" void abort(); + +using namespace std; + +struct A { int i,j; A(int _i,int _j): i(_i), j(_j) {} }; +struct B { A a; B(A _a): a(_a) {} }; +struct C { B b; C(B _b): b(_b) {} }; + +struct D +{ + int ia[3]; + D (initializer_list<int> l) + { + const int *p = l.begin(); + for (int i = 0; i < 3; ++i) + ia[i] = *p++; + } +}; + +void f(C c) +{ + if (c.b.a.i != 1) abort(); + if (c.b.a.j != 2) abort(); +} +void f(int); + +void g(D d) +{ + if (d.ia[0] != 1 || d.ia[1] != 2 || d.ia[2] != 3) + abort(); +} + +struct E +{ + int i, j, k; +}; + +void h(E e) +{ + if (e.i != 1 || e.j != 2 || e.k != 3) + abort(); +} + +void i(initializer_list<int> l) +{ + const int *p = l.begin(); + if (*p++ != 1) abort(); + if (*p++ != 2) abort(); + if (*p++ != 3) abort(); + if (p != l.end()) abort(); +} + +struct U { U(int, int) {} }; +U ua[] = { { 3, 2 } }; + +int main() +{ + g({1,2,3}); + + h({1,2,3}); + + f({{{1,2}}}); + f({{A{1,2}}}); + + i({1,2,3}); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist10.C b/gcc/testsuite/g++.dg/cpp0x/initlist10.C new file mode 100644 index 000000000..bf955f513 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist10.C @@ -0,0 +1,53 @@ +// PR c++/38380 +// { dg-options "-std=gnu++0x" } + +namespace std +{ + struct atomic_bool + { + bool _M_i; + + atomic_bool() = default; + ~atomic_bool() = default; + atomic_bool(const atomic_bool&) = delete; + atomic_bool& operator=(const atomic_bool&) = delete; + + explicit atomic_bool(bool __i) { _M_i = __i; } + + operator bool() const volatile + { return true; } + }; +} + +namespace __gnu_test +{ + struct direct_list_initializable + { + template<typename _Ttype, typename _Tvalue> + void + operator()() + { + struct _Concept + { + void __constraint() + { + _Ttype __v1 = { }; // default ctor + _Ttype __v2 { __a }; // single-argument ctor + } + + _Tvalue __a; + }; + + void (_Concept::*__x)() __attribute__((unused)) + = &_Concept::__constraint; + } + }; +} + +int main() +{ + __gnu_test::direct_list_initializable test; + + test.operator()<std::atomic_bool, bool>(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist11.C b/gcc/testsuite/g++.dg/cpp0x/initlist11.C new file mode 100644 index 000000000..546a5335f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist11.C @@ -0,0 +1,18 @@ +// PR c++/38684 +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct Y {}; + +struct X : Y { + X(std::initializer_list<int>) {} +}; + +struct A { + X v; +}; + +int main() { + A a{ {1,2,3} }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist12.C b/gcc/testsuite/g++.dg/cpp0x/initlist12.C new file mode 100644 index 000000000..f344c780c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist12.C @@ -0,0 +1,21 @@ +// PR c++/38698 +// { dg-options "-std=c++0x" } +// { dg-prune-output "note" } + +struct A +{ + int i; +}; + +A a({1,2}); // { dg-error "no match" } + +union U +{ + int i,j; +}; + +U u({1,2}); // { dg-error "no match" } + +union V {}; + +V v({1}); // { dg-error "no match" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist13.C b/gcc/testsuite/g++.dg/cpp0x/initlist13.C new file mode 100644 index 000000000..9ed6c7441 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist13.C @@ -0,0 +1,8 @@ +// PR c++/39056 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <complex> + +__complex__ int i ({0}); +std::complex<int> i2 ({0}); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist14.C b/gcc/testsuite/g++.dg/cpp0x/initlist14.C new file mode 100644 index 000000000..bb67f3e54 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist14.C @@ -0,0 +1,19 @@ +// Bug: We weren't doing the normal replacement of array with pointer +// for deduction in the context of a call because of the initializer list. +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct string +{ + string (const char *); +}; + +template <class T> +struct vector +{ + template <class U> + vector (std::initializer_list<U>); +}; + +vector<string> v = { "a", "b", "c" }; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist15.C b/gcc/testsuite/g++.dg/cpp0x/initlist15.C new file mode 100644 index 000000000..b75cc8172 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist15.C @@ -0,0 +1,20 @@ +// { dg-options "-std=c++0x" } + +// Just discard errors pointing at header files +// { dg-prune-output "include" } + +#include <vector> +#include <typeinfo> + +using namespace std; + +template< typename ... ArgTypes > +void test( ArgTypes ... args ) { + vector<type_info*> x = { &typeid(ArgTypes)... }; // { dg-error "" } +} + +int main() +{ + test( 1, 3.14f, 2.78 ); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist16.C b/gcc/testsuite/g++.dg/cpp0x/initlist16.C new file mode 100644 index 000000000..86a003960 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist16.C @@ -0,0 +1,12 @@ +// { dg-options "-std=c++0x" } +// { dg-do run } + +extern "C" void abort(); + +void f(int i) { if (i != 42) abort(); } + +int main() +{ + f({42}); + return {0}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist17.C b/gcc/testsuite/g++.dg/cpp0x/initlist17.C new file mode 100644 index 000000000..86371e819 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist17.C @@ -0,0 +1,9 @@ +// { dg-options "-std=c++0x" } + +void f(int i); + +int main() +{ + f({42.0}); // { dg-error "narrowing" } + return {1.0}; // { dg-error "narrowing" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist18.C b/gcc/testsuite/g++.dg/cpp0x/initlist18.C new file mode 100644 index 000000000..c9a9bcd94 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist18.C @@ -0,0 +1,19 @@ +// PR c++/40308, 40311 +// { dg-do run } +// { dg-options "-std=c++0x" } + +template< typename T > +struct test { + test() : data{} {} + + T data; +}; + +int main() +{ + test<int> x; + test<int*> y; + int * a = new int{}; + int * b = new int{5}; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist19.C b/gcc/testsuite/g++.dg/cpp0x/initlist19.C new file mode 100644 index 000000000..9cb197c9b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist19.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++0x" } + +// Allow other errors, too +// { dg-prune-output "error" } + +void f(double); +int main() +{ + f({{1}}); // { dg-error "too many braces" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist2.C b/gcc/testsuite/g++.dg/cpp0x/initlist2.C new file mode 100644 index 000000000..2fe477056 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist2.C @@ -0,0 +1,32 @@ +// Test that conversion to std::initializer_list takes priority over other +// user-defined conversions. + +// { dg-do link } +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct string +{ + string (const char *) {} + template <class Iter> string (Iter, Iter); +}; + +template <class T, class U> +struct pair +{ + pair (T t, U u) {} +}; + +template<class T, class U> +struct map +{ + void insert (pair<T,U>); + void insert (std::initializer_list<pair<T,U> >) {} +}; + +int main() +{ + map<string,string> m; + m.insert({ {"this","that"}, {"me","you"} }); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist20.C b/gcc/testsuite/g++.dg/cpp0x/initlist20.C new file mode 100644 index 000000000..fcdb73f19 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist20.C @@ -0,0 +1,17 @@ +// PR c++/40689 +// { dg-options "-std=c++0x" } + +class X +{ + public: + X(): data {1,2,3,4,5} {} + private: + const short data[5]; +}; + +int main() +{ + const float * pData = new const float[4] { 1.5, 2.5, 3.5, 4.5 }; + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist21.C b/gcc/testsuite/g++.dg/cpp0x/initlist21.C new file mode 100644 index 000000000..9412a0851 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist21.C @@ -0,0 +1,18 @@ +// PR c++/40689 +// { dg-options "-std=c++0x" } + +class X +{ + public: + X(): data {1,2} {} // { dg-error "too many initializers" } + private: + const short data[1]; +}; + +int f(int n) +{ + const float * pData = new const float[1] { 1.5, 2.5 }; // { dg-error "too many initializers" } + pData = new const float[n] { 1.5, 2.5 }; // { dg-warning "array size" } + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist22.C b/gcc/testsuite/g++.dg/cpp0x/initlist22.C new file mode 100644 index 000000000..0855b59d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist22.C @@ -0,0 +1,24 @@ +// Core issue 934 +// { dg-options "-std=c++0x" } + +int i; + +int& r1{ i }; // OK, direct binding +int&& r2{ i }; // { dg-error "" } binding && to lvalue + +int& r3{ }; // { dg-error "" } reference to temporary +int&& r4{ }; // OK, reference to temporary + +struct A { int i; } a; + +A& r5 { i }; // { dg-error "" } reference to temporary +A&& r6 { i }; // OK, aggregate initialization of temporary +A& r7 { a }; // { dg-error "" } invalid aggregate initializer for A +A&& r8 { a }; // { dg-error "" } invalid aggregate initializer for A + +struct B { B(int); int i; } b(0); + +B& r9 { i }; // { dg-error "" } reference to temporary +B&& r10 { i }; // OK, make temporary with B(int) constructor +B& r11 { b }; // { dg-error "" } reference to temporary +B&& r12 { b }; // OK, make temporary with copy constructor diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist23.C b/gcc/testsuite/g++.dg/cpp0x/initlist23.C new file mode 100644 index 000000000..48a997fca --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist23.C @@ -0,0 +1,15 @@ +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct A +{ + A& operator=(int i); + A& operator=(std::initializer_list<int> l) { return *this; } +}; + +int main() +{ + A a; + a = { }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist24.C b/gcc/testsuite/g++.dg/cpp0x/initlist24.C new file mode 100644 index 000000000..33e97c7df --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist24.C @@ -0,0 +1,9 @@ +// PR c++/39923 +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +void test3() +{ + std::initializer_list<int> list{move}; // { dg-error "not declared|could not convert" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist25.C b/gcc/testsuite/g++.dg/cpp0x/initlist25.C new file mode 100644 index 000000000..8e5e0065c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist25.C @@ -0,0 +1,17 @@ +// PR c++/41754 +// { dg-options -std=c++0x } +// { dg-do run } + +#include <map> +#include <string> +#include <iostream> + +using namespace std; + +int main() +{ + map<string, string> m; + m.insert({{"t", "t"}, {"y", "y"}}); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist26.C b/gcc/testsuite/g++.dg/cpp0x/initlist26.C new file mode 100644 index 000000000..bb28bdbd9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist26.C @@ -0,0 +1,10 @@ +// PR c++/42059 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +void +foo (int i) +{ + int a[i]; + a = { }; // { dg-error "assign" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist27.C b/gcc/testsuite/g++.dg/cpp0x/initlist27.C new file mode 100644 index 000000000..f8536d3e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist27.C @@ -0,0 +1,5 @@ +// PR c++/42061 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +int& i = { j }; // { dg-error "invalid initialization|was not declared" } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist28.C b/gcc/testsuite/g++.dg/cpp0x/initlist28.C new file mode 100644 index 000000000..d1df7cb00 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist28.C @@ -0,0 +1,8 @@ +// PR c++/42060 +// { dg-options "-std=c++0x" } + +void foo() +{ + int a[1]; + throw a = {}; // { dg-error "assign" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist29.C b/gcc/testsuite/g++.dg/cpp0x/initlist29.C new file mode 100644 index 000000000..1568678e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist29.C @@ -0,0 +1,14 @@ +// PR c++/42331 +// { dg-options "-std=c++0x" } + +class Mesh +{ +public: + Mesh(const char*) + { typele={0}; } // { dg-error "" } + +private: + int typele[7][2]; +}; + +Mesh m(0); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist3.C b/gcc/testsuite/g++.dg/cpp0x/initlist3.C new file mode 100644 index 000000000..412deb511 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist3.C @@ -0,0 +1,11 @@ +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +template <class T> void f(std::initializer_list<T>); + +void g() +{ + f({1,2,3}); +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist30.C b/gcc/testsuite/g++.dg/cpp0x/initlist30.C new file mode 100644 index 000000000..a5bdb2eda --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist30.C @@ -0,0 +1,12 @@ +// Testcase for variadic init list deduction. +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +template <class... Ts> +void f (std::initializer_list<Ts>... ls); + +int main() +{ + f({1},{2.0}); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist31.C b/gcc/testsuite/g++.dg/cpp0x/initlist31.C new file mode 100644 index 000000000..ffc985567 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist31.C @@ -0,0 +1,13 @@ +// PR c++/43028 +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct string { string(std::initializer_list<char>) { } }; + +void f() { + auto y = + { + string(Equation()) // { dg-error "not declared" } + }; // { dg-error "unable to deduce" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist32.C b/gcc/testsuite/g++.dg/cpp0x/initlist32.C new file mode 100644 index 000000000..78bbb5ef9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist32.C @@ -0,0 +1,21 @@ +// Test that we try normal init if no list ctor is viable. +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct B {}; + +struct C +{ + C(B); +}; + +struct A +{ + A(std::initializer_list<int>); + A(B) { } + A(C); +}; + +B b; +A a{b}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist33.C b/gcc/testsuite/g++.dg/cpp0x/initlist33.C new file mode 100644 index 000000000..b1c0ba09b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist33.C @@ -0,0 +1,13 @@ +// PR c++/44045 +// { dg-options "-std=c++0x" } + +struct base +{ + virtual ~base() { } +}; + +int main() +{ + base ptr_array[1]; + ptr_array = { base() }; // { dg-error "assign" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist34.C b/gcc/testsuite/g++.dg/cpp0x/initlist34.C new file mode 100644 index 000000000..92f5a3a46 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist34.C @@ -0,0 +1,14 @@ +// PR c++/44157 +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +template<typename T> +void f(T) { } + +int main() { + std::initializer_list<int> a = { 0 }; + f(a); + + f<std::initializer_list<int> >({ 0 }); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist35.C b/gcc/testsuite/g++.dg/cpp0x/initlist35.C new file mode 100644 index 000000000..e5b7cb4bd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist35.C @@ -0,0 +1,24 @@ +// PR c++/41510 +// { dg-options "-std=c++0x" } + +struct B +{ + B(int, int); +}; +struct A +{ + A(int, int); + A(const B&); +}; + +void f() +{ + A a = { 1, 2 }; +}; + +template <class T> void g() +{ + A a = { 1, 2 }; +}; + +template void g<int>(); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist36.C b/gcc/testsuite/g++.dg/cpp0x/initlist36.C new file mode 100644 index 000000000..94624c977 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist36.C @@ -0,0 +1,23 @@ +// PR c++/44358 +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct A +{ + A(int); +}; + +struct B +{ + B(std::initializer_list<A>); +}; + +void f (B b); +int main() +{ + B b0 = {{1}}; + B b1 = {{1.0}}; // { dg-error "narrowing" } + B b2 {1.0}; // { dg-error "narrowing" } + A a {1.0}; // { dg-error "narrowing" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist37.C b/gcc/testsuite/g++.dg/cpp0x/initlist37.C new file mode 100644 index 000000000..20c6ab631 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist37.C @@ -0,0 +1,24 @@ +// DR 990 +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct S { + S(std::initializer_list<double>); // #1 + S(std::initializer_list<int>); // #2 + S(); // #3 + // ... +}; +S s1 = { 1.0, 2.0, 3.0 }; // invoke #1 +S s2 = { 1, 2, 3 }; // invoke #2 +S s3 = { }; // invoke #3 (for value-initialization) + + +// Test some other situations, too. +void f (S); +int main() +{ + S s4 { }; + f({ }); + S {}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist38.C b/gcc/testsuite/g++.dg/cpp0x/initlist38.C new file mode 100644 index 000000000..32e20d591 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist38.C @@ -0,0 +1,21 @@ +// DR 990 +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct A { + A(std::initializer_list<int>); // #1 +}; +struct B { + A a; +}; + +void f (B); +int main() +{ + B{}; + f({}); + B b0 = { }; + B b1 { }; // OK, uses #1 + B b2 { 1 }; // { dg-error "could not convert" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist39.C b/gcc/testsuite/g++.dg/cpp0x/initlist39.C new file mode 100644 index 000000000..a6dd1ec43 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist39.C @@ -0,0 +1,15 @@ +// { dg-options -std=c++0x } + +struct A { int i; }; + +void f (const A &); +void f (A &&); + +void g (A, int); +void g (A, double); + +int main() +{ + f ( { 1 } ); + g ( { 1 }, 1 ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist4.C b/gcc/testsuite/g++.dg/cpp0x/initlist4.C new file mode 100644 index 000000000..d1ffab854 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist4.C @@ -0,0 +1,32 @@ +// Test for initializer-list 'explicit' rule +// { dg-options "-std=c++0x" } + +struct A +{ + explicit A(int,int); + operator bool(); +}; + +A f(A) +{ + A{1,2}; + A a1{1,2}; + new A{1,2}; + if (A a5{1,2}); + + A({1,2}); // { dg-error "explicit" } + A a2({1,2}); // { dg-error "explicit" } + A a3 = {1,2}; // { dg-error "explicit" } + new A({1,2}); // { dg-error "explicit" } + f({1,2}); // { dg-error "explicit" } + a1 = {1,2}; // { dg-error "explicit" } + if (A a4 = {1,2}); // { dg-error "explicit" } + return {1,2}; // { dg-error "explicit" } +} + +struct B +{ + A a; + B(): a{1,2} {} + B(const B&): a({1,2}) {} // { dg-error "explicit" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist40.C b/gcc/testsuite/g++.dg/cpp0x/initlist40.C new file mode 100644 index 000000000..f2703602c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist40.C @@ -0,0 +1,12 @@ +// { dg-options "-std=c++0x" } + +struct A +{ + explicit A(int = 42); +}; + +int main() +{ + A a1 = { }; + A a2 = { 24 }; // { dg-error "explicit" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist41.C b/gcc/testsuite/g++.dg/cpp0x/initlist41.C new file mode 100644 index 000000000..b5385480c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist41.C @@ -0,0 +1,14 @@ +// PR c++/44703 +// { dg-options -std=c++0x } + +#include <initializer_list> + +typedef std::initializer_list<int> type ; +void f(type) {} + +int main() +{ +// error: could not convert '{1, 2, 3}' to 'type' + f({1,2,3}) ; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist42.C b/gcc/testsuite/g++.dg/cpp0x/initlist42.C new file mode 100644 index 000000000..e63959deb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist42.C @@ -0,0 +1,13 @@ +// { dg-options -std=c++0x } + +enum Unscoped { }; +enum class Scoped { }; + +Unscoped bar(Unscoped x) { return x; } +Scoped bar(Scoped x) { return x; } + +auto var1u = bar(Unscoped()); // OK +auto var1s = bar(Scoped()); // OK + +auto var2u = bar(Unscoped{}); // #1 Error, but should work +auto var2s = bar(Scoped{}); // #2 Error, but should work diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist43.C b/gcc/testsuite/g++.dg/cpp0x/initlist43.C new file mode 100644 index 000000000..72a09bdea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist43.C @@ -0,0 +1,7 @@ +// Test that using T{} at file scope doesn't create a static temporary. +// { dg-options -std=c++0x } +// { dg-final { scan-assembler-not "local" } } + +struct A { }; + +A a = A{}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist44.C b/gcc/testsuite/g++.dg/cpp0x/initlist44.C new file mode 100644 index 000000000..fbe0ea3fe --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist44.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +#include <initializer_list> + +auto value = std::initializer_list<int>{ 1, 2, 3 }; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist45.C b/gcc/testsuite/g++.dg/cpp0x/initlist45.C new file mode 100644 index 000000000..0e34bc189 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist45.C @@ -0,0 +1,13 @@ +// PR c++/46289 +// { dg-options -std=c++0x } + +struct A +{ + int i[2]; +}; + +struct B +{ + A a; + B(): a({{1,2}}) { } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist46.C b/gcc/testsuite/g++.dg/cpp0x/initlist46.C new file mode 100644 index 000000000..2b9f07dbd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist46.C @@ -0,0 +1,14 @@ +// PR c++/48281 +// { dg-options "-std=c++0x -O2" } +// { dg-do run } + +#include <initializer_list> + +typedef std::initializer_list<int> int1; +typedef std::initializer_list<int1> int2; +static int2 ib = {{42,2,3,4,5},{2,3,4,5,1},{3,4,5,2,1}}; + +int main() +{ + return *(ib.begin()->begin()) != 42; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist47.C b/gcc/testsuite/g++.dg/cpp0x/initlist47.C new file mode 100644 index 000000000..b76fb5836 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist47.C @@ -0,0 +1,9 @@ +// { dg-options -std=c++0x } + +struct A { ~A() = delete; }; // { dg-error "declared" } + +int main() +{ + typedef const A cA[2]; + cA{}; // { dg-error "deleted" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist48.C b/gcc/testsuite/g++.dg/cpp0x/initlist48.C new file mode 100644 index 000000000..9eb451a82 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist48.C @@ -0,0 +1,11 @@ +// PR c++/48726 +// { dg-options -std=c++0x } + +#include <memory> + +struct Foo{ + int i; +}; +typedef std::unique_ptr<Foo> up; + +std::initializer_list<up> il{up{new Foo}, up{new Foo}}; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist5.C b/gcc/testsuite/g++.dg/cpp0x/initlist5.C new file mode 100644 index 000000000..32caac382 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist5.C @@ -0,0 +1,27 @@ +// Test for narrowing diagnostics +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +struct A { int i; int j; }; +A a2 { 1.2 }; // { dg-error "narrowing" } +A a1 { 1, 2 }; // aggregate initialization +struct B { + B(std::initializer_list<int>); +}; +B b1 { 1, 2 }; // creates initializer_list<int> and calls constructor +B b2 { 1, 2.0 }; // { dg-error "narrowing" } +struct C { + C(int i, double j); +}; +C c1 = { 1, 2.2 }; // calls constructor with arguments (1, 2.2) +C c2 = { 1.1, 2 }; // { dg-error "narrowing" } + +int j { 1 }; // initialize to 1 +int k {}; // initialize to 0 + +// PR c++/36963 +double d = 1.1; +float fa[] = { d, 1.1 }; // { dg-error "narrowing conversion of 'd'" } +constexpr double d2 = 1.1; +float fa2[] = { d2, 1.1 }; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist50.C b/gcc/testsuite/g++.dg/cpp0x/initlist50.C new file mode 100644 index 000000000..ef4e72c7c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist50.C @@ -0,0 +1,21 @@ +// PR c++/45418 +// { dg-options -std=c++0x } + +struct A1 { }; +struct A2 { + A2(); +}; + +template <class T> struct B { + T ar[1]; + B(T t):ar({t}) {} +}; + +int main(){ + B<int> bi{1}; + A1 a1; + B<A1> ba1{a1}; + A2 a2; + A2 a2r[1]{{a2}}; + B<A2> ba2{a2}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist51.C b/gcc/testsuite/g++.dg/cpp0x/initlist51.C new file mode 100644 index 000000000..9163dd3a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist51.C @@ -0,0 +1,15 @@ +// PR c++/47184 +// { dg-options -std=c++0x } + +struct S +{ + int a; +}; +struct T +{ + T(S s) {} +}; +int main() +{ + T t(S{1}); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist57.C b/gcc/testsuite/g++.dg/cpp0x/initlist57.C new file mode 100644 index 000000000..d945a4689 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist57.C @@ -0,0 +1,8 @@ +// PR c++/50054 +// { dg-options -std=c++0x } + +void g( const int& (a)[1] ) {} // { dg-error "array of references" } + +int main () { + g( { 1, 2 } ); // { dg-error "initializer list" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist6.C b/gcc/testsuite/g++.dg/cpp0x/initlist6.C new file mode 100644 index 000000000..523570315 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist6.C @@ -0,0 +1,30 @@ +// Test for initlist lifetime +// { dg-options "-std=c++0x" } +// { dg-do run } + +#include <initializer_list> + +int c; + +struct A +{ + A(int,int) { ++c; } + ~A() { --c; } +}; + +void f (std::initializer_list<A> l) { } + +int main() +{ + f({ {1,2}, {3,4} }); + if (c != 0) + return 1; + + { + std::initializer_list<A> l { {1,2}, {3,4} }; + if (c != 2) + return 2; + } + if (c != 0) + return 3; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist7.C b/gcc/testsuite/g++.dg/cpp0x/initlist7.C new file mode 100644 index 000000000..7913ed7ed --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist7.C @@ -0,0 +1,12 @@ +// PR c++/37932 +// { dg-options "-std=c++0x" } + +typedef enum { AA=1, BB=2 } my_enum; + +typedef struct { my_enum a:4 ; unsigned b:28; } stru; + +void foo (char c, my_enum x, int i) +{ + char arr[2] = {c+'0', 0}; // { dg-error "narrowing" } + stru s = {x,0}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist8.C b/gcc/testsuite/g++.dg/cpp0x/initlist8.C new file mode 100644 index 000000000..db63eee78 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist8.C @@ -0,0 +1,19 @@ +// PR c++/37740 +// { dg-options "-std=c++0x" } + +struct A +{ + int i; +}; + +struct B +{ + double d; + A i; +}; + +int main() +{ + A a; + new B{3.2, a}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist9.C b/gcc/testsuite/g++.dg/cpp0x/initlist9.C new file mode 100644 index 000000000..d596b3915 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist9.C @@ -0,0 +1,29 @@ +// PR c++/37860 +// { dg-options "-std=c++0x" } + +struct b +{ + bool t; + + b() = default; + ~b() = default; + b& operator=(const b&) = delete; + b(const b&) = delete; // { dg-error "declared" } + + b(bool _t): t (_t) { } +}; + +int main() +{ + // copy list initialization + b tst1 = { false }; + + // copy initialization. + b tst2 = false; // { dg-error "use" } + + // direct list initialization + b tst3 { false }; + + // default initialization + b tst4; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns1.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns1.C new file mode 100644 index 000000000..e422d8970 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns1.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } +// { dg-final { scan-assembler "_ZN1Q2V11fEv" } } +// { dg-final { scan-assembler "_ZN1Q2V11iE" } } + +namespace Q { + inline namespace V1 { + extern int i; + void f(); + } +} +int Q::i = 1; +void Q::f() { } diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns2.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns2.C new file mode 100644 index 000000000..03851725b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns2.C @@ -0,0 +1,25 @@ +// { dg-options -std=c++0x } + +namespace Q { + inline namespace V1 { + extern int i; // { dg-error "" } + extern int j; // { dg-error "" } + void f(); // { dg-error "" } + void g(); // { dg-error "" } + } + inline namespace V2 { + extern int j; // { dg-error "" } + void g(); // { dg-error "" } + } + extern int i; // { dg-error "" } + void f(); // { dg-error "" } + void h(); +} +namespace R { + using namespace Q; +} +int Q::i = 1; // { dg-error "ambiguous" } +int Q::j = 1; // { dg-error "ambiguous" } +void Q::f() { } // { dg-error "ambiguous" } +void Q::g() { } // { dg-error "ambiguous" } +void R::h() { } // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns3.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns3.C new file mode 100644 index 000000000..7c9d6b9b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns3.C @@ -0,0 +1,26 @@ +// { dg-options -std=c++0x } + +namespace C +{ + void f(); +} + +namespace B +{ + using namespace C; + + inline namespace B1 + { + void f(); + } +} + +namespace A +{ + using namespace B; +} + +int main() +{ + A::f(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns4.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns4.C new file mode 100644 index 000000000..25caefc0a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns4.C @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++98 -pedantic" } +inline namespace { } // { dg-warning "inline namespaces" } diff --git a/gcc/testsuite/g++.dg/cpp0x/inline-ns5.C b/gcc/testsuite/g++.dg/cpp0x/inline-ns5.C new file mode 100644 index 000000000..20a3dc6bb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/inline-ns5.C @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++98 -pedantic-errors" } +inline namespace { } // { dg-error "inline namespaces" } diff --git a/gcc/testsuite/g++.dg/cpp0x/iop.C b/gcc/testsuite/g++.dg/cpp0x/iop.C new file mode 100644 index 000000000..834cd314a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/iop.C @@ -0,0 +1,41 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test that the implicit object parameter is *not* an rvalue reference, but is instead +// identical to that specified in C++03. That is, the implicit object parameter is +// an lvalue reference that can bind to an rvalue. :-\ +// See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html under the +// section "Revision 1 Summary and Rationale" for more details. + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; + +struct os +{ + one operator<<(int); +}; + +struct A +{ + A(int); +}; + +two operator<<(os&, const A&); + +void test() +{ + os o; + sa<sizeof(o << 1) == 1 * sizeof(long)> t1; // Calls os::operator<<(int) + // Would be ambiguous if the implicit object parameter + // was an rvalue reference. +} + +int main() +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C new file mode 100644 index 000000000..240143cf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-50220.C @@ -0,0 +1,9 @@ +// PR c++/50220 +// { dg-options -std=c++0x } + +template<typename Foo> struct Foobar {}; + +void foobar(const Foobar<void>& obj) +{ + [obj](){}(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C new file mode 100644 index 000000000..ff1085f30 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-98.C @@ -0,0 +1,8 @@ +// PR c++/46159 +// { dg-options -std=c++98 } + +void +f() +{ + int **p = new(int(*[2])); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array.C new file mode 100644 index 000000000..2129051ed --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-array.C @@ -0,0 +1,20 @@ +// Test that array capture by copy works. +// { dg-options -std=c++0x } +// { dg-do run } + +struct A +{ + int i; + A(int i): i(i) {} + A(const A& a): i(a.i+1) {} +}; + +int main() +{ + A ar[4][3] = { { 10, 20, 30 }, + { 40, 50, 60 }, + { 70, 80, 90 }, + { 100, 110, 120 } }; + int i = [ar] { return ar[1][1]; }().i; + return (i!= 52); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-capture-const-ref-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-capture-const-ref-neg.C new file mode 100644 index 000000000..7d1a1bd89 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-capture-const-ref-neg.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } +#include <cassert> + +int main() { + int i = 1, j = 2; + const int& ci = i; + [&ci, &j] () -> void { j = ci; } (); + assert(i == 1); + assert(j == 1); + [&ci] () -> void { ci = 0; } (); // { dg-error "" "cannot assign to const int&" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-capture-const-ref.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-capture-const-ref.C new file mode 100644 index 000000000..704c24085 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-capture-const-ref.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +#include <cassert> + +int main() { + int i = 1, j = 2; + const int& ci = i; + [&ci, &j] () -> void { j = ci; } (); + assert(i == 1); + assert(j == 1); + //[&ci] () -> void { ci = 0; } (); { dg-error: cannot assign to const int& } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C new file mode 100644 index 000000000..7e7541ca2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const-neg.C @@ -0,0 +1,19 @@ +// { dg-options "-std=c++0x" } + +#include <cassert> + +template<typename F> +void call(const F& f) { f(); } + +int main() { + call([] () -> void {}); + call([] () mutable -> void {}); + + int i = -1; + call([&i] () -> void { i = 0; }); + assert(i == 0); + call([i] () -> void { i = 0; }); // { dg-error "" "assignment to non-reference capture in const lambda" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C new file mode 100644 index 000000000..5f6f0b3dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <cassert> + +template<typename F> +void call(const F& f) { f(); } + +int main() { + call([] () -> void {}); + //call([] () mutable -> void {}); // { dg-error: "`f' does not have const `operator()'" } + + int i = -1; + call([&i] () -> void { i = 0; }); + assert(i == 0); + //call([i] () -> void { i = 0; }); // { dg-error: "assignment to non-reference capture in const lambda" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv.C new file mode 100644 index 000000000..5409d5ca3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv.C @@ -0,0 +1,14 @@ +// Test for conversion from stateless lambda to function pointer. + +// { dg-options -std=c++0x } +// { dg-final { scan-assembler "weak\[^\n\r\]*_?_ZZ1fvENKUlvE_cvPFvvEEv" { target { ! { *-*-darwin* *-*-mingw* *-*-cygwin *-*-hpux10* } } } } } + +inline void f() +{ + void (*pfn)() = []{}; +} + +int main() +{ + f(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv2.C new file mode 100644 index 000000000..fc19c9969 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv2.C @@ -0,0 +1,12 @@ +// Test for conversion from stateless lambda to function pointer. + +// { dg-options -std=c++0x } +// { dg-do run } + +typedef int (*pfn)(int); + +int main() +{ + pfn p = [](int i) { return i-42; }; + return p (42); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv3.C new file mode 100644 index 000000000..e4e7daffd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv3.C @@ -0,0 +1,12 @@ +// Conversion to a function pointer uses a generic thunk, which doesn't +// work properly for variadics. Make sure that we can still use the lambda +// normally. + +// { dg-options -std=c++0x } + +void f() +{ + auto l = [](...){}; + void (*p1)(...) = l; // { dg-bogus "sorry" "" { xfail *-*-* } } + l(); // OK +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv4.C new file mode 100644 index 000000000..6584d28b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv4.C @@ -0,0 +1,13 @@ +// PR c++/43641 +// { dg-options "-std=c++0x" } + +struct B +{ + int i; +}; + +void func() +{ + [](const B& b) -> const int& { return b.i; }; + [](const B& b) { return b; }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C new file mode 100644 index 000000000..53d8e995e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv5.C @@ -0,0 +1,15 @@ +// PR c++/45080 +// { dg-options -std=c++0x } + +typedef void(*pfn)(); + +template<typename=int> +void f() +{ + pfn fn = []{}; +} + +void test() +{ + f(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-default-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-default-neg.C new file mode 100644 index 000000000..1af2a95d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-default-neg.C @@ -0,0 +1,13 @@ +// { dg-options "-std=c++0x" } + +int main() { + int i; + const char* s; + [=] () -> void { i; s; i; s; } (); + + [] () -> void { i; } (); // { dg-error "" "`i' is not captured" } + [1] () -> void {} (); // { dg-error "expected identifier" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-default.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-default.C new file mode 100644 index 000000000..239a99cbf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-default.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +int main() { + int i; + const char* s; + [=] () -> void { i; s; i; s; } (); + + //[] () -> void { i; } (); // { dg-error: "`i' is not in scope" } + //[1] () -> void {} (); // { dg-error: "expected identifier" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-neg.C new file mode 100644 index 000000000..d77e57e63 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy-neg.C @@ -0,0 +1,13 @@ +// { dg-options "-std=c++0x" } + +int main() { + int i; + const char* s; + [i, s] () -> void { i; s; } (); + + [] () -> void { i; } (); // { dg-error "" "`i' is not captured" } + [1] () -> void {} (); // { dg-error "expected identifier" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy.C new file mode 100644 index 000000000..7356872e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-copy.C @@ -0,0 +1,14 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +int main() { + int i; + const char* s; + [i, s] () -> void { i; s; } (); + + //[] () -> void { i; } (); // { dg-error: "`i' is not in scope" } + //[1] () -> void {} (); // { dg-error: "expected identifier" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ctor-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ctor-neg.C new file mode 100644 index 000000000..76ed7445f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ctor-neg.C @@ -0,0 +1,25 @@ +// { dg-options -std=c++0x } + +void f() +{ + int i; + auto lam = [i]{}; // { dg-message "" } + decltype(lam) lam2 = { 1 }; // { dg-error "" "not an aggregate" } + decltype(lam) lam3; // { dg-error "" "deleted default ctor" } + lam3 = lam; // { dg-error "" "deleted assignment op" } +} + +template <class T> +void g(T i) +{ + auto lam = [i]{}; // { dg-message "" } + decltype(lam) lam2 = { 1 }; // { dg-error "" "not an aggregate" } + decltype(lam) lam3; // { dg-error "" "deleted default ctor" } + lam3 = lam; // { dg-error "" "deleted assignment op" } +} + +int main() +{ + f(); + g(1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ctors.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ctors.C new file mode 100644 index 000000000..e263145b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ctors.C @@ -0,0 +1,18 @@ +// { dg-options -std=c++0x } +// { dg-do run } + +struct A +{ + A() { } + A(A&) { } + A(A&&) { } +}; + +int main() +{ + A a; + auto lam4 = [a]{}; // OK, implicit move ctor + lam4(); + auto lam5 = lam4; // OK, implicit copy ctor + lam5(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-debug.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-debug.C new file mode 100644 index 000000000..07fc1896c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-debug.C @@ -0,0 +1,15 @@ +// PR c++/43502 +// { dg-options "-std=c++0x -fcompare-debug" } + +void g (int n) +{ + int bef ([]{return 0;}()); +} +struct S { + void f (int = []{return 0;}(), int = [] { return 0;}()); +}; +int main () +{ + S ().f (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg.C new file mode 100644 index 000000000..bfe7acab6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg.C @@ -0,0 +1,24 @@ +// Testcase for an extension to allow return type deduction when the lambda +// contains more than just a single return-statement. + +// { dg-options -std=c++0x } + +bool b; +template <class T> +T f (T t) +{ + return [=] + { + auto i = t+1; + if (b) + return i+1; + else + return i+2; // { dg-error "lambda return type" } + }(); +} + +int main() +{ + if (f(1) != 3) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg2.C new file mode 100644 index 000000000..a236e6d11 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext-neg2.C @@ -0,0 +1,22 @@ +// Test that in pedantic mode, we warn about the extension to allow return +// type deduction when the lambda contains more than just a single +// return-statement. + +// { dg-options "-std=c++0x -pedantic" } + +bool b; +template <class T> +T f (T t) +{ + [=] { return t+1; }; // OK + return [=] { + auto i = t+1; + return i+1; // { dg-warning "only statement" } + }(); +} + +int main() +{ + if (f(1) != 3) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext.C new file mode 100644 index 000000000..9b5ab7983 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-ext.C @@ -0,0 +1,27 @@ +// Testcase for an extension to allow return type deduction when the lambda +// contains more than just a single return-statement. + +// { dg-options -std=c++0x } +// { dg-do run } + +bool b; +template <class T> +T f (T t) +{ + return [=] { + auto i = t+1; + if (b) + return i+1; + else + return i+1; + }(); +} + +int main() +{ + // Pointless, but well-formed. + [] { return 1; return 2; }(); + + if (f(1) != 3) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-neg.C new file mode 100644 index 000000000..4abdf59a6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce-neg.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++0x" } +#include <cassert> + +int main() { + int i = 0; + int& r = [&] () { return i; } (); // { dg-error "" "invalid initialization of non-const reference of type .int&. from a temporary of type .int." } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce.C new file mode 100644 index 000000000..cc5cc5402 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce.C @@ -0,0 +1,29 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +#include <cassert> + +int main() { + [] {}; + [] {} (); + [] () {}; + [] () {} (); + [] () { return "lambda"; }; + + int i = 1, j = 2; + [&i, j] () { i = j; } (); + assert(i == 2); + assert(j == 2); + + i = [] () { return 3; } (); + assert(i == 3); + + int k = [&] () { return i; } (); + + []{ return; }; + + int array[] = { 1, 2, 3 }; + int* p = [&] () { return array; } (); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C new file mode 100644 index 000000000..718d49cd9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-deduce2.C @@ -0,0 +1,7 @@ +// PR c++/43875 +// { dg-options "-std=c++0x" } + +int main() +{ + auto x2 = []{ return { 1, 2 }; }; // { dg-message "return" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C new file mode 100644 index 000000000..069935823 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x -pedantic-errors" } + +int main() +{ + [](int a = 1) { return a; }(); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg2.C new file mode 100644 index 000000000..f47c5ba27 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg2.C @@ -0,0 +1,7 @@ +// PR c++/43886 +// { dg-options -std=c++0x } + +void f2() { + int i = 1; + void g5(int = ([]{ return sizeof i; })()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-direct-init.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-direct-init.C new file mode 100644 index 000000000..bbc2a1ca5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-direct-init.C @@ -0,0 +1,14 @@ +// Test that capture by copy uses direct-initialization. +// { dg-options "-std=c++0x" } + +struct A +{ + A(); + explicit A(const A&); +}; + +int main() +{ + A a; + [a]{}; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C new file mode 100644 index 000000000..ea5060d1a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C @@ -0,0 +1,35 @@ +// Test that we properly clean up if we get an exception in the middle of +// constructing the closure object. +// { dg-options -std=c++0x } + +// This test fails because of PR 41449; it isn't a lambda issue. +// { dg-do run { xfail *-*-* } } + +struct A +{ + A() {} + A(const A&) { throw 1; } +}; + +int bs; +struct B +{ + B() { ++bs; } + B(const B&) { ++bs; } + ~B() { --bs; } +}; + +int main() +{ + { + B b1, b2; + A a; + + try + { + [b1, a, b2]{ }; + } + catch(...) {} + } + return bs; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C new file mode 100644 index 000000000..0c94b554f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C @@ -0,0 +1,17 @@ +// PR c++/47263 +// PR c++/49260 +// { dg-options "-std=c++0x -fno-asynchronous-unwind-tables -fno-dwarf2-cfi-asm" } +// { dg-do run } + +#include <exception> + +int main( void ) +{ + std::set_unexpected( []{ throw 0; } ); + try + { + []() throw( int ) { throw nullptr; }(); + } + catch( int ) + { } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc.C new file mode 100644 index 000000000..f4766691e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc.C @@ -0,0 +1,18 @@ +// Test that error messages about creating the closure object refer to +// the lambda-introducer. +// { dg-options -std=c++0x } + +struct A +{ + A(); + A(const A& a) = delete; // { dg-error "declared" } +}; + +int main() +{ + A ar[4][3]; + [ar] { }; // { dg-error "3:" } + + A a; + [a] { }; // { dg-error "3:" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc2.C new file mode 100644 index 000000000..dab53f127 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-errloc2.C @@ -0,0 +1,19 @@ +// PR c++/42399 +// { dg-options "-std=c++0x" } + +struct A { + A(); + A(const A&) = delete; // { dg-error "declared" } +}; + +template <class T> +void f() +{ + T t; + [t] { return 0; }; // { dg-error "use" } +} + +int main() +{ + f<A>(); // { dg-message "instantiated" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-field-names.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-field-names.C new file mode 100644 index 000000000..b292d8898 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-field-names.C @@ -0,0 +1,21 @@ +// "For each entity captured by copy, an unnamed non-static data member is +// declared in the closure type" -- test that there isn't a member of the +// closure with the same name as the captured variable. + +// { dg-options -std=c++0x } + +template <class T> +struct A: public T +{ + A(T t): T(t) { } + int f() { return this->i; } // { dg-error "" "no member named i" } +}; + +int main() +{ + int i = 42; + auto lam = [i]{ }; + lam.i = 24; // { dg-error "" "no member named i" } + A<decltype(lam)> a(lam); + return a.f(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice1.C new file mode 100644 index 000000000..1ea8f4d7b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice1.C @@ -0,0 +1,13 @@ +// PR c++/43790 +// { dg-options "-std=c++0x" } + +struct A +{ + int f(); +}; + +int main() +{ + A a; + auto l = [] () { return a.f(); }; // { dg-error "not captured|return" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice2.C new file mode 100644 index 000000000..352137aad --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice2.C @@ -0,0 +1,16 @@ +// PR c++/42083 +// { dg-options "-std=c++0x" } + +template<typename F> +decltype(F()) run(F f) // { dg-message "note" } +{ + return f(); +} + +int main() +{ + auto l = []() { return 5; }; + + run(l); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 14 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C new file mode 100644 index 000000000..8ff36478d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice3.C @@ -0,0 +1,23 @@ +// PR c++/47795 +// { dg-options "-std=c++0x" } + +class Klass +{ + unsigned int local; +public: + bool dostuff(); +}; + +bool Klass::dostuff() +{ + auto f = []() -> bool { + if (local & 1) { return true; } // { dg-error "not captured" } + return false; + }; +} + +int main() +{ + Klass c; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice4.C new file mode 100644 index 000000000..77c773bbd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice4.C @@ -0,0 +1,14 @@ +// PR c++/47242 +// { dg-options "-std=c++0x" } + +template < typename > void +bar () +{ + [i]{}; // { dg-error "declared|invalid" } +} + +void +foo () +{ + bar<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-in-class-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-in-class-neg.C new file mode 100644 index 000000000..a93857e46 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-in-class-neg.C @@ -0,0 +1,35 @@ +// { dg-options "-std=c++0x" } + +#include <cassert> + +class C { + private: + int m_i; + + public: + C() : m_i(-1) { + [] { this; } (); // { dg-error "not captured" } + [this] () -> void { m_i = 0; } (); + assert(m_i == 0); + [this] () -> void { this->m_i = 1; } (); + assert(m_i == 1); + [&] () -> void { m_i = 2; } (); + assert(m_i == 2); + [&] () -> void { this->m_i = 3; } (); + assert(m_i == 3); + [=] () -> void { m_i = 4; } (); // copies 'this' or --copies-m_i--? + assert(m_i == 4); + [=] () -> void { this->m_i = 5; } (); + assert(m_i == 5); + } + +}; + +int main() { + C c; + + [this] () -> void {} (); // { dg-error "use of 'this' in non-member function" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-in-class.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-in-class.C new file mode 100644 index 000000000..33f4301e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-in-class.C @@ -0,0 +1,36 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <cassert> + +class C { + private: + int m_i; + + public: + C() : m_i(-1) { + //[] { this; } (); + [this] () -> void { m_i = 0; } (); + assert(m_i == 0); + [this] () -> void { this->m_i = 1; } (); + assert(m_i == 1); + [&] () -> void { m_i = 2; } (); + assert(m_i == 2); + [&] () -> void { this->m_i = 3; } (); + assert(m_i == 3); + [=] () -> void { m_i = 4; } (); // copies 'this' or --copies-m_i--? + assert(m_i == 4); + [=] () -> void { this->m_i = 5; } (); + assert(m_i == 5); + } + +}; + +int main() { + C c; + + //[this] () -> void {} (); // { dg-error: "cannot capture `this' outside of class method" } + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-init.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-init.C new file mode 100644 index 000000000..03c94e959 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-init.C @@ -0,0 +1,8 @@ +// Test for the explicit initializer extension +// { dg-options "-std=c++0x" } + +int main() +{ + int j = [i = 2]{sizeof(i); return i;}(); + return (j != 2); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-lookup-neg.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-lookup-neg.C new file mode 100644 index 000000000..e07e892a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-lookup-neg.C @@ -0,0 +1,7 @@ +// Test that we don't crash on a failed lookup. +// { dg-options -std=c++0x } + +int main() +{ + [i]{}; // { dg-error "not declared" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C new file mode 100644 index 000000000..5c9b483d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C @@ -0,0 +1,103 @@ +// Test lambda mangling +// { dg-require-weak "" } +// { dg-options "-std=c++0x -fno-inline" } + +template<typename F> int algo(F fn) { return fn(); } +inline void g(int n) { + int bef(int i = []{ return 1; }()); + // Default arguments of block-extern function declarations + // remain in the context of the encloding function body. + // The closure type is encoded as Z1giEUlvE_. + // The call operator of that type is _ZZ1giENKUlvE_clEv. + +// { dg-final { scan-assembler "_ZZ1giENKUlvE_clEv" } } +// { dg-final { scan-assembler "weak\[^\n\r\]*_?_ZZ1giENKUlvE_clEv" { target { ! { *-*-darwin* *-*-mingw* *-*-cygwin } } } } } + + algo([=]{return n+bef();}); + // The captured entities do not participate in <lambda-sig> + // and so this closure type has the same <lambda-sig> as + // the previous one. It encoding is therefore Z1giEUlvE0_ + // and the call operator is _ZZ1giENKUlvE0_clEv. The + // instance of "algo" being called is then + // _Z4algoIZ1giEUlvE0_EiT_. + +// { dg-final { scan-assembler "_Z4algoIZ1giEUlvE0_EiT_" } } +// { dg-final { scan-assembler "_ZZ1giENKUlvE0_clEv" } } + + int i = []{return 1;}(); + +} + +struct S { + void f(int = + // Type: ZN1S1fEiiEd0_UlvE_ + // Operator: _ZZN1S1fEiiEd0_NKUlvE_clEv +// { dg-final { scan-assembler "_ZZN1S1fEiiEd0_NKUlvE_clEv" } } +// { dg-final { scan-assembler "weak\[^\n\r\]*_?_ZZN1S1fEiiEd0_NKUlvE_clEv" { target { ! { *-*-darwin* *-*-mingw* *-*-cygwin } } } } } + []{return 1;}() + // Type: ZN1S1fEiiEd0_UlvE0_ + // Operator: _ZZN1S1fEiiEd0_NKUlvE0_clEv +// { dg-final { scan-assembler "_ZZN1S1fEiiEd0_NKUlvE0_clEv" } } + + []{return 2;}(), + int = + // Type: ZN1S1fEiiEd_UlvE_ + // Operator: _ZZN1S1fEiiEd_NKUlvE_clEv +// { dg-final { scan-assembler "_ZZN1S1fEiiEd_NKUlvE_clEv" } } + []{return 3;}()); +}; + +template<typename T> struct R { + static int x; +}; +template<typename T> int R<T>::x = []{return 1;}(); +template int R<int>::x; +// Type of lambda in intializer of R<int>::x: N1RIiE1xMUlvE_E +// Corresponding operator(): _ZNK1RIiE1xMUlvE_clEv +// { dg-final { scan-assembler "_ZNK1RIiE1xMUlvE_clEv" } } +// { dg-final { scan-assembler "weak\[^\n\r\]*_?_ZNK1RIiE1xMUlvE_clEv" { target { ! { *-*-mingw* *-*-cygwin } } } } } + +void bar() +{ + // lambdas in non-vague linkage functions have internal linkage. + // { dg-final { scan-assembler-not "weak\[^\n\r\]*bar\[^\n\r\]*Ul" } } + []{}(); +} + +// lambdas used in non-template, non-class body initializers are internal. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*_ZNKUlv" } } +// { dg-final { scan-assembler-not "weak\[^\n\r\]*variable" } } +int variable = []{return 1;}(); + +// And a template instantiated with such a lambda is also internal. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*algoIUl" } } +int var2 = algo([]{return 1;}); + +// As are lambdas used in non-class-body default arguments. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*function" } } +void function (int i = []{return 1;}()+[]{return 1;}()); + +struct Foo +{ + static int Int; + void Bar(int); +}; + +int Foo::Int = []{return 1;}(); +// Even default arguments for member functions that appear outside the +// class body are internal. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*Foo" } } +void Foo::Bar(int i = []{return 1;}()) {} + +// Even default arguments for function templates. +// { dg-final { scan-assembler-not "weak\[^\n\r\]*fn2\[^\n\r\]*Ulv" } } +template <class T> +void fn2 (T t = []{return 1;}()) {} + +int main() +{ + g(42); + S().f(); + function(); + Foo().Bar(); + fn2<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle2.C new file mode 100644 index 000000000..4b7d15ad9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle2.C @@ -0,0 +1,21 @@ +// PR c++/49276 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <int N> +struct F +{ + template <typename U> F (U); +}; + +struct S +{ + void foo (F <0> x = [] {}) {} +}; + +int +main () +{ + S s; + s.foo (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mixed.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mixed.C new file mode 100644 index 000000000..ed0565fa9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mixed.C @@ -0,0 +1,13 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +#include <cassert> + +int main() { + int i = 1, j = 2; + [&i, j] () mutable -> void { i = 0; j = 0; } (); + assert(i == 0); + assert(j == 2); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mutable.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mutable.C new file mode 100644 index 000000000..73a4d1bac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mutable.C @@ -0,0 +1,16 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +#include <cassert> + +int main() { + int i = 1; + const char* s1 = "hello"; + const char* s2 = s1; + [i, s2] () mutable -> void { i = 2; s2 = "world"; } (); + //[i, s2] () -> void { i = 2; s2 = "world"; } (); // { dg-error: "assignment of data-member in read-only structure" } + assert(i == 1); + assert(s1 == s2); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested.C new file mode 100644 index 000000000..feb0cde59 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested.C @@ -0,0 +1,63 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <cassert> + +struct A { + int i; + A(): i(42) { } + int f() { + return [this]{ + return [=]{ return i; }(); + }(); + } +}; + +int main() { + int i = 1; + + [] (int& i) -> void { + [&] () -> void { + i = 2; + } (); + } (i); + + assert(i == 2); + + [&] () -> void { + [&i] () -> void { + i = 3; + } (); + } (); + + assert(i == 3); + + [&] () -> void { + [&] () -> void { + i = 4; + } (); + } (); + + assert(i == 4); + i = 4; + + [&] () -> void { + [=] () mutable -> void { + i = 5; + } (); + } (); + + assert(i == 4); + + [=] () mutable -> void { + [&] () -> void { + i = 6; + } (); + } (); + + assert(i == 4); + + assert (A().f() == 42); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested2.C new file mode 100644 index 000000000..b78874855 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested2.C @@ -0,0 +1,31 @@ +// Testcase from N2998 +// { dg-options -std=c++0x } + +void f1(int i) { + int const N = 20; + auto m1 = [=]{ + int const M = 30; + auto m2 = [i]{ + int x[N][M]; // OK: N and M are not "used" + x[0][0] = i; // OK: i is explicitly captured by m2 + // and implicitly captured by m1 + }; + }; + struct s1 { + int f; + int work(int n) { + int m = n*n; + int j = 40; + auto m3 = [this,m]{ + /*auto m4=*/[&,j]{ // { dg-error "j. is not captured" } + int x = n; // { dg-error "n. is not captured" } + x += m; // OK: m implicitly captured by m4 + // and explicitly captured by m3 + x += i; // { dg-error "i. is not captured" } + x += f; // OK: this captured implicitly by m4 + // and explicitly by m3 + }; + }; + } + }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C new file mode 100644 index 000000000..2cc6f9640 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C @@ -0,0 +1,12 @@ +// PR c++/41896 +// { dg-options "-std=c++0x" } + +void nested_lambda() +{ + float val; + + [val]() + { + [val](){}; + }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-non-const.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-non-const.C new file mode 100644 index 000000000..b6489de4b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-non-const.C @@ -0,0 +1,19 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <cassert> + +template<typename F> +void call(F f) { f(); } + +int main() { + call([] () -> void {}); + call([] () mutable -> void {}); + + int i = -1; + call([i] () mutable -> void { i = 0; }); + assert(i == -1); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nop.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nop.C new file mode 100644 index 000000000..74149b231 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nop.C @@ -0,0 +1,19 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +#include <cassert> + +int main() { + int i = 1, j = 2; + [i, j] () -> void {} (); + assert(i == 1); + assert(j == 2); + [&i, &j] () -> void {} (); + assert(i == 1); + assert(j == 2); + [] (int x) -> void {} (1); + [] (int& x) -> void {} (i); + [] (int x, int y) -> void {} (i, j); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ns-scope.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ns-scope.C new file mode 100644 index 000000000..cde0c2e53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ns-scope.C @@ -0,0 +1,18 @@ +// { dg-options -std=c++0x } +// { dg-do run } + +auto f = [](int i) { return i+1; }; + +int g(int i = [] { return 237; }()) +{ + return i; +} + +int main() +{ + if (f(41) != 42) + return 1; + if (g() != 237) + return 2; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-pass.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-pass.C new file mode 100644 index 000000000..9dd64484a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-pass.C @@ -0,0 +1,27 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <cassert> +#include <algorithm> + +template <typename F, typename A1> +void call(F f, const A1& arg1) { + f(arg1); +} + +int main() { + int i = 1; + call( + [&i] (int j) -> void { i = j; }, + 2 + ); + assert(i == 2); + + int A[] = {1, 2, 3, 4}; + int sum = 0; + std::for_each(A, A+4, [&sum] (int n) -> void { sum += n; }); + assert(sum == 10); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-qualified.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-qualified.C new file mode 100644 index 000000000..ef041c2bb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-qualified.C @@ -0,0 +1,17 @@ +// PR c++/50089 +// { dg-options -std=c++0x } + +struct TestBase +{ + void foo() {} +}; + +struct Test : TestBase +{ + void foo() + { + [this]{ + /*this->*/TestBase::foo(); // ICE without this-> + }(); + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-recursive.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-recursive.C new file mode 100644 index 000000000..1a12eab31 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-recursive.C @@ -0,0 +1,21 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +//#include <iostream> +#include <functional> +#include <cassert> + +int main() { + + std::function<int(int)> fib = [&fib] (int n) -> int { + //std::cerr << "fib(" << n << ")\n"; + if (n <= 2) return 1; + else return fib(n-1) + fib(n-2); + }; + + assert(fib(5) == 5); + assert(fib(10) == 55); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref-default.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref-default.C new file mode 100644 index 000000000..40376f43d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref-default.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <cassert> + +int main() { + int i = 1; + float j = 2.0; + [&] () -> void { i = 3; j = 4.0; } (); + assert(i == 3); + assert(j == 4.0); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref.C new file mode 100644 index 000000000..a5ee7b4c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref.C @@ -0,0 +1,15 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <cassert> + +int main() { + int i = 1; + float j = 2.0; + [&i, &j] () -> void { i = 3; j = 4.0; } (); + assert(i == 3); + assert(j == 4.0); + + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C new file mode 100644 index 000000000..15f1d9034 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref2.C @@ -0,0 +1,13 @@ +// PR c++/49598 +// { dg-options -std=c++0x } +// { dg-do run } + +int +main() +{ + int i = 10; + int& ir = i; + + if ([=]{ return ir; }() != 10) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-std-function.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-std-function.C new file mode 100644 index 000000000..26c09fdb1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-std-function.C @@ -0,0 +1,22 @@ +// Test using std::function wrapper. +// { dg-do run } +// { dg-options -std=c++0x } + +#include <functional> + +typedef std::function<int()> FN; + +template<typename T> +FN f(T fn) +{ + return [fn]{return fn(2);}; +} + +int main() +{ + auto fn = f([](int i){return i*21;}); + + if (fn() != 42) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C new file mode 100644 index 000000000..b4db3b881 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template.C @@ -0,0 +1,41 @@ +// { dg-options -std=c++0x } +// { dg-do run } + +extern "C" void abort(); + +template <class T> +auto apply (T t) -> decltype (t()) +{ + return t(); +} + +template <class T> +T f(T t) +{ + T t2 = t; + if (t != [=]()->T { return t; }()) + abort (); + if (t != [=] { return t; }()) + abort (); + if (t != [=] { return t2; }()) + abort (); + if (t != [&] { return t; }()) + abort (); + if (t != apply([=]{return t;})) + abort (); + + int i; + [&] (int a) { return a+i+t; } (0); + [&] (int a) -> decltype(a) { return a+i+t; } (0); + [&] (int a) -> decltype(i) { return a+i+t; } (0); + [&] (int a) -> decltype(t) { return a+i+t; } (0); + [&] (int a) -> decltype(a+i) { return a+i+t; } (0); + [&] (int a) -> decltype(a+t) { return a+i+t; } (0); + [&] (int a) -> decltype(i+t) { return a+i+t; } (0); + [&] (int a) -> decltype(a+i+t) { return a+i+t; } (0); +} + +int main() +{ + f(0xbeef); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template2.C new file mode 100644 index 000000000..12ffde724 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template2.C @@ -0,0 +1,20 @@ +// PR c++/47049 +// { dg-options -std=c++0x } + +enum { E = 0, F = 1 }; +template <int N, int M = ((N == 1) ? F : E)> class S {}; +template <int N> +struct T +{ + static void + foo (S<N> *p) + { + S<N> u; + [&u] ()->bool {} (); + } +}; + +int main() +{ + T<0>().foo(0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this.C new file mode 100644 index 000000000..ed2747654 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this.C @@ -0,0 +1,13 @@ +// Test that implicit 'this' capture works, but that it's still an rvalue. +// { dg-options -std=c++0x } + +struct A +{ + int i; + void f() + { + [=] { i = 0; }; + [&] { i = 0; }; + [=] { this = 0; }; // { dg-error "lvalue" } + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C new file mode 100644 index 000000000..04fe474c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this2.C @@ -0,0 +1,17 @@ +// PR c++/43856 +// Test for implicit 'this' capture via rewriting. +// { dg-options "-std=c++0x" } + +struct S1 { + int operator()(int); + int i; + void g(); + void f() { + [=]() { + i; + g(); + S1::g(); + operator()(42); + }; + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this3.C new file mode 100644 index 000000000..de0d357f3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this3.C @@ -0,0 +1,14 @@ +// PR c++/45520 +// { dg-options -std=c++0x } + +struct M { + int i; +}; + +struct S { + M m; + + void f() { + auto lambda=[&](decltype(m.i) & i) { }; + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C new file mode 100644 index 000000000..29cd2a97b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this4.C @@ -0,0 +1,13 @@ +// PR c++/48523 +// { dg-options -std=c++0x } + +template<typename> +struct X +{ + bool b; + + void f() + { + [this]{ return b; }; + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-type.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-type.C new file mode 100644 index 000000000..3b2a2a76a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-type.C @@ -0,0 +1,74 @@ +// Every id-expression that is a use (_basic.def.odr_ 3.2) of an entity +// captured by copy is transformed into an access to the corresponding +// unnamed data member of the closure type. +//... +// Every occurrence of decltype((x)) where x is a possibly parenthesized +// id-expression that names an entity of automatic storage duration is +// treated as if x were transformed into an access to a corresponding data +// member of the closure type that would have been declared if x were a use +// of the denoted entity. + +// So, other appearances of 'x' within decltype do not refer to the closure +// member, because they are not "use"s in the sense of 3.2. + +// { dg-options -std=c++0x } + +template<class T, class U> +struct same_type; +template <class T> +struct same_type<T,T> { }; + +int main() +{ + int i; + [=] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int const&>(); + i+1; + same_type<decltype((i)),int const&>(); + same_type<decltype(i),int>(); + }; + [=] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int const&>(); + same_type<decltype(i),int>(); + }; + [=] () mutable { + same_type<decltype(i),int>(); + same_type<decltype((i)),int &>(); + same_type<decltype(i),int>(); + }; + [&] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int &>(); + same_type<decltype(i),int>(); + }; + [i] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int const&>(); + }; + [&,i] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int const&>(); + }; + [i] () mutable { + same_type<decltype(i),int>(); + same_type<decltype((i)),int &>(); + }; + [&,i] () mutable { + same_type<decltype(i),int>(); + same_type<decltype((i)),int &>(); + }; + [&i] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int &>(); + }; + [=,&i] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int &>(); + }; + [] { + same_type<decltype(i),int>(); + same_type<decltype((i)),int const&>(); // { dg-error "" "not captured" } + }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-uneval.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-uneval.C new file mode 100644 index 000000000..33ba7b0a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-uneval.C @@ -0,0 +1,7 @@ +// 5.1.2/2: A lambda-expression shall not appear in an unevaluated operand. +// { dg-options "-std=c++0x" } + +template <class T> +struct A { }; +A<decltype([]{ return 1; }())> a; // { dg-error "lambda.*unevaluated context" } + diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use.C new file mode 100644 index 000000000..b1d6c300c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } + +int main(int argc, char** argv) +{ + int i; + int &ir = i; + const int ci = 0; + const int &cir = ci; + + [] { sizeof (argc); sizeof (i); sizeof (ir); sizeof (ci); sizeof (cir); }; + [] { int ia[ci]; }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use2.C new file mode 100644 index 000000000..695a0b432 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-use2.C @@ -0,0 +1,11 @@ +// PR c++/50224 +// { dg-options "-std=c++0x -Wunused-parameter" } + +struct T; + +void m(T& t) // ERROR here +{ + [&]{ + t; // ``t`` is referenced here + }; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic1.C new file mode 100644 index 000000000..f17b33618 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic1.C @@ -0,0 +1,15 @@ +// PR c++/49672 +// { dg-options -std=c++0x } + +template<typename ... Args> +static void foo() +{ + [](Args..., int x) { + x; + }; +} + +int main() +{ + foo(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn1.C new file mode 100644 index 000000000..b384d5cff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn1.C @@ -0,0 +1,8 @@ +// PR c++/41920 +// { dg-options "-std=c++0x -Wall -Wextra" } + +int foo(int i) +{ + auto bar = [=](){ return i; }; + return bar(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn2.C new file mode 100644 index 000000000..ce5e7c450 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn2.C @@ -0,0 +1,7 @@ +// PR c++/42370 +// { dg-options "-std=c++0x -Wall" } + +void foo() +{ + []{ return 0; }(); +} // { dg-bogus "no return statement" } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C new file mode 100644 index 000000000..77f35bc46 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-warn3.C @@ -0,0 +1,12 @@ +// PR c++/49482 +// { dg-options "-std=c++0x -Wunused-but-set-parameter" } + +template<class T> +void f() { + []( bool b ){ return b; }; +} + +int main() +{ + f<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/linkage2.C b/gcc/testsuite/g++.dg/cpp0x/linkage2.C new file mode 100644 index 000000000..f41c21a77 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/linkage2.C @@ -0,0 +1,33 @@ +// DR 743: A type without linkage shall not be used as the type of a +// variable or function with linkage, unless +// o the variable or function has extern "C" linkage (7.5 [dcl.link]), or +// o the variable or function is not used (3.2 [basic.def.odr]) or is +// defined in the same translation unit. + +// { dg-options -std=c++0x } + +template <typename T> struct B { + void g(T){} + void h(T); // { dg-error "never defined" } + friend void i(B, T){} + static T t1; // { dg-error "never defined" } + static T t2; +}; + +template <typename T> T B<T>::t2 = { }; + +enum {} e1; // OK, defined +extern enum {} e2; // { dg-error "never defined" } +extern "C" enum {} e3; // OK, extern "C" + +void f() { + struct A { int x; }; // no linkage + A a = {1}; + B<A> ba; // declares B<A>::g(A) and B<A>::h(A) + ba.t1 = a; // error, B<T>::t never defined + ba.t2 = a; // OK + ba.g(a); // OK + ba.h(a); // error, B<T>::h never defined + i(ba, a); // OK + e1+e2+e3; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/long_long.C b/gcc/testsuite/g++.dg/cpp0x/long_long.C new file mode 100644 index 000000000..3ef710df4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/long_long.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x -pedantic" } + +void foo() +{ + long long x = 17; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/move1.C b/gcc/testsuite/g++.dg/cpp0x/move1.C new file mode 100644 index 000000000..12e363a8c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/move1.C @@ -0,0 +1,15 @@ +// { dg-options "-std=c++0x -pedantic-errors" } + +#include <utility> + +class A { }; + +static void g ( A && ) { } + +template < class T > class B { +public: + void f ( ) { + A a; + g ( std :: move ( a ) ); + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/named.C b/gcc/testsuite/g++.dg/cpp0x/named.C new file mode 100644 index 000000000..ef1a2fb6f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/named.C @@ -0,0 +1,40 @@ +// { dg-options "--std=c++0x" } +// { dg-do link } + +template<typename _Tp> +inline _Tp&& +movel(_Tp& __t) +{ return static_cast<_Tp&&>(__t); } + +struct S {}; +struct T +{ + T(S && s_) : s(movel(s_)) {} + S && get() { return movel(s); } + operator S&&() { return movel(s); } + S && s; +}; + +void named(S const &) {} +void named(S&&); + +void unnamed(S const &); +void unnamed(S&&) {} + +void f(S && p) +{ + S && s(movel(p)); + T t(movel(s)); + + named(s); // variable reference + named(p); // parameter reference + named(t.s); // class member access + + unnamed(t.get()); // function return + unnamed(t); // implicit conversion + unnamed(static_cast<S&&>(s)); // cast to rvalue +} + +int main() +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/named_refs.C b/gcc/testsuite/g++.dg/cpp0x/named_refs.C new file mode 100644 index 000000000..697867e11 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/named_refs.C @@ -0,0 +1,28 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test: Named rvalue references are treated as lvalues. + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; + +struct A {}; + +one foo(const A&) {return one();} +two foo(A&&) {return two();} + +int test1(A&& a) +{ + sa<sizeof(foo(a)) == 1 * sizeof(long)> t1; + return 0; +} + +int main() +{ + return test1(A()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept01.C b/gcc/testsuite/g++.dg/cpp0x/noexcept01.C new file mode 100644 index 000000000..f314684ea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept01.C @@ -0,0 +1,83 @@ +// Test for noexcept-expression +// { dg-options "-std=c++0x -O2" } + +#include <typeinfo> + +#define SA(X) static_assert(X, #X) + +void f(); +void g() throw(); +SA(noexcept(g())); +SA(!noexcept(f())); +SA(!noexcept(throw 1)); +SA(noexcept(42)); + +struct A +{ + virtual ~A(); +}; + +struct B: public A +{ + virtual ~B(); +}; + +A* ap; + +struct C { }; +C* cp; + +SA (noexcept (dynamic_cast<B*>(ap))); +SA (!noexcept (dynamic_cast<B&>(*ap))); +SA (!noexcept (typeid (*ap))); +SA (noexcept (typeid (*cp))); + +SA (!noexcept (true ? 1 : throw 1)); +SA (!noexcept (true || true ? 1 : throw 1)); + +SA (noexcept (C())); + +struct D +{ + D() throw(); +}; + +SA (noexcept (D())); + +struct E +{ + E() throw(); + ~E(); +}; + +SA (!noexcept (E())); + +struct F +{ + virtual void f(); +}; + +SA (noexcept (F())); + +struct G +{ + G() = default; + ~G() = default; +}; + +SA (noexcept (G())); + +template <class T, bool b> +void tf() +{ + SA (noexcept (T()) == b); +} + +template void tf<int,true>(); +template void tf<E, false>(); + +// Make sure that noexcept uses the declared exception-specification, not +// any knowledge we might have about whether or not the function really +// throws. +void h() { } +SA(!noexcept(h())); diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept02.C b/gcc/testsuite/g++.dg/cpp0x/noexcept02.C new file mode 100644 index 000000000..ffbb09192 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept02.C @@ -0,0 +1,54 @@ +// Test for noexcept-specification +// { dg-options "-std=c++0x" } + +#define SA(X) static_assert(X, #X) + +void f(); +void f() noexcept(false); +void f() noexcept(1 == 0); +void f(); + +SA(!noexcept(f())); + +void g() throw (int); // { dg-error "previous declaration" } +void g() noexcept(false); // { dg-error "different exception" } +void g(); + +void h() throw(); +void h() noexcept; +void h() throw(); +void h() noexcept; + +template <class T> +void g (T) noexcept(noexcept(T())); // { dg-error "previous declaration" } +template <class T> +void g (T) noexcept(noexcept(T(0))); // { dg-error "different exception" } + +template <class T> +void f (T) noexcept(noexcept(T()) && noexcept(T())); +template <class T> +void f (T) noexcept(noexcept(T()) && noexcept(T())); +template <class T> +void f2(T a) noexcept (noexcept (f (a))); + +struct A { A(); }; +SA(noexcept(f(1))); +SA(!noexcept(f(A()))); +SA(noexcept(f2(1))); +SA(!noexcept(f2(A()))); + +template <class... Ts> +void f3(Ts... ts) noexcept (noexcept (f(ts...))); + +SA(noexcept(f3(1))); +SA(!noexcept(f3(A()))); + +template <class T1, class T2> +void f (T1, T2) noexcept(noexcept(T1(), T2())); + +struct B { }; + +SA(noexcept(f3(1,B()))); +SA(!noexcept(f3(1,A()))); +SA(!noexcept(f3(A(),1))); +SA(!noexcept(f3(A(),A()))); diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept03.C b/gcc/testsuite/g++.dg/cpp0x/noexcept03.C new file mode 100644 index 000000000..54e04f3d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept03.C @@ -0,0 +1,51 @@ +// Runtime test for noexcept-specification. +// { dg-options "-std=c++0x -Wnoexcept" } +// { dg-do run } + +#include <exception> +#include <cstdlib> + +void my_terminate () +{ + std::exit (0); +} + +void my_unexpected () +{ + throw; +} + +void g() { throw 1; } +void (*p)() = g; +void f () noexcept (false) +{ + p(); +} + +template <class T> +void f(T) noexcept (noexcept (T())) // { dg-warning "false" } +{ + p(); +} + +template <class T> +void f2(T a) noexcept (noexcept (f (a))) +{ + f(a); +} + +struct A { A() { } }; // { dg-warning "does not throw" } + +int main() +{ + // noexcept(false) allows throw. + try { f(); } catch (int) { } + // noexcept(noexcept(A())) == noexcept(false). + try { f(A()); } catch (int) { } + try { f2(A()); } catch (int) { } + + std::set_terminate (my_terminate); + // noexcept(noexcept(int())) == noexcept(true). + try { f2(1); } catch (...) { } + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept04.C b/gcc/testsuite/g++.dg/cpp0x/noexcept04.C new file mode 100644 index 000000000..8df818610 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept04.C @@ -0,0 +1,31 @@ +// Make sure that we call terminate when a noexcept spec is violated. +// The function pointers are there to make sure that +// the compiler doesn't get clever about optimizing the calls based on +// knowledge about the called functions. + +// { dg-options "-std=c++0x" } +// { dg-do run } + +#include <exception> +#include <cstdlib> + +void my_terminate () +{ + std::exit (0); +} + +void g() { throw 1; } +void (*p1)() = g; +void f() noexcept { p1(); } +void (*p2)() = f; +void h() { p2(); } + +int main() +{ + std::set_terminate (my_terminate); + + try { h(); } + catch (int) { } + + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept05.C b/gcc/testsuite/g++.dg/cpp0x/noexcept05.C new file mode 100644 index 000000000..6acea4327 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept05.C @@ -0,0 +1,19 @@ +// Make sure that we force an LSDA for a noexcept spec so +// that the personality routine will call terminate. Also check that we +// optimize away the EH cleanup for var because the personality routine +// will call terminate before unwinding: there should not be an EH region +// (i.e. LEHB/LEHE labels) around the call to g(). + +// { dg-final { scan-assembler-not "_ZSt9terminatev" } } +// { dg-final { scan-assembler-not "EHB" } } +// { dg-final { scan-assembler "LSDA" } } + +// { dg-options "-std=c++0x" } + +struct A { ~A(); }; +void g(); +void f() noexcept +{ + A var; + g(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept06.C b/gcc/testsuite/g++.dg/cpp0x/noexcept06.C new file mode 100644 index 000000000..3babdffda --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept06.C @@ -0,0 +1,30 @@ +// Test that checking of a nothrow specification uses the one on the +// definition. +// { dg-options "-std=c++0x" } +// { dg-do run } + +#include <exception> +#include <cstdlib> + +void my_unexpected () +{ + std::abort (); +} +void my_terminate () +{ + std::exit (0); +} + +void f() throw(); +void f() noexcept +{ + throw 1; +} + +int main() +{ + std::set_unexpected (my_unexpected); + std::set_terminate (my_terminate); + f(); + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept07.C b/gcc/testsuite/g++.dg/cpp0x/noexcept07.C new file mode 100644 index 000000000..0a5773fc8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept07.C @@ -0,0 +1,25 @@ +// Test that checking of a nothrow specification uses the one on the +// definition. +// { dg-options "-std=c++0x" } +// { dg-do run } + +#include <exception> +#include <cstdlib> + +void my_unexpected () +{ + std::exit (0); +} + +void f() noexcept; +void f() throw() +{ + throw 1; +} + +int main() +{ + std::set_unexpected (my_unexpected); + f(); + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept08.C b/gcc/testsuite/g++.dg/cpp0x/noexcept08.C new file mode 100644 index 000000000..1df85efff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept08.C @@ -0,0 +1,56 @@ +// { dg-options "-std=c++0x" } +// { dg-prune-output "overriding" } + +struct A +{ + virtual void f(); + virtual void g() throw(); + virtual void h() noexcept; + virtual void i() noexcept(false); + virtual void j() throw(int); +}; + +struct B: A +{ + void f() noexcept; + void g() noexcept; + void h() noexcept; + void i() noexcept; + void j() noexcept; +}; + +struct C: A +{ + void f() throw(); + void g() throw(); + void h() throw(); + void i() throw(); + void j() throw(); +}; + +struct D: A +{ + void f() noexcept(false); + void g() noexcept(false); // { dg-error "looser" } + void h() noexcept(false); // { dg-error "looser" } + void i() noexcept(false); + void j() noexcept(false); // { dg-error "looser" } +}; + +struct E: A +{ + void f() throw(int); + void g() throw(int); // { dg-error "looser" } + void h() throw(int); // { dg-error "looser" } + void i() throw(int); + void j() throw(int); +}; + +struct F: A +{ + void f(); + void g(); // { dg-error "looser" } + void h(); // { dg-error "looser" } + void i(); + void j(); // { dg-error "looser" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept09.C b/gcc/testsuite/g++.dg/cpp0x/noexcept09.C new file mode 100644 index 000000000..2a4525cbd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept09.C @@ -0,0 +1,14 @@ +// Test that -Wnoexcept works with templates +// { dg-options "-std=c++0x -Wnoexcept" } + +template <class T> +T f (T t) { return t; } // { dg-warning "does not throw" } + +#define SA(X) static_assert(X, #X) + +SA (!noexcept(f(1))); // { dg-warning "noexcept" } + +int main() +{ + f(1); // Use f(int) so it gets instantiated +} diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept10.C b/gcc/testsuite/g++.dg/cpp0x/noexcept10.C new file mode 100644 index 000000000..058a387d7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept10.C @@ -0,0 +1,27 @@ +// PR c++/49082 +// { dg-options -std=c++0x } + +namespace std { template <class T> T&& declval() noexcept; } + +struct Base +{ + Base(const Base&) noexcept(false); + Base(Base&&) noexcept(false); + ~Base() noexcept(false); +}; + +struct Derived +: Base +{ + // Derived(const Derived&) = default; + // Derived(Derived&&) = default; +}; + +static_assert(!noexcept(Base(std::declval<const Base&>())), "Error"); +static_assert(!noexcept(Derived(std::declval<const Derived&>())), "Error"); // Error + +static_assert(!noexcept(Base(std::declval<Base&&>())), "Error"); +static_assert(!noexcept(Derived(std::declval<Derived&&>())), "Error"); // Error + +static_assert(!noexcept(std::declval<Base&>().~Base()), "Error"); // OK +static_assert(!noexcept(std::declval<Derived&>().~Derived()), "Error"); // Error diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept11.C b/gcc/testsuite/g++.dg/cpp0x/noexcept11.C new file mode 100644 index 000000000..eba2c4080 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept11.C @@ -0,0 +1,4 @@ +// PR c++/50309 +// { dg-options -std=c++0x } + +void foo () noexcept () { } // { dg-error "expected" } diff --git a/gcc/testsuite/g++.dg/cpp0x/nolinkage1.C b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.C new file mode 100644 index 000000000..b69b6ddc4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.C @@ -0,0 +1,22 @@ +// DR 757 allows using types without linkage in declarations with linkage. +// Test that this doesn't lead to link-time collisions. + +// { dg-additional-sources "nolinkage1a.cc" } +// { dg-do link } +// { dg-options -std=c++0x } + +#include "nolinkage1.h" + +typedef struct { int i; } *AP; + +void f(AP) { } + +A<AP> a; + +static void g() +{ + struct B { }; + A<B> a; +} + +int main() { g(); f(0); } diff --git a/gcc/testsuite/g++.dg/cpp0x/nolinkage1.h b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.h new file mode 100644 index 000000000..3cb5f63b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.h @@ -0,0 +1,8 @@ +template <class T> +struct A +{ + A(); +}; + +template <class T> +A<T>::A() { } diff --git a/gcc/testsuite/g++.dg/cpp0x/nolinkage1a.cc b/gcc/testsuite/g++.dg/cpp0x/nolinkage1a.cc new file mode 100644 index 000000000..f8528f3e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nolinkage1a.cc @@ -0,0 +1,15 @@ +#include "nolinkage1.h" + +typedef struct { double d; } *BP; + +void f(BP) { } + +A<BP> b; + +static void g() +{ + struct B { }; + A<B> a; +} + +int dummy() { g(); f(0); } diff --git a/gcc/testsuite/g++.dg/cpp0x/not_special.C b/gcc/testsuite/g++.dg/cpp0x/not_special.C new file mode 100644 index 000000000..6d73bd086 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/not_special.C @@ -0,0 +1,52 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test that move constructor and move assignement are special. +// That is, their presence should inhibit compiler generated +// copy ctor or assignment. + +// { dg-options "-std=c++0x" } + +#include <assert.h> + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; + +int copy = 0; +int assign = 0; + +struct base +{ + base() {} + base(const base&) {++copy;} + base& operator=(const base&) {++assign; return *this;} +}; + +struct derived + : base +{ + derived() {} + derived(derived&&) {} // { dg-error "argument 1" } + derived& operator=(derived&&) {return *this;} // { dg-error "argument 1" } +}; + +int test1() +{ + derived d; + derived d2(static_cast<derived&&>(d)); // should not call base::(const base&) + assert(copy == 0); + derived d3(d); // { dg-error "lvalue" } + assert(copy == 1); + d2 = static_cast<derived&&>(d); // should not call base::operator= + assert(assign == 0); + d3 = d; // { dg-error "lvalue" } + assert(assign == 1); + return 0; +} + +int main() +{ + return test1(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr01.C b/gcc/testsuite/g++.dg/cpp0x/nullptr01.C new file mode 100644 index 000000000..de3860c9e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr01.C @@ -0,0 +1,10 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test assignment to pointer + +char* const cp1 = nullptr; +char* const cp2 = __null; +char* const cp3 = 0; +decltype(nullptr) mynull = 0; +char* const cp4 = mynull; diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr02.C b/gcc/testsuite/g++.dg/cpp0x/nullptr02.C new file mode 100644 index 000000000..80977cb2f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr02.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test assignment to nullptr_t + +typedef decltype(nullptr) nullptr_t; + +const nullptr_t np1 = nullptr; +const nullptr_t np2 = __null; +const nullptr_t np3 = 0; +const nullptr_t np4 = np1; +const nullptr_t np5 = np2; +const nullptr_t np6 = np3; +const nullptr_t np7 = np4; +const nullptr_t np8 = np5; +const nullptr_t np9 = np6; diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr03.C b/gcc/testsuite/g++.dg/cpp0x/nullptr03.C new file mode 100644 index 000000000..b6df89637 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr03.C @@ -0,0 +1,9 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test assignment to int + +const int n1 = nullptr; // { dg-error "cannot convert " } +decltype(nullptr) mynull = 0; +const int n2 = mynull; // { dg-error "cannot convert " } + diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr04.C b/gcc/testsuite/g++.dg/cpp0x/nullptr04.C new file mode 100644 index 000000000..be581bcb6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr04.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test cast to int + +__extension__ typedef __INTPTR_TYPE__ intptr_t; + +const int n4 = static_cast<const int>(nullptr); // { dg-error "invalid static_cast " } +const short int n5 = reinterpret_cast<short int>(nullptr); // { dg-error "loses precision" } +const intptr_t n6 = reinterpret_cast<intptr_t>(nullptr); +const intptr_t n7 = (intptr_t)nullptr; + +decltype(nullptr) mynull = 0; +const int n8 = static_cast<const int>(mynull); // { dg-error "invalid static_cast " } +const short int n9 = reinterpret_cast<short int>(mynull); // { dg-error "loses precision" } +const intptr_t n10 = reinterpret_cast<intptr_t>(mynull); +const intptr_t n11 = (intptr_t)mynull; diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr05.C b/gcc/testsuite/g++.dg/cpp0x/nullptr05.C new file mode 100644 index 000000000..22a8b51c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr05.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test assignment to method pointer + +class F { }; + +typedef void (F::*pmf)(); + +const pmf pmf1 = nullptr; +const pmf pmf2 = __null; +const pmf pmf3 = 0; +decltype(nullptr) mynull = 0; +const pmf pmf4 = mynull; diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr06.C b/gcc/testsuite/g++.dg/cpp0x/nullptr06.C new file mode 100644 index 000000000..c50bb9bc1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr06.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test compare to pointer + +#define assert_true(b) do { char c[2 * bool(b) - 1]; } while(0) + +char* const cp1 = nullptr; + +void fun() +{ + assert_true(cp1 == nullptr); + decltype(nullptr) mynull = 0; + assert_true(cp1 == mynull); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr07.C b/gcc/testsuite/g++.dg/cpp0x/nullptr07.C new file mode 100644 index 000000000..64d442be3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr07.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test compare to int + +void fun() +{ + int n = 0; + if( n == nullptr ); // { dg-error "invalid operands of types " } + const int m = 1; + if( m == nullptr ); // { dg-error "invalid operands of types " } + decltype(nullptr) mynull = 0; + if( n == mynull ); // { dg-error "invalid operands of types " } + if( m == mynull ); // { dg-error "invalid operands of types " } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr08.C b/gcc/testsuite/g++.dg/cpp0x/nullptr08.C new file mode 100644 index 000000000..1e5db278d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr08.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test conversion to bool + +#define assert_true(b) do { char c[2 * bool(b) - 1]; } while(0) + +void fun() +{ + assert_true(nullptr ? false : true); + decltype(nullptr) mynull = 0; + assert_true(mynull ? false : true); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr09.C b/gcc/testsuite/g++.dg/cpp0x/nullptr09.C new file mode 100644 index 000000000..b35a3c320 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr09.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test compare to literal 0 + +void fun() +{ + if( nullptr == 0 ); + decltype(nullptr) mynull = 0; + if( mynull == 0 ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr10.C b/gcc/testsuite/g++.dg/cpp0x/nullptr10.C new file mode 100644 index 000000000..fa32267ec --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr10.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test arithmetic operations + +void fun() +{ + nullptr = 0; // { dg-error "lvalue required as left operand" } + nullptr + 2; // { dg-error "invalid operands of types " } + decltype(nullptr) mynull = 0; + mynull = 1; // { dg-error "cannot convert" } + mynull = 0; + mynull + 2; // { dg-error "invalid operands of types " } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr11.C b/gcc/testsuite/g++.dg/cpp0x/nullptr11.C new file mode 100644 index 000000000..5907816a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr11.C @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test relational operators + +#define assert_true(b) do { char c[2 * bool(b) - 1]; } while(0) +#define assert_false(b) do { char c[1 - 2 * bool(b)]; } while(0) + +void fun() +{ + assert_true(nullptr == nullptr); + assert_false(nullptr != nullptr); + assert_false(nullptr < nullptr); + assert_false(nullptr > nullptr); + assert_true(nullptr <= nullptr); + assert_true(nullptr >= nullptr); + + decltype(nullptr) mynull = 0; + + assert_true(mynull == nullptr); + assert_false(mynull != nullptr); + assert_false(mynull < nullptr); + assert_false(mynull > nullptr); + assert_true(mynull <= nullptr); + assert_true(mynull >= nullptr); + + assert_true(nullptr == mynull); + assert_false(nullptr != mynull); + assert_false(nullptr < mynull); + assert_false(nullptr > mynull); + assert_true(nullptr <= mynull); + assert_true(nullptr >= mynull); + + assert_true(mynull == mynull); + assert_false(mynull != mynull); + assert_false(mynull < mynull); + assert_false(mynull > mynull); + assert_true(mynull <= mynull); + assert_true(mynull >= mynull); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr12.C b/gcc/testsuite/g++.dg/cpp0x/nullptr12.C new file mode 100644 index 000000000..1713259f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr12.C @@ -0,0 +1,8 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test sizeof + +static_assert(sizeof(nullptr) == sizeof(void*), "sizeof(nullptr) is wrong"); +const decltype(nullptr) mynull = 0; +static_assert(sizeof(mynull) == sizeof(void*), "sizeof(nullptr) is wrong"); diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr13.C b/gcc/testsuite/g++.dg/cpp0x/nullptr13.C new file mode 100644 index 000000000..a9377584c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr13.C @@ -0,0 +1,16 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test typeid + +#include <typeinfo> + +#define assert_true(b) do { char c[2 * bool(b) - 1]; } while(0) + +void fun() +{ + typeid(nullptr); + const decltype(nullptr) mynull = 0; + typeid(mynull); + assert_true(typeid(nullptr) == typeid(mynull)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr14.C b/gcc/testsuite/g++.dg/cpp0x/nullptr14.C new file mode 100644 index 000000000..4c4627b54 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr14.C @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test overload preference char*/int + +template <typename T, typename U> struct tType_equal; +template <typename T> struct tType_equal<T, T> { typedef void type; }; + +template <typename T, typename U> +inline typename tType_equal<T, U>::type +type_equal(U) { } + +char* f( char* ); +int f( int ); +long int f( long int ); + +void test_f() +{ + // Overloading cases + // + type_equal<char*>(f(nullptr)); + type_equal<int>(f(0)); + decltype(nullptr) mynull = 0; + type_equal<char*>(f(mynull)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr15.C b/gcc/testsuite/g++.dg/cpp0x/nullptr15.C new file mode 100644 index 000000000..e02fd5592 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr15.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test template deduction + +template <typename T, typename U> struct tType_equal; +template <typename T> struct tType_equal<T, T> { typedef void type; }; + +template <typename T, typename U> +inline typename tType_equal<T, U>::type +type_equal(U) { } + +template<typename T> T* g( T* t ); // { dg-message "note" } + +void test_g() +{ + // Deduction to nullptr_t, no deduction to pointer type + // + g(nullptr); // { dg-error "no matching function for call to " } + // { dg-message "candidate" "candidate note" { target *-*-* } 19 } + type_equal<float*>(g((float*)nullptr)); + decltype(nullptr) mynull = 0; + g(mynull); // { dg-error "no matching function for call to " } + // { dg-message "candidate" "candidate note" { target *-*-* } 23 } + type_equal<float*>(g((float*)mynull)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr16.C b/gcc/testsuite/g++.dg/cpp0x/nullptr16.C new file mode 100644 index 000000000..0ec0b6a12 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr16.C @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test template deduction + +typedef decltype(nullptr) nullptr_t; + +template <typename T, typename U> struct tType_equal; +template <typename T> struct tType_equal<T, T> { typedef void type; }; + +template <typename T, typename U> +inline typename tType_equal<T, U>::type +type_equal(U) { } + +template<typename T> T h( T t ); + +void test_h() +{ + type_equal<int>(h(0)); + type_equal<nullptr_t>(h(nullptr)); + type_equal<float*>(h((float*)nullptr)); + nullptr_t mynull = 0; + type_equal<nullptr_t>(h(mynull)); + type_equal<float*>(h((float*)mynull)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr17.C b/gcc/testsuite/g++.dg/cpp0x/nullptr17.C new file mode 100644 index 000000000..2e580557b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr17.C @@ -0,0 +1,23 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test that bool is a better overload match than int + +template <typename T, typename U> struct tType_equal; +template <typename T> struct tType_equal<T, T> { typedef void type; }; + +template <typename T, typename U> +inline typename tType_equal<T, U>::type +type_equal(U) { } + +int i( int ); +long int i( long int ); +bool i( bool ); + +void test_i() +{ + // Overload to bool, not int + type_equal<bool>(i(nullptr)); + decltype(nullptr) mynull = 0; + type_equal<bool>(i(mynull)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr18.C b/gcc/testsuite/g++.dg/cpp0x/nullptr18.C new file mode 100644 index 000000000..b8fa38c71 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr18.C @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test overload of pointer versus bool when applied on a nullptr_t + +template <typename T, typename U> struct tType_equal; +template <typename T> struct tType_equal<T, T> { typedef void type; }; + +template <typename T, typename U> +inline typename tType_equal<T, U>::type +type_equal(U) { } + +char* j( char* ); +bool j( bool ); + +void test_j() +{ + type_equal<char*>(j(nullptr)); + decltype(nullptr) mynull = 0; + type_equal<char*>(j(mynull)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr19.C b/gcc/testsuite/g++.dg/cpp0x/nullptr19.C new file mode 100644 index 000000000..cf30f1c23 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr19.C @@ -0,0 +1,17 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +// Test overload of pointer versus nullptr_t when applied on a literal 0/__null + +typedef decltype(nullptr) nullptr_t; + +char* k( char* ); /* { dg-message "note" } { dg-message "note" } */ +nullptr_t k( nullptr_t ); /* { dg-message "note" } { dg-message "note" } */ + +void test_k() +{ + k(0); /* { dg-error "is ambiguous" } */ + // { dg-message "candidate" "candidate note" { target *-*-* } 13 } + k(__null); /* { dg-error "is ambiguous" } */ + // { dg-message "candidate" "candidate note" { target *-*-* } 15 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr20.C b/gcc/testsuite/g++.dg/cpp0x/nullptr20.C new file mode 100644 index 000000000..3e5840677 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr20.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +// Test passing to ellipisis + +#include <cstdio> +#include <cstring> + +int main() +{ + char buf1[64]; + char buf2[64]; + char buf3[64]; + + std::sprintf(buf1, "%p", (void*)0); + std::sprintf(buf2, "%p", nullptr); + decltype(nullptr) mynull = 0; + std::sprintf(buf3, "%p", nullptr); + return std::strcmp(buf1, buf2) != 0 || std::strcmp(buf1, buf3) != 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr21.C b/gcc/testsuite/g++.dg/cpp0x/nullptr21.C new file mode 100644 index 000000000..c30cb3c8b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr21.C @@ -0,0 +1,44 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } + +// Test throw and catch + +#include <cstdio> + +typedef decltype(nullptr) nullptr_t; + +int main() +{ + try { + throw nullptr; + } catch (void*) { + printf("Test 1 Fail"); + } catch (bool) { + printf("Test 1 Fail"); + } catch (int) { + printf("Test 1 Fail"); + } catch (long int) { + printf("Test 1 Fail"); + } catch (nullptr_t) { + printf("Test 1 OK"); + } catch (...) { + printf("Test 1 Fail"); + } // { dg-output "Test 1 OK" } + + nullptr_t mynull = 0; + try { + throw mynull; + } catch (void*) { + printf("Test 2 Fail"); + } catch (bool) { + printf("Test 2 Fail"); + } catch (int) { + printf("Test 2 Fail"); + } catch (long int) { + printf("Test 2 Fail"); + } catch (nullptr_t) { + printf("Test 2 OK"); + } catch (...) { + printf("Test 2 Fail"); + } // { dg-output "Test 2 OK" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr22.C b/gcc/testsuite/g++.dg/cpp0x/nullptr22.C new file mode 100644 index 000000000..d800f9869 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr22.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// { dg-options "-std=c++0x -Wall -Wformat=2 -Wstrict-null-sentinel" } + +// Test various warnings + +void f1(const char*, ...) __attribute__((format(printf, 1, 2))); +void f2(const char*) __attribute__((nonnull)); +void f3(const char*, ...) __attribute__((sentinel)); + +void f() +{ + f1("%p", nullptr); + f2(nullptr); // { dg-warning "null argument where non-null required " } + f3("x", "y", __null); // { dg-warning "missing sentinel in function call" } + f3("x", "y", nullptr); + decltype(nullptr) mynull = 0; + f1("%p", mynull); + f2(mynull); // { dg-warning "null argument where non-null required " } + f3("x", "y", mynull); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr28.C b/gcc/testsuite/g++.dg/cpp0x/nullptr28.C new file mode 100644 index 000000000..4cc790d31 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr28.C @@ -0,0 +1,17 @@ +// { dg-do run } +// { dg-options "-std=c++0x -pedantic-errors" } + +typedef decltype(nullptr) nullptr_t; + +int i; +nullptr_t n; +const nullptr_t& f() { ++i; return n; } + +nullptr_t g() { return f(); } + +int main() +{ + g(); + if (i != 1) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/overload-conv-1.C b/gcc/testsuite/g++.dg/cpp0x/overload-conv-1.C new file mode 100644 index 000000000..778111283 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/overload-conv-1.C @@ -0,0 +1,29 @@ +// { dg-options "--std=c++0x" } +// { dg-do link } + +struct S {}; + +struct T +{ + operator S() { return S(); } +}; + +struct U +{ + operator S&() { return *static_cast<S*>(0); } +}; + +void f(const S&); +void f(S&&) {} + +void g(const S&) {} +void g(S&&); + +int main() +{ + T t; + f(t); + + U u; + g(u); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/overload-conv-2.C b/gcc/testsuite/g++.dg/cpp0x/overload-conv-2.C new file mode 100644 index 000000000..0e622bcac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/overload-conv-2.C @@ -0,0 +1,17 @@ +// { dg-options "--std=c++0x" } +// { dg-do link } + +struct T {}; +struct S +{ + S(T const &) {} +}; + +void f(const S&); +void f(S&&) {} + +int main() +{ + T t; + f(t); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/overload.C b/gcc/testsuite/g++.dg/cpp0x/overload.C new file mode 100644 index 000000000..3782d4a20 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/overload.C @@ -0,0 +1,708 @@ +// { dg-options "--std=c++0x" } +// { dg-do link } +// Generated by overload.py + +template<typename _Tp> +inline _Tp&& +movel(_Tp& __t) +{ return static_cast<_Tp&&>(__t); } + +struct S{}; + +S l; // lvalue (l) +S const cl = l; // const lvalue (cl) +S r() { return l; } // rvalue (r) +S const cr() { return l; } // const rvalue (cr) +S & nl = l; // named lvalue reference (nl) +S const & ncl = l; // named const lvalue reference (ncl) +S && nr = movel(l); // named rvalue reference (nr) +S const && ncr = movel(l); // named const rvalue reference (ncr) +S & ul() { return l; } // unnamed lvalue reference (ul) +S const & ucl() { return l; } // unnamed const lvalue reference (ucl) +S && ur() { return movel(l); } // unnamed rvalue reference (ur) +S const && ucr() { return movel(l); } // unnamed const rvalue reference (ucr) + +void l0001(const S&&) {} + +void l0010(S&&) {} + +void l0011(S&&) {} +void l0011(const S&&); + +void l0100(const S&) {} + +void l0101(const S&) {} +void l0101(const S&&); + +void l0110(const S&) {} +void l0110(S&&); + +void l0111(const S&) {} +void l0111(S&&); +void l0111(const S&&); + +void l1000(S&) {} + +void l1001(S&) {} +void l1001(const S&&); + +void l1010(S&) {} +void l1010(S&&); + +void l1011(S&) {} +void l1011(S&&); +void l1011(const S&&); + +void l1100(S&) {} +void l1100(const S&); + +void l1101(S&) {} +void l1101(const S&); +void l1101(const S&&); + +void l1110(S&) {} +void l1110(const S&); +void l1110(S&&); + +void l1111(S&) {} +void l1111(const S&); +void l1111(S&&); +void l1111(const S&&); + +void cl0001(const S&&) {} + +void cl0011(S&&); +void cl0011(const S&&) {} + +void cl0100(const S&) {} + +void cl0101(const S&) {} +void cl0101(const S&&); + +void cl0110(const S&) {} +void cl0110(S&&); + +void cl0111(const S&) {} +void cl0111(S&&); +void cl0111(const S&&); + +void cl1001(S&); +void cl1001(const S&&) {} + +void cl1011(S&); +void cl1011(S&&); +void cl1011(const S&&) {} + +void cl1100(S&); +void cl1100(const S&) {} + +void cl1101(S&); +void cl1101(const S&) {} +void cl1101(const S&&); + +void cl1110(S&); +void cl1110(const S&) {} +void cl1110(S&&); + +void cl1111(S&); +void cl1111(const S&) {} +void cl1111(S&&); +void cl1111(const S&&); + +void r0001(const S&&) {} + +void r0010(S&&) {} + +void r0011(S&&) {} +void r0011(const S&&); + +void r0100(const S&) {} + +void r0101(const S&); +void r0101(const S&&) {} + +void r0110(const S&); +void r0110(S&&) {} + +void r0111(const S&); +void r0111(S&&) {} +void r0111(const S&&); + +void r1001(S&); +void r1001(const S&&) {} + +void r1010(S&); +void r1010(S&&) {} + +void r1011(S&); +void r1011(S&&) {} +void r1011(const S&&); + +void r1100(S&); +void r1100(const S&) {} + +void r1101(S&); +void r1101(const S&); +void r1101(const S&&) {} + +void r1110(S&); +void r1110(const S&); +void r1110(S&&) {} + +void r1111(S&); +void r1111(const S&); +void r1111(S&&) {} +void r1111(const S&&); + +void cr0001(const S&&) {} + +void cr0011(S&&); +void cr0011(const S&&) {} + +void cr0100(const S&) {} + +void cr0101(const S&); +void cr0101(const S&&) {} + +void cr0110(const S&) {} +void cr0110(S&&); + +void cr0111(const S&); +void cr0111(S&&); +void cr0111(const S&&) {} + +void cr1001(S&); +void cr1001(const S&&) {} + +void cr1011(S&); +void cr1011(S&&); +void cr1011(const S&&) {} + +void cr1100(S&); +void cr1100(const S&) {} + +void cr1101(S&); +void cr1101(const S&); +void cr1101(const S&&) {} + +void cr1110(S&); +void cr1110(const S&) {} +void cr1110(S&&); + +void cr1111(S&); +void cr1111(const S&); +void cr1111(S&&); +void cr1111(const S&&) {} + +void nl0001(const S&&) {} + +void nl0010(S&&) {} + +void nl0011(S&&) {} +void nl0011(const S&&); + +void nl0100(const S&) {} + +void nl0101(const S&) {} +void nl0101(const S&&); + +void nl0110(const S&) {} +void nl0110(S&&); + +void nl0111(const S&) {} +void nl0111(S&&); +void nl0111(const S&&); + +void nl1000(S&) {} + +void nl1001(S&) {} +void nl1001(const S&&); + +void nl1010(S&) {} +void nl1010(S&&); + +void nl1011(S&) {} +void nl1011(S&&); +void nl1011(const S&&); + +void nl1100(S&) {} +void nl1100(const S&); + +void nl1101(S&) {} +void nl1101(const S&); +void nl1101(const S&&); + +void nl1110(S&) {} +void nl1110(const S&); +void nl1110(S&&); + +void nl1111(S&) {} +void nl1111(const S&); +void nl1111(S&&); +void nl1111(const S&&); + +void ncl0001(const S&&) {} + +void ncl0011(S&&); +void ncl0011(const S&&) {} + +void ncl0100(const S&) {} + +void ncl0101(const S&) {} +void ncl0101(const S&&); + +void ncl0110(const S&) {} +void ncl0110(S&&); + +void ncl0111(const S&) {} +void ncl0111(S&&); +void ncl0111(const S&&); + +void ncl1001(S&); +void ncl1001(const S&&) {} + +void ncl1011(S&); +void ncl1011(S&&); +void ncl1011(const S&&) {} + +void ncl1100(S&); +void ncl1100(const S&) {} + +void ncl1101(S&); +void ncl1101(const S&) {} +void ncl1101(const S&&); + +void ncl1110(S&); +void ncl1110(const S&) {} +void ncl1110(S&&); + +void ncl1111(S&); +void ncl1111(const S&) {} +void ncl1111(S&&); +void ncl1111(const S&&); + +void nr0001(const S&&) {} + +void nr0010(S&&) {} + +void nr0011(S&&) {} +void nr0011(const S&&); + +void nr0100(const S&) {} + +void nr0101(const S&) {} +void nr0101(const S&&); + +void nr0110(const S&) {} +void nr0110(S&&); + +void nr0111(const S&) {} +void nr0111(S&&); +void nr0111(const S&&); + +void nr1000(S&) {} + +void nr1001(S&) {} +void nr1001(const S&&); + +void nr1010(S&) {} +void nr1010(S&&); + +void nr1011(S&) {} +void nr1011(S&&); +void nr1011(const S&&); + +void nr1100(S&) {} +void nr1100(const S&); + +void nr1101(S&) {} +void nr1101(const S&); +void nr1101(const S&&); + +void nr1110(S&) {} +void nr1110(const S&); +void nr1110(S&&); + +void nr1111(S&) {} +void nr1111(const S&); +void nr1111(S&&); +void nr1111(const S&&); + +void ncr0001(const S&&) {} + +void ncr0011(S&&); +void ncr0011(const S&&) {} + +void ncr0100(const S&) {} + +void ncr0101(const S&) {} +void ncr0101(const S&&); + +void ncr0110(const S&) {} +void ncr0110(S&&); + +void ncr0111(const S&) {} +void ncr0111(S&&); +void ncr0111(const S&&); + +void ncr1001(S&); +void ncr1001(const S&&) {} + +void ncr1011(S&); +void ncr1011(S&&); +void ncr1011(const S&&) {} + +void ncr1100(S&); +void ncr1100(const S&) {} + +void ncr1101(S&); +void ncr1101(const S&) {} +void ncr1101(const S&&); + +void ncr1110(S&); +void ncr1110(const S&) {} +void ncr1110(S&&); + +void ncr1111(S&); +void ncr1111(const S&) {} +void ncr1111(S&&); +void ncr1111(const S&&); + +void ul0001(const S&&) {} + +void ul0010(S&&) {} + +void ul0011(S&&) {} +void ul0011(const S&&); + +void ul0100(const S&) {} + +void ul0101(const S&) {} +void ul0101(const S&&); + +void ul0110(const S&) {} +void ul0110(S&&); + +void ul0111(const S&) {} +void ul0111(S&&); +void ul0111(const S&&); + +void ul1000(S&) {} + +void ul1001(S&) {} +void ul1001(const S&&); + +void ul1010(S&) {} +void ul1010(S&&); + +void ul1011(S&) {} +void ul1011(S&&); +void ul1011(const S&&); + +void ul1100(S&) {} +void ul1100(const S&); + +void ul1101(S&) {} +void ul1101(const S&); +void ul1101(const S&&); + +void ul1110(S&) {} +void ul1110(const S&); +void ul1110(S&&); + +void ul1111(S&) {} +void ul1111(const S&); +void ul1111(S&&); +void ul1111(const S&&); + +void ucl0001(const S&&) {} + +void ucl0011(S&&); +void ucl0011(const S&&) {} + +void ucl0100(const S&) {} + +void ucl0101(const S&) {} +void ucl0101(const S&&); + +void ucl0110(const S&) {} +void ucl0110(S&&); + +void ucl0111(const S&) {} +void ucl0111(S&&); +void ucl0111(const S&&); + +void ucl1001(S&); +void ucl1001(const S&&) {} + +void ucl1011(S&); +void ucl1011(S&&); +void ucl1011(const S&&) {} + +void ucl1100(S&); +void ucl1100(const S&) {} + +void ucl1101(S&); +void ucl1101(const S&) {} +void ucl1101(const S&&); + +void ucl1110(S&); +void ucl1110(const S&) {} +void ucl1110(S&&); + +void ucl1111(S&); +void ucl1111(const S&) {} +void ucl1111(S&&); +void ucl1111(const S&&); + +void ur0001(const S&&) {} + +void ur0010(S&&) {} + +void ur0011(S&&) {} +void ur0011(const S&&); + +void ur0100(const S&) {} + +void ur0101(const S&); +void ur0101(const S&&) {} + +void ur0110(const S&); +void ur0110(S&&) {} + +void ur0111(const S&); +void ur0111(S&&) {} +void ur0111(const S&&); + +void ur1001(S&); +void ur1001(const S&&) {} + +void ur1010(S&); +void ur1010(S&&) {} + +void ur1011(S&); +void ur1011(S&&) {} +void ur1011(const S&&); + +void ur1100(S&); +void ur1100(const S&) {} + +void ur1101(S&); +void ur1101(const S&); +void ur1101(const S&&) {} + +void ur1110(S&); +void ur1110(const S&); +void ur1110(S&&) {} + +void ur1111(S&); +void ur1111(const S&); +void ur1111(S&&) {} +void ur1111(const S&&); + +void ucr0001(const S&&) {} + +void ucr0011(S&&); +void ucr0011(const S&&) {} + +void ucr0100(const S&) {} + +void ucr0101(const S&); +void ucr0101(const S&&) {} + +void ucr0110(const S&) {} +void ucr0110(S&&); + +void ucr0111(const S&); +void ucr0111(S&&); +void ucr0111(const S&&) {} + +void ucr1001(S&); +void ucr1001(const S&&) {} + +void ucr1011(S&); +void ucr1011(S&&); +void ucr1011(const S&&) {} + +void ucr1100(S&); +void ucr1100(const S&) {} + +void ucr1101(S&); +void ucr1101(const S&); +void ucr1101(const S&&) {} + +void ucr1110(S&); +void ucr1110(const S&) {} +void ucr1110(S&&); + +void ucr1111(S&); +void ucr1111(const S&); +void ucr1111(S&&); +void ucr1111(const S&&) {} + + +int main() +{ + //l0001(l); + //l0010(l); + //l0011(l); + l0100(l); + l0101(l); + l0110(l); + l0111(l); + l1000(l); + l1001(l); + l1010(l); + l1011(l); + l1100(l); + l1101(l); + l1110(l); + l1111(l); + //cl0001(cl); + //cl0011(cl); + cl0100(cl); + cl0101(cl); + cl0110(cl); + cl0111(cl); + //cl1001(cl); + //cl1011(cl); + cl1100(cl); + cl1101(cl); + cl1110(cl); + cl1111(cl); + r0001(r()); + r0010(r()); + r0011(r()); + r0100(r()); + r0101(r()); + r0110(r()); + r0111(r()); + r1001(r()); + r1010(r()); + r1011(r()); + r1100(r()); + r1101(r()); + r1110(r()); + r1111(r()); + cr0001(cr()); + cr0011(cr()); + cr0100(cr()); + cr0101(cr()); + cr0110(cr()); + cr0111(cr()); + cr1001(cr()); + cr1011(cr()); + cr1100(cr()); + cr1101(cr()); + cr1110(cr()); + cr1111(cr()); + //nl0001(nl); + //nl0010(nl); + //nl0011(nl); + nl0100(nl); + nl0101(nl); + nl0110(nl); + nl0111(nl); + nl1000(nl); + nl1001(nl); + nl1010(nl); + nl1011(nl); + nl1100(nl); + nl1101(nl); + nl1110(nl); + nl1111(nl); + //ncl0001(ncl); + //ncl0011(ncl); + ncl0100(ncl); + ncl0101(ncl); + ncl0110(ncl); + ncl0111(ncl); + //ncl1001(ncl); + //ncl1011(ncl); + ncl1100(ncl); + ncl1101(ncl); + ncl1110(ncl); + ncl1111(ncl); + //nr0001(nr); + //nr0010(nr); + //nr0011(nr); + nr0100(nr); + nr0101(nr); + nr0110(nr); + nr0111(nr); + nr1000(nr); + nr1001(nr); + nr1010(nr); + nr1011(nr); + nr1100(nr); + nr1101(nr); + nr1110(nr); + nr1111(nr); + //ncr0001(ncr); + //ncr0011(ncr); + ncr0100(ncr); + ncr0101(ncr); + ncr0110(ncr); + ncr0111(ncr); + //ncr1001(ncr); + //ncr1011(ncr); + ncr1100(ncr); + ncr1101(ncr); + ncr1110(ncr); + ncr1111(ncr); + //ul0001(ul()); + //ul0010(ul()); + //ul0011(ul()); + ul0100(ul()); + ul0101(ul()); + ul0110(ul()); + ul0111(ul()); + ul1000(ul()); + ul1001(ul()); + ul1010(ul()); + ul1011(ul()); + ul1100(ul()); + ul1101(ul()); + ul1110(ul()); + ul1111(ul()); + //ucl0001(ucl()); + //ucl0011(ucl()); + ucl0100(ucl()); + ucl0101(ucl()); + ucl0110(ucl()); + ucl0111(ucl()); + //ucl1001(ucl()); + //ucl1011(ucl()); + ucl1100(ucl()); + ucl1101(ucl()); + ucl1110(ucl()); + ucl1111(ucl()); + ur0001(ur()); + ur0010(ur()); + ur0011(ur()); + ur0100(ur()); + ur0101(ur()); + ur0110(ur()); + ur0111(ur()); + ur1001(ur()); + ur1010(ur()); + ur1011(ur()); + ur1100(ur()); + ur1101(ur()); + ur1110(ur()); + ur1111(ur()); + ucr0001(ucr()); + ucr0011(ucr()); + ucr0100(ucr()); + ucr0101(ucr()); + ucr0110(ucr()); + ucr0111(ucr()); + ucr1001(ucr()); + ucr1011(ucr()); + ucr1100(ucr()); + ucr1101(ucr()); + ucr1110(ucr()); + ucr1111(ucr()); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/overloadn.C b/gcc/testsuite/g++.dg/cpp0x/overloadn.C new file mode 100644 index 000000000..a42707fe4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/overloadn.C @@ -0,0 +1,708 @@ +// { dg-options "--std=c++0x" } +// { dg-do link } +// Generated by overload.py + +template<typename _Tp> +inline _Tp&& +movel(_Tp& __t) +{ return static_cast<_Tp&&>(__t); } + +struct S{}; + +S l; // lvalue (l) +S const cl = l; // const lvalue (cl) +S r() { return l; } // rvalue (r) +S const cr() { return l; } // const rvalue (cr) +S & nl = l; // named lvalue reference (nl) +S const & ncl = l; // named const lvalue reference (ncl) +S && nr = movel(l); // named rvalue reference (nr) +S const && ncr = movel(l); // named const rvalue reference (ncr) +S & ul() { return l; } // unnamed lvalue reference (ul) +S const & ucl() { return l; } // unnamed const lvalue reference (ucl) +S && ur() { return movel(l); } // unnamed rvalue reference (ur) +S const && ucr() { return movel(l); } // unnamed const rvalue reference (ucr) + +void l0001(const S&&) {} // { dg-message "" } + +void l0010(S&&) {} // { dg-message "" } + +void l0011(S&&) {} // { dg-message "" } +void l0011(const S&&); + +void l0100(const S&) {} + +void l0101(const S&) {} +void l0101(const S&&); + +void l0110(const S&) {} +void l0110(S&&); + +void l0111(const S&) {} +void l0111(S&&); +void l0111(const S&&); + +void l1000(S&) {} + +void l1001(S&) {} +void l1001(const S&&); + +void l1010(S&) {} +void l1010(S&&); + +void l1011(S&) {} +void l1011(S&&); +void l1011(const S&&); + +void l1100(S&) {} +void l1100(const S&); + +void l1101(S&) {} +void l1101(const S&); +void l1101(const S&&); + +void l1110(S&) {} +void l1110(const S&); +void l1110(S&&); + +void l1111(S&) {} +void l1111(const S&); +void l1111(S&&); +void l1111(const S&&); + +void cl0001(const S&&) {} // { dg-message "" } + +void cl0011(S&&); +void cl0011(const S&&) {} // { dg-message "" } + +void cl0100(const S&) {} + +void cl0101(const S&) {} +void cl0101(const S&&); + +void cl0110(const S&) {} +void cl0110(S&&); + +void cl0111(const S&) {} +void cl0111(S&&); +void cl0111(const S&&); + +void cl1001(S&); +void cl1001(const S&&) {} // { dg-message "" } + +void cl1011(S&); +void cl1011(S&&); +void cl1011(const S&&) {} // { dg-message "" } + +void cl1100(S&); +void cl1100(const S&) {} + +void cl1101(S&); +void cl1101(const S&) {} +void cl1101(const S&&); + +void cl1110(S&); +void cl1110(const S&) {} +void cl1110(S&&); + +void cl1111(S&); +void cl1111(const S&) {} +void cl1111(S&&); +void cl1111(const S&&); + +void r0001(const S&&) {} + +void r0010(S&&) {} + +void r0011(S&&) {} +void r0011(const S&&); + +void r0100(const S&) {} + +void r0101(const S&); +void r0101(const S&&) {} + +void r0110(const S&); +void r0110(S&&) {} + +void r0111(const S&); +void r0111(S&&) {} +void r0111(const S&&); + +void r1001(S&); +void r1001(const S&&) {} + +void r1010(S&); +void r1010(S&&) {} + +void r1011(S&); +void r1011(S&&) {} +void r1011(const S&&); + +void r1100(S&); +void r1100(const S&) {} + +void r1101(S&); +void r1101(const S&); +void r1101(const S&&) {} + +void r1110(S&); +void r1110(const S&); +void r1110(S&&) {} + +void r1111(S&); +void r1111(const S&); +void r1111(S&&) {} +void r1111(const S&&); + +void cr0001(const S&&) {} + +void cr0011(S&&); +void cr0011(const S&&) {} + +void cr0100(const S&) {} + +void cr0101(const S&); +void cr0101(const S&&) {} + +void cr0110(const S&) {} +void cr0110(S&&); + +void cr0111(const S&); +void cr0111(S&&); +void cr0111(const S&&) {} + +void cr1001(S&); +void cr1001(const S&&) {} + +void cr1011(S&); +void cr1011(S&&); +void cr1011(const S&&) {} + +void cr1100(S&); +void cr1100(const S&) {} + +void cr1101(S&); +void cr1101(const S&); +void cr1101(const S&&) {} + +void cr1110(S&); +void cr1110(const S&) {} +void cr1110(S&&); + +void cr1111(S&); +void cr1111(const S&); +void cr1111(S&&); +void cr1111(const S&&) {} + +void nl0001(const S&&) {} // { dg-message "" } + +void nl0010(S&&) {} // { dg-message "" } + +void nl0011(S&&) {} // { dg-message "" } +void nl0011(const S&&); + +void nl0100(const S&) {} + +void nl0101(const S&) {} +void nl0101(const S&&); + +void nl0110(const S&) {} +void nl0110(S&&); + +void nl0111(const S&) {} +void nl0111(S&&); +void nl0111(const S&&); + +void nl1000(S&) {} + +void nl1001(S&) {} +void nl1001(const S&&); + +void nl1010(S&) {} +void nl1010(S&&); + +void nl1011(S&) {} +void nl1011(S&&); +void nl1011(const S&&); + +void nl1100(S&) {} +void nl1100(const S&); + +void nl1101(S&) {} +void nl1101(const S&); +void nl1101(const S&&); + +void nl1110(S&) {} +void nl1110(const S&); +void nl1110(S&&); + +void nl1111(S&) {} +void nl1111(const S&); +void nl1111(S&&); +void nl1111(const S&&); + +void ncl0001(const S&&) {} // { dg-message "" } + +void ncl0011(S&&); +void ncl0011(const S&&) {} // { dg-message "" } + +void ncl0100(const S&) {} + +void ncl0101(const S&) {} +void ncl0101(const S&&); + +void ncl0110(const S&) {} +void ncl0110(S&&); + +void ncl0111(const S&) {} +void ncl0111(S&&); +void ncl0111(const S&&); + +void ncl1001(S&); +void ncl1001(const S&&) {} // { dg-message "" } + +void ncl1011(S&); +void ncl1011(S&&); +void ncl1011(const S&&) {} // { dg-message "" } + +void ncl1100(S&); +void ncl1100(const S&) {} + +void ncl1101(S&); +void ncl1101(const S&) {} +void ncl1101(const S&&); + +void ncl1110(S&); +void ncl1110(const S&) {} +void ncl1110(S&&); + +void ncl1111(S&); +void ncl1111(const S&) {} +void ncl1111(S&&); +void ncl1111(const S&&); + +void nr0001(const S&&) {} // { dg-message "" } + +void nr0010(S&&) {} // { dg-message "" } + +void nr0011(S&&) {} // { dg-message "" } +void nr0011(const S&&); + +void nr0100(const S&) {} + +void nr0101(const S&) {} +void nr0101(const S&&); + +void nr0110(const S&) {} +void nr0110(S&&); + +void nr0111(const S&) {} +void nr0111(S&&); +void nr0111(const S&&); + +void nr1000(S&) {} + +void nr1001(S&) {} +void nr1001(const S&&); + +void nr1010(S&) {} +void nr1010(S&&); + +void nr1011(S&) {} +void nr1011(S&&); +void nr1011(const S&&); + +void nr1100(S&) {} +void nr1100(const S&); + +void nr1101(S&) {} +void nr1101(const S&); +void nr1101(const S&&); + +void nr1110(S&) {} +void nr1110(const S&); +void nr1110(S&&); + +void nr1111(S&) {} +void nr1111(const S&); +void nr1111(S&&); +void nr1111(const S&&); + +void ncr0001(const S&&) {} // { dg-message "" } + +void ncr0011(S&&); +void ncr0011(const S&&) {} // { dg-message "" } + +void ncr0100(const S&) {} + +void ncr0101(const S&) {} +void ncr0101(const S&&); + +void ncr0110(const S&) {} +void ncr0110(S&&); + +void ncr0111(const S&) {} +void ncr0111(S&&); +void ncr0111(const S&&); + +void ncr1001(S&); +void ncr1001(const S&&) {} // { dg-message "" } + +void ncr1011(S&); +void ncr1011(S&&); +void ncr1011(const S&&) {} // { dg-message "" } + +void ncr1100(S&); +void ncr1100(const S&) {} + +void ncr1101(S&); +void ncr1101(const S&) {} +void ncr1101(const S&&); + +void ncr1110(S&); +void ncr1110(const S&) {} +void ncr1110(S&&); + +void ncr1111(S&); +void ncr1111(const S&) {} +void ncr1111(S&&); +void ncr1111(const S&&); + +void ul0001(const S&&) {} // { dg-message "" } + +void ul0010(S&&) {} // { dg-message "" } + +void ul0011(S&&) {} // { dg-message "" } +void ul0011(const S&&); + +void ul0100(const S&) {} + +void ul0101(const S&) {} +void ul0101(const S&&); + +void ul0110(const S&) {} +void ul0110(S&&); + +void ul0111(const S&) {} +void ul0111(S&&); +void ul0111(const S&&); + +void ul1000(S&) {} + +void ul1001(S&) {} +void ul1001(const S&&); + +void ul1010(S&) {} +void ul1010(S&&); + +void ul1011(S&) {} +void ul1011(S&&); +void ul1011(const S&&); + +void ul1100(S&) {} +void ul1100(const S&); + +void ul1101(S&) {} +void ul1101(const S&); +void ul1101(const S&&); + +void ul1110(S&) {} +void ul1110(const S&); +void ul1110(S&&); + +void ul1111(S&) {} +void ul1111(const S&); +void ul1111(S&&); +void ul1111(const S&&); + +void ucl0001(const S&&) {} // { dg-message "" } + +void ucl0011(S&&); +void ucl0011(const S&&) {} // { dg-message "" } + +void ucl0100(const S&) {} + +void ucl0101(const S&) {} +void ucl0101(const S&&); + +void ucl0110(const S&) {} +void ucl0110(S&&); + +void ucl0111(const S&) {} +void ucl0111(S&&); +void ucl0111(const S&&); + +void ucl1001(S&); +void ucl1001(const S&&) {} // { dg-message "" } + +void ucl1011(S&); +void ucl1011(S&&); +void ucl1011(const S&&) {} // { dg-message "" } + +void ucl1100(S&); +void ucl1100(const S&) {} + +void ucl1101(S&); +void ucl1101(const S&) {} +void ucl1101(const S&&); + +void ucl1110(S&); +void ucl1110(const S&) {} +void ucl1110(S&&); + +void ucl1111(S&); +void ucl1111(const S&) {} +void ucl1111(S&&); +void ucl1111(const S&&); + +void ur0001(const S&&) {} + +void ur0010(S&&) {} + +void ur0011(S&&) {} +void ur0011(const S&&); + +void ur0100(const S&) {} + +void ur0101(const S&); +void ur0101(const S&&) {} + +void ur0110(const S&); +void ur0110(S&&) {} + +void ur0111(const S&); +void ur0111(S&&) {} +void ur0111(const S&&); + +void ur1001(S&); +void ur1001(const S&&) {} + +void ur1010(S&); +void ur1010(S&&) {} + +void ur1011(S&); +void ur1011(S&&) {} +void ur1011(const S&&); + +void ur1100(S&); +void ur1100(const S&) {} + +void ur1101(S&); +void ur1101(const S&); +void ur1101(const S&&) {} + +void ur1110(S&); +void ur1110(const S&); +void ur1110(S&&) {} + +void ur1111(S&); +void ur1111(const S&); +void ur1111(S&&) {} +void ur1111(const S&&); + +void ucr0001(const S&&) {} + +void ucr0011(S&&); +void ucr0011(const S&&) {} + +void ucr0100(const S&) {} + +void ucr0101(const S&); +void ucr0101(const S&&) {} + +void ucr0110(const S&) {} +void ucr0110(S&&); + +void ucr0111(const S&); +void ucr0111(S&&); +void ucr0111(const S&&) {} + +void ucr1001(S&); +void ucr1001(const S&&) {} + +void ucr1011(S&); +void ucr1011(S&&); +void ucr1011(const S&&) {} + +void ucr1100(S&); +void ucr1100(const S&) {} + +void ucr1101(S&); +void ucr1101(const S&); +void ucr1101(const S&&) {} + +void ucr1110(S&); +void ucr1110(const S&) {} +void ucr1110(S&&); + +void ucr1111(S&); +void ucr1111(const S&); +void ucr1111(S&&); +void ucr1111(const S&&) {} + + +int main() +{ + l0001(l); // { dg-error "lvalue" } + l0010(l); // { dg-error "lvalue" } + l0011(l); // { dg-error "lvalue" } + l0100(l); + l0101(l); + l0110(l); + l0111(l); + l1000(l); + l1001(l); + l1010(l); + l1011(l); + l1100(l); + l1101(l); + l1110(l); + l1111(l); + cl0001(cl); // { dg-error "lvalue" } + cl0011(cl); // { dg-error "lvalue" } + cl0100(cl); + cl0101(cl); + cl0110(cl); + cl0111(cl); + cl1001(cl); // { dg-error "lvalue" } + cl1011(cl); // { dg-error "lvalue" } + cl1100(cl); + cl1101(cl); + cl1110(cl); + cl1111(cl); + r0001(r()); + r0010(r()); + r0011(r()); + r0100(r()); + r0101(r()); + r0110(r()); + r0111(r()); + r1001(r()); + r1010(r()); + r1011(r()); + r1100(r()); + r1101(r()); + r1110(r()); + r1111(r()); + cr0001(cr()); + cr0011(cr()); + cr0100(cr()); + cr0101(cr()); + cr0110(cr()); + cr0111(cr()); + cr1001(cr()); + cr1011(cr()); + cr1100(cr()); + cr1101(cr()); + cr1110(cr()); + cr1111(cr()); + nl0001(nl); // { dg-error "lvalue" } + nl0010(nl); // { dg-error "lvalue" } + nl0011(nl); // { dg-error "lvalue" } + nl0100(nl); + nl0101(nl); + nl0110(nl); + nl0111(nl); + nl1000(nl); + nl1001(nl); + nl1010(nl); + nl1011(nl); + nl1100(nl); + nl1101(nl); + nl1110(nl); + nl1111(nl); + ncl0001(ncl); // { dg-error "lvalue" } + ncl0011(ncl); // { dg-error "lvalue" } + ncl0100(ncl); + ncl0101(ncl); + ncl0110(ncl); + ncl0111(ncl); + ncl1001(ncl); // { dg-error "lvalue" } + ncl1011(ncl); // { dg-error "lvalue" } + ncl1100(ncl); + ncl1101(ncl); + ncl1110(ncl); + ncl1111(ncl); + nr0001(nr); // { dg-error "lvalue" } + nr0010(nr); // { dg-error "lvalue" } + nr0011(nr); // { dg-error "lvalue" } + nr0100(nr); + nr0101(nr); + nr0110(nr); + nr0111(nr); + nr1000(nr); + nr1001(nr); + nr1010(nr); + nr1011(nr); + nr1100(nr); + nr1101(nr); + nr1110(nr); + nr1111(nr); + ncr0001(ncr); // { dg-error "lvalue" } + ncr0011(ncr); // { dg-error "lvalue" } + ncr0100(ncr); + ncr0101(ncr); + ncr0110(ncr); + ncr0111(ncr); + ncr1001(ncr); // { dg-error "lvalue" } + ncr1011(ncr); // { dg-error "lvalue" } + ncr1100(ncr); + ncr1101(ncr); + ncr1110(ncr); + ncr1111(ncr); + ul0001(ul()); // { dg-error "lvalue" } + ul0010(ul()); // { dg-error "lvalue" } + ul0011(ul()); // { dg-error "lvalue" } + ul0100(ul()); + ul0101(ul()); + ul0110(ul()); + ul0111(ul()); + ul1000(ul()); + ul1001(ul()); + ul1010(ul()); + ul1011(ul()); + ul1100(ul()); + ul1101(ul()); + ul1110(ul()); + ul1111(ul()); + ucl0001(ucl()); // { dg-error "lvalue" } + ucl0011(ucl()); // { dg-error "lvalue" } + ucl0100(ucl()); + ucl0101(ucl()); + ucl0110(ucl()); + ucl0111(ucl()); + ucl1001(ucl()); // { dg-error "lvalue" } + ucl1011(ucl()); // { dg-error "lvalue" } + ucl1100(ucl()); + ucl1101(ucl()); + ucl1110(ucl()); + ucl1111(ucl()); + ur0001(ur()); + ur0010(ur()); + ur0011(ur()); + ur0100(ur()); + ur0101(ur()); + ur0110(ur()); + ur0111(ur()); + ur1001(ur()); + ur1010(ur()); + ur1011(ur()); + ur1100(ur()); + ur1101(ur()); + ur1110(ur()); + ur1111(ur()); + ucr0001(ucr()); + ucr0011(ucr()); + ucr0100(ucr()); + ucr0101(ucr()); + ucr0110(ucr()); + ucr0111(ucr()); + ucr1001(ucr()); + ucr1011(ucr()); + ucr1100(ucr()); + ucr1101(ucr()); + ucr1110(ucr()); + ucr1111(ucr()); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/parse1.C b/gcc/testsuite/g++.dg/cpp0x/parse1.C new file mode 100644 index 000000000..41811853c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/parse1.C @@ -0,0 +1,5 @@ +// PR c++/43509 +// { dg-options "-std=c++0x" } + +typedef int B; // { dg-error "" } +B::B() {} // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31431-2.C b/gcc/testsuite/g++.dg/cpp0x/pr31431-2.C new file mode 100644 index 000000000..15efbc5d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31431-2.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template<typename, typename..., typename> void foo(); // { dg-message "note" } + +void bar() +{ + foo<int>(); // { dg-error "no matching function" } + // { dg-message "candidate" "candidate note" { target *-*-* } 6 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31431.C b/gcc/testsuite/g++.dg/cpp0x/pr31431.C new file mode 100644 index 000000000..36f341f3d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31431.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template<typename..., typename> void foo(); // { dg-message "note" } + +void bar() +{ + foo<int>(); // { dg-error "no matching function" } + // { dg-message "candidate" "candidate note" { target *-*-* } 6 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31432.C b/gcc/testsuite/g++.dg/cpp0x/pr31432.C new file mode 100644 index 000000000..8016ee69d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31432.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template<typename..., typename> struct A // { dg-error "parameter pack" } +{ + static int i; +}; + +A<int, int> a; // { dg-error "mismatch|expected|invalid type" } +A<char,int> b; // { dg-error "mismatch|expected|invalid type" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31434.C b/gcc/testsuite/g++.dg/cpp0x/pr31434.C new file mode 100644 index 000000000..97ad079ab --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31434.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template<typename... T> int foo(const T&) // { dg-error "not expanded with|T" } +{ + union { T t; }; // { dg-error "not expanded with|T" } + return t; +} + +void bar() +{ + foo(0); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 10 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31437.C b/gcc/testsuite/g++.dg/cpp0x/pr31437.C new file mode 100644 index 000000000..0b64f7273 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31437.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template <typename... T> struct A // { dg-error "candidates|A" } +{ + A(T* p) { // { dg-error "parameter packs|T" } + (A<T...>*)(p); + } +}; + +A<int> a(0); // { dg-error "no matching" } +// { dg-message "candidate" "candidate note" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31438.C b/gcc/testsuite/g++.dg/cpp0x/pr31438.C new file mode 100644 index 000000000..74738830a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31438.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } + +template<typename> struct A; +template<typename T, typename... U> struct A<T(U)> // { dg-error "parameter packs|U" } +{ + template<typename X> A(X); +}; + +A<void(int)> a(0); // { dg-error "incomplete type" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31439.C b/gcc/testsuite/g++.dg/cpp0x/pr31439.C new file mode 100644 index 000000000..9d22b56c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31439.C @@ -0,0 +1,8 @@ +// { dg-options "-std=c++0x" } +template<typename...> struct A; // { dg-error "declaration" } + +template<char> struct A<> {}; // { dg-error "not used in partial specialization|anonymous" } + +template<typename T, typename... U> struct A<T, U...> : A<U...> {}; // { dg-error "incomplete type" } + +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31442.C b/gcc/testsuite/g++.dg/cpp0x/pr31442.C new file mode 100644 index 000000000..f4e411c45 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31442.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +template<typename... T, T = 0> struct A {}; // { dg-error "parameter packs|T|the end|parameter packs|anonymous" } + +struct B +{ + template <template <typename...> class C> B(C<int>); +}; + +B b = A<int>(); // { dg-error "mismatch|expected" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31443.C b/gcc/testsuite/g++.dg/cpp0x/pr31443.C new file mode 100644 index 000000000..1eb9d318d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31443.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } + +template<int, typename... T> struct A +{ + template<int N> void foo(A<N,T>); // { dg-error "parameter packs|T" } +}; + +void bar() +{ + A<0,int>().foo(A<0,int>()); // { dg-error "no member named" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31444.C b/gcc/testsuite/g++.dg/cpp0x/pr31444.C new file mode 100644 index 000000000..b1f86fe7a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31444.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename... T> struct A +{ + template<int> void foo(A<T>); // { dg-error "not expanded|T" } +}; + +void bar() +{ + A<int>().foo<0>(A<int>()); // { dg-error "no member named" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31445.C b/gcc/testsuite/g++.dg/cpp0x/pr31445.C new file mode 100644 index 000000000..b3f2b5b09 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31445.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template <typename... T> struct A +{ + void foo(T...); + A(T... t) { foo(t); } // { dg-error "parameter packs|t" } +}; + +A<int> a(0); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31993.C b/gcc/testsuite/g++.dg/cpp0x/pr31993.C new file mode 100644 index 000000000..94fb9ccda --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr31993.C @@ -0,0 +1,9 @@ +// { dg-options "-std=c++0x" } + +template<typename...> struct A; + +template<template<int> class... T> struct A<T<0>...> +{ + template<int> struct B {}; + B<0> b; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32114.C b/gcc/testsuite/g++.dg/cpp0x/pr32114.C new file mode 100644 index 000000000..e78dfdf1d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32114.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +template<typename ...T> struct A +{ + typedef typename T::X Y; // { dg-error "not expanded|T" } +}; + +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32115.C b/gcc/testsuite/g++.dg/cpp0x/pr32115.C new file mode 100644 index 000000000..a721eed4e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32115.C @@ -0,0 +1,4 @@ +// { dg-options "-std=c++0x" } +template<typename ...T, int = 0> struct A {}; // { dg-error "end of" } + +A<int> a; // { dg-error "mismatch|expected|invalid" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32125.C b/gcc/testsuite/g++.dg/cpp0x/pr32125.C new file mode 100644 index 000000000..210a29c08 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32125.C @@ -0,0 +1,8 @@ +// { dg-options "-std=c++0x" } +template<typename...> struct A; + +template<typename...T> struct A<T*> // { dg-error "not expanded|T" } +{ + A(); + A(T); +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32126.C b/gcc/testsuite/g++.dg/cpp0x/pr32126.C new file mode 100644 index 000000000..c525cca68 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32126.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++0x" } +template<typename...> struct A; + +template<typename...T> struct A<T> // { dg-error "not expanded|T|" } +{ + static int i; +}; + +A<char> a; // { dg-error "incomplete" } +A<int> b; // { dg-error "incomplete" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32127.C b/gcc/testsuite/g++.dg/cpp0x/pr32127.C new file mode 100644 index 000000000..8e4bc0050 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32127.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +template<typename...T> struct A +{ + static T i; // { dg-error "parameter packs|T" } +}; + +int j = A<int>::i; // { dg-error "not a member" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32128.C b/gcc/testsuite/g++.dg/cpp0x/pr32128.C new file mode 100644 index 000000000..5876dbec4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32128.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +template<typename...> struct A; + +template<typename...T, typename...U> + struct A<T..., U...> {}; // { dg-error "must be at the end" } + +A<int> a; // { dg-error "incomplete" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32252.C b/gcc/testsuite/g++.dg/cpp0x/pr32252.C new file mode 100644 index 000000000..543dc8873 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32252.C @@ -0,0 +1,8 @@ +// { dg-options "-std=c++0x" } +int x[5]; + +template<int M, int N, int (&... p)[N]> struct A; + +template<int M> struct A<M,5,x> {}; + +A<0,5,x> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32253.C b/gcc/testsuite/g++.dg/cpp0x/pr32253.C new file mode 100644 index 000000000..d8f7b03b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32253.C @@ -0,0 +1,9 @@ +// { dg-options "-std=c++0x" } +template<void (*... fp)()> struct A +{ + A() { fp(); } // { dg-error "not expanded|fp" } +}; + +void foo(); + +A<foo> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr32566.C b/gcc/testsuite/g++.dg/cpp0x/pr32566.C new file mode 100644 index 000000000..f6e7a5b54 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr32566.C @@ -0,0 +1,4 @@ +// { dg-options "-std=c++0x" } +template<int...> struct A; + +template<template<int> class... T> struct A<T...> {}; // { dg-error "mismatch|expected" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr33839.C b/gcc/testsuite/g++.dg/cpp0x/pr33839.C new file mode 100644 index 000000000..0a6610ac9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr33839.C @@ -0,0 +1,8 @@ +// { dg-options -std=c++0x } +template<int> struct A; + +void foo() +{ + __decltype A<0>; // { dg-error "invalid declarator|expected" } + __decltype (A<0>); // { dg-error "must be an expression" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr33930.C b/gcc/testsuite/g++.dg/cpp0x/pr33930.C new file mode 100644 index 000000000..d1e6fa56b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr33930.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++0x" } +typedef const int* type; + +float& foo( const type& ggg ); +int& foo( type&& ggg ); + +void bar( int* someptr ) +{ + int& x = foo( someptr ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr33955.C b/gcc/testsuite/g++.dg/cpp0x/pr33955.C new file mode 100644 index 000000000..cde92dedf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr33955.C @@ -0,0 +1,39 @@ +// { dg-options "-std=c++0x" } +template<typename T> +struct uncvref +{ + typedef T type; +}; + +template<typename... Args> +struct args +{ + static const int size = sizeof...(Args); +}; + +template<typename G, typename E, typename S, typename V, long GN = G::size, long EN = E::size> +struct apply_args; + +template<typename... G, typename... E, typename S, typename V, long N> +struct apply_args<args<G...>, args<E...>, S, V, N, N> +{ + typedef args< + typename G::template apply<typename uncvref<E>::type, S, V>::type... + > type; +}; + +struct or_ +{ + template<typename E, typename S, typename V> + struct apply { + typedef typename E::type type; + }; +}; + +template<typename T> +struct identity +{ + typedef T type; +}; + +apply_args<args<or_>, args<identity<int>>, float, double> a1; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr33996.C b/gcc/testsuite/g++.dg/cpp0x/pr33996.C new file mode 100644 index 000000000..07590f06f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr33996.C @@ -0,0 +1,52 @@ +// { dg-options "-std=c++0x" } + +#define BUG +struct type +{ + type() { } + type(const type&) { } + +private: + type(type&&); +}; + +template<typename _Tp> + struct identity + { + typedef _Tp type; + }; + +template<typename _Tp> + inline _Tp&& + forward(typename identity<_Tp>::type&& __t) + { return __t; } + +struct vec +{ + template<typename _Args> + void + bar(_Args&& __args) +#ifdef BUG + ; +#else + { + type(forward<_Args>(__args)); + } +#endif +}; + +#ifdef BUG +template<typename _Args> + void + vec::bar(_Args&& __args) + { + type(forward<_Args>(__args)); + } +#endif + +int main() +{ + vec v; + type c; + v.bar(c); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34054.C b/gcc/testsuite/g++.dg/cpp0x/pr34054.C new file mode 100644 index 000000000..cfc6c4bdc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34054.C @@ -0,0 +1,5 @@ +// PR c++/34054 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename... T> T foo() {} // { dg-error "not expanded|T" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34056.C b/gcc/testsuite/g++.dg/cpp0x/pr34056.C new file mode 100644 index 000000000..0e5246b6a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34056.C @@ -0,0 +1,10 @@ +// PR c++/34056 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename... T> struct A +{ + void foo (T *) { ++p; } // { dg-error "not expanded|T" } + void bar (T **) { } // { dg-error "not expanded|T" } + T *p; // { dg-error "not expanded|T" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34057.C b/gcc/testsuite/g++.dg/cpp0x/pr34057.C new file mode 100644 index 000000000..38da5ff50 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34057.C @@ -0,0 +1,8 @@ +// PR c++/34057 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <typename... T> struct A +{ + typedef T X __attribute__ ((vector_size (8))); // { dg-error "not expanded|T" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34058.C b/gcc/testsuite/g++.dg/cpp0x/pr34058.C new file mode 100644 index 000000000..0cf1faec7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34058.C @@ -0,0 +1,10 @@ +// PR c++/34058 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <typename...T> struct A +{ + typedef T X; // { dg-error "not expanded|T" } +}; + +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34060.C b/gcc/testsuite/g++.dg/cpp0x/pr34060.C new file mode 100644 index 000000000..8e0d321b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34060.C @@ -0,0 +1,11 @@ +// PR c++/34060 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <int> struct A +{ + template <typename... > struct B {}; + template <typename... T> struct B <int, T *> {}; // { dg-error "not expanded|T" } +}; + +A<0>::B<int>b; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr34061.C b/gcc/testsuite/g++.dg/cpp0x/pr34061.C new file mode 100644 index 000000000..7d6e71d0e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr34061.C @@ -0,0 +1,5 @@ +// PR c++/34061 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<template<int> class ...T> struct A : T<0> {}; // { dg-error "not expanded|T" } diff --git a/gcc/testsuite/g++.dg/cpp0x/pr38646.C b/gcc/testsuite/g++.dg/cpp0x/pr38646.C new file mode 100644 index 000000000..f15fc8c29 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr38646.C @@ -0,0 +1,12 @@ +/* PR c++/38646 */ +/* { dg-do compile } */ +/* { dg-options "-std=c++0x" } */ + +template<int...> struct A; + +template<int... N> struct A<N..., N...> /* { dg-error "must be at the end" } */ +{ + template<typename> struct B; + + template<typename T> struct B<T*> {}; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr38795.C b/gcc/testsuite/g++.dg/cpp0x/pr38795.C new file mode 100644 index 000000000..54fb361d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr38795.C @@ -0,0 +1,13 @@ +// PR c++/38795 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<typename... T> int foo(int i) +{ + return *reinterpret_cast<T*>(i); // { dg-error "not expanded with|T" } +} + +void bar(int i) +{ + foo<int>(i); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr39639.C b/gcc/testsuite/g++.dg/cpp0x/pr39639.C new file mode 100644 index 000000000..4fd8b56fd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr39639.C @@ -0,0 +1,20 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin: PR c++/39639 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <class... Types> +struct S + : S<...Types>, // { dg-error "expected parameter pack before '...'" } + S<...Types...>, // { dg-error "expected parameter pack before '...'" } + S<...> // { dg-error "expected parameter pack before '...'" } +{ + static int f () { return 1;} +}; + +int +main () +{ + return S<void>::f (); +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/pr42844-2.C b/gcc/testsuite/g++.dg/cpp0x/pr42844-2.C new file mode 100644 index 000000000..4425aacf6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr42844-2.C @@ -0,0 +1,42 @@ +// PR c++/42844 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct A // { dg-message "user-provided default constructor" } +{ + int i; + A() = default; // { dg-message "not user-provided" } +}; + +struct Base +{ + Base() {} +}; + +struct Derived : Base // { dg-message "user-provided default constructor" } +{ + int i; + Derived() = default; // { dg-message "not user-provided" } +}; + +struct Derived2 : Base // { dg-message "user-provided default constructor" } +{ + int i; + Derived2() = default; // { dg-message "not user-provided" } + Derived2( Derived2 const& ) = default; +}; + +struct Derived3 : Base // { dg-message "user-provided default constructor" } +{ + int i; + Derived3( Derived3 const& ) = default; + Derived3() = default; // { dg-message "not user-provided" } +}; + +void f() +{ + const A a; // { dg-error "uninitialized const" } + const Derived d; // { dg-error "uninitialized const" } + const Derived2 d2; // { dg-error "uninitialized const" } + const Derived3 d3; // { dg-error "uninitialized const" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr45908.C b/gcc/testsuite/g++.dg/cpp0x/pr45908.C new file mode 100644 index 000000000..3a8508890 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr45908.C @@ -0,0 +1,18 @@ +// PR c++/45908 +// Testcase by Jonathan Wakely <redi@gcc.gnu.org> + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct vector { + struct iterator { }; + struct const_iterator { }; + iterator begin(); + const_iterator begin() const; +}; + +class block { + vector v; + auto end() const -> decltype(v.begin()) + { return v.begin(); } // { dg-error "could not convert" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr47416.C b/gcc/testsuite/g++.dg/cpp0x/pr47416.C new file mode 100644 index 000000000..a11368a50 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr47416.C @@ -0,0 +1,225 @@ +// PR c++/47416 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +namespace std +{ + template < typename _Tp, _Tp __v > struct integral_constant + { + static const _Tp value = __v; + }; + typedef integral_constant < bool, false > false_type; + template < typename > struct is_array:false_type + { + }; + template < typename > struct is_function:false_type + { + }; + template < typename _Tp > struct remove_const + { + typedef _Tp type; + }; + template < typename _Tp > struct remove_volatile + { + typedef _Tp type; + }; + template < typename _Tp > struct remove_cv + { + typedef typename remove_const < typename remove_volatile < + _Tp >::type >::type type; + }; + template < typename > struct remove_reference + { + }; + template < typename _Tp > struct remove_reference <_Tp & > + { + typedef _Tp type; + }; + template < typename _Up, bool = is_array < _Up >::value, bool = + is_function < _Up >::value > struct __decay_selector; + template < typename _Up > struct __decay_selector <_Up, false, false > + { + typedef typename remove_cv < _Up >::type __type; + }; + template < typename _Tp > class decay + { + typedef typename remove_reference < _Tp >::type __remove_type; + public:typedef typename __decay_selector < + __remove_type >::__type type; + }; + template < typename _Tp > struct __strip_reference_wrapper + { + typedef _Tp __type; + }; + template < typename _Tp > struct __decay_and_strip + { + typedef typename __strip_reference_wrapper < typename decay < + _Tp >::type >::__type __type; + }; + template < typename _Tp > _Tp forward (typename remove_reference < + _Tp >::type &) + { + } + template < class _T1, class _T2 > struct pair + { + _T1 first; + _T2 second; + constexpr pair (_T1, _T2 &):first (), second (__b) // { dg-error "was not declared in this scope" } + { + } + }; + template < class _T1, + class _T2 > pair < typename __decay_and_strip < _T1 >::__type, + typename __decay_and_strip < _T2 >::__type > make_pair (_T1 && __x, _T2 + && __y) + { + typedef typename __decay_and_strip < _T1 >::__type __ds_type1; + typedef typename __decay_and_strip < _T2 >::__type __ds_type2; + typedef pair < __ds_type1, __ds_type2 > __pair_type; + __pair_type (forward < _T1 > (__x), std::forward < _T2 > (__y)); + } +} + +typedef long size_t; +namespace std +{ + template < typename > class allocator; + template < class > struct char_traits; + template < typename _CharT, typename = char_traits < _CharT >, typename = + allocator < _CharT > >class basic_string; + typedef basic_string < char >string; +} +namespace __gnu_cxx +{ + template < bool > class __pool; + template < template < bool > class, bool > struct __common_pool + { + }; + template < template < bool > class, bool > struct __common_pool_base; + template < template < bool > class _PoolTp > + struct __common_pool_base <_PoolTp, true >:__common_pool < _PoolTp, true > + { + }; + template < template < bool > class _PoolTp, + bool _Thread > struct __common_pool_policy:__common_pool_base < _PoolTp, + _Thread > + { + template < typename, template < bool > class _PoolTp1 = + _PoolTp, bool _Thread1 = _Thread > struct _M_rebind + { + typedef __common_pool_policy < _PoolTp1, _Thread1 > other; + }; + }; + template < typename _Tp > class __mt_alloc_base + { + }; +template < typename _Tp, typename _Poolp = __common_pool_policy < __pool, true > >class __mt_alloc:public __mt_alloc_base < + _Tp + > + { + public:size_t size_type; + typedef _Tp value_type; + template < typename _Tp1, typename _Poolp1 = _Poolp > struct rebind + { + typedef typename _Poolp1::template _M_rebind < _Tp1 >::other pol_type; + typedef __mt_alloc < _Tp1, pol_type > other; + }; + }; +} + +namespace std +{ + template < typename _Tp > class allocator:public __gnu_cxx::__mt_alloc < + _Tp > + { + }; + template < typename, typename > struct unary_function + { + }; + template < typename, typename, typename > struct binary_function + { + }; + template < typename _Tp > struct equal_to:binary_function < _Tp, _Tp, bool > + { + }; +} + +namespace boost +{ + template < class > struct hash; + template < class K, class T, class = hash < K >, class = + std::equal_to < K >, class = + std::allocator < std::pair < const K, T > >>class unordered_map; + template < >struct hash <std::string >:std::unary_function < std::string, + size_t > + { + }; + namespace unordered_detail + { + template < class Alloc, class T > struct rebind_wrap + { + typedef typename Alloc::template rebind < T >::other type; + }; + } + namespace unordered_detail + { + size_t default_bucket_count; + template < class, class > struct map_extractor; + struct ungrouped + { + }; + template < class T > class hash_table:T::buckets, T::buffered_functions + { + }; + template < class, class, class H, class P, class A, class, class G > struct types + { + typedef H hasher; + typedef P key_equal; + typedef A value_allocator; + }; + template < class T > class hash_unique_table:T + { + public:typedef typename T::hasher hasher; + typedef typename T::key_equal key_equal; + typedef typename T::value_allocator value_allocator; + typedef typename T::table table; + hash_unique_table (size_t n, hasher, key_equal, + value_allocator & a):table (n, a) // { dg-error "is not a direct base" } + { + } + }; + template < class K, class H, class P, class A > struct map:types < K, + typename A::value_type, H, P, A, map_extractor < K, + typename A::value_type >, ungrouped > + { + typedef hash_unique_table < map < K, H, P, A > >impl; + typedef hash_table < map < K, H, P, A > >table; + }; + } + template < class K, class T, class H, class P, class A > class unordered_map + { + typedef std::pair < const K, T > value_type; + typedef H hasher; + typedef P key_equal; + typedef A allocator_type; + typedef typename unordered_detail::rebind_wrap < allocator_type, + value_type >::type value_allocator; + typedef boost::unordered_detail::map < K, H, P, value_allocator > types; + typedef typename types::impl table; + typedef size_t size_type; + private:table table_; + public: unordered_map (size_type n = boost::unordered_detail::default_bucket_count, + hasher hf = hasher (), key_equal eql = key_equal (), + allocator_type a = allocator_type ()):table_ (n, hf, eql, a) // { dg-message "instantiated" } + { + } + }; +}; + +void +foo (const int &a) +{ + typedef boost::unordered_map < std::string, int >Name2Port; + Name2Port b; // { dg-message "instantiated" } + std::make_pair (a, b); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr47476.C b/gcc/testsuite/g++.dg/cpp0x/pr47476.C new file mode 100644 index 000000000..1f6f09ccc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr47476.C @@ -0,0 +1,10 @@ +// PR c++/47476 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +int +foo (int a, int b) +{ + const bool c ((a != 0) == (b != 26)); + return c; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr48522.C b/gcc/testsuite/g++.dg/cpp0x/pr48522.C new file mode 100644 index 000000000..1543d8a28 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr48522.C @@ -0,0 +1,24 @@ +// { dg-options "-std=c++0x" } + +template <typename T> +struct Handle +{ + Handle(T& t); +}; + +template<class T> +struct Class { + struct Struct {} data; + void f(); + void g(); +}; + +template<class T> +void Class<T>::f() { + Handle< decltype((data)) > handle(data); +} + +template<class T> +void Class<T>::g() { + Handle< decltype((data)) > handle(data); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr50491.C b/gcc/testsuite/g++.dg/cpp0x/pr50491.C new file mode 100644 index 000000000..48e7a1f74 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr50491.C @@ -0,0 +1,17 @@ +// { dg-options "-std=c++0x" } + +struct GrandParent { + void *get(); +}; + +template<class OBJ> +struct Parent : public GrandParent{ +}; + +template<typename T> +struct Child : public Parent<T> { + using GrandParent::get; + void Foo() { + void* ex = get(); + } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr50901.C b/gcc/testsuite/g++.dg/cpp0x/pr50901.C new file mode 100644 index 000000000..439c15cc1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr50901.C @@ -0,0 +1,9 @@ +// { dg-options "-std=c++0x" } + +template<class T> int foo(int a) +{ + const unsigned b = a < 0 ? -a : a; + return 0; +} + +int i = foo<float>(1); diff --git a/gcc/testsuite/g++.dg/cpp0x/pr51150.C b/gcc/testsuite/g++.dg/cpp0x/pr51150.C new file mode 100644 index 000000000..37eb166b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr51150.C @@ -0,0 +1,20 @@ +// PR c++/51150 +// { dg-options "-std=c++0x" } + +struct Clock { + double Now(); +}; +template <class T> void Foo(Clock* clock) { + const int now = clock->Now(); +} + +template void Foo<float>(Clock*); + +template <class T> void Boo(int val) { + const int now1 = (double)(val); + const int now2 = const_cast<double>(val); // { dg-error "invalid" } + const int now3 = static_cast<double>(val); + const int now4 = reinterpret_cast<double>(val); // { dg-error "invalid" } +} + +template void Boo<float>(int); diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for1.C b/gcc/testsuite/g++.dg/cpp0x/range-for1.C new file mode 100644 index 000000000..49e2ecd0b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for1.C @@ -0,0 +1,17 @@ +// Test for range-based for loop +// Test the loop with an array + +// { dg-do run } +// { dg-options "-std=c++0x" } + +extern "C" void abort(); + +int main() +{ + int a[] = {1,2,3,4}; + int sum = 0; + for (int x : a) + sum += x; + if (sum != 10) + abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for10.C b/gcc/testsuite/g++.dg/cpp0x/range-for10.C new file mode 100644 index 000000000..662074890 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for10.C @@ -0,0 +1,18 @@ +// PR c++/47388 +// { dg-do compile } +// { dg-options "-fno-for-scope -std=c++0x" } + +template <int> +void +foo () +{ + int a[] = { 1, 2, 3, 4 }; + for (int i : a) + ; +} + +void +bar () +{ + foo <0> (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for2.C b/gcc/testsuite/g++.dg/cpp0x/range-for2.C new file mode 100644 index 000000000..bfab37673 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for2.C @@ -0,0 +1,41 @@ +// Test for range-based for loop +// Test the loop with a custom iterator +// with begin/end in an associated namespace + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct iterator +{ + int x; + iterator(int v) :x(v) {} + iterator &operator ++() { ++x; return *this; } + int operator *() { return x; } + bool operator != (const iterator &o) { return x != o.x; } +}; + +namespace foo +{ + struct container + { + int min, max; + container(int a, int b) :min(a), max(b) {} + }; + + iterator begin(container &c) + { + return iterator(c.min); + } + + iterator end(container &c) + { + return iterator(c.max + 1); + } +} + +int main() +{ + foo::container c(1,4); + for (iterator it : c) + ; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for3.C b/gcc/testsuite/g++.dg/cpp0x/range-for3.C new file mode 100644 index 000000000..947f01ced --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for3.C @@ -0,0 +1,42 @@ +// Test for range-based for loop +// Test the loop with a custom iterator +// with begin/end in std + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct iterator +{ + int x; + iterator(int v) :x(v) {} + iterator &operator ++() { ++x; return *this; } + int operator *() { return x; } + bool operator != (const iterator &o) { return x != o.x; } +}; + +struct container +{ + int min, max; + container(int a, int b) :min(a), max(b) {} +}; + +namespace std +{ + iterator begin(container &c) + { + return iterator(c.min); + } + + iterator end(container &c) + { + return iterator(c.max + 1); + } +} + +int main() +{ + container c(1,4); + for (iterator it : c) + { + } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for4.C b/gcc/testsuite/g++.dg/cpp0x/range-for4.C new file mode 100644 index 000000000..afbcf14b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for4.C @@ -0,0 +1,116 @@ +// Test for range-based for loop with templates + +// { dg-do run } +// { dg-options "-std=c++0x" } + +/* Preliminary declarations */ +namespace pre +{ + struct iterator + { + int x; + iterator (int v) :x(v) {} + iterator &operator ++() { ++x; return *this; } + int operator *() { return x; } + bool operator != (const iterator &o) { return x != o.x; } + }; + + struct container + { + int min, max; + container(int a, int b) :min(a), max(b) {} + }; + + iterator begin(const container &c) + { + return iterator(c.min); + } + + iterator end(const container &c) + { + return iterator(c.max); + } + +} //namespace pre + +using pre::container; +extern "C" void abort(void); + +container run_me_just_once() +{ + static bool run = false; + if (run) + abort(); + run = true; + return container(1,2); +} + +/* Template with dependent expression. */ +template<typename T> int test1(const T &r) +{ + int t = 0; + for (int i : r) + t += i; + return t; +} + +/* Template with non-dependent expression and dependent declaration. */ +template<typename T> int test2(const container &r) +{ + int t = 0; + for (T i : r) + t += i; + return t; +} + +/* Template with non-dependent expression (array) and dependent declaration. */ +template<typename T> int test2(const int (&r)[4]) +{ + int t = 0; + for (T i : r) + t += i; + return t; +} + +/* Template with non-dependent expression and auto declaration. */ +template<typename T> int test3(const container &r) +{ + int t = 0; + for (auto i : r) + t += i; + return t; +} + +/* Template with non-dependent expression (array) and auto declaration. */ +template<typename T> int test3(const int (&r)[4]) +{ + int t = 0; + for (auto i : r) + t += i; + return t; +} + +int main () +{ + container c(1,5); + int a[4] = {5,6,7,8}; + + for (auto x : run_me_just_once()) + ; + + if (test1 (c) != 10) + abort(); + if (test1 (a) != 26) + abort(); + + if (test2<int> (c) != 10) + abort(); + if (test2<int> (a) != 26) + abort(); + + if (test3<int> (c) != 10) + abort(); + if (test3<int> (a) != 26) + abort(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for5.C b/gcc/testsuite/g++.dg/cpp0x/range-for5.C new file mode 100644 index 000000000..9c97ad5fa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for5.C @@ -0,0 +1,54 @@ +// Test for errors in range-based for loops + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct container +{ +}; + +int *begin(const container &c) +{ + return 0; +} + +int end(const container &c) //Ops! wrong type +{ + return 0; +} + + +struct Implicit +{ + Implicit(int x) + {} +}; +struct Explicit +{ + explicit Explicit(int x) + {} +}; + +void test1() +{ + container c; + for (int x : c) // { dg-error "inconsistent|conversion" } + ; + + int a[2] = {1,2}; + for (Implicit x : a) + ; + for (Explicit x : a) // { dg-error "conversion" } + ; + for (const Implicit &x : a) + ; + for (Implicit &&x : a) + ; + + //Check the correct scopes + int i; + for (int i : a) + { + int i; + } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for6.C b/gcc/testsuite/g++.dg/cpp0x/range-for6.C new file mode 100644 index 000000000..775507f8d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for6.C @@ -0,0 +1,29 @@ +// Test for range-based for loop +// Test the loop with an initializer_list + +// { dg-do run } +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +extern "C" void abort(); + +template<typename T> T foo() +{ + T sum = 0; + for (T x : {T(1),T(2),T(3),T(4)}) + sum += x; + if (sum != T(10)) + abort(); +} + +int main() +{ + int sum = 0; + for (int x : {1,2,3,4}) + sum += x; + if (sum != 10) + abort(); + + foo<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for7.C b/gcc/testsuite/g++.dg/cpp0x/range-for7.C new file mode 100644 index 000000000..ad89dc201 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for7.C @@ -0,0 +1,117 @@ +// PR c++/46056 +// Check that range-based for loop calls destructors +// when required +// { dg-options "-std=c++0x" } +// { dg-do run } +extern "C" void abort(); + +int value_counter = 0, it_counter = 0, seq_counter = 0; + +struct Int +{ + int x; + Int(int v) + :x(v) + { + ++value_counter; + } + Int(const Int &o) + :x(o.x) + { + ++value_counter; + } + ~Int() + { + --value_counter; + } +}; + +struct iterator +{ + int x; + iterator(int v) + :x(v) + { + ++it_counter; + } + iterator(const iterator &o) + :x(o.x) + { + ++it_counter; + } + ~iterator() + { + --it_counter; + } + iterator &operator ++() { ++x; return *this; } + int operator *() { return x; } + bool operator != (const iterator &o) { return x != o.x; } +}; + +struct container +{ + int min, max; + container(int a, int b) :min(a), max(b) + { + ++seq_counter; + } + container(const container &) = delete; + ~container() + { + --seq_counter; + } +}; + +iterator begin(container &c) +{ + return iterator(c.min); +} + +iterator end(container &c) +{ + return iterator(c.max + 1); +} + +int main() +{ + for (Int x : container(0, 10)) + { + if (value_counter != 1) abort(); + if (it_counter != 2) abort(); + if (seq_counter != 1) abort(); + } + if (value_counter != 0) abort(); + if (it_counter != 0) abort(); + if (seq_counter != 0) abort(); + + try + { + for (Int x : container(0, 10)) + { + if (value_counter != 1) abort(); + if (it_counter != 2) abort(); + if (seq_counter != 1) abort(); + } + if (value_counter != 0) abort(); + if (it_counter != 0) abort(); + if (seq_counter != 0) abort(); + + for (Int x : container(0, 10)) + { + if (value_counter != 1) abort(); + if (it_counter != 2) abort(); + if (seq_counter != 1) abort(); + + if (x.x == 5) + throw 0; + } + } + catch (int) + { + if (value_counter != 0) abort(); + if (it_counter != 0) abort(); + if (seq_counter != 0) abort(); + } + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for8.C b/gcc/testsuite/g++.dg/cpp0x/range-for8.C new file mode 100644 index 000000000..641dfe052 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for8.C @@ -0,0 +1,16 @@ +// Test for range-based for loop when the declarator declares +// a new type + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +#include <initializer_list> + +void test() +{ + for (struct S { } *x : { (S*)0, (S*)0 } ) + ; + + for (struct S { } x : { S(), S() } ) + ; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for9.C b/gcc/testsuite/g++.dg/cpp0x/range-for9.C new file mode 100644 index 000000000..96e9cb61f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for9.C @@ -0,0 +1,11 @@ +// Test for range-based for loop error in C++98 mode + +// { dg-do compile } +// { dg-options "-std=c++98" } + +void test() +{ + int a[] = {0,1,2}; + for (int x : a) // { dg-error "range-based-for" } + ; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/reference_collapsing.C b/gcc/testsuite/g++.dg/cpp0x/reference_collapsing.C new file mode 100644 index 000000000..5b682e304 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/reference_collapsing.C @@ -0,0 +1,175 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test the reference collapsing rules. Note that there are recent differences +// for how cv-qualifications are applied to reference types. 7.1.3, 14.3.1 + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +template <class T, T v> +struct integral_constant +{ + static const T value = v; + typedef T value_type; + typedef integral_constant<T, v> type; +}; + +typedef integral_constant<bool, true> true_type; +typedef integral_constant<bool, false> false_type; + +template <class T> struct is_lvalue_reference : public integral_constant<bool, false> {}; +template <class T> struct is_lvalue_reference<T&> : public integral_constant<bool, true> {}; + +template <class T> struct is_rvalue_reference : public integral_constant<bool, false> {}; +template <class T> struct is_rvalue_reference<T&&> : public integral_constant<bool, true> {}; + +template <class T> struct remove_reference {typedef T type;}; +template <class T> struct remove_reference<T&> {typedef T type;}; +template <class T> struct remove_reference<T&&> {typedef T type;}; + +template <class T> struct is_const : public integral_constant<bool, false> {}; +template <class T> struct is_const<T const> : public integral_constant<bool, true> {}; + +template <class T> struct is_volatile : public integral_constant<bool, false> {}; +template <class T> struct is_volatile<T volatile> : public integral_constant<bool, true> {}; + +struct A {}; + +typedef A& Alref; +typedef const A& cAlref; +typedef volatile A& vAlref; +typedef const volatile A& cvAlref; + +typedef A&& Arref; +typedef const A&& cArref; +typedef volatile A&& vArref; +typedef const volatile A&& cvArref; + +template <class T, bool is_lvalue_ref, bool is_rvalue_ref, bool s_const, bool s_volatile> +void test() +{ + sa<is_lvalue_reference<T>::value == is_lvalue_ref> t1; + sa<is_rvalue_reference<T>::value == is_rvalue_ref> t2; + sa<is_const <typename remove_reference<T>::type>::value == s_const> t3; + sa<is_volatile<typename remove_reference<T>::type>::value == s_volatile> t4; + sa<is_const <typename remove_reference<const T>::type>::value == s_const > t5; + sa<is_volatile<typename remove_reference< volatile T>::type>::value == s_volatile> t6; +} + +int main() +{ + // sanity check + test< A&, true, false, false, false>(); + test<const A&, true, false, true, false>(); + test< volatile A&, true, false, false, true>(); + test<const volatile A&, true, false, true, true>(); + test< A&&, false, true, false, false>(); + test<const A&&, false, true, true, false>(); + test< volatile A&&, false, true, false, true>(); + test<const volatile A&&, false, true, true, true>(); + +// lvalue reference test + + // Alref + test< Alref&, true, false, false, false>(); + test<const Alref&, true, false, false, false>(); + test< volatile Alref&, true, false, false, false>(); + test<const volatile Alref&, true, false, false, false>(); + + // cAlref + test< cAlref&, true, false, true, false>(); + test<const cAlref&, true, false, true, false>(); + test< volatile cAlref&, true, false, true, false>(); + test<const volatile cAlref&, true, false, true, false>(); + + // vAlref + test< vAlref&, true, false, false, true>(); + test<const vAlref&, true, false, false, true>(); + test< volatile vAlref&, true, false, false, true>(); + test<const volatile vAlref&, true, false, false, true>(); + + // cvAlref + test< cvAlref&, true, false, true, true>(); + test<const cvAlref&, true, false, true, true>(); + test< volatile cvAlref&, true, false, true, true>(); + test<const volatile cvAlref&, true, false, true, true>(); + + // Arref + test< Arref&, true, false, false, false>(); + test<const Arref&, true, false, false, false>(); + test< volatile Arref&, true, false, false, false>(); + test<const volatile Arref&, true, false, false, false>(); + + // cArref + test< cArref&, true, false, true, false>(); + test<const cArref&, true, false, true, false>(); + test< volatile cArref&, true, false, true, false>(); + test<const volatile cArref&, true, false, true, false>(); + + // vArref + test< vArref&, true, false, false, true>(); + test<const vArref&, true, false, false, true>(); + test< volatile vArref&, true, false, false, true>(); + test<const volatile vArref&, true, false, false, true>(); + + // vArref + test< cvArref&, true, false, true, true>(); + test<const cvArref&, true, false, true, true>(); + test< volatile cvArref&, true, false, true, true>(); + test<const volatile cvArref&, true, false, true, true>(); + +// rvalue reference test + + // Alref + test< Alref&&, true, false, false, false>(); + test<const Alref&&, true, false, false, false>(); + test< volatile Alref&&, true, false, false, false>(); + test<const volatile Alref&&, true, false, false, false>(); + + // cAlref + test< cAlref&&, true, false, true, false>(); + test<const cAlref&&, true, false, true, false>(); + test< volatile cAlref&&, true, false, true, false>(); + test<const volatile cAlref&&, true, false, true, false>(); + + // vAlref + test< vAlref&&, true, false, false, true>(); + test<const vAlref&&, true, false, false, true>(); + test< volatile vAlref&&, true, false, false, true>(); + test<const volatile vAlref&&, true, false, false, true>(); + + // cvAlref + test< cvAlref&&, true, false, true, true>(); + test<const cvAlref&&, true, false, true, true>(); + test< volatile cvAlref&&, true, false, true, true>(); + test<const volatile cvAlref&&, true, false, true, true>(); + + // Arref + test< Arref&&, false, true, false, false>(); + test<const Arref&&, false, true, false, false>(); + test< volatile Arref&&, false, true, false, false>(); + test<const volatile Arref&&, false, true, false, false>(); + + // cArref + test< cArref&&, false, true, true, false>(); + test<const cArref&&, false, true, true, false>(); + test< volatile cArref&&, false, true, true, false>(); + test<const volatile cArref&&, false, true, true, false>(); + + // vArref + test< vArref&&, false, true, false, true>(); + test<const vArref&&, false, true, false, true>(); + test< volatile vArref&&, false, true, false, true>(); + test<const volatile vArref&&, false, true, false, true>(); + + // cvArref + test< cvArref&&, false, true, true, true>(); + test<const cvArref&&, false, true, true, true>(); + test< volatile cvArref&&, false, true, true, true>(); + test<const volatile cvArref&&, false, true, true, true>(); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/49290.C b/gcc/testsuite/g++.dg/cpp0x/regress/49290.C new file mode 100644 index 000000000..71e46c579 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/49290.C @@ -0,0 +1,12 @@ +typedef unsigned T; +struct S +{ + T foo (void); + static unsigned s1[16]; +}; +T +S::foo () +{ + T u = *(T *) (s1 + 10); + return u; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/README b/gcc/testsuite/g++.dg/cpp0x/regress/README new file mode 100644 index 000000000..5c3402e74 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/README @@ -0,0 +1,3 @@ +This directory contains tests that were passing in C++98 mode but failing +in C++0x mode; it should be replaced by an improvement to the test harness +to run all tests in both modes. diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/abi-empty7.C b/gcc/testsuite/g++.dg/cpp0x/regress/abi-empty7.C new file mode 100644 index 000000000..adc71278d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/abi-empty7.C @@ -0,0 +1,20 @@ +// Copy of abi/empty7.C. +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-require-effective-target ilp32 } +// { dg-options "-fabi-version=0 -std=c++0x" } + +struct S1 {}; +struct S2 { virtual void f () {} S1 s1[4]; }; +struct S3 : virtual public S2 {}; +struct S4 : virtual public S2 { int i; }; +struct S5 : public S3, virtual public S4 {}; +struct S6 { S5 s5; }; +struct S7 { S1 s1[5]; }; +struct S8 : public S1, public S6, virtual public S7 { }; + +S8 s8; + +int main () { + if ((char *)(S7 *)&s8 - (char *)&s8 != 24) + return 1; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/array1.C b/gcc/testsuite/g++.dg/cpp0x/regress/array1.C new file mode 100644 index 000000000..629ab4103 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/array1.C @@ -0,0 +1,16 @@ +// PR c++/47808 +// { dg-options -std=c++0x } + +template <typename T> +inline T abs (T const & x) { return x; } + +template <typename T> +void f (T) +{ + typedef int ai[(abs(0.1) > 0) ? 1 : -1]; +} + +int main() +{ + f(1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C b/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C new file mode 100644 index 000000000..a2e9d47b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C @@ -0,0 +1,9 @@ +// PR c++/46282 +// { dg-options -std=c++0x } + +template<int> +class A +{ + A : i() {} // { dg-message "" } + int i; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/call1.C b/gcc/testsuite/g++.dg/cpp0x/regress/call1.C new file mode 100644 index 000000000..833318b05 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/call1.C @@ -0,0 +1,13 @@ +// PR c++/48500 +// { dg-options -std=c++0x } + +struct linked_ptr { +}; +template <typename T> linked_ptr make_linked_ptr(T* ptr); +struct Concrete; +struct NewedClass { + NewedClass(const Concrete& req){} +}; +template<typename ArgT> void AddObjToChange(const ArgT& req) { + linked_ptr p = make_linked_ptr(new NewedClass(req)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/condition1.C b/gcc/testsuite/g++.dg/cpp0x/regress/condition1.C new file mode 100644 index 000000000..0346764f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/condition1.C @@ -0,0 +1,80 @@ +// PR c++/47950 +// { dg-options -std=c++0x } + +template <typename T> struct empty +{ + // allow success case to build (not relevant to bug) + operator bool() { return true; } +}; + +template <typename T> struct from_int +{ + from_int(int) {} + + // allow success case to build (not relevant to bug) + operator bool() { return true; } +}; + +template <typename T> +from_int<T> via_function(T v) +{ + return from_int<T>(v); +} + +template <typename T> +void f() +{ + // ********* this section compiles *********** + + // these plain initializers work fine + from_int<int> a = 7; + from_int<int> b = from_int<int>(7); + empty<int> c = empty<int>(); + from_int<T> ta = 7; + from_int<T> tb = from_int<T>(7); + empty<T> tc = empty<T>(); + + // these dependent condition decls work fine + if (empty<T> x = empty<T>()) + ; + if (from_int<T> x = 7) + ; + if (from_int<T> x = from_int<T>(7)) + ; + if (from_int<T> x = via_function(T())) + ; + + // this non-dependent condition decl using conversion works fine + if (from_int<int> x = 7) + ; + + // these non-dependent condition decls using conversion or braced- + // initialization work fine (in c++0x mode only course) + #if __GXX_EXPERIMENTAL_CXX0X__ + if (empty<int> x {}) + ; + if (from_int<int> x {7}) + ; + #endif + + // ********** this section fails in C++0x *********** + + // the following non-dependent condition decls cause an assertion + // failure in + // + // tsubst_copy_and_build, at cp/pt.c:13370 + // + // in C++0x mode + // + if (empty<int> x = empty<int>()) + ; + if (from_int<int> x = from_int<int>(7)) + ; + if (from_int<int> x = via_function(7)) + ; +} + +int main() +{ + f<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/debug-debug7.C b/gcc/testsuite/g++.dg/cpp0x/regress/debug-debug7.C new file mode 100644 index 000000000..ea8f1eb2e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/debug-debug7.C @@ -0,0 +1,19 @@ +// { dg-do compile } +// { dg-options -std=c++0x } + +void f (int); + +int +main() { + + int a = 4; + int b = 5; // { dg-message "not const" } + int (*x)[b] = new int[a][b]; // { dg-error "not usable" } + + x[2][1] = 7; + + for (int i = 0; i < a; ++i) + for (int j = 0; j < b; ++j) + f (x[i][j]); + delete [] x; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C b/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C new file mode 100644 index 000000000..6e29f9ea9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C @@ -0,0 +1,8 @@ +// PR c++/47482 +// { dg-options -std=c++0x } + +template<class> +struct K +{ + enum { A = sizeof"A", B = +A }; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C b/gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C new file mode 100644 index 000000000..2094d3e3e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/error-recovery1.C @@ -0,0 +1,9 @@ +// PR c++/48212 +// { dg-options -std=c++0x } + +template < bool > void +foo () +{ + const bool b =; // { dg-error "" } + foo < b > (); // { dg-error "constant expression" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ext-cond1.C b/gcc/testsuite/g++.dg/cpp0x/regress/ext-cond1.C new file mode 100644 index 000000000..dc9814ebd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/ext-cond1.C @@ -0,0 +1,4 @@ +// PR c++/12515 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +template<int> void foo() { 0 ?: 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C b/gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C new file mode 100644 index 000000000..652d94af0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C @@ -0,0 +1,17 @@ +// PR c++/33836 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<int N> struct A +{ + enum { M = && N }; // { dg-error "referenced outside|cannot appear in|not an integer constant" } +}; + +A<0> a; + +void foo () +{ + __label__ P; + enum { O = && P }; // { dg-error "cannot appear in|not an integer constant" } + P:; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/isnan.C b/gcc/testsuite/g++.dg/cpp0x/regress/isnan.C new file mode 100644 index 000000000..40d07e5de --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/isnan.C @@ -0,0 +1,9 @@ +// PR c++/48369 +// { dg-options -std=gnu++0x } + +extern "C" int isnan (double); + +void f(double d) +{ + bool b = isnan(d); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/no-elide1.C b/gcc/testsuite/g++.dg/cpp0x/regress/no-elide1.C new file mode 100644 index 000000000..50df95016 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/no-elide1.C @@ -0,0 +1,14 @@ +// PR c++/47503 +// { dg-options "-std=c++0x -fno-elide-constructors" } + +struct A +{ + int i; + A (); +}; + +struct B +{ + A a; + B (A &aa) : a (aa) { } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/non-const1.C b/gcc/testsuite/g++.dg/cpp0x/regress/non-const1.C new file mode 100644 index 000000000..7fc66a7ae --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/non-const1.C @@ -0,0 +1,9 @@ +// PR c++/48015 +// { dg-options -std=c++0x } + +template <typename T> T f(T); +template <typename T> void g() +{ + int const c = f (1); + int i = c - 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/parse-ambig5.C b/gcc/testsuite/g++.dg/cpp0x/regress/parse-ambig5.C new file mode 100644 index 000000000..9be2f9258 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/parse-ambig5.C @@ -0,0 +1,8 @@ +// PR c++/41786 +// { dg-options -std=c++0x } + +struct A { A(int, char const*); }; +int main() { + int i = 0, *b = &i; + A a(int(b[i]), "hello"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ptrmem1.C b/gcc/testsuite/g++.dg/cpp0x/regress/ptrmem1.C new file mode 100644 index 000000000..873000b9c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/ptrmem1.C @@ -0,0 +1,9 @@ +// PR c++/49298 +// { dg-options -std=c++0x } + +template <class T, int T::*> struct B { }; +template <class T> struct A +{ + int i; + B<A,&A::i> b; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/regress1.C b/gcc/testsuite/g++.dg/cpp0x/regress/regress1.C new file mode 100644 index 000000000..a6fe3999c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/regress1.C @@ -0,0 +1,10 @@ +// PR c++/46903 +// This isn't C++0x code, but it was breaking in C++0x mode. +// { dg-options -std=c++0x } + +struct A {}; +struct B { + void *(*a)(); +}; +template <typename T> void *CreateA() {} +B b = {CreateA<A>}; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/regress2.C b/gcc/testsuite/g++.dg/cpp0x/regress/regress2.C new file mode 100644 index 000000000..470ee1c4c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/regress2.C @@ -0,0 +1,13 @@ +// PR c++/46552 +// { dg-options -std=c++0x } + +struct S +{ + int x; +}; + +template < typename > +void f( void ) +{ + &S::x; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/regress3.C b/gcc/testsuite/g++.dg/cpp0x/regress/regress3.C new file mode 100644 index 000000000..ffbb97f6b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/regress3.C @@ -0,0 +1,13 @@ +// PR c++/47511 +// { dg-options -std=c++0x } + +namespace N { + template <typename T> bool g( T ) { + return true; + } + struct A { }; +} +template <class T> void f(const T&) { + N::A x; + g(x) ; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C b/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C new file mode 100644 index 000000000..b1935912d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C @@ -0,0 +1,16 @@ +// { dg-options -std=c++0x } + +struct A +{ + int i; + A(int); +}; + +struct B +{ + virtual void f(); + A ar[3]; +}; + +extern B b; +B b2(b); diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/template-const1.C b/gcc/testsuite/g++.dg/cpp0x/regress/template-const1.C new file mode 100644 index 000000000..32db1f831 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/template-const1.C @@ -0,0 +1,9 @@ +// PR c++/47897 +// { dg-options -std=c++0x } + +template < typename T, T N > +struct S +{ + static const T value = N; + typedef S< T, value + 1 > next; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/template-const2.C b/gcc/testsuite/g++.dg/cpp0x/regress/template-const2.C new file mode 100644 index 000000000..25354b3a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/template-const2.C @@ -0,0 +1,14 @@ +// PR c++/48707 +// { dg-options -std=c++0x } + +struct A { + static int a(); +}; + +template<typename X> +struct B: A { + static int const b; +}; + +template<typename X> +int const B<X>::b=B<X>::a(); diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C b/gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C new file mode 100644 index 000000000..66cbd4ba1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/template-function1.C @@ -0,0 +1,29 @@ +// PR c++/38647 +// { dg-do compile } +// { dg-options "-std=c++0x" } +// { dg-prune-output "note" } + +template<const char *, int> struct A {}; +const char func[] = "abc"; +template<int N> struct A<func, N> {}; // { dg-error "cannot appear|is invalid|not a valid|constant expression" } + +char a1[1]; +A<a1, 0> a; + +template<const char *, int> struct B {}; +template<int N> struct B<__FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid|constant expression" } + +char b1[1]; +B<b1, 0> b; + +template<const char *, int> struct C {}; +template<int N> struct C<__PRETTY_FUNCTION__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid|constant expression" } + +char c1[1]; +C<c1, 0> c; + +template<const char *, int> struct D {}; +template<int N> struct D<__func__, N> {}; // { dg-error "cannot appear|is invalid|is not a valid|function scope|constant expression" } + +char d1[1]; +D<d1, 0> d; diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C b/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C new file mode 100644 index 000000000..112389d4a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/value-dep1.C @@ -0,0 +1,7 @@ +// PR c++/48265 +// { dg-options -std=c++0x } + +template < int > struct S +{ + S () { const int i = i; i; }; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-bitfield.C b/gcc/testsuite/g++.dg/cpp0x/rv-bitfield.C new file mode 100644 index 000000000..ed866f9e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-bitfield.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } + +struct A +{ + int i : 1; +}; + +int main() +{ + A a; + static_cast<int&&>(a.i); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-bitfield2.C b/gcc/testsuite/g++.dg/cpp0x/rv-bitfield2.C new file mode 100644 index 000000000..e054151b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-bitfield2.C @@ -0,0 +1,17 @@ +// PR c++/51868 +// { dg-options -std=c++0x } + +struct A { + A() {} + A(const A&) {} + A(A&&) {} +}; + +struct B { + A a; + int f : 1; +}; + +B func() { + return B(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cast.C b/gcc/testsuite/g++.dg/cpp0x/rv-cast.C new file mode 100644 index 000000000..48b7c13ba --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-cast.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x" } + +void f(int i) +{ + int&& r = static_cast<int&&>(i); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C b/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C new file mode 100644 index 000000000..94ee4ca84 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C @@ -0,0 +1,21 @@ +// Test for const_cast to reference (5.2.11/4). +// { dg-options -std=c++0x } + +template <class T> T&& xval(); +template <class T> T& lval(); +template <class T> T prval(); + +struct A { }; + +int main() +{ + const_cast<int&>(lval<int>()); + const_cast<int&>(xval<int>()); // { dg-error "" } + const_cast<int&>(prval<int>()); // { dg-error "" } + const_cast<int&&>(lval<int>()); + const_cast<int&&>(xval<int>()); + const_cast<int&&>(prval<int>()); // { dg-error "" } + const_cast<A&&>(lval<A>()); + const_cast<A&&>(xval<A>()); + const_cast<A&&>(prval<A>()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cast3.C b/gcc/testsuite/g++.dg/cpp0x/rv-cast3.C new file mode 100644 index 000000000..e7d5b6d34 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-cast3.C @@ -0,0 +1,18 @@ +// PR c++/51406 +// { dg-do run } +// { dg-options "-std=c++0x" } + +extern "C" int printf(const char *,...); +extern "C" void abort(); + +struct A { int a; A() : a(1) {} }; +struct B { int b; B() : b(2) {} }; +struct X : A, B {}; + +int main() { + X x; + int a=static_cast<A&&>(x).a; + int b=static_cast<B&&>(x).b; + // printf ("%d %d\n", a, b); + if (a!=1 || b!=2) abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cast4.C b/gcc/testsuite/g++.dg/cpp0x/rv-cast4.C new file mode 100644 index 000000000..8f4a56bf9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-cast4.C @@ -0,0 +1,13 @@ +// PR c++/51161 +// { dg-options "-std=c++0x" } + +struct A{}; +struct B : A{}; +struct C : A{}; +struct D : B, C{}; + +int main() +{ + D d; + static_cast<A &&>(d); // { dg-error "ambiguous" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-deduce.C b/gcc/testsuite/g++.dg/cpp0x/rv-deduce.C new file mode 100644 index 000000000..043543631 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-deduce.C @@ -0,0 +1,8 @@ +// PR c++/36816, core issue 873 +// { dg-options -std=c++0x } + +template <class T> void h (T&&) { } + +void (*pf)(int&) = &h; +template <> void h(char&); +template void h(double&); diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C b/gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C new file mode 100644 index 000000000..160296f64 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-deduce2.C @@ -0,0 +1,18 @@ +// PR c++/48313 +// { dg-options -std=c++0x } + +template<typename F> +void f(F&&) { } + +void g() { } + +template<typename T> void h() { } + +int main() +{ + f( g ); // OK + void (&p)() = h<int>; + f( p ); // OK + f( h<int> ); // ??? +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-lvalue-req.C b/gcc/testsuite/g++.dg/cpp0x/rv-lvalue-req.C new file mode 100644 index 000000000..a8f424df0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-lvalue-req.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } + +template <class T> T&& declval(); + +int main() +{ + &declval<int>(); // { dg-error "xvalue" } + declval<int>() = declval<int>(); // { dg-error "xvalue" } + declval<int>()++; // { dg-error "xvalue" } + --declval<int>(); // { dg-error "xvalue" } + declval<int>() += 1; // { dg-error "xvalue" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-reinterpret.C b/gcc/testsuite/g++.dg/cpp0x/rv-reinterpret.C new file mode 100644 index 000000000..5b6e4c3d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-reinterpret.C @@ -0,0 +1,11 @@ +// { dg-options -std=c++0x } +// { dg-do run } + +void f(int &); +void f(int &&ir) { ir = 42; } +int main() +{ + int x; + f(reinterpret_cast<int&&>(x)); + return (x != 42); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-restrict.C b/gcc/testsuite/g++.dg/cpp0x/rv-restrict.C new file mode 100644 index 000000000..569ee5bb6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-restrict.C @@ -0,0 +1,6 @@ +// PR c++/45401 +// { dg-options -std=c++0x } + +typedef int &__restrict restrictLvref; +typedef restrictLvref &&rvrefToRestrictLvref; +typedef restrictLvref rvrefToRestrictLvref; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-return.C b/gcc/testsuite/g++.dg/cpp0x/rv-return.C new file mode 100644 index 000000000..e52101fea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-return.C @@ -0,0 +1,18 @@ +// PR c++/41815 +// { dg-options -std=c++0x } + +template<typename T, typename U> struct same_type; +template<typename T> struct same_type<T, T> {}; + +int const f() { return 0; } + +int &&r = f(); // binding "int&&" to "int" should succeed +same_type<decltype(f()), int const> s1; +same_type<decltype(0,f()), int> s2; + +template <class T> +T const g() { return 0; } + +int &&r2 = g<int>(); +same_type<decltype(g<int>()), int const> s3; +same_type<decltype(0,g<int>()), int> s4; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-trivial-bug.C b/gcc/testsuite/g++.dg/cpp0x/rv-trivial-bug.C new file mode 100644 index 000000000..2765b5f3c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-trivial-bug.C @@ -0,0 +1,33 @@ +// { dg-options "-std=c++0x" } +// PR c++/33235 +#include <cassert> + +int move_construct = 0; +int move_assign = 0; + +struct base2 +{ + base2() {} + base2(base2&&) {++move_construct;} // { dg-error "argument 1" } + base2& operator=(base2&&) {++move_assign; return *this;} // { dg-error "argument 1" } +}; + +int test2() +{ + base2 b; + base2 b2(b); // { dg-error "lvalue" } + assert(move_construct == 0); + base2 b3(static_cast<base2&&>(b)); + base2 b4 = static_cast<base2&&>(b); + assert(move_construct == 2); + b = b2; // { dg-error "lvalue" } + assert(move_assign == 0); + b = static_cast<base2&&>(b2); + assert(move_assign == 1); +} + +int main() +{ + test2(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv10.C b/gcc/testsuite/g++.dg/cpp0x/rv10.C new file mode 100644 index 000000000..5e78b1dbb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv10.C @@ -0,0 +1,15 @@ +// { dg-options "-std=gnu++0x" } + +struct A +{ + A() = default; + A(const A&) = delete; +}; + +A&& f(); +void h(A&&); +void g() +{ + A&& arr = f(); + h(f()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv1n.C b/gcc/testsuite/g++.dg/cpp0x/rv1n.C new file mode 100644 index 000000000..5224d3eb7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv1n.C @@ -0,0 +1,169 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; +struct three {char x[3];}; +struct four {char x[4];}; +struct five {char x[5];}; +struct six {char x[6];}; +struct seven {char x[7];}; +struct eight {char x[8];}; + +struct A +{ + A(); + A(const volatile A&&); // { dg-error "argument 1" } +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 1 at a time + +one sink_1_1( A&); // { dg-error "" } + +int test1_1() +{ + A a; + const A ca = a; // { dg-error "cannot bind" } + volatile A va; + const volatile A cva = a; // { dg-error "cannot bind" } + sink_1_1(ca); // { dg-error "invalid initialization" } + sink_1_1(va); // { dg-error "invalid initialization" } + sink_1_1(cva); // { dg-error "invalid initialization" } + sink_1_1(source()); // { dg-error "invalid initialization" } + sink_1_1(c_source()); // { dg-error "invalid initialization" } + sink_1_1(v_source()); // { dg-error "invalid initialization" } + sink_1_1(cv_source()); // { dg-error "invalid initialization" } + return 0; +} + +two sink_1_2(const A&); // { dg-error "" } + +int test1_2() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_1_2(va); // { dg-error "invalid initialization" } + sink_1_2(cva); // { dg-error "invalid initialization" } + sink_1_2(v_source()); // { dg-error "invalid initialization" } + sink_1_2(cv_source()); // { dg-error "invalid initialization" } + return 0; +} + +three sink_1_3(volatile A&); // { dg-error "" } + +int test1_3() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_1_3(ca); // { dg-error "invalid initialization" } + sink_1_3(cva); // { dg-error "invalid initialization" } + sink_1_3(source()); // { dg-error "invalid initialization" } + sink_1_3(c_source()); // { dg-error "invalid initialization" } + sink_1_3(v_source()); // { dg-error "invalid initialization" } + sink_1_3(cv_source()); // { dg-error "invalid initialization" } + return 0; +} + +four sink_1_4(const volatile A&); // { dg-error "" } + +int test1_4() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_1_4(source()); // { dg-error "invalid initialization" } + sink_1_4(c_source()); // { dg-error "invalid initialization" } + sink_1_4(v_source()); // { dg-error "invalid initialization" } + sink_1_4(cv_source()); // { dg-error "invalid initialization" } + return 0; +} + +five sink_1_5( A&&); // { dg-error "" } + +int test1_5() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_1_5(a); // { dg-error "lvalue" } + sink_1_5(ca); // { dg-error "invalid initialization" } + sink_1_5(va); // { dg-error "invalid initialization" } + sink_1_5(cva); // { dg-error "invalid initialization" } + sink_1_5(c_source()); // { dg-error "invalid initialization" } + sink_1_5(v_source()); // { dg-error "invalid initialization" } + sink_1_5(cv_source()); // { dg-error "invalid initialization" } + return 0; +} + +six sink_1_6(const A&&); // { dg-error "" } + +int test1_6() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_1_6(a); // { dg-error "lvalue" } + sink_1_6(ca); // { dg-error "lvalue" } + sink_1_6(va); // { dg-error "invalid initialization" } + sink_1_6(cva); // { dg-error "invalid initialization" } + sink_1_6(v_source()); // { dg-error "invalid initialization" } + sink_1_6(cv_source()); // { dg-error "invalid initialization" } + return 0; +} + +seven sink_1_7(volatile A&&); // { dg-error "" } + +int test1_7() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_1_7(a); // { dg-error "lvalue" } + sink_1_7(ca); // { dg-error "invalid initialization" } + sink_1_7(va); // { dg-error "lvalue" } + sink_1_7(cva); // { dg-error "invalid initialization" } + sink_1_7(c_source()); // { dg-error "invalid initialization" } + sink_1_7(cv_source()); // { dg-error "invalid initialization" } + return 0; +} + +eight sink_1_8(const volatile A&&); // { dg-error "" } + +int test1_8() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_1_8(a); // { dg-error "lvalue" } + sink_1_8(ca); // { dg-error "lvalue" } + sink_1_8(va); // { dg-error "lvalue" } + sink_1_8(cva); // { dg-error "lvalue" } + return 0; +} + +int main() +{ + return test1_1() + test1_2() + test1_3() + test1_5() + + test1_6() + test1_7(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv1p.C b/gcc/testsuite/g++.dg/cpp0x/rv1p.C new file mode 100644 index 000000000..abe5de0b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv1p.C @@ -0,0 +1,145 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 1 at a time + +one sink_1_1( A&); + +int test1_1() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_1(a)) == 1 * sizeof(long)> t1; + return 0; +} + +two sink_1_2(const A&); + +int test1_2() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_2(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_1_2(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_1_2(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_1_2(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +three sink_1_3(volatile A&); + +int test1_3() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_3(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_1_3(va)) == 3 * sizeof(long)> t3; + return 0; +} + +four sink_1_4(const volatile A&); + +int test1_4() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_4(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_1_4(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_1_4(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_1_4(cva)) == 4 * sizeof(long)> t4; + return 0; +} + +five sink_1_5( A&&); + +int test1_5() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_5(source())) == 5 * sizeof(long)> t5; + return 0; +} + +six sink_1_6(const A&&); + +int test1_6() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_6(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_1_6(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +seven sink_1_7(volatile A&&); + +int test1_7() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_7(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_1_7(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +eight sink_1_8(const volatile A&&); + +int test1_8() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_1_8(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_1_8(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_1_8(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_1_8(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test1_1() + test1_2() + test1_3() + test1_4() + + test1_5() + test1_6() + test1_7() + test1_8(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv2n.C b/gcc/testsuite/g++.dg/cpp0x/rv2n.C new file mode 100644 index 000000000..2b3a9c06a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv2n.C @@ -0,0 +1,544 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; +struct three {char x[3];}; +struct four {char x[4];}; +struct five {char x[5];}; +struct six {char x[6];}; +struct seven {char x[7];}; +struct eight {char x[8];}; + +struct A +{ + A(); + A(const volatile A&&); // { dg-error "argument 1" } +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 2 at a time + +one sink_2_12( A&); // { dg-message "note|argument" } +two sink_2_12(const A&); // { dg-message "note|argument" } + +int test2_12() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_12(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 42 } + sink_2_12(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 44 } + sink_2_12(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 46 } + sink_2_12(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 48 } + return 0; +} + +one sink_2_13( A&); // { dg-message "note|argument" } +three sink_2_13(volatile A&); // { dg-message "note|argument" } + +int test2_13() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_13(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 62 } + sink_2_13(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 64 } + sink_2_13(source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + sink_2_13(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 68 } + sink_2_13(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 70 } + sink_2_13(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 72 } + return 0; +} + +one sink_2_14( A&); // { dg-message "note|argument" } +four sink_2_14(const volatile A&); // { dg-message "note|argument" } + +int test2_14() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_14(source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 86 } + sink_2_14(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 88 } + sink_2_14(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 90 } + sink_2_14(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 92 } + return 0; +} + +one sink_2_15( A&); // { dg-message "note|argument" } +five sink_2_15( A&&); // { dg-message "note|argument" } + +int test2_15() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_15(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 106 } + sink_2_15(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 108 } + sink_2_15(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 110 } + sink_2_15(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 112 } + sink_2_15(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 114 } + sink_2_15(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 116 } + return 0; +} + +one sink_2_16( A&); // { dg-message "note|argument" } +six sink_2_16(const A&&); // { dg-message "note|argument" } + +int test2_16() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_16(ca); // { dg-error "lvalue" } + sink_2_16(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 131 } + sink_2_16(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 133 } + sink_2_16(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 135 } + sink_2_16(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 137 } + return 0; +} + +one sink_2_17( A&); // { dg-message "note|argument" } +seven sink_2_17(volatile A&&); // { dg-message "note|argument" } + +int test2_17() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_17(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 151 } + sink_2_17(va); // { dg-error "lvalue" } + sink_2_17(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 154 } + sink_2_17(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 156 } + sink_2_17(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 158 } + return 0; +} + +one sink_2_18( A&); +eight sink_2_18(const volatile A&&); // { dg-error "argument" } + +int test2_18() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_18(ca); // { dg-error "lvalue" } + sink_2_18(va); // { dg-error "lvalue" } + sink_2_18(cva); // { dg-error "lvalue" } +} + +two sink_2_23(const A&); // { dg-message "note|argument" } +three sink_2_23(volatile A&); // { dg-message "note|argument" } + +int test2_23() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_23(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 186 } + sink_2_23(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 188 } + sink_2_23(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 190 } + sink_2_23(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 192 } + return 0; +} + +two sink_2_24(const A&); // { dg-message "note|argument" } +four sink_2_24(const volatile A&); // { dg-message "note|argument" } + +int test2_24() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_24(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 206 } + sink_2_24(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 208 } + return 0; +} + +three sink_2_34(volatile A&); // { dg-message "three sink_2_34|no known conversion" } +four sink_2_34(const volatile A&); // { dg-message "note|argument" } + +int test2_34() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_34(source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 222 } + sink_2_34(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 224 } + sink_2_34(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 226 } + sink_2_34(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 228 } + return 0; +} + +two sink_2_25(const A&); // { dg-message "two sink_2_25|no known conversion" } +five sink_2_25( A&&); // { dg-message "note|argument" } + +int test2_25() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_25(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 242 } + sink_2_25(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 244 } + sink_2_25(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 246 } + sink_2_25(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 248 } + return 0; +} + +two sink_2_26(const A&); // { dg-message "two sink_2_26|no known conversion" } +six sink_2_26(const A&&); // { dg-message "note|argument" } + +int test2_26() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_26(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 262 } + sink_2_26(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 264 } + sink_2_26(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 266 } + sink_2_26(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 268 } + return 0; +} + +two sink_2_27(const A&); // { dg-message "two sink_2_27|no known conversion" } +seven sink_2_27(volatile A&&); // { dg-message "note|argument" } + +int test2_27() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_27(va); // { dg-error "lvalue" } + sink_2_27(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 283 } + sink_2_27(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 285 } + return 0; +} + +two sink_2_28(const A&); +eight sink_2_28(const volatile A&&); // { dg-error "argument" } + +int test2_28() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_28(va); // { dg-error "lvalue" } + sink_2_28(cva); // { dg-error "lvalue" } +} + +three sink_2_35(volatile A&); // { dg-message "three sink_2_35|no known conversion" } +five sink_2_35( A&&); // { dg-message "note|argument" } + +int test2_35() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_35(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 312 } + sink_2_35(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 314 } + sink_2_35(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 316 } + sink_2_35(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 318 } + sink_2_35(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 320 } + return 0; +} + +three sink_2_36(volatile A&); // { dg-message "three sink_2_36|no known conversion" } +six sink_2_36(const A&&); // { dg-message "note|argument" } + +int test2_36() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_36(ca); // { dg-error "lvalue" } + sink_2_36(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 335 } + sink_2_36(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 337 } + sink_2_36(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 339 } + return 0; +} + +three sink_2_37(volatile A&); // { dg-message "three sink_2_37|no known conversion" } +seven sink_2_37(volatile A&&); // { dg-message "note|argument" } + +int test2_37() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_37(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 353 } + sink_2_37(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 355 } + sink_2_37(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 357 } + sink_2_37(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 359 } + return 0; +} + +three sink_2_38(volatile A&); +eight sink_2_38(const volatile A&&); // { dg-error "argument" } + +int test2_38() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_38(ca); // { dg-error "lvalue" } + sink_2_38(cva); // { dg-error "lvalue" } +} + +four sink_2_45(const volatile A&); // { dg-message "note" } +five sink_2_45( A&&); // { dg-message "note|argument" } + +int test2_45() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_45(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 386 } + sink_2_45(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 388 } + sink_2_45(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 390 } + return 0; +} + +four sink_2_46(const volatile A&); // { dg-message "note" } +six sink_2_46(const A&&); // { dg-message "note|argument" } + +int test2_46() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_46(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 404 } + sink_2_46(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 406 } + return 0; +} + +four sink_2_47(const volatile A&); // { dg-message "note" } +seven sink_2_47(volatile A&&); // { dg-message "note|argument" } + +int test2_47() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_47(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 420 } + sink_2_47(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 422 } + return 0; +} + +five sink_2_56( A&&); // { dg-message "note|argument" } +six sink_2_56(const A&&); // { dg-message "note|argument" } + +int test2_56() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_56(a); // { dg-error "lvalue" } + sink_2_56(ca); // { dg-error "lvalue" } + sink_2_56(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 438 } + sink_2_56(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 440 } + sink_2_56(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 442 } + sink_2_56(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 444 } + return 0; +} + +five sink_2_57( A&&); // { dg-message "note|argument" } +seven sink_2_57(volatile A&&); // { dg-message "note|argument" } + +int test2_57() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_57(a); // { dg-error "lvalue" } + sink_2_57(va); // { dg-error "lvalue" } + sink_2_57(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 460 } + sink_2_57(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 462 } + sink_2_57(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 464 } + sink_2_57(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 466 } + return 0; +} + +five sink_2_58( A&&); // { dg-error "argument" } +eight sink_2_58(const volatile A&&); // { dg-error "argument" } + +int test2_58() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_58(a); // { dg-error "lvalue" } + sink_2_58(ca); // { dg-error "lvalue" } + sink_2_58(va); // { dg-error "lvalue" } + sink_2_58(cva); // { dg-error "lvalue" } +} + +six sink_2_67(const A&&); // { dg-message "note|argument" } +seven sink_2_67(volatile A&&); // { dg-message "note|argument" } + +int test2_67() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_67(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 495 } + sink_2_67(ca); // { dg-error "lvalue" } + sink_2_67(va); // { dg-error "lvalue" } + sink_2_67(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 499 } + sink_2_67(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 501 } + sink_2_67(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 503 } + return 0; +} + +six sink_2_68(const A&&); // { dg-error "argument" } +eight sink_2_68(const volatile A&&); // { dg-error "argument" } + +int test2_68() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_68(a); // { dg-error "lvalue" } + sink_2_68(ca); // { dg-error "lvalue" } + sink_2_68(va); // { dg-error "lvalue" } + sink_2_68(cva); // { dg-error "lvalue" } +} + +seven sink_2_78(volatile A&&); // { dg-error "argument" } +eight sink_2_78(const volatile A&&); // { dg-error "argument" } + +int test2_78() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_2_78(a); // { dg-error "lvalue" } + sink_2_78(ca); // { dg-error "lvalue" } + sink_2_78(va); // { dg-error "lvalue" } + sink_2_78(cva); // { dg-error "lvalue" } +} + +int main() +{ + return test2_12() + test2_13() + test2_15() + test2_16() + + test2_17() + test2_23() + test2_25() + test2_26() + + test2_27() + test2_35() + test2_36() + test2_37() + + test2_56() + test2_57() + test2_67(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv2p.C b/gcc/testsuite/g++.dg/cpp0x/rv2p.C new file mode 100644 index 000000000..722d1b8d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv2p.C @@ -0,0 +1,507 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 2 at a time + +one sink_2_12( A&); +two sink_2_12(const A&); + +int test2_12() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_12(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_2_12(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_2_12(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_2_12(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +one sink_2_13( A&); +three sink_2_13(volatile A&); + +int test2_13() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_13(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_2_13(va)) == 3 * sizeof(long)> t3; + return 0; +} + +one sink_2_14( A&); +four sink_2_14(const volatile A&); + +int test2_14() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_14(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_2_14(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_2_14(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_2_14(cva)) == 4 * sizeof(long)> t4; + return 0; +} + +one sink_2_15( A&); +five sink_2_15( A&&); + +int test2_15() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_15(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_2_15(source())) == 5 * sizeof(long)> t5; + return 0; +} + +one sink_2_16( A&); +six sink_2_16(const A&&); + +int test2_16() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_16(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_2_16(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_2_16(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_2_17( A&); +seven sink_2_17(volatile A&&); + +int test2_17() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_17(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_2_17(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_2_17(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_2_18( A&); +eight sink_2_18(const volatile A&&); + +int test2_18() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_18(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_2_18(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_2_18(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_2_18(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_2_18(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_2_23(const A&); +three sink_2_23(volatile A&); + +int test2_23() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_23(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_2_23(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_2_23(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_2_23(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +two sink_2_24(const A&); +four sink_2_24(const volatile A&); + +int test2_24() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_24(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_2_24(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_2_24(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_2_24(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_2_24(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_2_24(c_source())) == 2 * sizeof(long)> t6; +// sa<sizeof(sink_2_24(v_source())) == 4 * sizeof(long)> t7; +// sa<sizeof(sink_2_24(cv_source())) == 4 * sizeof(long)> t8; + return 0; +} + +two sink_2_25(const A&); +five sink_2_25( A&&); + +int test2_25() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_25(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_2_25(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_2_25(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_2_25(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +two sink_2_26(const A&); +six sink_2_26(const A&&); + +int test2_26() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_26(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_2_26(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_2_26(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_2_26(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +two sink_2_27(const A&); +seven sink_2_27(volatile A&&); + +int test2_27() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_27(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_2_27(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_2_27(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_2_27(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_2_27(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_2_28(const A&); +eight sink_2_28(const volatile A&&); + +int test2_28() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_28(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_2_28(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_2_28(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_2_28(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_2_28(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_2_28(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_2_34(volatile A&); +four sink_2_34(const volatile A&); + +int test2_34() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_34(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_2_34(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_2_34(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_2_34(cva)) == 4 * sizeof(long)> t4; +// sa<sizeof(sink_2_34(source())) == 4 * sizeof(long)> t5; +// sa<sizeof(sink_2_34(c_source())) == 4 * sizeof(long)> t6; +// sa<sizeof(sink_2_34(v_source())) == 4 * sizeof(long)> t7; +// sa<sizeof(sink_2_34(cv_source())) == 4 * sizeof(long)> t8; + return 0; +} + +three sink_2_35(volatile A&); +five sink_2_35( A&&); + +int test2_35() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_35(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_2_35(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_2_35(source())) == 5 * sizeof(long)> t5; + return 0; +} + +three sink_2_36(volatile A&); +six sink_2_36(const A&&); + +int test2_36() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_36(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_2_36(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_2_36(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_2_36(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +three sink_2_37(volatile A&); +seven sink_2_37(volatile A&&); + +int test2_37() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_37(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_2_37(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_2_37(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_2_37(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +three sink_2_38(volatile A&); +eight sink_2_38(const volatile A&&); + +int test2_38() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_38(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_2_38(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_2_38(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_2_38(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_2_38(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_2_38(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_2_45(const volatile A&); +five sink_2_45( A&&); + +int test2_45() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_45(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_2_45(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_2_45(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_2_45(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_2_45(source())) == 5 * sizeof(long)> t5; +// sa<sizeof(sink_2_45(c_source())) == 4 * sizeof(long)> t6; +// sa<sizeof(sink_2_45(v_source())) == 4 * sizeof(long)> t7; +// sa<sizeof(sink_2_45(cv_source())) == 4 * sizeof(long)> t8; + return 0; +} + +four sink_2_46(const volatile A&); +six sink_2_46(const A&&); + +int test2_46() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_46(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_2_46(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_2_46(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_2_46(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_2_46(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_2_46(c_source())) == 6 * sizeof(long)> t6; +// sa<sizeof(sink_2_46(v_source())) == 4 * sizeof(long)> t7; +// sa<sizeof(sink_2_46(cv_source())) == 4 * sizeof(long)> t8; + return 0; +} + +four sink_2_47(const volatile A&); +seven sink_2_47(volatile A&&); + +int test2_47() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_47(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_2_47(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_2_47(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_2_47(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_2_47(source())) == 7 * sizeof(long)> t5; +// sa<sizeof(sink_2_47(c_source())) == 4 * sizeof(long)> t6; + sa<sizeof(sink_2_47(v_source())) == 7 * sizeof(long)> t7; +// sa<sizeof(sink_2_47(cv_source())) == 4 * sizeof(long)> t8; + return 0; +} + +four sink_2_48(const volatile A&); +eight sink_2_48(const volatile A&&); + +int test2_48() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_48(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_2_48(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_2_48(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_2_48(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_2_48(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_2_48(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_2_48(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_2_48(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +five sink_2_56( A&&); +six sink_2_56(const A&&); + +int test2_56() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_56(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_2_56(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +five sink_2_57( A&&); +seven sink_2_57(volatile A&&); + +int test2_57() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_57(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_2_57(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +five sink_2_58( A&&); +eight sink_2_58(const volatile A&&); + +int test2_58() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_58(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_2_58(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_2_58(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_2_58(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +six sink_2_67(const A&&); +seven sink_2_67(volatile A&&); + +int test2_67() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_67(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_2_67(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +six sink_2_68(const A&&); +eight sink_2_68(const volatile A&&); + +int test2_68() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_68(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_2_68(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_2_68(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_2_68(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +seven sink_2_78(volatile A&&); +eight sink_2_78(const volatile A&&); + +int test2_78() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_2_78(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_2_78(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_2_78(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_2_78(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test2_12() + test2_13() + test2_14() + test2_15() + + test2_16() + test2_17() + test2_18() + test2_23() + + test2_24() + test2_25() + test2_26() + test2_27() + + test2_28() + test2_34() + test2_35() + test2_36() + + test2_37() + test2_38() + test2_45() + test2_46() + + test2_47() + test2_48() + test2_56() + test2_57() + + test2_58() + test2_67() + test2_68() + test2_78(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv3n.C b/gcc/testsuite/g++.dg/cpp0x/rv3n.C new file mode 100644 index 000000000..637716f9b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv3n.C @@ -0,0 +1,951 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; +struct three {char x[3];}; +struct four {char x[4];}; +struct five {char x[5];}; +struct six {char x[6];}; +struct seven {char x[7];}; +struct eight {char x[8];}; + +struct A +{ + A(); + A(const volatile A&&); // { dg-error "argument 1" } +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 3 at a time + +one sink_3_123( A&); // { dg-message "one sink_3_123|no known conversion" } +two sink_3_123(const A&); // { dg-message "two sink_3_123|no known conversion" } +three sink_3_123(volatile A&); // { dg-message "three sink_3_123|no known conversion" } + +int test3_123() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_123(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 43 } + sink_3_123(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 45 } + sink_3_123(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 47 } + return 0; +} + +one sink_3_125( A&); // { dg-message "one sink_3_125|no known conversion" } +two sink_3_125(const A&); // { dg-message "two sink_3_125|no known conversion" } +five sink_3_125( A&&); // { dg-message "five sink_3_125|no known conversion" } + +one sink_3_124( A&); // { dg-message "one sink_3_124|no known conversion" } +two sink_3_124(const A&); // { dg-message "two sink_3_124|no known conversion" } +four sink_3_124(const volatile A&); // { dg-message "four sink_3_124|no known conversion" } + +int test3_124() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_124(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + sink_3_124(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 68 } + return 0; +} + +int test3_125() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_125(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 79 } + sink_3_125(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 81 } + sink_3_125(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 83 } + sink_3_125(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 85 } + return 0; +} + +one sink_3_126( A&); // { dg-message "one sink_3_126|no known conversion" } +two sink_3_126(const A&); // { dg-message "two sink_3_126|no known conversion" } +six sink_3_126(const A&&); // { dg-message "six sink_3_126|no known conversion" } + +int test3_126() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_126(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 100 } + sink_3_126(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 102 } + sink_3_126(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 104 } + sink_3_126(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 106 } + return 0; +} + +one sink_3_127( A&); // { dg-message "one sink_3_127|no known conversion" } +two sink_3_127(const A&); // { dg-message "two sink_3_127|no known conversion" } +seven sink_3_127(volatile A&&); // { dg-message "seven sink_3_127|no known conversion" } + +int test3_127() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_127(va); // { dg-error "lvalue" } + sink_3_127(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 122 } + sink_3_127(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 124 } + return 0; +} + +one sink_3_128( A&); +two sink_3_128(const A&); +eight sink_3_128(const volatile A&&); // { dg-message "" } + +int test3_128() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + + sink_3_128(va); // { dg-error "lvalue" } + sink_3_128(cva); // { dg-error "lvalue" } +} + +one sink_3_134( A&); // { dg-message "one sink_3_134|no known conversion" } +three sink_3_134(volatile A&); // { dg-message "three sink_3_134|no known conversion" } +four sink_3_134(const volatile A&); // { dg-message "four sink_3_134|no known conversion" } + +int test3_134() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_134(source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 154 } + sink_3_134(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 156 } + sink_3_134(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 158 } + sink_3_134(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 160 } + return 0; +} + +one sink_3_135( A&); // { dg-message "one sink_3_135|no known conversion" } +three sink_3_135(volatile A&); // { dg-message "three sink_3_135|no known conversion" } +five sink_3_135( A&&); // { dg-message "five sink_3_135|no known conversion" } + +int test3_135() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_135(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 175 } + sink_3_135(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 177 } + sink_3_135(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 179 } + sink_3_135(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 181 } + sink_3_135(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 183 } + return 0; +} + +one sink_3_136( A&); // { dg-message "one sink_3_136|no known conversion" } +three sink_3_136(volatile A&); // { dg-message "note" } +six sink_3_136(const A&&); // { dg-message "" } + +int test3_136() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_136(ca); // { dg-error "lvalue" } + sink_3_136(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 199 } + sink_3_136(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 201 } + sink_3_136(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 203 } + return 0; +} + +one sink_3_137( A&); // { dg-message "one sink_3_137|no known conversion" } +three sink_3_137(volatile A&); // { dg-message "note" } +seven sink_3_137(volatile A&&); // { dg-message "note" } + +int test3_137() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_137(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 218 } + sink_3_137(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 220 } + sink_3_137(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 222 } + sink_3_137(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 224 } + return 0; +} + +one sink_3_138( A&); +three sink_3_138(volatile A&); +eight sink_3_138(const volatile A&&); // { dg-message "" } + +int test3_138() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_138(ca); // { dg-error "lvalue" } + sink_3_138(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_3_145( A&); // { dg-message "one sink_3_145|no known conversion" } +four sink_3_145(const volatile A&); // { dg-message "note" } +five sink_3_145( A&&); // { dg-message "note" } + +int test3_145() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_145(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 254 } + sink_3_145(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 256 } + sink_3_145(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 258 } + return 0; +} + +one sink_3_146( A&); // { dg-message "one sink_3_146|no known conversion" } +four sink_3_146(const volatile A&); // { dg-message "note" } +six sink_3_146(const A&&); // { dg-message "note" } + +int test3_146() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_146(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 273 } + sink_3_146(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 275 } + return 0; +} + +one sink_3_147( A&); // { dg-message "one sink_3_147|no known conversion" } +four sink_3_147(const volatile A&); // { dg-message "note" } +seven sink_3_147(volatile A&&); // { dg-message "note" } + +int test3_147() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_147(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 290 } + sink_3_147(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 292 } + return 0; +} + +one sink_3_156( A&); // { dg-message "one sink_3_156|no known conversion" } +five sink_3_156( A&&); // { dg-message "note" } +six sink_3_156(const A&&); // { dg-message "" } + +int test3_156() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_156(ca); // { dg-error "lvalue" } + sink_3_156(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 308 } + sink_3_156(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 310 } + sink_3_156(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 312 } + sink_3_156(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 314 } + return 0; +} + +one sink_3_157( A&); // { dg-message "one sink_3_157|no known conversion" } +five sink_3_157( A&&); // { dg-message "note" } +seven sink_3_157(volatile A&&); // { dg-message "" } + +int test3_157() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_157(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 329 } + sink_3_157(va); // { dg-error "lvalue" } + sink_3_157(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 332 } + sink_3_157(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 334 } + sink_3_157(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 336 } + return 0; +} + +one sink_3_158( A&); +five sink_3_158( A&&); +eight sink_3_158(const volatile A&&); // { dg-message "" } + +int test3_158() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_158(ca); // { dg-error "lvalue" } + sink_3_158(va); // { dg-error "lvalue" } + sink_3_158(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_3_167( A&); // { dg-message "one sink_3_167|no known conversion" } +six sink_3_167(const A&&); // { dg-message "" } +seven sink_3_167(volatile A&&); // { dg-message "" } + +int test3_167() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_167(ca); // { dg-error "lvalue" } + sink_3_167(va); // { dg-error "lvalue" } + sink_3_167(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 369 } + sink_3_167(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 371 } + sink_3_167(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 373 } + return 0; +} + +one sink_3_168( A&); +six sink_3_168(const A&&); // { dg-message "" } +eight sink_3_168(const volatile A&&); // { dg-message "" } + +int test3_168() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_168(ca); // { dg-error "lvalue" } + sink_3_168(va); // { dg-error "lvalue" } + sink_3_168(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_3_178( A&); +seven sink_3_178(volatile A&&); // { dg-message "" } +eight sink_3_178(const volatile A&&); // { dg-message "" } + +int test3_178() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_178(ca); // { dg-error "lvalue" } + sink_3_178(va); // { dg-error "lvalue" } + sink_3_178(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_3_234(const A&); // { dg-message "two sink_3_234|no known conversion" } +three sink_3_234(volatile A&); // { dg-message "note" } +four sink_3_234(const volatile A&); // { dg-message "note" } + +int test3_234() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_234(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 420 } + sink_3_234(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 422 } + sink_3_234(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 424 } + return 0; +} + +two sink_3_235(const A&); // { dg-message "two sink_3_235|no known conversion" } +three sink_3_235(volatile A&); // { dg-message "note" } +five sink_3_235( A&&); // { dg-message "note" } + +int test3_235() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_235(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 439 } + sink_3_235(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 441 } + sink_3_235(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 443 } + sink_3_235(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 445 } + return 0; +} + +two sink_3_236(const A&); // { dg-message "two sink_3_236|no known conversion" } +three sink_3_236(volatile A&); // { dg-message "note" } +six sink_3_236(const A&&); // { dg-message "note" } + +int test3_236() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_236(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 460 } + sink_3_236(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 462 } + sink_3_236(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 464 } + sink_3_236(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 466 } + return 0; +} + +two sink_3_237(const A&); // { dg-message "two sink_3_237|no known conversion" } +three sink_3_237(volatile A&); // { dg-message "note" } +seven sink_3_237(volatile A&&); // { dg-message "note" } + +int test3_237() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_237(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 481 } + sink_3_237(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 483 } + sink_3_237(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 485 } + return 0; +} + +two sink_3_238(const A&); // { dg-message "two sink_3_238|no known conversion" } +three sink_3_238(volatile A&); // { dg-message "three sink_3_238|no known conversion" } +eight sink_3_238(const volatile A&&); // { dg-message "eight sink_3_238|no known conversion" } + +int test3_238() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_238(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 500 } + sink_3_238(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_3_245(const A&); // { dg-message "two sink_3_245|no known conversion" } +four sink_3_245(const volatile A&); // { dg-message "four sink_3_245|no known conversion" } +five sink_3_245( A&&); // { dg-message "five sink_3_245|no known conversion" } + +int test3_245() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_245(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 516 } + sink_3_245(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 518 } + return 0; +} + +two sink_3_246(const A&); // { dg-message "two sink_3_246|no known conversion" } +four sink_3_246(const volatile A&); // { dg-message "four sink_3_246|no known conversion" } +six sink_3_246(const A&&); // { dg-message "six sink_3_246|no known conversion" } + +int test3_246() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_246(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 533 } + sink_3_246(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 535 } + return 0; +} + +two sink_3_247(const A&); // { dg-message "two sink_3_247|no known conversion" } +four sink_3_247(const volatile A&); // { dg-message "four sink_3_247|no known conversion" } +seven sink_3_247(volatile A&&); // { dg-message "seven sink_3_247|no known conversion" } + +int test3_247() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_247(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 550 } + return 0; +} + +two sink_3_256(const A&); // { dg-message "two sink_3_256|no known conversion" } +five sink_3_256( A&&); // { dg-message "five sink_3_256|no known conversion" } +six sink_3_256(const A&&); // { dg-message "six sink_3_256|no known conversion" } + +int test3_256() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_256(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 565 } + sink_3_256(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 567 } + sink_3_256(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 569 } + sink_3_256(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 571 } + return 0; +} + +two sink_3_257(const A&); // { dg-message "two sink_3_257|no known conversion" } +five sink_3_257( A&&); // { dg-message "five sink_3_257|no known conversion" } +seven sink_3_257(volatile A&&); // { dg-message "seven sink_3_257|no known conversion" } + +int test3_257() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_257(va); // { dg-error "lvalue" } + sink_3_257(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 587 } + sink_3_257(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 589 } + return 0; +} + +two sink_3_258(const A&); +five sink_3_258( A&&); +eight sink_3_258(const volatile A&&); // { dg-message "" } + +int test3_258() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_258(va); // { dg-error "lvalue" } + sink_3_258(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_3_267(const A&); // { dg-message "two sink_3_267|no known conversion" } +six sink_3_267(const A&&); // { dg-message "six sink_3_267|no known conversion" } +seven sink_3_267(volatile A&&); // { dg-message "seven sink_3_267|no known conversion" } + +int test3_267() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_267(va); // { dg-error "lvalue" } + sink_3_267(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 620 } + sink_3_267(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 622 } + sink_3_267(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 624 } + return 0; +} + +two sink_3_268(const A&); +six sink_3_268(const A&&); +eight sink_3_268(const volatile A&&); // { dg-message "" } + +int test3_268() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_268(va); // { dg-error "lvalue" } + sink_3_268(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_3_278(const A&); +seven sink_3_278(volatile A&&); // { dg-message "" } +eight sink_3_278(const volatile A&&); // { dg-message "" } + +int test3_278() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_278(va); // { dg-error "lvalue" } + sink_3_278(cva); // { dg-error "lvalue" } + return 0; +} + +three sink_3_345(volatile A&); // { dg-message "three sink_3_345|no known conversion" } +four sink_3_345(const volatile A&); // { dg-message "four sink_3_345|no known conversion" } +five sink_3_345( A&&); // { dg-message "five sink_3_345|no known conversion" } + +int test3_345() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_345(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 669 } + sink_3_345(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 671 } + sink_3_345(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 673 } + return 0; +} + +three sink_3_346(volatile A&); // { dg-message "three sink_3_346|no known conversion" } +four sink_3_346(const volatile A&); // { dg-message "four sink_3_346|no known conversion" } +six sink_3_346(const A&&); // { dg-message "six sink_3_346|no known conversion" } + +int test3_346() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_346(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 688 } + sink_3_346(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 690 } + return 0; +} + +three sink_3_347(volatile A&); // { dg-message "three sink_3_347|no known conversion" } +four sink_3_347(const volatile A&); // { dg-message "four sink_3_347|no known conversion" } +seven sink_3_347(volatile A&&); // { dg-message "seven sink_3_347|no known conversion" } + +int test3_347() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_347(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 705 } + sink_3_347(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 707 } + return 0; +} + +three sink_3_356(volatile A&); // { dg-message "three sink_3_356|no known conversion" } +five sink_3_356( A&&); // { dg-message "five sink_3_356|no known conversion" } +six sink_3_356(const A&&); // { dg-message "six sink_3_356|no known conversion" } + +int test3_356() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_356(ca); // { dg-error "lvalue" } + sink_3_356(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 723 } + sink_3_356(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 725 } + sink_3_356(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 727 } + return 0; +} + +three sink_3_357(volatile A&); // { dg-message "three sink_3_357|no known conversion" } +five sink_3_357( A&&); // { dg-message "five sink_3_357|no known conversion" } +seven sink_3_357(volatile A&&); // { dg-message "seven sink_3_357|no known conversion" } + +int test3_357() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_357(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 742 } + sink_3_357(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 744 } + sink_3_357(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 746 } + sink_3_357(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 748 } + return 0; +} + +three sink_3_358(volatile A&); +five sink_3_358( A&&); +eight sink_3_358(const volatile A&&); // { dg-message "" } + +int test3_358() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_358(ca); // { dg-error "lvalue" } + sink_3_358(cva); // { dg-error "lvalue" } + return 0; +} + +three sink_3_367(volatile A&); // { dg-message "three sink_3_367|no known conversion" } +six sink_3_367(const A&&); // { dg-message "six sink_3_367|no known conversion" } +seven sink_3_367(volatile A&&); // { dg-message "seven sink_3_367|no known conversion" } + +int test3_367() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_367(ca); // { dg-error "lvalue" } + sink_3_367(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 779 } + sink_3_367(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 781 } + sink_3_367(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 783 } + return 0; +} + +three sink_3_368(volatile A&); +six sink_3_368(const A&&); // { dg-message "" } +eight sink_3_368(const volatile A&&); // { dg-message "" } + +int test3_368() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_368(ca); // { dg-error "lvalue" } + sink_3_368(cva); // { dg-error "lvalue" } + return 0; +} + +three sink_3_378(volatile A&); +seven sink_3_378(volatile A&&); +eight sink_3_378(const volatile A&&); // { dg-message "" } + +int test3_378() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_378(ca); // { dg-error "lvalue" } + sink_3_378(cva); // { dg-error "lvalue" } + return 0; +} + +four sink_3_456(const volatile A&); // { dg-message "note" } +five sink_3_456( A&&); // { dg-message "note" } +six sink_3_456(const A&&); // { dg-message "note" } + +int test3_456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 828 } + sink_3_456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 830 } + return 0; +} + +four sink_3_457(const volatile A&); // { dg-message "note" } +five sink_3_457( A&&); // { dg-message "note" } +seven sink_3_457(volatile A&&); // { dg-message "note" } + +int test3_457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_457(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 845 } + sink_3_457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 847 } + return 0; +} + +four sink_3_467(const volatile A&); // { dg-message "note" } +six sink_3_467(const A&&); // { dg-message "note" } +seven sink_3_467(volatile A&&); // { dg-message "note" } + +int test3_467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 862 } + sink_3_467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 864 } + return 0; +} + +five sink_3_567( A&&); // { dg-message "five sink_3_567|no known conversion" } +six sink_3_567(const A&&); // { dg-message "six sink_3_567|no known conversion" } +seven sink_3_567(volatile A&&); // { dg-message "seven sink_3_567|no known conversion" } + +int test3_567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_567(a); // { dg-error "lvalue" } + sink_3_567(ca); // { dg-error "lvalue" } + sink_3_567(va); // { dg-error "lvalue" } + sink_3_567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 882 } + sink_3_567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 884 } + return 0; +} + +five sink_3_568( A&&); // { dg-message "" } +six sink_3_568(const A&&); // { dg-message "" } +eight sink_3_568(const volatile A&&); // { dg-message "" } + +int test3_568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_568(a); // { dg-error "lvalue" } + sink_3_568(ca); // { dg-error "lvalue" } + sink_3_568(va); // { dg-error "lvalue" } + sink_3_568(cva); // { dg-error "lvalue" } + return 0; +} + +five sink_3_578( A&&); // { dg-message "" } +seven sink_3_578(volatile A&&); // { dg-message "" } +eight sink_3_578(const volatile A&&); // { dg-message "" } + +int test3_578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_578(a); // { dg-error "lvalue" } + sink_3_578(ca); // { dg-error "lvalue" } + sink_3_578(va); // { dg-error "lvalue" } + sink_3_578(cva); // { dg-error "lvalue" } + return 0; +} + +six sink_3_678(const A&&); // { dg-message "six sink_3_678|no known conversion" } +seven sink_3_678(volatile A&&); // { dg-message "seven sink_3_678|no known conversion" } +eight sink_3_678(const volatile A&&); // { dg-message "eight sink_3_678|no known conversion" } + +int test3_678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_3_678(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 933 } + sink_3_678(ca); // { dg-error "lvalue" } + sink_3_678(va); // { dg-error "lvalue" } + sink_3_678(cva); // { dg-error "lvalue" } + sink_3_678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 938 } + return 0; +} + +int main() +{ + return test3_123() + test3_125() + test3_126() + test3_127() + + test3_135() + test3_136() + test3_137() + test3_156() + + test3_157() + test3_167() + test3_234() + test3_235() + + test3_236() + test3_237() + test3_238() + test3_256() + + test3_257() + test3_267() + test3_356() + test3_357() + + test3_367() + test3_467() + test3_567() + test3_678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv3p.C b/gcc/testsuite/g++.dg/cpp0x/rv3p.C new file mode 100644 index 000000000..fad89e1d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv3p.C @@ -0,0 +1,1070 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 3 at a time + +one sink_3_123( A&); +two sink_3_123(const A&); +three sink_3_123(volatile A&); + +int test3_123() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_123(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_123(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_123(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_123(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_3_123(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +one sink_3_124( A&); +two sink_3_124(const A&); +four sink_3_124(const volatile A&); + +int test3_124() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_124(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_124(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_124(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_124(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_124(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_3_124(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +one sink_3_125( A&); +two sink_3_125(const A&); +five sink_3_125( A&&); + +int test3_125() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_125(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_125(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_125(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_125(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +one sink_3_126( A&); +two sink_3_126(const A&); +six sink_3_126(const A&&); + +int test3_126() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_126(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_126(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_126(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_126(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_3_127( A&); +two sink_3_127(const A&); +seven sink_3_127(volatile A&&); + +int test3_127() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_127(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_127(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_127(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_127(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_3_127(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_3_128( A&); +two sink_3_128(const A&); +eight sink_3_128(const volatile A&&); + +int test3_128() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_128(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_128(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_128(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_3_128(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_128(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_128(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_3_134( A&); +three sink_3_134(volatile A&); +four sink_3_134(const volatile A&); + +int test3_134() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_134(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_134(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_134(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_134(cva)) == 4 * sizeof(long)> t4; + return 0; +} + +one sink_3_135( A&); +three sink_3_135(volatile A&); +five sink_3_135( A&&); + +int test3_135() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_135(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_135(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_135(source())) == 5 * sizeof(long)> t5; + return 0; +} + +one sink_3_136( A&); +three sink_3_136(volatile A&); +six sink_3_136(const A&&); + +int test3_136() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_136(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_136(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_136(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_136(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_3_137( A&); +three sink_3_137(volatile A&); +seven sink_3_137(volatile A&&); + +int test3_137() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_137(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_137(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_137(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_137(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_3_138( A&); +three sink_3_138(volatile A&); +eight sink_3_138(const volatile A&&); + +int test3_138() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_138(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_138(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_138(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_3_138(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_138(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_138(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_3_145( A&); +four sink_3_145(const volatile A&); +five sink_3_145( A&&); + +int test3_145() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_145(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_145(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_145(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_145(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_145(source())) == 5 * sizeof(long)> t5; + return 0; +} + +one sink_3_146( A&); +four sink_3_146(const volatile A&); +six sink_3_146(const A&&); + +int test3_146() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_146(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_146(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_146(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_146(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_146(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_146(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_3_147( A&); +four sink_3_147(const volatile A&); +seven sink_3_147(volatile A&&); + +int test3_147() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_147(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_147(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_147(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_147(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_147(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_147(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_3_148( A&); +four sink_3_148(const volatile A&); +eight sink_3_148(const volatile A&&); + +int test3_148() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_148(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_148(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_148(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_148(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_148(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_3_148(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_148(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_148(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_3_156( A&); +five sink_3_156( A&&); +six sink_3_156(const A&&); + +int test3_156() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_156(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_156(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_156(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_3_157( A&); +five sink_3_157( A&&); +seven sink_3_157(volatile A&&); + +int test3_157() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_157(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_157(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_157(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_3_158( A&); +five sink_3_158( A&&); +eight sink_3_158(const volatile A&&); + +int test3_158() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_158(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_158(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_158(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_158(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_158(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_3_167( A&); +six sink_3_167(const A&&); +seven sink_3_167(volatile A&&); + +int test3_167() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_167(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_167(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_167(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_3_168( A&); +six sink_3_168(const A&&); +eight sink_3_168(const volatile A&&); + +int test3_168() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_168(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_168(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_168(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_168(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_168(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_3_178( A&); +seven sink_3_178(volatile A&&); +eight sink_3_178(const volatile A&&); + +int test3_178() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_178(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_3_178(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_178(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_178(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_3_178(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_3_234(const A&); +three sink_3_234(volatile A&); +four sink_3_234(const volatile A&); + +int test3_234() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_234(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_234(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_234(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_234(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_3_234(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +two sink_3_235(const A&); +three sink_3_235(volatile A&); +five sink_3_235( A&&); + +int test3_235() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_235(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_235(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_235(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_235(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +two sink_3_236(const A&); +three sink_3_236(volatile A&); +six sink_3_236(const A&&); + +int test3_236() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_236(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_236(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_236(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_236(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +two sink_3_237(const A&); +three sink_3_237(volatile A&); +seven sink_3_237(volatile A&&); + +int test3_237() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_237(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_237(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_237(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_237(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_3_237(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_3_238(const A&); +three sink_3_238(volatile A&); +eight sink_3_238(const volatile A&&); + +int test3_238() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_238(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_238(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_238(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_3_238(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_238(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_238(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_3_245(const A&); +four sink_3_245(const volatile A&); +five sink_3_245( A&&); + +int test3_245() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_245(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_245(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_245(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_245(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_245(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_245(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +two sink_3_246(const A&); +four sink_3_246(const volatile A&); +six sink_3_246(const A&&); + +int test3_246() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_246(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_246(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_246(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_246(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_246(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_246(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +two sink_3_247(const A&); +four sink_3_247(const volatile A&); +seven sink_3_247(volatile A&&); + +int test3_247() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_247(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_247(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_247(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_247(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_247(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_247(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_3_247(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_3_248(const A&); +four sink_3_248(const volatile A&); +eight sink_3_248(const volatile A&&); + +int test3_248() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_248(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_248(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_248(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_248(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_248(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_3_248(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_248(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_248(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_3_256(const A&); +five sink_3_256( A&&); +six sink_3_256(const A&&); + +int test3_256() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_256(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_256(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_256(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_256(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +two sink_3_257(const A&); +five sink_3_257( A&&); +seven sink_3_257(volatile A&&); + +int test3_257() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_257(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_257(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_257(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_257(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_3_257(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_3_258(const A&); +five sink_3_258( A&&); +eight sink_3_258(const volatile A&&); + +int test3_258() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_258(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_258(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_258(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_258(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_258(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_258(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_3_267(const A&); +six sink_3_267(const A&&); +seven sink_3_267(volatile A&&); + +int test3_267() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_267(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_267(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_267(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_267(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_3_268(const A&); +six sink_3_268(const A&&); +eight sink_3_268(const volatile A&&); + +int test3_268() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_268(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_268(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_268(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_268(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_268(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_268(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_3_278(const A&); +seven sink_3_278(volatile A&&); +eight sink_3_278(const volatile A&&); + +int test3_278() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_278(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_3_278(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_3_278(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_278(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_278(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_3_278(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_3_345(volatile A&); +four sink_3_345(const volatile A&); +five sink_3_345( A&&); + +int test3_345() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_345(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_345(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_345(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_345(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_345(source())) == 5 * sizeof(long)> t5; + return 0; +} + +three sink_3_346(volatile A&); +four sink_3_346(const volatile A&); +six sink_3_346(const A&&); + +int test3_346() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_346(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_346(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_346(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_346(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_346(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_346(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +three sink_3_347(volatile A&); +four sink_3_347(const volatile A&); +seven sink_3_347(volatile A&&); + +int test3_347() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_347(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_347(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_347(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_347(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_347(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_347(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +three sink_3_348(volatile A&); +four sink_3_348(const volatile A&); +eight sink_3_348(const volatile A&&); + +int test3_348() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_348(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_348(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_348(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_348(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_348(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_3_348(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_348(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_348(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_3_356(volatile A&); +five sink_3_356( A&&); +six sink_3_356(const A&&); + +int test3_356() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_356(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_356(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_356(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_356(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +three sink_3_357(volatile A&); +five sink_3_357( A&&); +seven sink_3_357(volatile A&&); + +int test3_357() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_357(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_357(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_357(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_357(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +three sink_3_358(volatile A&); +five sink_3_358( A&&); +eight sink_3_358(const volatile A&&); + +int test3_358() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_358(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_358(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_358(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_358(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_358(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_358(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_3_367(volatile A&); +six sink_3_367(const A&&); +seven sink_3_367(volatile A&&); + +int test3_367() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_367(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_367(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_367(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_367(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +three sink_3_368(volatile A&); +six sink_3_368(const A&&); +eight sink_3_368(const volatile A&&); + +int test3_368() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_368(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_368(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_368(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_368(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_368(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_368(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_3_378(volatile A&); +seven sink_3_378(volatile A&&); +eight sink_3_378(const volatile A&&); + +int test3_378() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_378(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_3_378(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_3_378(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_378(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_378(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_3_378(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_3_456(const volatile A&); +five sink_3_456( A&&); +six sink_3_456(const A&&); + +int test3_456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_456(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_3_456(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_456(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_456(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_456(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_456(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +four sink_3_457(const volatile A&); +five sink_3_457( A&&); +seven sink_3_457(volatile A&&); + +int test3_457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_457(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_3_457(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_457(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_457(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_457(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_457(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +four sink_3_458(const volatile A&); +five sink_3_458( A&&); +eight sink_3_458(const volatile A&&); + +int test3_458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_458(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_3_458(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_458(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_458(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_458(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_458(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_458(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_458(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_3_467(const volatile A&); +six sink_3_467(const A&&); +seven sink_3_467(volatile A&&); + +int test3_467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_467(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_3_467(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_467(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_467(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_467(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_467(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +four sink_3_468(const volatile A&); +six sink_3_468(const A&&); +eight sink_3_468(const volatile A&&); + +int test3_468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_468(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_3_468(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_468(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_468(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_468(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_3_468(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_468(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_468(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_3_478(const volatile A&); +seven sink_3_478(volatile A&&); +eight sink_3_478(const volatile A&&); + +int test3_478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_478(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_3_478(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_3_478(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_3_478(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_3_478(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_3_478(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_478(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_3_478(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +five sink_3_567( A&&); +six sink_3_567(const A&&); +seven sink_3_567(volatile A&&); + +int test3_567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +five sink_3_568( A&&); +six sink_3_568(const A&&); +eight sink_3_568(const volatile A&&); + +int test3_568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_3_568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +five sink_3_578( A&&); +seven sink_3_578(volatile A&&); +eight sink_3_578(const volatile A&&); + +int test3_578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_3_578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_3_578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_3_578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +six sink_3_678(const A&&); +seven sink_3_678(volatile A&&); +eight sink_3_678(const volatile A&&); + +int test3_678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_3_678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_3_678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_3_678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test3_123() + test3_124() + test3_125() + test3_126() + + test3_127() + test3_128() + test3_134() + test3_135() + + test3_136() + test3_137() + test3_138() + test3_145() + + test3_146() + test3_147() + test3_148() + test3_156() + + test3_157() + test3_158() + test3_167() + test3_168() + + test3_178() + test3_234() + test3_235() + test3_236() + + test3_237() + test3_238() + test3_245() + test3_246() + + test3_247() + test3_248() + test3_256() + test3_257() + + test3_258() + test3_267() + test3_268() + test3_278() + + test3_345() + test3_346() + test3_347() + test3_348() + + test3_356() + test3_357() + test3_358() + test3_367() + + test3_368() + test3_378() + test3_456() + test3_457() + + test3_458() + test3_467() + test3_468() + test3_478() + + test3_567() + test3_568() + test3_578() + test3_678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv4n.C b/gcc/testsuite/g++.dg/cpp0x/rv4n.C new file mode 100644 index 000000000..daff30798 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv4n.C @@ -0,0 +1,1072 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; +struct three {char x[3];}; +struct four {char x[4];}; +struct five {char x[5];}; +struct six {char x[6];}; +struct seven {char x[7];}; +struct eight {char x[8];}; + +struct A +{ + A(); + A(const volatile A&&); // { dg-error "argument 1" } +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 4 at a time + +one sink_4_1234( A&); // { dg-message "one sink_4_1234|no known conversion" } +two sink_4_1234(const A&); // { dg-message "note" } +three sink_4_1234(volatile A&); // { dg-message "note" } +four sink_4_1234(const volatile A&); // { dg-message "note" } + +int test4_1234() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1234(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 44 } + sink_4_1234(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 46 } + return 0; +} + +one sink_4_1235( A&); // { dg-message "one sink_4_1235|no known conversion" } +two sink_4_1235(const A&); // { dg-message "note" } +three sink_4_1235(volatile A&); // { dg-message "note" } +five sink_4_1235( A&&); // { dg-message "note" } + +int test4_1235() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1235(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 62 } + sink_4_1235(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 64 } + sink_4_1235(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + return 0; +} + +one sink_4_1236( A&); // { dg-message "one sink_4_1236|no known conversion" } +two sink_4_1236(const A&); // { dg-message "note" } +three sink_4_1236(volatile A&); // { dg-message "note" } +six sink_4_1236(const A&&); // { dg-message "note" } + +int test4_1236() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1236(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 82 } + sink_4_1236(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 84 } + sink_4_1236(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 86 } + return 0; +} + +one sink_4_1237( A&); // { dg-message "one sink_4_1237|no known conversion" } +two sink_4_1237(const A&); // { dg-message "note" } +three sink_4_1237(volatile A&); // { dg-message "note" } +seven sink_4_1237(volatile A&&); // { dg-message "note" } + +int test4_1237() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1237(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 102 } + sink_4_1237(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 104 } + return 0; +} + +one sink_4_1238( A&); +two sink_4_1238(const A&); +three sink_4_1238(volatile A&); +eight sink_4_1238(const volatile A&&); // { dg-message "" } + +int test4_1238() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1238(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1245( A&); // { dg-message "one sink_4_1245|no known conversion" } +two sink_4_1245(const A&); // { dg-message "note" } +four sink_4_1245(const volatile A&); // { dg-message "note" } +five sink_4_1245( A&&); // { dg-message "note" } + +int test4_1245() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1245(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 135 } + sink_4_1245(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 137 } + return 0; +} + +one sink_4_1246( A&); // { dg-message "one sink_4_1246|no known conversion" } +two sink_4_1246(const A&); // { dg-message "note" } +four sink_4_1246(const volatile A&); // { dg-message "note" } +six sink_4_1246(const A&&); // { dg-message "note" } + +int test4_1246() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1246(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 153 } + sink_4_1246(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 155 } + return 0; +} + +one sink_4_1247( A&); // { dg-message "one sink_4_1247|no known conversion" } +two sink_4_1247(const A&); // { dg-message "note" } +four sink_4_1247(const volatile A&); // { dg-message "note" } +seven sink_4_1247(volatile A&&); // { dg-message "note" } + +int test4_1247() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1247(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 171 } + return 0; +} + +one sink_4_1256( A&); // { dg-message "one sink_4_1256|no known conversion" } +two sink_4_1256(const A&); // { dg-message "note" } +five sink_4_1256( A&&); // { dg-message "note" } +six sink_4_1256(const A&&); // { dg-message "note" } + +int test4_1256() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1256(va); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 187 } + sink_4_1256(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 189 } + sink_4_1256(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 191 } + sink_4_1256(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 193 } + return 0; +} + +one sink_4_1257( A&); // { dg-message "one sink_4_1257|no known conversion" } +two sink_4_1257(const A&); // { dg-message "note" } +five sink_4_1257( A&&); // { dg-message "note" } +seven sink_4_1257(volatile A&&); // { dg-message "" } + +int test4_1257() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1257(va); // { dg-error "lvalue" } + sink_4_1257(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 210 } + sink_4_1257(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 212 } + return 0; +} + +one sink_4_1258( A&); +two sink_4_1258(const A&); +five sink_4_1258( A&&); +eight sink_4_1258(const volatile A&&); // { dg-message "" } + +int test4_1258() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1258(va); // { dg-error "lvalue" } + sink_4_1258(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1267( A&); // { dg-message "one sink_4_1267|no known conversion" } +two sink_4_1267(const A&); // { dg-message "note" } +six sink_4_1267(const A&&); // { dg-message "note" } +seven sink_4_1267(volatile A&&); // { dg-message "" } + +int test4_1267() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1267(va); // { dg-error "lvalue" } + sink_4_1267(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 245 } + sink_4_1267(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 247 } + sink_4_1267(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 249 } + return 0; +} + +one sink_4_1268( A&); +two sink_4_1268(const A&); +six sink_4_1268(const A&&); +eight sink_4_1268(const volatile A&&); // { dg-message "" } + +int test4_1268() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1268(va); // { dg-error "lvalue" } + sink_4_1268(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1278( A&); +two sink_4_1278(const A&); +seven sink_4_1278(volatile A&&); // { dg-message "" } +eight sink_4_1278(const volatile A&&); // { dg-message "" } + +int test4_1278() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1278(va); // { dg-error "lvalue" } + sink_4_1278(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1345( A&); // { dg-message "one sink_4_1345|no known conversion" } +three sink_4_1345(volatile A&); // { dg-message "note" } +four sink_4_1345(const volatile A&); // { dg-message "note" } +five sink_4_1345( A&&); // { dg-message "note" } + +int test4_1345() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1345(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 297 } + sink_4_1345(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 299 } + sink_4_1345(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 301 } + return 0; +} + +one sink_4_1346( A&); // { dg-message "one sink_4_1346|no known conversion" } +three sink_4_1346(volatile A&); // { dg-message "note" } +four sink_4_1346(const volatile A&); // { dg-message "note" } +six sink_4_1346(const A&&); // { dg-message "note" } + +int test4_1346() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1346(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 317 } + sink_4_1346(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 319 } + return 0; +} + +one sink_4_1347( A&); // { dg-message "one sink_4_1347|no known conversion" } +three sink_4_1347(volatile A&); // { dg-message "note" } +four sink_4_1347(const volatile A&); // { dg-message "note" } +seven sink_4_1347(volatile A&&); // { dg-message "note" } + +int test4_1347() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1347(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 335 } + sink_4_1347(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 337 } + return 0; +} + +one sink_4_1356( A&); // { dg-message "one sink_4_1356|no known conversion" } +three sink_4_1356(volatile A&); // { dg-message "note" } +five sink_4_1356( A&&); // { dg-message "note" } +six sink_4_1356(const A&&); // { dg-message "" } + +int test4_1356() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1356(ca); // { dg-error "lvalue" } + sink_4_1356(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 354 } + sink_4_1356(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 356 } + sink_4_1356(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 358 } + return 0; +} + +one sink_4_1357( A&); // { dg-message "one sink_4_1357|no known conversion" } +three sink_4_1357(volatile A&); // { dg-message "note" } +five sink_4_1357( A&&); // { dg-message "note" } +seven sink_4_1357(volatile A&&); // { dg-message "note" } + +int test4_1357() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1357(ca); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 374 } + sink_4_1357(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 376 } + sink_4_1357(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 378 } + sink_4_1357(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 380 } + return 0; +} + +one sink_4_1358( A&); +three sink_4_1358(volatile A&); +five sink_4_1358( A&&); +eight sink_4_1358(const volatile A&&); // { dg-message "" } + +int test4_1358() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1358(ca); // { dg-error "lvalue" } + sink_4_1358(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1367( A&); // { dg-message "one sink_4_1367|no known conversion" } +three sink_4_1367(volatile A&); // { dg-message "note" } +six sink_4_1367(const A&&); // { dg-message "" } +seven sink_4_1367(volatile A&&); // { dg-message "note" } + +int test4_1367() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1367(ca); // { dg-error "lvalue" } + sink_4_1367(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 413 } + sink_4_1367(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 415 } + sink_4_1367(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 417 } + return 0; +} + +one sink_4_1368( A&); +three sink_4_1368(volatile A&); +six sink_4_1368(const A&&); // { dg-message "" } +eight sink_4_1368(const volatile A&&); // { dg-message "" } + +int test4_1368() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1368(ca); // { dg-error "lvalue" } + sink_4_1368(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1378( A&); +three sink_4_1378(volatile A&); +seven sink_4_1378(volatile A&&); +eight sink_4_1378(const volatile A&&); // { dg-message "" } + +int test4_1378() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1378(ca); // { dg-error "lvalue" } + sink_4_1378(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1456( A&); // { dg-message "one sink_4_1456|no known conversion" } +four sink_4_1456(const volatile A&); // { dg-message "note" } +five sink_4_1456( A&&); // { dg-message "note" } +six sink_4_1456(const A&&); // { dg-message "note" } + +int test4_1456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 465 } + sink_4_1456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 467 } + return 0; +} + +one sink_4_1457( A&); // { dg-message "one sink_4_1457|no known conversion" } +four sink_4_1457(const volatile A&); // { dg-message "note" } +five sink_4_1457( A&&); // { dg-message "note" } +seven sink_4_1457(volatile A&&); // { dg-message "note" } + +int test4_1457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1457(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 483 } + sink_4_1457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 485 } + return 0; +} + +one sink_4_1467( A&); // { dg-message "one sink_4_1467|no known conversion" } +four sink_4_1467(const volatile A&); // { dg-message "note" } +six sink_4_1467(const A&&); // { dg-message "note" } +seven sink_4_1467(volatile A&&); // { dg-message "note" } + +int test4_1467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 501 } + sink_4_1467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 503 } + return 0; +} + +one sink_4_1567( A&); // { dg-message "one sink_4_1567|no known conversion" } +five sink_4_1567( A&&); // { dg-message "note" } +six sink_4_1567(const A&&); // { dg-message "" } +seven sink_4_1567(volatile A&&); // { dg-message "" } + +int test4_1567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1567(ca); // { dg-error "lvalue" } + sink_4_1567(va); // { dg-error "lvalue" } + sink_4_1567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 521 } + sink_4_1567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 523 } + return 0; +} + +one sink_4_1568( A&); +five sink_4_1568( A&&); +six sink_4_1568(const A&&); // { dg-message "" } +eight sink_4_1568(const volatile A&&); // { dg-message "" } + +int test4_1568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1568(ca); // { dg-error "lvalue" } + sink_4_1568(va); // { dg-error "lvalue" } + sink_4_1568(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1578( A&); +five sink_4_1578( A&&); +seven sink_4_1578(volatile A&&); // { dg-message "" } +eight sink_4_1578(const volatile A&&); // { dg-message "" } + +int test4_1578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1578(ca); // { dg-error "lvalue" } + sink_4_1578(va); // { dg-error "lvalue" } + sink_4_1578(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_4_1678( A&); +six sink_4_1678(const A&&); // { dg-message "" } +seven sink_4_1678(volatile A&&); // { dg-message "" } +eight sink_4_1678(const volatile A&&); // { dg-message "" } + +int test4_1678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_1678(ca); // { dg-error "lvalue" } + sink_4_1678(va); // { dg-error "lvalue" } + sink_4_1678(cva); // { dg-error "lvalue" } + sink_4_1678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 576 } + return 0; +} + +two sink_4_2345(const A&); // { dg-message "two sink_4_2345|no known conversion" } +three sink_4_2345(volatile A&); // { dg-message "note" } +four sink_4_2345(const volatile A&); // { dg-message "note" } +five sink_4_2345( A&&); // { dg-message "note" } + +int test4_2345() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2345(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 592 } + sink_4_2345(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 594 } + sink_4_2345(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 596 } + return 0; +} + +two sink_4_2346(const A&); // { dg-message "two sink_4_2346|no known conversion" } +three sink_4_2346(volatile A&); // { dg-message "note" } +four sink_4_2346(const volatile A&); // { dg-message "note" } +six sink_4_2346(const A&&); // { dg-message "note" } + +int test4_2346() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2346(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 612 } + sink_4_2346(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 614 } + sink_4_2346(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 616 } + return 0; +} + +two sink_4_2347(const A&); // { dg-message "two sink_4_2347|no known conversion" } +three sink_4_2347(volatile A&); // { dg-message "note" } +four sink_4_2347(const volatile A&); // { dg-message "note" } +seven sink_4_2347(volatile A&&); // { dg-message "note" } + +int test4_2347() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2347(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 632 } + sink_4_2347(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 634 } + return 0; +} + +two sink_4_2348(const A&); // { dg-message "note" } +three sink_4_2348(volatile A&); // { dg-message "note" } +four sink_4_2348(const volatile A&); // { dg-message "note" } +eight sink_4_2348(const volatile A&&); // { dg-message "note" } + +int test4_2348() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2348(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 650 } + return 0; +} + +two sink_4_2356(const A&); // { dg-message "two sink_4_2356|no known conversion" } +three sink_4_2356(volatile A&); // { dg-message "note" } +five sink_4_2356( A&&); // { dg-message "note" } +six sink_4_2356(const A&&); // { dg-message "note" } + +int test4_2356() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2356(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 666 } + sink_4_2356(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 668 } + sink_4_2356(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 670 } + sink_4_2356(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 672 } + return 0; +} + +two sink_4_2357(const A&); // { dg-message "two sink_4_2357|no known conversion" } +three sink_4_2357(volatile A&); // { dg-message "note" } +five sink_4_2357( A&&); // { dg-message "note" } +seven sink_4_2357(volatile A&&); // { dg-message "note" } + +int test4_2357() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2357(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 688 } + sink_4_2357(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 690 } + sink_4_2357(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 692 } + return 0; +} + +two sink_4_2358(const A&); // { dg-message "note" } +three sink_4_2358(volatile A&); // { dg-message "note" } +five sink_4_2358( A&&); // { dg-message "note" } +eight sink_4_2358(const volatile A&&); // { dg-message "" } + +int test4_2358() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2358(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 708 } + sink_4_2358(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_4_2367(const A&); // { dg-message "two sink_4_2367|no known conversion" } +three sink_4_2367(volatile A&); // { dg-message "note" } +six sink_4_2367(const A&&); // { dg-message "note" } +seven sink_4_2367(volatile A&&); // { dg-message "note" } + +int test4_2367() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2367(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 725 } + sink_4_2367(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 727 } + sink_4_2367(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 729 } + sink_4_2367(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 731 } + return 0; +} + +two sink_4_2368(const A&); // { dg-message "note" } +three sink_4_2368(volatile A&); // { dg-message "note" } +six sink_4_2368(const A&&); // { dg-message "note" } +eight sink_4_2368(const volatile A&&); // { dg-message "" } + +int test4_2368() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2368(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 747 } + sink_4_2368(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_4_2378(const A&); // { dg-message "note" } +three sink_4_2378(volatile A&); // { dg-message "note" } +seven sink_4_2378(volatile A&&); // { dg-message "note" } +eight sink_4_2378(const volatile A&&); // { dg-message "" } + +int test4_2378() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2378(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 764 } + sink_4_2378(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_4_2456(const A&); // { dg-message "two sink_4_2456|no known conversion" } +four sink_4_2456(const volatile A&); // { dg-message "note" } +five sink_4_2456( A&&); // { dg-message "note" } +six sink_4_2456(const A&&); // { dg-message "note" } + +int test4_2456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 781 } + sink_4_2456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 783 } + return 0; +} + +two sink_4_2457(const A&); // { dg-message "two sink_4_2457|no known conversion" } +four sink_4_2457(const volatile A&); // { dg-message "note" } +five sink_4_2457( A&&); // { dg-message "note" } +seven sink_4_2457(volatile A&&); // { dg-message "note" } + +int test4_2457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 799 } + return 0; +} + +two sink_4_2467(const A&); // { dg-message "two sink_4_2467|no known conversion" } +four sink_4_2467(const volatile A&); // { dg-message "note" } +six sink_4_2467(const A&&); // { dg-message "note" } +seven sink_4_2467(volatile A&&); // { dg-message "note" } + +int test4_2467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 815 } + sink_4_2467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 817 } + return 0; +} + +two sink_4_2567(const A&); // { dg-message "two sink_4_2567|no known conversion" } +five sink_4_2567( A&&); // { dg-message "note" } +six sink_4_2567(const A&&); // { dg-message "note" } +seven sink_4_2567(volatile A&&); // { dg-message "" } + +int test4_2567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2567(va); // { dg-error "lvalue" } + sink_4_2567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 834 } + sink_4_2567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 836 } + return 0; +} + +two sink_4_2568(const A&); +five sink_4_2568( A&&); +six sink_4_2568(const A&&); +eight sink_4_2568(const volatile A&&); // { dg-message "" } + +int test4_2568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2568(va); // { dg-error "lvalue" } + sink_4_2568(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_4_2578(const A&); +five sink_4_2578( A&&); +seven sink_4_2578(volatile A&&); // { dg-message "" } +eight sink_4_2578(const volatile A&&); // { dg-message "" } + +int test4_2578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2578(va); // { dg-error "lvalue" } + sink_4_2578(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_4_2678(const A&); // { dg-message "note" } +six sink_4_2678(const A&&); // { dg-message "note" } +seven sink_4_2678(volatile A&&); // { dg-message "" } +eight sink_4_2678(const volatile A&&); // { dg-message "" } + +int test4_2678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_2678(va); // { dg-error "lvalue" } + sink_4_2678(cva); // { dg-error "lvalue" } + sink_4_2678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 886 } + return 0; +} + +three sink_4_3456(volatile A&); // { dg-message "three sink_4_3456|no known conversion" } +four sink_4_3456(const volatile A&); // { dg-message "note" } +five sink_4_3456( A&&); // { dg-message "note" } +six sink_4_3456(const A&&); // { dg-message "note" } + +int test4_3456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_3456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 902 } + sink_4_3456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 904 } + return 0; +} + +three sink_4_3457(volatile A&); // { dg-message "three sink_4_3457|no known conversion" } +four sink_4_3457(const volatile A&); // { dg-message "note" } +five sink_4_3457( A&&); // { dg-message "note" } +seven sink_4_3457(volatile A&&); // { dg-message "note" } + +int test4_3457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_3457(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 920 } + sink_4_3457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 922 } + return 0; +} + +three sink_4_3467(volatile A&); // { dg-message "three sink_4_3467|no known conversion" } +four sink_4_3467(const volatile A&); // { dg-message "note" } +six sink_4_3467(const A&&); // { dg-message "note" } +seven sink_4_3467(volatile A&&); // { dg-message "note" } + +int test4_3467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_3467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 938 } + sink_4_3467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 940 } + return 0; +} + +three sink_4_3567(volatile A&); // { dg-message "three sink_4_3567|no known conversion" } +five sink_4_3567( A&&); // { dg-message "note" } +six sink_4_3567(const A&&); // { dg-message "" } +seven sink_4_3567(volatile A&&); // { dg-message "note" } + +int test4_3567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_3567(ca); // { dg-error "lvalue" } + sink_4_3567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 957 } + sink_4_3567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 959 } + return 0; +} + +three sink_4_3568(volatile A&); +five sink_4_3568( A&&); +six sink_4_3568(const A&&); // { dg-message "" } +eight sink_4_3568(const volatile A&&); // { dg-message "" } + +int test4_3568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_3568(ca); // { dg-error "lvalue" } + sink_4_3568(cva); // { dg-error "lvalue" } + return 0; +} + +three sink_4_3578(volatile A&); +five sink_4_3578( A&&); +seven sink_4_3578(volatile A&&); +eight sink_4_3578(const volatile A&&); // { dg-message "" } + +int test4_3578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_3578(ca); // { dg-error "lvalue" } + sink_4_3578(cva); // { dg-error "lvalue" } + return 0; +} + +three sink_4_3678(volatile A&); +six sink_4_3678(const A&&); // { dg-message "" } +seven sink_4_3678(volatile A&&); // { dg-message "note" } +eight sink_4_3678(const volatile A&&); // { dg-message "" } + +int test4_3678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_3678(ca); // { dg-error "lvalue" } + sink_4_3678(cva); // { dg-error "lvalue" } + sink_4_3678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 1009 } + return 0; +} + +four sink_4_4567(const volatile A&); // { dg-message "note" } +five sink_4_4567( A&&); // { dg-message "note" } +six sink_4_4567(const A&&); // { dg-message "note" } +seven sink_4_4567(volatile A&&); // { dg-message "note" } + +int test4_4567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_4567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 1025 } + return 0; +} + +four sink_4_4678(const volatile A&); +six sink_4_4678(const A&&); // { dg-message "note" } +seven sink_4_4678(volatile A&&); // { dg-message "note" } +eight sink_4_4678(const volatile A&&); // { dg-message "note" } + +int test4_4678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_4678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 1041 } + return 0; +} + +five sink_4_5678( A&&); // { dg-message "" } +six sink_4_5678(const A&&); // { dg-message "" } +seven sink_4_5678(volatile A&&); // { dg-message "" } +eight sink_4_5678(const volatile A&&); // { dg-message "" } + +int test4_5678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_4_5678(a); // { dg-error "lvalue" } + sink_4_5678(ca); // { dg-error "lvalue" } + sink_4_5678(va); // { dg-error "lvalue" } + sink_4_5678(cva); // { dg-error "lvalue" } + return 0; +} + +int main() +{ + return test4_1235() + test4_1236() + test4_1237() + test4_1256() + test4_1257() + + test4_1267() + test4_1356() + test4_1357() + test4_1467() + test4_1567() + + test4_1678() + test4_2345() + test4_2346() + test4_2347() + test4_2348() + + test4_2356() + test4_2357() + test4_2358() + test4_2367() + test4_2368() + + test4_2378() + test4_2467() + test4_2567() + test4_2678() + test4_3467() + + test4_3567() + test4_3678() + test4_4678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv4p.C b/gcc/testsuite/g++.dg/cpp0x/rv4p.C new file mode 100644 index 000000000..134ca13e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv4p.C @@ -0,0 +1,1448 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 4 at a time + +one sink_4_1234( A&); +two sink_4_1234(const A&); +three sink_4_1234(volatile A&); +four sink_4_1234(const volatile A&); + +int test4_1234() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1234(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1234(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1234(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1234(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1234(source())) == 2 * sizeof(long)> t5; + sa<sizeof(sink_4_1234(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +one sink_4_1235( A&); +two sink_4_1235(const A&); +three sink_4_1235(volatile A&); +five sink_4_1235( A&&); + +int test4_1235() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1235(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1235(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1235(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1235(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1235(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +one sink_4_1236( A&); +two sink_4_1236(const A&); +three sink_4_1236(volatile A&); +six sink_4_1236(const A&&); + +int test4_1236() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1236(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1236(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1236(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1236(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_1236(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_4_1237( A&); +two sink_4_1237(const A&); +three sink_4_1237(volatile A&); +seven sink_4_1237(volatile A&&); + +int test4_1237() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1237(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1237(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1237(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1237(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_1237(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_4_1237(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1238( A&); +two sink_4_1238(const A&); +three sink_4_1238(volatile A&); +eight sink_4_1238(const volatile A&&); + +int test4_1238() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1238(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1238(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1238(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1238(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_4_1238(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1238(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1238(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1245( A&); +two sink_4_1245(const A&); +four sink_4_1245(const volatile A&); +five sink_4_1245( A&&); + +int test4_1245() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1245(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1245(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1245(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1245(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1245(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1245(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +one sink_4_1246( A&); +two sink_4_1246(const A&); +four sink_4_1246(const volatile A&); +six sink_4_1246(const A&&); + +int test4_1246() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1246(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1246(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1246(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1246(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1246(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_1246(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_4_1247( A&); +two sink_4_1247(const A&); +four sink_4_1247(const volatile A&); +seven sink_4_1247(volatile A&&); + +int test4_1247() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1247(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1247(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1247(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1247(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1247(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_1247(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_4_1247(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1248( A&); +two sink_4_1248(const A&); +four sink_4_1248(const volatile A&); +eight sink_4_1248(const volatile A&&); + +int test4_1248() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1248(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1248(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1248(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1248(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1248(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_4_1248(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1248(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1248(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1256( A&); +two sink_4_1256(const A&); +five sink_4_1256( A&&); +six sink_4_1256(const A&&); + +int test4_1256() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1256(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1256(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1256(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1256(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_4_1257( A&); +two sink_4_1257(const A&); +five sink_4_1257( A&&); +seven sink_4_1257(volatile A&&); + +int test4_1257() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1257(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1257(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1257(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1257(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_4_1257(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1258( A&); +two sink_4_1258(const A&); +five sink_4_1258( A&&); +eight sink_4_1258(const volatile A&&); + +int test4_1258() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1258(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1258(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1258(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1258(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1258(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1258(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1267( A&); +two sink_4_1267(const A&); +six sink_4_1267(const A&&); +seven sink_4_1267(volatile A&&); + +int test4_1267() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1267(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1267(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1267(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1267(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1268( A&); +two sink_4_1268(const A&); +six sink_4_1268(const A&&); +eight sink_4_1268(const volatile A&&); + +int test4_1268() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1268(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1268(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1268(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_1268(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1268(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1268(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1278( A&); +two sink_4_1278(const A&); +seven sink_4_1278(volatile A&&); +eight sink_4_1278(const volatile A&&); + +int test4_1278() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1278(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1278(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_1278(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_1278(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1278(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_1278(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1345( A&); +three sink_4_1345(volatile A&); +four sink_4_1345(const volatile A&); +five sink_4_1345( A&&); + +int test4_1345() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1345(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1345(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1345(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1345(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1345(source())) == 5 * sizeof(long)> t5; + return 0; +} + +one sink_4_1346( A&); +three sink_4_1346(volatile A&); +four sink_4_1346(const volatile A&); +six sink_4_1346(const A&&); + +int test4_1346() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1346(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1346(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1346(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1346(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1346(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_1346(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_4_1347( A&); +three sink_4_1347(volatile A&); +four sink_4_1347(const volatile A&); +seven sink_4_1347(volatile A&&); + +int test4_1347() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1347(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1347(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1347(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1347(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1347(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_1347(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1348( A&); +three sink_4_1348(volatile A&); +four sink_4_1348(const volatile A&); +eight sink_4_1348(const volatile A&&); + +int test4_1348() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1348(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1348(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1348(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1348(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1348(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_4_1348(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1348(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1348(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1356( A&); +three sink_4_1356(volatile A&); +five sink_4_1356( A&&); +six sink_4_1356(const A&&); + +int test4_1356() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1356(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1356(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1356(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1356(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_4_1357( A&); +three sink_4_1357(volatile A&); +five sink_4_1357( A&&); +seven sink_4_1357(volatile A&&); + +int test4_1357() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1357(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1357(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1357(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1357(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1358( A&); +three sink_4_1358(volatile A&); +five sink_4_1358( A&&); +eight sink_4_1358(const volatile A&&); + +int test4_1358() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1358(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1358(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1358(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1358(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1358(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1358(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1367( A&); +three sink_4_1367(volatile A&); +six sink_4_1367(const A&&); +seven sink_4_1367(volatile A&&); + +int test4_1367() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1367(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1367(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1367(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1367(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1368( A&); +three sink_4_1368(volatile A&); +six sink_4_1368(const A&&); +eight sink_4_1368(const volatile A&&); + +int test4_1368() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1368(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1368(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1368(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_1368(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1368(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1368(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1378( A&); +three sink_4_1378(volatile A&); +seven sink_4_1378(volatile A&&); +eight sink_4_1378(const volatile A&&); + +int test4_1378() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1378(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1378(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_1378(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_1378(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1378(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_1378(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1456( A&); +four sink_4_1456(const volatile A&); +five sink_4_1456( A&&); +six sink_4_1456(const A&&); + +int test4_1456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1456(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1456(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1456(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1456(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1456(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1456(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_4_1457( A&); +four sink_4_1457(const volatile A&); +five sink_4_1457( A&&); +seven sink_4_1457(volatile A&&); + +int test4_1457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1457(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1457(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1457(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1457(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1457(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1457(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1458( A&); +four sink_4_1458(const volatile A&); +five sink_4_1458( A&&); +eight sink_4_1458(const volatile A&&); + +int test4_1458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1458(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1458(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1458(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1458(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1458(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1458(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1458(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1458(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1467( A&); +four sink_4_1467(const volatile A&); +six sink_4_1467(const A&&); +seven sink_4_1467(volatile A&&); + +int test4_1467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1467(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1467(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1467(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1467(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1467(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1467(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1468( A&); +four sink_4_1468(const volatile A&); +six sink_4_1468(const A&&); +eight sink_4_1468(const volatile A&&); + +int test4_1468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1468(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1468(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1468(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1468(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1468(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_1468(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1468(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1468(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1478( A&); +four sink_4_1478(const volatile A&); +seven sink_4_1478(volatile A&&); +eight sink_4_1478(const volatile A&&); + +int test4_1478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1478(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1478(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_1478(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_1478(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_1478(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_1478(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1478(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_1478(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1567( A&); +five sink_4_1567( A&&); +six sink_4_1567(const A&&); +seven sink_4_1567(volatile A&&); + +int test4_1567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1567(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_4_1568( A&); +five sink_4_1568( A&&); +six sink_4_1568(const A&&); +eight sink_4_1568(const volatile A&&); + +int test4_1568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1568(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_1568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1578( A&); +five sink_4_1578( A&&); +seven sink_4_1578(volatile A&&); +eight sink_4_1578(const volatile A&&); + +int test4_1578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1578(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_1578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_1578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_1578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_4_1678( A&); +six sink_4_1678(const A&&); +seven sink_4_1678(volatile A&&); +eight sink_4_1678(const volatile A&&); + +int test4_1678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_1678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_4_1678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_1678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_1678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2345(const A&); +three sink_4_2345(volatile A&); +four sink_4_2345(const volatile A&); +five sink_4_2345( A&&); + +int test4_2345() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2345(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2345(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2345(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2345(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2345(c_source())) == 2 * sizeof(long)> t6; + return 0; +} + +two sink_4_2346(const A&); +three sink_4_2346(volatile A&); +four sink_4_2346(const volatile A&); +six sink_4_2346(const A&&); + +int test4_2346() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2346(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2346(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2346(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2346(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_2346(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +two sink_4_2347(const A&); +three sink_4_2347(volatile A&); +four sink_4_2347(const volatile A&); +seven sink_4_2347(volatile A&&); + +int test4_2347() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2347(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2347(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2347(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2347(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_2347(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_4_2347(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_4_2348(const A&); +three sink_4_2348(volatile A&); +four sink_4_2348(const volatile A&); +eight sink_4_2348(const volatile A&&); + +int test4_2348() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2348(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2348(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2348(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2348(source())) == 8 * sizeof(long)> t5; + sa<sizeof(sink_4_2348(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_2348(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_2348(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2356(const A&); +three sink_4_2356(volatile A&); +five sink_4_2356( A&&); +six sink_4_2356(const A&&); + +int test4_2356() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2356(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2356(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2356(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2356(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +two sink_4_2357(const A&); +three sink_4_2357(volatile A&); +five sink_4_2357( A&&); +seven sink_4_2357(volatile A&&); + +int test4_2357() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2357(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2357(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2357(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2357(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_4_2357(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_4_2358(const A&); +three sink_4_2358(volatile A&); +five sink_4_2358( A&&); +eight sink_4_2358(const volatile A&&); + +int test4_2358() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2358(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2358(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2358(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2358(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_2358(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_2358(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2367(const A&); +three sink_4_2367(volatile A&); +six sink_4_2367(const A&&); +seven sink_4_2367(volatile A&&); + +int test4_2367() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2367(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2367(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2367(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_2367(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_4_2368(const A&); +three sink_4_2368(volatile A&); +six sink_4_2368(const A&&); +eight sink_4_2368(const volatile A&&); + +int test4_2368() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2368(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2368(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2368(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_2368(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_2368(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_2368(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2378(const A&); +three sink_4_2378(volatile A&); +seven sink_4_2378(volatile A&&); +eight sink_4_2378(const volatile A&&); + +int test4_2378() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2378(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2378(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_2378(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_2378(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_2378(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_2378(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2456(const A&); +four sink_4_2456(const volatile A&); +five sink_4_2456( A&&); +six sink_4_2456(const A&&); + +int test4_2456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2456(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2456(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2456(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_2456(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2456(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2456(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +two sink_4_2457(const A&); +four sink_4_2457(const volatile A&); +five sink_4_2457( A&&); +seven sink_4_2457(volatile A&&); + +int test4_2457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2457(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2457(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2457(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_2457(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2457(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2457(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_4_2457(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_4_2458(const A&); +four sink_4_2458(const volatile A&); +five sink_4_2458( A&&); +eight sink_4_2458(const volatile A&&); + +int test4_2458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2458(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2458(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2458(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_2458(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2458(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2458(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_2458(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_2458(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2467(const A&); +four sink_4_2467(const volatile A&); +six sink_4_2467(const A&&); +seven sink_4_2467(volatile A&&); + +int test4_2467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2467(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2467(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2467(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_2467(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2467(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_2467(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_4_2468(const A&); +four sink_4_2468(const volatile A&); +six sink_4_2468(const A&&); +eight sink_4_2468(const volatile A&&); + +int test4_2468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2468(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2468(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2468(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_2468(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2468(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_2468(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_2468(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_2468(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2478(const A&); +four sink_4_2478(const volatile A&); +seven sink_4_2478(volatile A&&); +eight sink_4_2478(const volatile A&&); + +int test4_2478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2478(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2478(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2478(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_2478(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_2478(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_2478(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_2478(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_2478(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2567(const A&); +five sink_4_2567( A&&); +six sink_4_2567(const A&&); +seven sink_4_2567(volatile A&&); + +int test4_2567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2567(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2567(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_2567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_4_2568(const A&); +five sink_4_2568( A&&); +six sink_4_2568(const A&&); +eight sink_4_2568(const volatile A&&); + +int test4_2568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2568(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2568(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_2568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_2568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2578(const A&); +five sink_4_2578( A&&); +seven sink_4_2578(volatile A&&); +eight sink_4_2578(const volatile A&&); + +int test4_2578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2578(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2578(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_2578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_2578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_2578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_4_2678(const A&); +six sink_4_2678(const A&&); +seven sink_4_2678(volatile A&&); +eight sink_4_2678(const volatile A&&); + +int test4_2678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_2678(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_4_2678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_4_2678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_2678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_2678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_4_3456(volatile A&); +four sink_4_3456(const volatile A&); +five sink_4_3456( A&&); +six sink_4_3456(const A&&); + +int test4_3456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3456(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3456(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_3456(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3456(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_3456(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_3456(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +three sink_4_3457(volatile A&); +four sink_4_3457(const volatile A&); +five sink_4_3457( A&&); +seven sink_4_3457(volatile A&&); + +int test4_3457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3457(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3457(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_3457(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3457(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_3457(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_3457(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +three sink_4_3458(volatile A&); +four sink_4_3458(const volatile A&); +five sink_4_3458( A&&); +eight sink_4_3458(const volatile A&&); + +int test4_3458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3458(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3458(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_3458(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3458(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_3458(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_3458(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_3458(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_3458(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_4_3467(volatile A&); +four sink_4_3467(const volatile A&); +six sink_4_3467(const A&&); +seven sink_4_3467(volatile A&&); + +int test4_3467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3467(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3467(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_3467(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3467(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_3467(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_3467(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +three sink_4_3468(volatile A&); +four sink_4_3468(const volatile A&); +six sink_4_3468(const A&&); +eight sink_4_3468(const volatile A&&); + +int test4_3468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3468(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3468(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_3468(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3468(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_3468(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_4_3468(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_3468(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_3468(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_4_3478(volatile A&); +four sink_4_3478(const volatile A&); +seven sink_4_3478(volatile A&&); +eight sink_4_3478(const volatile A&&); + +int test4_3478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3478(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3478(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_3478(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3478(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_3478(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_4_3478(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_3478(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_3478(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_4_3567(volatile A&); +five sink_4_3567( A&&); +six sink_4_3567(const A&&); +seven sink_4_3567(volatile A&&); + +int test4_3567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3567(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3567(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_3567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_3567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +three sink_4_3568(volatile A&); +five sink_4_3568( A&&); +six sink_4_3568(const A&&); +eight sink_4_3568(const volatile A&&); + +int test4_3568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3568(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3568(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_3568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_3568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_3568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_4_3578(volatile A&); +five sink_4_3578( A&&); +seven sink_4_3578(volatile A&&); +eight sink_4_3578(const volatile A&&); + +int test4_3578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3578(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3578(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_3578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_3578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_3578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_4_3678(volatile A&); +six sink_4_3678(const A&&); +seven sink_4_3678(volatile A&&); +eight sink_4_3678(const volatile A&&); + +int test4_3678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_3678(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_4_3678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_4_3678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_3678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_3678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_4_4567(const volatile A&); +five sink_4_4567( A&&); +six sink_4_4567(const A&&); +seven sink_4_4567(volatile A&&); + +int test4_4567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_4567(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_4_4567(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_4567(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_4567(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_4567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_4567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_4567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +four sink_4_4568(const volatile A&); +five sink_4_4568( A&&); +six sink_4_4568(const A&&); +eight sink_4_4568(const volatile A&&); + +int test4_4568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_4568(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_4_4568(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_4568(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_4568(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_4568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_4568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_4568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_4_4568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_4_4578(const volatile A&); +five sink_4_4578( A&&); +seven sink_4_4578(volatile A&&); +eight sink_4_4578(const volatile A&&); + +int test4_4578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_4578(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_4_4578(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_4578(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_4578(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_4578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_4578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_4_4578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_4578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_4_4678(const volatile A&); +six sink_4_4678(const A&&); +seven sink_4_4678(volatile A&&); +eight sink_4_4678(const volatile A&&); + +int test4_4678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_4678(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_4_4678(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_4_4678(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_4_4678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_4_4678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_4678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_4678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +five sink_4_5678( A&&); +six sink_4_5678(const A&&); +seven sink_4_5678(volatile A&&); +eight sink_4_5678(const volatile A&&); + +int test4_5678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_4_5678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_4_5678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_4_5678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_4_5678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test4_1234() + test4_1235() + test4_1236() + test4_1237() + test4_1238() + + test4_1245() + test4_1246() + test4_1247() + test4_1248() + test4_1256() + + test4_1257() + test4_1258() + test4_1267() + test4_1268() + test4_1278() + + test4_1345() + test4_1346() + test4_1347() + test4_1348() + test4_1356() + + test4_1357() + test4_1358() + test4_1367() + test4_1368() + test4_1378() + + test4_1456() + test4_1457() + test4_1458() + test4_1467() + test4_1468() + + test4_1478() + test4_1567() + test4_1568() + test4_1578() + test4_1678() + + test4_2345() + test4_2346() + test4_2347() + test4_2348() + test4_2356() + + test4_2357() + test4_2358() + test4_2367() + test4_2368() + test4_2378() + + test4_2456() + test4_2457() + test4_2458() + test4_2467() + test4_2468() + + test4_2478() + test4_2567() + test4_2568() + test4_2578() + test4_2678() + + test4_3456() + test4_3457() + test4_3458() + test4_3467() + test4_3468() + + test4_3478() + test4_3567() + test4_3568() + test4_3578() + test4_3678() + + test4_4567() + test4_4568() + test4_4578() + test4_4678() + test4_5678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv5n.C b/gcc/testsuite/g++.dg/cpp0x/rv5n.C new file mode 100644 index 000000000..660a68986 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv5n.C @@ -0,0 +1,806 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; +struct three {char x[3];}; +struct four {char x[4];}; +struct five {char x[5];}; +struct six {char x[6];}; +struct seven {char x[7];}; +struct eight {char x[8];}; + +struct A +{ + A(); + A(const volatile A&&); // { dg-error "argument 1" } +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 5 at a time + +one sink_5_12345( A&); // { dg-message "one sink_5_12345|no known conversion" } +two sink_5_12345(const A&); // { dg-message "note" } +three sink_5_12345(volatile A&); // { dg-message "note" } +four sink_5_12345(const volatile A&); // { dg-message "note" } +five sink_5_12345( A&&); // { dg-message "note" } + +int test5_12345() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12345(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 45 } + sink_5_12345(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 47 } + return 0; +} + +one sink_5_12346( A&); // { dg-message "one sink_5_12346|no known conversion" } +two sink_5_12346(const A&); // { dg-message "note" } +three sink_5_12346(volatile A&); // { dg-message "note" } +four sink_5_12346(const volatile A&); // { dg-message "note" } +six sink_5_12346(const A&&); // { dg-message "note" } + +int test5_12346() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12346(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 64 } + sink_5_12346(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + return 0; +} + +one sink_5_12347( A&); // { dg-message "one sink_5_12347|no known conversion" } +two sink_5_12347(const A&); // { dg-message "note" } +three sink_5_12347(volatile A&); // { dg-message "note" } +four sink_5_12347(const volatile A&); // { dg-message "note" } +seven sink_5_12347(volatile A&&); // { dg-message "note" } + +int test5_12347() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12347(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 83 } + return 0; +} + +one sink_5_12356( A&); // { dg-message "one sink_5_12356|no known conversion" } +two sink_5_12356(const A&); // { dg-message "note" } +three sink_5_12356(volatile A&); // { dg-message "note" } +five sink_5_12356( A&&); // { dg-message "note" } +six sink_5_12356(const A&&); // { dg-message "note" } + +int test5_12356() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12356(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 100 } + sink_5_12356(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 102 } + sink_5_12356(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 104 } + return 0; +} + +one sink_5_12357( A&); // { dg-message "one sink_5_12357|no known conversion" } +two sink_5_12357(const A&); // { dg-message "note" } +three sink_5_12357(volatile A&); // { dg-message "note" } +five sink_5_12357( A&&); // { dg-message "note" } +seven sink_5_12357(volatile A&&); // { dg-message "note" } + +int test5_12357() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12357(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 121 } + sink_5_12357(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 123 } + return 0; +} + +one sink_5_12358( A&); +two sink_5_12358(const A&); +three sink_5_12358(volatile A&); +five sink_5_12358( A&&); +eight sink_5_12358(const volatile A&&); // { dg-message "" } + +int test5_12358() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12358(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_5_12367( A&); // { dg-message "one sink_5_12367|no known conversion" } +two sink_5_12367(const A&); // { dg-message "note" } +three sink_5_12367(volatile A&); // { dg-message "note" } +six sink_5_12367(const A&&); // { dg-message "note" } +seven sink_5_12367(volatile A&&); // { dg-message "note" } + +int test5_12367() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12367(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 156 } + sink_5_12367(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 158 } + sink_5_12367(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 160 } + return 0; +} + +one sink_5_12368( A&); +two sink_5_12368(const A&); +three sink_5_12368(volatile A&); +six sink_5_12368(const A&&); +eight sink_5_12368(const volatile A&&); // { dg-message "" } + +int test5_12368() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12368(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_5_12378( A&); +two sink_5_12378(const A&); +three sink_5_12378(volatile A&); +seven sink_5_12378(volatile A&&); +eight sink_5_12378(const volatile A&&); // { dg-message "" } + +int test5_12378() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12378(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_5_12456( A&); // { dg-message "one sink_5_12456|no known conversion" } +two sink_5_12456(const A&); // { dg-message "note" } +four sink_5_12456(const volatile A&); // { dg-message "note" } +five sink_5_12456( A&&); // { dg-message "note" } +six sink_5_12456(const A&&); // { dg-message "note" } + +int test5_12456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 209 } + sink_5_12456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 211 } + return 0; +} + +one sink_5_12457( A&); // { dg-message "one sink_5_12457|no known conversion" } +two sink_5_12457(const A&); // { dg-message "note" } +four sink_5_12457(const volatile A&); // { dg-message "note" } +five sink_5_12457( A&&); // { dg-message "note" } +seven sink_5_12457(volatile A&&); // { dg-message "note" } + +int test5_12457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 228 } + return 0; +} + +one sink_5_12467( A&); // { dg-message "one sink_5_12467|no known conversion" } +two sink_5_12467(const A&); // { dg-message "note" } +four sink_5_12467(const volatile A&); // { dg-message "note" } +six sink_5_12467(const A&&); // { dg-message "note" } +seven sink_5_12467(volatile A&&); // { dg-message "note" } + +int test5_12467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 245 } + sink_5_12467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 247 } + return 0; +} + +one sink_5_12567( A&); // { dg-message "one sink_5_12567|no known conversion" } +two sink_5_12567(const A&); // { dg-message "note" } +five sink_5_12567( A&&); // { dg-message "note" } +six sink_5_12567(const A&&); // { dg-message "note" } +seven sink_5_12567(volatile A&&); // { dg-message "" } + +int test5_12567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12567(va); // { dg-error "lvalue" } + sink_5_12567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 265 } + sink_5_12567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 267 } + return 0; +} + +one sink_5_12568( A&); +two sink_5_12568(const A&); +five sink_5_12568( A&&); +six sink_5_12568(const A&&); +eight sink_5_12568(const volatile A&&); // { dg-message "" } + +int test5_12568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12568(va); // { dg-error "lvalue" } + sink_5_12568(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_5_12578( A&); +two sink_5_12578(const A&); +five sink_5_12578( A&&); +seven sink_5_12578(volatile A&&); // { dg-message "" } +eight sink_5_12578(const volatile A&&); // { dg-message "" } + +int test5_12578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12578(va); // { dg-error "lvalue" } + sink_5_12578(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_5_12678( A&); +two sink_5_12678(const A&); // { dg-message "note" } +six sink_5_12678(const A&&); // { dg-message "note" } +seven sink_5_12678(volatile A&&); // { dg-message "" } +eight sink_5_12678(const volatile A&&); // { dg-message "" } + +int test5_12678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_12678(va); // { dg-error "lvalue" } + sink_5_12678(cva); // { dg-error "lvalue" } + sink_5_12678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 320 } + return 0; +} + +one sink_5_13456( A&); // { dg-message "one sink_5_13456|no known conversion" } +three sink_5_13456(volatile A&); // { dg-message "note" } +four sink_5_13456(const volatile A&); // { dg-message "note" } +five sink_5_13456( A&&); // { dg-message "note" } +six sink_5_13456(const A&&); // { dg-message "note" } + +int test5_13456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_13456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 337 } + sink_5_13456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 339 } + return 0; +} + +one sink_5_13457( A&); // { dg-message "one sink_5_13457|no known conversion" } +three sink_5_13457(volatile A&); // { dg-message "note" } +four sink_5_13457(const volatile A&); // { dg-message "note" } +five sink_5_13457( A&&); // { dg-message "note" } +seven sink_5_13457(volatile A&&); // { dg-message "note" } + +int test5_13457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_13457(c_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 356 } + sink_5_13457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 358 } + return 0; +} + +one sink_5_13467( A&); // { dg-message "one sink_5_13467|no known conversion" } +three sink_5_13467(volatile A&); // { dg-message "note" } +four sink_5_13467(const volatile A&); // { dg-message "note" } +six sink_5_13467(const A&&); // { dg-message "note" } +seven sink_5_13467(volatile A&&); // { dg-message "note" } + +int test5_13467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_13467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 375 } + sink_5_13467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 377 } + return 0; +} + +one sink_5_13567( A&); // { dg-message "one sink_5_13567|no known conversion" } +three sink_5_13567(volatile A&); // { dg-message "note" } +five sink_5_13567( A&&); // { dg-message "note" } +six sink_5_13567(const A&&); // { dg-message "" } +seven sink_5_13567(volatile A&&); // { dg-message "note" } + +int test5_13567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_13567(ca); // { dg-error "lvalue" } + sink_5_13567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 395 } + sink_5_13567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 397 } + return 0; +} + +one sink_5_13568( A&); +three sink_5_13568(volatile A&); +five sink_5_13568( A&&); +six sink_5_13568(const A&&); // { dg-message "" } +eight sink_5_13568(const volatile A&&); // { dg-message "" } + +int test5_13568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_13568(ca); // { dg-error "lvalue" } + sink_5_13568(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_5_13578( A&); +three sink_5_13578(volatile A&); +five sink_5_13578( A&&); +seven sink_5_13578(volatile A&&); +eight sink_5_13578(const volatile A&&); // { dg-message "" } + +int test5_13578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_13578(ca); // { dg-error "lvalue" } + sink_5_13578(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_5_13678( A&); +three sink_5_13678(volatile A&); +six sink_5_13678(const A&&); // { dg-message "" } +seven sink_5_13678(volatile A&&); // { dg-message "note" } +eight sink_5_13678(const volatile A&&); // { dg-message "" } + +int test5_13678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_13678(ca); // { dg-error "lvalue" } + sink_5_13678(cva); // { dg-error "lvalue" } + sink_5_13678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 450 } + return 0; +} + +one sink_5_14567( A&); // { dg-message "one sink_5_14567|no known conversion" } +four sink_5_14567(const volatile A&); // { dg-message "note" } +five sink_5_14567( A&&); // { dg-message "note" } +six sink_5_14567(const A&&); // { dg-message "note" } +seven sink_5_14567(volatile A&&); // { dg-message "note" } + +int test5_14567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_14567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 467 } + return 0; +} + +one sink_5_14678( A&); +four sink_5_14678(const volatile A&); +six sink_5_14678(const A&&); // { dg-message "note" } +seven sink_5_14678(volatile A&&); // { dg-message "note" } +eight sink_5_14678(const volatile A&&); // { dg-message "note" } + +int test5_14678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_14678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 484 } + return 0; +} + +one sink_5_15678( A&); +five sink_5_15678( A&&); +six sink_5_15678(const A&&); // { dg-message "" } +seven sink_5_15678(volatile A&&); // { dg-message "" } +eight sink_5_15678(const volatile A&&); // { dg-message "" } + +int test5_15678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_15678(ca); // { dg-error "lvalue" } + sink_5_15678(va); // { dg-error "lvalue" } + sink_5_15678(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_5_23456(const A&); // { dg-message "two sink_5_23456|no known conversion" } +three sink_5_23456(volatile A&); // { dg-message "note" } +four sink_5_23456(const volatile A&); // { dg-message "note" } +five sink_5_23456( A&&); // { dg-message "note" } +six sink_5_23456(const A&&); // { dg-message "note" } + +int test5_23456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23456(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 519 } + sink_5_23456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 521 } + sink_5_23456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 523 } + return 0; +} + +two sink_5_23457(const A&); // { dg-message "two sink_5_23457|no known conversion" } +three sink_5_23457(volatile A&); // { dg-message "note" } +four sink_5_23457(const volatile A&); // { dg-message "note" } +five sink_5_23457( A&&); // { dg-message "note" } +seven sink_5_23457(volatile A&&); // { dg-message "note" } + +int test5_23457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23457(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 540 } + sink_5_23457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 542 } + return 0; +} + +two sink_5_23458(const A&); // { dg-message "note" } +three sink_5_23458(volatile A&); // { dg-message "note" } +four sink_5_23458(const volatile A&); // { dg-message "note" } +five sink_5_23458( A&&); // { dg-message "note" } +eight sink_5_23458(const volatile A&&); // { dg-message "note" } + +int test5_23458() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23458(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 559 } + return 0; +} + +two sink_5_23467(const A&); // { dg-message "two sink_5_23467|no known conversion" } +three sink_5_23467(volatile A&); // { dg-message "note" } +four sink_5_23467(const volatile A&); // { dg-message "note" } +six sink_5_23467(const A&&); // { dg-message "note" } +seven sink_5_23467(volatile A&&); // { dg-message "note" } + +int test5_23467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23467(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 576 } + sink_5_23467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 578 } + sink_5_23467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 580 } + return 0; +} + +two sink_5_23468(const A&); // { dg-message "note" } +three sink_5_23468(volatile A&); // { dg-message "note" } +four sink_5_23468(const volatile A&); // { dg-message "note" } +six sink_5_23468(const A&&); // { dg-message "note" } +eight sink_5_23468(const volatile A&&); // { dg-message "note" } + +int test5_23468() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23468(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 597 } + return 0; +} + +two sink_5_23478(const A&); // { dg-message "note" } +three sink_5_23478(volatile A&); // { dg-message "note" } +four sink_5_23478(const volatile A&); // { dg-message "note" } +seven sink_5_23478(volatile A&&); // { dg-message "note" } +eight sink_5_23478(const volatile A&&); // { dg-message "note" } + +int test5_23478() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23478(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 614 } + return 0; +} + +two sink_5_23567(const A&); // { dg-message "two sink_5_23567|no known conversion" } +three sink_5_23567(volatile A&); // { dg-message "note" } +five sink_5_23567( A&&); // { dg-message "note" } +six sink_5_23567(const A&&); // { dg-message "note" } +seven sink_5_23567(volatile A&&); // { dg-message "note" } + +int test5_23567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23567(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 631 } + sink_5_23567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 633 } + sink_5_23567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 635 } + return 0; +} + +two sink_5_23568(const A&); // { dg-message "note" } +three sink_5_23568(volatile A&); // { dg-message "note" } +five sink_5_23568( A&&); // { dg-message "note" } +six sink_5_23568(const A&&); // { dg-message "note" } +eight sink_5_23568(const volatile A&&); // { dg-message "" } + +int test5_23568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23568(cva); // { dg-error "lvalue" } + sink_5_23568(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 653 } + return 0; +} + +two sink_5_23578(const A&); // { dg-message "note" } +three sink_5_23578(volatile A&); // { dg-message "note" } +five sink_5_23578( A&&); // { dg-message "note" } +seven sink_5_23578(volatile A&&); // { dg-message "note" } +eight sink_5_23578(const volatile A&&); // { dg-message "" } + +int test5_23578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23578(cva); // { dg-error "lvalue" } + sink_5_23578(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 671 } + return 0; +} + +two sink_5_23678(const A&); // { dg-message "note" } +three sink_5_23678(volatile A&); // { dg-message "note" } +six sink_5_23678(const A&&); // { dg-message "note" } +seven sink_5_23678(volatile A&&); // { dg-message "note" } +eight sink_5_23678(const volatile A&&); // { dg-message "" } + +int test5_23678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_23678(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 688 } + sink_5_23678(cva); // { dg-error "lvalue" } + sink_5_23678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 691 } + return 0; +} + +two sink_5_24567(const A&); // { dg-message "two sink_5_24567|no known conversion" } +four sink_5_24567(const volatile A&); // { dg-message "note" } +five sink_5_24567( A&&); // { dg-message "note" } +six sink_5_24567(const A&&); // { dg-message "note" } +seven sink_5_24567(volatile A&&); // { dg-message "note" } + +int test5_24567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_24567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 708 } + return 0; +} + +two sink_5_24678(const A&); // { dg-message "note" } +four sink_5_24678(const volatile A&); +six sink_5_24678(const A&&); // { dg-message "note" } +seven sink_5_24678(volatile A&&); // { dg-message "note" } +eight sink_5_24678(const volatile A&&); // { dg-message "note" } + +int test5_24678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_24678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 725 } + return 0; +} + +two sink_5_25678(const A&); +five sink_5_25678( A&&); +six sink_5_25678(const A&&); +seven sink_5_25678(volatile A&&); // { dg-message "" } +eight sink_5_25678(const volatile A&&); // { dg-message "" } + +int test5_25678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_25678(va); // { dg-error "lvalue" } + sink_5_25678(cva); // { dg-error "lvalue" } + return 0; +} + +three sink_5_34567(volatile A&); // { dg-message "three sink_5_34567|no known conversion" } +four sink_5_34567(const volatile A&); // { dg-message "note" } +five sink_5_34567( A&&); // { dg-message "note" } +six sink_5_34567(const A&&); // { dg-message "note" } +seven sink_5_34567(volatile A&&); // { dg-message "note" } + +int test5_34567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_34567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 759 } + return 0; +} + +three sink_5_34678(volatile A&); +four sink_5_34678(const volatile A&); +six sink_5_34678(const A&&); // { dg-message "note" } +seven sink_5_34678(volatile A&&); // { dg-message "note" } +eight sink_5_34678(const volatile A&&); // { dg-message "note" } + +int test5_34678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_34678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 776 } + return 0; +} + +three sink_5_35678(volatile A&); +five sink_5_35678( A&&); +six sink_5_35678(const A&&); // { dg-message "" } +seven sink_5_35678(volatile A&&); +eight sink_5_35678(const volatile A&&); // { dg-message "" } + +int test5_35678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_5_35678(ca); // { dg-error "lvalue" } + sink_5_35678(cva); // { dg-error "lvalue" } + return 0; +} + +int main() +{ + return test5_12356() + test5_12357() + test5_12367() + test5_12467() + + test5_12567() + test5_12678() + test5_13467() + test5_13567() + + test5_13678() + test5_13678() + test5_23456() + test5_23457() + + test5_23458() + test5_23467() + test5_23468() + test5_23478() + + test5_23567() + test5_23568() + test5_23578() + test5_23678() + + test5_24678() + test5_34678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv5p.C b/gcc/testsuite/g++.dg/cpp0x/rv5p.C new file mode 100644 index 000000000..b8ab54588 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv5p.C @@ -0,0 +1,1256 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 5 at a time + +one sink_5_12345( A&); +two sink_5_12345(const A&); +three sink_5_12345(volatile A&); +four sink_5_12345(const volatile A&); +five sink_5_12345( A&&); + +int test5_12345() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12345(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12345(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12345(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12345(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12345(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12345(c_source())) == 2* sizeof(long)> t6; + return 0; +} + +one sink_5_12346( A&); +two sink_5_12346(const A&); +three sink_5_12346(volatile A&); +four sink_5_12346(const volatile A&); +six sink_5_12346(const A&&); + +int test5_12346() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12346(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12346(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12346(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12346(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12346(source())) == 6* sizeof(long)> t5; + sa<sizeof(sink_5_12346(c_source())) == 6* sizeof(long)> t6; + return 0; +} + +one sink_5_12347( A&); +two sink_5_12347(const A&); +three sink_5_12347(volatile A&); +four sink_5_12347(const volatile A&); +seven sink_5_12347(volatile A&&); + +int test5_12347() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12347(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12347(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12347(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12347(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12347(source())) == 7* sizeof(long)> t5; + sa<sizeof(sink_5_12347(c_source())) == 2* sizeof(long)> t6; + sa<sizeof(sink_5_12347(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_12348( A&); +two sink_5_12348(const A&); +three sink_5_12348(volatile A&); +four sink_5_12348(const volatile A&); +eight sink_5_12348(const volatile A&&); + +int test5_12348() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12348(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12348(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12348(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12348(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12348(source())) == 8* sizeof(long)> t5; + sa<sizeof(sink_5_12348(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_12348(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_12348(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12356( A&); +two sink_5_12356(const A&); +three sink_5_12356(volatile A&); +five sink_5_12356( A&&); +six sink_5_12356(const A&&); + +int test5_12356() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12356(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12356(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12356(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12356(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12356(c_source())) == 6* sizeof(long)> t6; + return 0; +} + +one sink_5_12357( A&); +two sink_5_12357(const A&); +three sink_5_12357(volatile A&); +five sink_5_12357( A&&); +seven sink_5_12357(volatile A&&); + +int test5_12357() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12357(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12357(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12357(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12357(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12357(c_source())) == 2* sizeof(long)> t6; + sa<sizeof(sink_5_12357(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_12358( A&); +two sink_5_12358(const A&); +three sink_5_12358(volatile A&); +five sink_5_12358( A&&); +eight sink_5_12358(const volatile A&&); + +int test5_12358() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12358(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12358(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12358(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12358(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12358(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_12358(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_12358(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12367( A&); +two sink_5_12367(const A&); +three sink_5_12367(volatile A&); +six sink_5_12367(const A&&); +seven sink_5_12367(volatile A&&); + +int test5_12367() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12367(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12367(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12367(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12367(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_12367(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_12368( A&); +two sink_5_12368(const A&); +three sink_5_12368(volatile A&); +six sink_5_12368(const A&&); +eight sink_5_12368(const volatile A&&); + +int test5_12368() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12368(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12368(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12368(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12368(source())) == 6* sizeof(long)> t5; + sa<sizeof(sink_5_12368(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_12368(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_12368(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12378( A&); +two sink_5_12378(const A&); +three sink_5_12378(volatile A&); +seven sink_5_12378(volatile A&&); +eight sink_5_12378(const volatile A&&); + +int test5_12378() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12378(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12378(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12378(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_12378(source())) == 7* sizeof(long)> t5; + sa<sizeof(sink_5_12378(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_12378(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_12378(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12456( A&); +two sink_5_12456(const A&); +four sink_5_12456(const volatile A&); +five sink_5_12456( A&&); +six sink_5_12456(const A&&); + +int test5_12456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12456(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12456(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12456(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_12456(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12456(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12456(c_source())) == 6* sizeof(long)> t6; + return 0; +} + +one sink_5_12457( A&); +two sink_5_12457(const A&); +four sink_5_12457(const volatile A&); +five sink_5_12457( A&&); +seven sink_5_12457(volatile A&&); + +int test5_12457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12457(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12457(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12457(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_12457(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12457(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12457(c_source())) == 2* sizeof(long)> t6; + sa<sizeof(sink_5_12457(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_12458( A&); +two sink_5_12458(const A&); +four sink_5_12458(const volatile A&); +five sink_5_12458( A&&); +eight sink_5_12458(const volatile A&&); + +int test5_12458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12458(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12458(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12458(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_12458(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12458(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12458(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_12458(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_12458(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12467( A&); +two sink_5_12467(const A&); +four sink_5_12467(const volatile A&); +six sink_5_12467(const A&&); +seven sink_5_12467(volatile A&&); + +int test5_12467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12467(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12467(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12467(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_12467(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12467(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_12467(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_12468( A&); +two sink_5_12468(const A&); +four sink_5_12468(const volatile A&); +six sink_5_12468(const A&&); +eight sink_5_12468(const volatile A&&); + +int test5_12468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12468(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12468(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12468(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_12468(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12468(source())) == 6* sizeof(long)> t5; + sa<sizeof(sink_5_12468(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_12468(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_12468(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12478( A&); +two sink_5_12478(const A&); +four sink_5_12478(const volatile A&); +seven sink_5_12478(volatile A&&); +eight sink_5_12478(const volatile A&&); + +int test5_12478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12478(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12478(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12478(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_12478(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_12478(source())) == 7* sizeof(long)> t5; + sa<sizeof(sink_5_12478(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_12478(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_12478(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12567( A&); +two sink_5_12567(const A&); +five sink_5_12567( A&&); +six sink_5_12567(const A&&); +seven sink_5_12567(volatile A&&); + +int test5_12567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12567(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12567(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12567(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12567(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_12567(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_12568( A&); +two sink_5_12568(const A&); +five sink_5_12568( A&&); +six sink_5_12568(const A&&); +eight sink_5_12568(const volatile A&&); + +int test5_12568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12568(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12568(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12568(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12568(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_12568(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_12568(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12578( A&); +two sink_5_12578(const A&); +five sink_5_12578( A&&); +seven sink_5_12578(volatile A&&); +eight sink_5_12578(const volatile A&&); + +int test5_12578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12578(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12578(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12578(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_12578(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_12578(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_12578(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_12678( A&); +two sink_5_12678(const A&); +six sink_5_12678(const A&&); +seven sink_5_12678(volatile A&&); +eight sink_5_12678(const volatile A&&); + +int test5_12678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_12678(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_12678(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_12678(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_12678(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_12678(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_13456( A&); +three sink_5_13456(volatile A&); +four sink_5_13456(const volatile A&); +five sink_5_13456( A&&); +six sink_5_13456(const A&&); + +int test5_13456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13456(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13456(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_13456(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13456(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_13456(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_13456(c_source())) == 6* sizeof(long)> t6; + return 0; +} + +one sink_5_13457( A&); +three sink_5_13457(volatile A&); +four sink_5_13457(const volatile A&); +five sink_5_13457( A&&); +seven sink_5_13457(volatile A&&); + +int test5_13457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13457(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13457(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_13457(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13457(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_13457(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_13457(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_13458( A&); +three sink_5_13458(volatile A&); +four sink_5_13458(const volatile A&); +five sink_5_13458( A&&); +eight sink_5_13458(const volatile A&&); + +int test5_13458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13458(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13458(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_13458(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13458(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_13458(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_13458(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_13458(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_13458(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_13467( A&); +three sink_5_13467(volatile A&); +four sink_5_13467(const volatile A&); +six sink_5_13467(const A&&); +seven sink_5_13467(volatile A&&); + +int test5_13467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13467(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13467(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_13467(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13467(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_13467(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_13467(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_13468( A&); +three sink_5_13468(volatile A&); +four sink_5_13468(const volatile A&); +six sink_5_13468(const A&&); +eight sink_5_13468(const volatile A&&); + +int test5_13468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13468(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13468(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_13468(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13468(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_13468(source())) == 6* sizeof(long)> t5; + sa<sizeof(sink_5_13468(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_13468(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_13468(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_13478( A&); +three sink_5_13478(volatile A&); +four sink_5_13478(const volatile A&); +seven sink_5_13478(volatile A&&); +eight sink_5_13478(const volatile A&&); + +int test5_13478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13478(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13478(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_13478(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13478(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_13478(source())) == 7* sizeof(long)> t5; + sa<sizeof(sink_5_13478(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_13478(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_13478(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_13567( A&); +three sink_5_13567(volatile A&); +five sink_5_13567( A&&); +six sink_5_13567(const A&&); +seven sink_5_13567(volatile A&&); + +int test5_13567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13567(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13567(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13567(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_13567(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_13567(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_13568( A&); +three sink_5_13568(volatile A&); +five sink_5_13568( A&&); +six sink_5_13568(const A&&); +eight sink_5_13568(const volatile A&&); + +int test5_13568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13568(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13568(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13568(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_13568(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_13568(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_13568(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_13578( A&); +three sink_5_13578(volatile A&); +five sink_5_13578( A&&); +seven sink_5_13578(volatile A&&); +eight sink_5_13578(const volatile A&&); + +int test5_13578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13578(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13578(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13578(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_13578(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_13578(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_13578(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_13678( A&); +three sink_5_13678(volatile A&); +six sink_5_13678(const A&&); +seven sink_5_13678(volatile A&&); +eight sink_5_13678(const volatile A&&); + +int test5_13678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_13678(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_13678(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_13678(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_13678(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_13678(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_14567( A&); +four sink_5_14567(const volatile A&); +five sink_5_14567( A&&); +six sink_5_14567(const A&&); +seven sink_5_14567(volatile A&&); + +int test5_14567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_14567(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_14567(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_14567(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_14567(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_14567(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_14567(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_14567(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +one sink_5_14568( A&); +four sink_5_14568(const volatile A&); +five sink_5_14568( A&&); +six sink_5_14568(const A&&); +eight sink_5_14568(const volatile A&&); + +int test5_14568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_14568(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_14568(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_14568(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_14568(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_14568(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_14568(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_14568(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_14568(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_14578( A&); +four sink_5_14578(const volatile A&); +five sink_5_14578( A&&); +seven sink_5_14578(volatile A&&); +eight sink_5_14578(const volatile A&&); + +int test5_14578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_14578(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_14578(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_14578(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_14578(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_14578(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_14578(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_14578(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_14578(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_14678( A&); +four sink_5_14678(const volatile A&); +six sink_5_14678(const A&&); +seven sink_5_14678(volatile A&&); +eight sink_5_14678(const volatile A&&); + +int test5_14678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_14678(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_14678(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_14678(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_14678(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_14678(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_14678(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_14678(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +one sink_5_15678( A&); +five sink_5_15678( A&&); +six sink_5_15678(const A&&); +seven sink_5_15678(volatile A&&); +eight sink_5_15678(const volatile A&&); + +int test5_15678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_15678(a)) == 1* sizeof(long)> t1; + sa<sizeof(sink_5_15678(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_15678(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_15678(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_15678(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_23456(const A&); +three sink_5_23456(volatile A&); +four sink_5_23456(const volatile A&); +five sink_5_23456( A&&); +six sink_5_23456(const A&&); + +int test5_23456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23456(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23456(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23456(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_23456(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_23456(c_source())) == 6* sizeof(long)> t6; + return 0; +} + +two sink_5_23457(const A&); +three sink_5_23457(volatile A&); +four sink_5_23457(const volatile A&); +five sink_5_23457( A&&); +seven sink_5_23457(volatile A&&); + +int test5_23457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23457(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23457(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23457(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_23457(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_23457(c_source())) == 2* sizeof(long)> t6; + sa<sizeof(sink_5_23457(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +two sink_5_23458(const A&); +three sink_5_23458(volatile A&); +four sink_5_23458(const volatile A&); +five sink_5_23458( A&&); +eight sink_5_23458(const volatile A&&); + +int test5_23458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23458(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23458(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23458(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_23458(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_23458(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_23458(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_23458(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_23467(const A&); +three sink_5_23467(volatile A&); +four sink_5_23467(const volatile A&); +six sink_5_23467(const A&&); +seven sink_5_23467(volatile A&&); + +int test5_23467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23467(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23467(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23467(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_23467(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_23467(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +two sink_5_23468(const A&); +three sink_5_23468(volatile A&); +four sink_5_23468(const volatile A&); +six sink_5_23468(const A&&); +eight sink_5_23468(const volatile A&&); + +int test5_23468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23468(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23468(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23468(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_23468(source())) == 6* sizeof(long)> t5; + sa<sizeof(sink_5_23468(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_23468(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_23468(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_23478(const A&); +three sink_5_23478(volatile A&); +four sink_5_23478(const volatile A&); +seven sink_5_23478(volatile A&&); +eight sink_5_23478(const volatile A&&); + +int test5_23478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23478(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23478(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23478(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_23478(source())) == 7* sizeof(long)> t5; + sa<sizeof(sink_5_23478(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_23478(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_23478(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_23567(const A&); +three sink_5_23567(volatile A&); +five sink_5_23567( A&&); +six sink_5_23567(const A&&); +seven sink_5_23567(volatile A&&); + +int test5_23567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23567(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23567(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23567(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_23567(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_23567(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +two sink_5_23568(const A&); +three sink_5_23568(volatile A&); +five sink_5_23568( A&&); +six sink_5_23568(const A&&); +eight sink_5_23568(const volatile A&&); + +int test5_23568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23568(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23568(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23568(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_23568(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_23568(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_23568(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_23578(const A&); +three sink_5_23578(volatile A&); +five sink_5_23578( A&&); +seven sink_5_23578(volatile A&&); +eight sink_5_23578(const volatile A&&); + +int test5_23578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23578(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23578(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23578(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_23578(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_23578(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_23578(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_23678(const A&); +three sink_5_23678(volatile A&); +six sink_5_23678(const A&&); +seven sink_5_23678(volatile A&&); +eight sink_5_23678(const volatile A&&); + +int test5_23678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_23678(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_23678(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_23678(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_23678(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_23678(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_24567(const A&); +four sink_5_24567(const volatile A&); +five sink_5_24567( A&&); +six sink_5_24567(const A&&); +seven sink_5_24567(volatile A&&); + +int test5_24567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_24567(a)) == 2* sizeof(long)> t1; + sa<sizeof(sink_5_24567(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_24567(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_24567(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_24567(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_24567(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_24567(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +two sink_5_24568(const A&); +four sink_5_24568(const volatile A&); +five sink_5_24568( A&&); +six sink_5_24568(const A&&); +eight sink_5_24568(const volatile A&&); + +int test5_24568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_24568(a)) == 2* sizeof(long)> t1; + sa<sizeof(sink_5_24568(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_24568(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_24568(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_24568(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_24568(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_24568(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_24568(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_24578(const A&); +four sink_5_24578(const volatile A&); +five sink_5_24578( A&&); +seven sink_5_24578(volatile A&&); +eight sink_5_24578(const volatile A&&); + +int test5_24578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_24578(a)) == 2* sizeof(long)> t1; + sa<sizeof(sink_5_24578(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_24578(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_24578(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_24578(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_24578(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_24578(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_24578(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_24678(const A&); +four sink_5_24678(const volatile A&); +six sink_5_24678(const A&&); +seven sink_5_24678(volatile A&&); +eight sink_5_24678(const volatile A&&); + +int test5_24678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_24678(a)) == 2* sizeof(long)> t1; + sa<sizeof(sink_5_24678(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_24678(va)) == 4* sizeof(long)> t3; + sa<sizeof(sink_5_24678(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_24678(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_24678(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_24678(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +two sink_5_25678(const A&); +five sink_5_25678( A&&); +six sink_5_25678(const A&&); +seven sink_5_25678(volatile A&&); +eight sink_5_25678(const volatile A&&); + +int test5_25678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_25678(a)) == 2* sizeof(long)> t1; + sa<sizeof(sink_5_25678(ca)) == 2* sizeof(long)> t2; + sa<sizeof(sink_5_25678(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_25678(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_25678(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_25678(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +three sink_5_34567(volatile A&); +four sink_5_34567(const volatile A&); +five sink_5_34567( A&&); +six sink_5_34567(const A&&); +seven sink_5_34567(volatile A&&); + +int test5_34567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_34567(a)) == 3* sizeof(long)> t1; + sa<sizeof(sink_5_34567(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_34567(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_34567(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_34567(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_34567(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_34567(v_source())) == 7* sizeof(long)> t7; + return 0; +} + +three sink_5_34568(volatile A&); +four sink_5_34568(const volatile A&); +five sink_5_34568( A&&); +six sink_5_34568(const A&&); +eight sink_5_34568(const volatile A&&); + +int test5_34568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_34568(a)) == 3* sizeof(long)> t1; + sa<sizeof(sink_5_34568(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_34568(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_34568(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_34568(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_34568(c_source())) == 6* sizeof(long)> t6; + sa<sizeof(sink_5_34568(v_source())) == 8* sizeof(long)> t7; + sa<sizeof(sink_5_34568(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +three sink_5_34578(volatile A&); +four sink_5_34578(const volatile A&); +five sink_5_34578( A&&); +seven sink_5_34578(volatile A&&); +eight sink_5_34578(const volatile A&&); + +int test5_34578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_34578(a)) == 3* sizeof(long)> t1; + sa<sizeof(sink_5_34578(ca)) == 4* sizeof(long)> t2; + sa<sizeof(sink_5_34578(va)) == 3* sizeof(long)> t3; + sa<sizeof(sink_5_34578(cva)) == 4* sizeof(long)> t4; + sa<sizeof(sink_5_34578(source())) == 5* sizeof(long)> t5; + sa<sizeof(sink_5_34578(c_source())) == 8* sizeof(long)> t6; + sa<sizeof(sink_5_34578(v_source())) == 7* sizeof(long)> t7; + sa<sizeof(sink_5_34578(cv_source())) == 8* sizeof(long)> t8; + return 0; +} + +three sink_5_34678(volatile A&); +four sink_5_34678(const volatile A&); +six sink_5_34678(const A&&); +seven sink_5_34678(volatile A&&); +eight sink_5_34678(const volatile A&&); + +int test5_34678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_34678(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_5_34678(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_5_34678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_5_34678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_5_34678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_5_34678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_5_34678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_5_35678(volatile A&); +five sink_5_35678( A&&); +six sink_5_35678(const A&&); +seven sink_5_35678(volatile A&&); +eight sink_5_35678(const volatile A&&); + +int test5_35678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_35678(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_5_35678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_5_35678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_5_35678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_5_35678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_5_35678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +four sink_5_45678(const volatile A&); +five sink_5_45678( A&&); +six sink_5_45678(const A&&); +seven sink_5_45678(volatile A&&); +eight sink_5_45678(const volatile A&&); + +int test5_45678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_5_45678(a)) == 4 * sizeof(long)> t1; + sa<sizeof(sink_5_45678(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_5_45678(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_5_45678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_5_45678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_5_45678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_5_45678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_5_45678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test5_12345() + test5_12346() + test5_12347() + test5_12348() + + test5_12356() + test5_12357() + test5_12358() + test5_12367() + + test5_12368() + test5_12378() + test5_12456() + test5_12457() + + test5_12458() + test5_12467() + test5_12468() + test5_12478() + + test5_12567() + test5_12568() + test5_12578() + test5_12678() + + test5_13456() + test5_13457() + test5_13458() + test5_13467() + + test5_13468() + test5_13478() + test5_13567() + test5_13568() + + test5_13578() + test5_13678() + test5_14567() + test5_14568() + + test5_14578() + test5_14678() + test5_15678() + test5_23456() + + test5_23457() + test5_23458() + test5_23467() + test5_23468() + + test5_23478() + test5_23567() + test5_23568() + test5_23578() + + test5_23678() + test5_24567() + test5_24568() + test5_24578() + + test5_24678() + test5_25678() + test5_34567() + test5_34568() + + test5_34578() + test5_34678() + test5_35678() + test5_45678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv6n.C b/gcc/testsuite/g++.dg/cpp0x/rv6n.C new file mode 100644 index 000000000..d0fdbb7e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv6n.C @@ -0,0 +1,372 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; +struct three {char x[3];}; +struct four {char x[4];}; +struct five {char x[5];}; +struct six {char x[6];}; +struct seven {char x[7];}; +struct eight {char x[8];}; + +struct A +{ + A(); + A(const volatile A&&); // { dg-error "argument 1" } +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 6 at a time + +one sink_6_123456( A&); // { dg-message "one sink_6_123456|no known conversion" } +two sink_6_123456(const A&); // { dg-message "note" } +three sink_6_123456(volatile A&); // { dg-message "note" } +four sink_6_123456(const volatile A&); // { dg-message "note" } +five sink_6_123456( A&&); // { dg-message "note" } +six sink_6_123456(const A&&); // { dg-message "note" } + +int test6_123456() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_123456(v_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 46 } + sink_6_123456(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 48 } + return 0; +} + +one sink_6_123457( A&); // { dg-message "one sink_6_123457|no known conversion" } +two sink_6_123457(const A&); // { dg-message "note" } +three sink_6_123457(volatile A&); // { dg-message "note" } +four sink_6_123457(const volatile A&); // { dg-message "note" } +five sink_6_123457( A&&); // { dg-message "note" } +seven sink_6_123457(volatile A&&); // { dg-message "note" } + +int test6_123457() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_123457(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 66 } + return 0; +} + +two sink_6_235678(const A&); // { dg-message "note" } +three sink_6_235678(volatile A&); // { dg-message "note" } +five sink_6_235678( A&&); // { dg-message "note" } +six sink_6_235678(const A&&); // { dg-message "note" } +seven sink_6_235678(volatile A&&); // { dg-message "note" } +eight sink_6_235678(const volatile A&&); // { dg-message "" } + +int test6_235678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_235678(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 84 } + sink_6_235678(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_6_234678(const A&); // { dg-message "note" } +three sink_6_234678(volatile A&); // { dg-message "note" } +four sink_6_234678(const volatile A&); // { dg-message "note" } +six sink_6_234678(const A&&); // { dg-message "note" } +seven sink_6_234678(volatile A&&); // { dg-message "note" } +eight sink_6_234678(const volatile A&&); // { dg-message "note" } + +int test6_234678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_234678(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 103 } + sink_6_234678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 105 } + return 0; +} + +two sink_6_234578(const A&); // { dg-message "note" } +three sink_6_234578(volatile A&); // { dg-message "note" } +four sink_6_234578(const volatile A&); // { dg-message "note" } +five sink_6_234578( A&&); // { dg-message "note" } +seven sink_6_234578(volatile A&&); // { dg-message "note" } +eight sink_6_234578(const volatile A&&); // { dg-message "note" } + +int test6_234578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_234578(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 123 } + return 0; +} + +two sink_6_234568(const A&); // { dg-message "note" } +three sink_6_234568(volatile A&); // { dg-message "note" } +four sink_6_234568(const volatile A&); // { dg-message "note" } +five sink_6_234568( A&&); // { dg-message "note" } +six sink_6_234568(const A&&); // { dg-message "note" } +eight sink_6_234568(const volatile A&&); // { dg-message "note" } + +int test6_234568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_234568(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 141 } + return 0; +} + +two sink_6_234567(const A&); // { dg-message "two sink_6_234567|no known conversion" } +three sink_6_234567(volatile A&); // { dg-message "note" } +four sink_6_234567(const volatile A&); // { dg-message "note" } +five sink_6_234567( A&&); // { dg-message "note" } +six sink_6_234567(const A&&); // { dg-message "note" } +seven sink_6_234567(volatile A&&); // { dg-message "note" } + +int test6_234567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_234567(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 159 } + sink_6_234567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 161 } + return 0; +} + +one sink_6_134678( A&); +three sink_6_134678(volatile A&); +four sink_6_134678(const volatile A&); +six sink_6_134678(const A&&); // { dg-message "note" } +seven sink_6_134678(volatile A&&); // { dg-message "note" } +eight sink_6_134678(const volatile A&&); // { dg-message "note" } + +int test6_134678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_134678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 179 } + return 0; +} + +one sink_6_124678( A&); +two sink_6_124678(const A&); // { dg-message "note" } +four sink_6_124678(const volatile A&); +six sink_6_124678(const A&&); // { dg-message "note" } +seven sink_6_124678(volatile A&&); // { dg-message "note" } +eight sink_6_124678(const volatile A&&); // { dg-message "note" } + +int test6_124678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_124678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 197 } + return 0; +} + +one sink_6_123678( A&); +two sink_6_123678(const A&); // { dg-message "note" } +three sink_6_123678(volatile A&); +six sink_6_123678(const A&&); // { dg-message "note" } +seven sink_6_123678(volatile A&&); // { dg-message "note" } +eight sink_6_123678(const volatile A&&); // { dg-message "" } + +int test6_123678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_123678(cva); // { dg-error "lvalue" } + sink_6_123678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 216 } + return 0; +} + +one sink_6_123567( A&); // { dg-message "one sink_6_123567|no known conversion" } +two sink_6_123567(const A&); // { dg-message "note" } +three sink_6_123567(volatile A&); // { dg-message "note" } +five sink_6_123567( A&&); // { dg-message "note" } +six sink_6_123567(const A&&); // { dg-message "note" } +seven sink_6_123567(volatile A&&); // { dg-message "note" } + +int test6_123567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_123567(cva); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 234 } + sink_6_123567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 236 } + return 0; +} + +one sink_6_123568( A&); +two sink_6_123568(const A&); +three sink_6_123568(volatile A&); +five sink_6_123568( A&&); +six sink_6_123568(const A&&); +eight sink_6_123568(const volatile A&&); // { dg-message "" } + +int test6_123568() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_123568(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_6_123578( A&); +two sink_6_123578(const A&); +three sink_6_123578(volatile A&); +five sink_6_123578( A&&); +seven sink_6_123578(volatile A&&); +eight sink_6_123578(const volatile A&&); // { dg-message "" } + +int test6_123578() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_123578(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_6_123467( A&); // { dg-message "one sink_6_123467|no known conversion" } +two sink_6_123467(const A&); // { dg-message "note" } +three sink_6_123467(volatile A&); // { dg-message "note" } +four sink_6_123467(const volatile A&); // { dg-message "note" } +six sink_6_123467(const A&&); // { dg-message "note" } +seven sink_6_123467(volatile A&&); // { dg-message "note" } + +int test6_123467() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_123467(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 288 } + sink_6_123467(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 290 } + return 0; +} + +one sink_6_124567( A&); // { dg-message "one sink_6_124567|no known conversion" } +two sink_6_124567(const A&); // { dg-message "note" } +four sink_6_124567(const volatile A&); // { dg-message "note" } +five sink_6_124567( A&&); // { dg-message "note" } +six sink_6_124567(const A&&); // { dg-message "note" } +seven sink_6_124567(volatile A&&); // { dg-message "note" } + +int test6_124567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_124567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 308 } + return 0; +} + +one sink_6_125678( A&); +two sink_6_125678(const A&); +five sink_6_125678( A&&); +six sink_6_125678(const A&&); +seven sink_6_125678(volatile A&&); // { dg-message "" } +eight sink_6_125678(const volatile A&&); // { dg-message "" } + +int test6_125678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_125678(va); // { dg-error "lvalue" } + sink_6_125678(cva); // { dg-error "lvalue" } + return 0; +} + +one sink_6_134567( A&); // { dg-message "one sink_6_134567|no known conversion" } +three sink_6_134567(volatile A&); // { dg-message "note" } +four sink_6_134567(const volatile A&); // { dg-message "note" } +five sink_6_134567( A&&); // { dg-message "note" } +six sink_6_134567(const A&&); // { dg-message "note" } +seven sink_6_134567(volatile A&&); // { dg-message "note" } + +int test6_134567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_134567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 344 } + return 0; +} + +one sink_6_135678( A&); +three sink_6_135678(volatile A&); +five sink_6_135678( A&&); +six sink_6_135678(const A&&); // { dg-message "" } +seven sink_6_135678(volatile A&&); +eight sink_6_135678(const volatile A&&); // { dg-message "" } + +int test6_135678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_6_135678(ca); // { dg-error "lvalue" } + sink_6_135678(cva); // { dg-error "lvalue" } + return 0; +} + +int main() +{ + return test6_235678() + test6_234678() + test6_234578() + test6_234568() + + test6_234567() + test6_134678() + test6_124678() + test6_123678() + + test6_123567(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv6p.C b/gcc/testsuite/g++.dg/cpp0x/rv6p.C new file mode 100644 index 000000000..4b78ef70b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv6p.C @@ -0,0 +1,687 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 6 at a time + +one sink_6_123456( A&); +two sink_6_123456(const A&); +three sink_6_123456(volatile A&); +four sink_6_123456(const volatile A&); +five sink_6_123456( A&&); +six sink_6_123456(const A&&); + +int test6_123456() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123456(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123456(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123456(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123456(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_123456(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_123456(c_source())) == 6 * sizeof(long)> t6; + return 0; +} + +one sink_6_123457( A&); +two sink_6_123457(const A&); +three sink_6_123457(volatile A&); +four sink_6_123457(const volatile A&); +five sink_6_123457( A&&); +seven sink_6_123457(volatile A&&); + +int test6_123457() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123457(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123457(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123457(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123457(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_123457(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_123457(c_source())) == 2 * sizeof(long)> t6; + sa<sizeof(sink_6_123457(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_6_123458( A&); +two sink_6_123458(const A&); +three sink_6_123458(volatile A&); +four sink_6_123458(const volatile A&); +five sink_6_123458( A&&); +eight sink_6_123458(const volatile A&&); + +int test6_123458() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123458(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123458(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123458(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123458(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_123458(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_123458(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_6_123458(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_6_123458(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_123467( A&); +two sink_6_123467(const A&); +three sink_6_123467(volatile A&); +four sink_6_123467(const volatile A&); +six sink_6_123467(const A&&); +seven sink_6_123467(volatile A&&); + +int test6_123467() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123467(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123467(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123467(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123467(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_123467(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_123467(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_6_123468( A&); +two sink_6_123468(const A&); +three sink_6_123468(volatile A&); +four sink_6_123468(const volatile A&); +six sink_6_123468(const A&&); +eight sink_6_123468(const volatile A&&); + +int test6_123468() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123468(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123468(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123468(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123468(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_123468(source())) == 6 * sizeof(long)> t5; + sa<sizeof(sink_6_123468(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_123468(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_6_123468(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_123478( A&); +two sink_6_123478(const A&); +three sink_6_123478(volatile A&); +four sink_6_123478(const volatile A&); +seven sink_6_123478(volatile A&&); +eight sink_6_123478(const volatile A&&); + +int test6_123478() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123478(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123478(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123478(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123478(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_123478(source())) == 7 * sizeof(long)> t5; + sa<sizeof(sink_6_123478(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_6_123478(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_123478(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_123567( A&); +two sink_6_123567(const A&); +three sink_6_123567(volatile A&); +five sink_6_123567( A&&); +six sink_6_123567(const A&&); +seven sink_6_123567(volatile A&&); + +int test6_123567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123567(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123567(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123567(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_123567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_123567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_6_123568( A&); +two sink_6_123568(const A&); +three sink_6_123568(volatile A&); +five sink_6_123568( A&&); +six sink_6_123568(const A&&); +eight sink_6_123568(const volatile A&&); + +int test6_123568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123568(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123568(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123568(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_123568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_123568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_6_123568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_123578( A&); +two sink_6_123578(const A&); +three sink_6_123578(volatile A&); +five sink_6_123578( A&&); +seven sink_6_123578(volatile A&&); +eight sink_6_123578(const volatile A&&); + +int test6_123578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123578(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123578(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123578(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_123578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_6_123578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_123578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_123678( A&); +two sink_6_123678(const A&); +three sink_6_123678(volatile A&); +six sink_6_123678(const A&&); +seven sink_6_123678(volatile A&&); +eight sink_6_123678(const volatile A&&); + +int test6_123678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_123678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_123678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_123678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_123678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_123678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_123678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_124567( A&); +two sink_6_124567(const A&); +four sink_6_124567(const volatile A&); +five sink_6_124567( A&&); +six sink_6_124567(const A&&); +seven sink_6_124567(volatile A&&); + +int test6_124567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_124567(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_124567(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_124567(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_6_124567(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_124567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_124567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_124567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_6_124568( A&); +two sink_6_124568(const A&); +four sink_6_124568(const volatile A&); +five sink_6_124568( A&&); +six sink_6_124568(const A&&); +eight sink_6_124568(const volatile A&&); + +int test6_124568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_124568(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_124568(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_124568(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_6_124568(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_124568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_124568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_124568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_6_124568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_124578( A&); +two sink_6_124578(const A&); +four sink_6_124578(const volatile A&); +five sink_6_124578( A&&); +seven sink_6_124578(volatile A&&); +eight sink_6_124578(const volatile A&&); + +int test6_124578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_124578(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_124578(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_124578(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_6_124578(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_124578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_124578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_6_124578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_124578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_124678( A&); +two sink_6_124678(const A&); +four sink_6_124678(const volatile A&); +six sink_6_124678(const A&&); +seven sink_6_124678(volatile A&&); +eight sink_6_124678(const volatile A&&); + +int test6_124678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_124678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_124678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_124678(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_6_124678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_124678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_124678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_124678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_125678( A&); +two sink_6_125678(const A&); +five sink_6_125678( A&&); +six sink_6_125678(const A&&); +seven sink_6_125678(volatile A&&); +eight sink_6_125678(const volatile A&&); + +int test6_125678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_125678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_125678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_125678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_125678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_125678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_125678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_134567( A&); +three sink_6_134567(volatile A&); +four sink_6_134567(const volatile A&); +five sink_6_134567( A&&); +six sink_6_134567(const A&&); +seven sink_6_134567(volatile A&&); + +int test6_134567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_134567(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_134567(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_6_134567(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_134567(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_134567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_134567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_134567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_6_134568( A&); +three sink_6_134568(volatile A&); +four sink_6_134568(const volatile A&); +five sink_6_134568( A&&); +six sink_6_134568(const A&&); +eight sink_6_134568(const volatile A&&); + +int test6_134568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_134568(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_134568(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_6_134568(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_134568(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_134568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_134568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_134568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_6_134568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_134578( A&); +three sink_6_134578(volatile A&); +four sink_6_134578(const volatile A&); +five sink_6_134578( A&&); +seven sink_6_134578(volatile A&&); +eight sink_6_134578(const volatile A&&); + +int test6_134578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_134578(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_134578(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_6_134578(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_134578(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_134578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_134578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_6_134578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_134578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_134678( A&); +three sink_6_134678(volatile A&); +four sink_6_134678(const volatile A&); +six sink_6_134678(const A&&); +seven sink_6_134678(volatile A&&); +eight sink_6_134678(const volatile A&&); + +int test6_134678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_134678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_134678(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_6_134678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_134678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_134678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_134678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_134678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_135678( A&); +three sink_6_135678(volatile A&); +five sink_6_135678( A&&); +six sink_6_135678(const A&&); +seven sink_6_135678(volatile A&&); +eight sink_6_135678(const volatile A&&); + +int test6_135678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_135678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_135678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_135678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_135678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_135678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_135678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_6_145678( A&); +four sink_6_145678(const volatile A&); +five sink_6_145678( A&&); +six sink_6_145678(const A&&); +seven sink_6_145678(volatile A&&); +eight sink_6_145678(const volatile A&&); + +int test6_145678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_145678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_6_145678(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_6_145678(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_6_145678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_145678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_145678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_145678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_145678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_6_234567(const A&); +three sink_6_234567(volatile A&); +four sink_6_234567(const volatile A&); +five sink_6_234567( A&&); +six sink_6_234567(const A&&); +seven sink_6_234567(volatile A&&); + +int test6_234567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_234567(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_234567(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_234567(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_234567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_234567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_234567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +two sink_6_234568(const A&); +three sink_6_234568(volatile A&); +four sink_6_234568(const volatile A&); +five sink_6_234568( A&&); +six sink_6_234568(const A&&); +eight sink_6_234568(const volatile A&&); + +int test6_234568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_234568(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_234568(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_234568(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_234568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_234568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_234568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_6_234568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_6_234578(const A&); +three sink_6_234578(volatile A&); +four sink_6_234578(const volatile A&); +five sink_6_234578( A&&); +seven sink_6_234578(volatile A&&); +eight sink_6_234578(const volatile A&&); + +int test6_234578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_234578(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_234578(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_234578(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_234578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_234578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_6_234578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_234578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_6_234678(const A&); +three sink_6_234678(volatile A&); +four sink_6_234678(const volatile A&); +six sink_6_234678(const A&&); +seven sink_6_234678(volatile A&&); +eight sink_6_234678(const volatile A&&); + +int test6_234678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_234678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_234678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_234678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_234678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_234678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_234678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_6_235678(const A&); +three sink_6_235678(volatile A&); +five sink_6_235678( A&&); +six sink_6_235678(const A&&); +seven sink_6_235678(volatile A&&); +eight sink_6_235678(const volatile A&&); + +int test6_235678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_235678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_235678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_235678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_235678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_235678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_235678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_6_245678(const A&); +four sink_6_245678(const volatile A&); +five sink_6_245678( A&&); +six sink_6_245678(const A&&); +seven sink_6_245678(volatile A&&); +eight sink_6_245678(const volatile A&&); + +int test6_245678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_245678(a)) == 2 * sizeof(long)> t1; + sa<sizeof(sink_6_245678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_6_245678(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_6_245678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_245678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_245678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_245678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_245678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +three sink_6_345678(volatile A&); +four sink_6_345678(const volatile A&); +five sink_6_345678( A&&); +six sink_6_345678(const A&&); +seven sink_6_345678(volatile A&&); +eight sink_6_345678(const volatile A&&); + +int test6_345678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_6_345678(a)) == 3 * sizeof(long)> t1; + sa<sizeof(sink_6_345678(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_6_345678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_6_345678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_6_345678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_6_345678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_6_345678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_6_345678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test6_123456() + test6_123457() + test6_123458() + test6_123467() + + test6_123468() + test6_123478() + test6_123567() + test6_123568() + + test6_123578() + test6_123678() + test6_124567() + test6_124568() + + test6_124578() + test6_124678() + test6_125678() + test6_134567() + + test6_134568() + test6_134578() + test6_134678() + test6_135678() + + test6_145678() + test6_234567() + test6_234568() + test6_234578() + + test6_234678() + test6_235678() + test6_245678() + test6_345678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv7n.C b/gcc/testsuite/g++.dg/cpp0x/rv7n.C new file mode 100644 index 000000000..6071e0568 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv7n.C @@ -0,0 +1,111 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {char x[1];}; +struct two {char x[2];}; +struct three {char x[3];}; +struct four {char x[4];}; +struct five {char x[5];}; +struct six {char x[6];}; +struct seven {char x[7];}; +struct eight {char x[8];}; + +struct A +{ + A(); + A(const volatile A&&); // { dg-error "argument 1" } +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 7 at a time + +one sink_7_1234567( A&); // { dg-message "one sink_7_1234567|no known conversion" } +two sink_7_1234567(const A&); // { dg-message "note" } +three sink_7_1234567(volatile A&); // { dg-message "note" } +four sink_7_1234567(const volatile A&); // { dg-message "note" } +five sink_7_1234567( A&&); // { dg-message "note" } +six sink_7_1234567(const A&&); // { dg-message "note" } +seven sink_7_1234567(volatile A&&); // { dg-message "note" } + +int test7_1234567() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_7_1234567(cv_source()); // { dg-error "no match" } + // { dg-message "candidate" "candidate note" { target *-*-* } 47 } + return 0; +} + +one sink_7_1235678( A&); +two sink_7_1235678(const A&); +three sink_7_1235678(volatile A&); +five sink_7_1235678( A&&); +six sink_7_1235678(const A&&); +seven sink_7_1235678(volatile A&&); +eight sink_7_1235678(const volatile A&&); // { dg-message "" } + +int test7_1235678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_7_1235678(cva); // { dg-error "lvalue" } + return 0; +} + +two sink_7_2345678(const A&); // { dg-message "note" } +three sink_7_2345678(volatile A&); // { dg-message "note" } +four sink_7_2345678(const volatile A&); // { dg-message "note" } +five sink_7_2345678( A&&); // { dg-message "note" } +six sink_7_2345678(const A&&); // { dg-message "note" } +seven sink_7_2345678(volatile A&&); // { dg-message "note" } +eight sink_7_2345678(const volatile A&&); // { dg-message "note" } + +int test7_2345678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_7_2345678(a); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 84 } + return 0; +} + +one sink_7_1234678( A&); +two sink_7_1234678(const A&); // { dg-message "note" } +three sink_7_1234678(volatile A&); +four sink_7_1234678(const volatile A&); +six sink_7_1234678(const A&&); // { dg-message "note" } +seven sink_7_1234678(volatile A&&); // { dg-message "note" } +eight sink_7_1234678(const volatile A&&); // { dg-message "note" } + +int test7_1234678() +{ + A a; + const A ca = a; // { dg-error "lvalue" } + volatile A va; + const volatile A cva = a; // { dg-error "lvalue" } + sink_7_1234678(source()); // { dg-error "ambiguous" } + // { dg-message "candidate" "candidate note" { target *-*-* } 103 } + return 0; +} + +int main() +{ + return test7_2345678() + test7_1234678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv7p.C b/gcc/testsuite/g++.dg/cpp0x/rv7p.C new file mode 100644 index 000000000..94aa07b93 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv7p.C @@ -0,0 +1,233 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 7 at a time + +one sink_7_1234567( A&); +two sink_7_1234567(const A&); +three sink_7_1234567(volatile A&); +four sink_7_1234567(const volatile A&); +five sink_7_1234567( A&&); +six sink_7_1234567(const A&&); +seven sink_7_1234567(volatile A&&); + +int test7_1234567() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_1234567(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_7_1234567(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_7_1234567(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_7_1234567(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_7_1234567(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_7_1234567(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_7_1234567(v_source())) == 7 * sizeof(long)> t7; + return 0; +} + +one sink_7_1234568( A&); +two sink_7_1234568(const A&); +three sink_7_1234568(volatile A&); +four sink_7_1234568(const volatile A&); +five sink_7_1234568( A&&); +six sink_7_1234568(const A&&); +eight sink_7_1234568(const volatile A&&); + +int test7_1234568() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_1234568(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_7_1234568(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_7_1234568(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_7_1234568(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_7_1234568(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_7_1234568(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_7_1234568(v_source())) == 8 * sizeof(long)> t7; + sa<sizeof(sink_7_1234568(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_7_1234578( A&); +two sink_7_1234578(const A&); +three sink_7_1234578(volatile A&); +four sink_7_1234578(const volatile A&); +five sink_7_1234578( A&&); +seven sink_7_1234578(volatile A&&); +eight sink_7_1234578(const volatile A&&); + +int test7_1234578() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_1234578(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_7_1234578(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_7_1234578(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_7_1234578(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_7_1234578(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_7_1234578(c_source())) == 8 * sizeof(long)> t6; + sa<sizeof(sink_7_1234578(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_7_1234578(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_7_1234678( A&); +two sink_7_1234678(const A&); +three sink_7_1234678(volatile A&); +four sink_7_1234678(const volatile A&); +six sink_7_1234678(const A&&); +seven sink_7_1234678(volatile A&&); +eight sink_7_1234678(const volatile A&&); + +int test7_1234678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_1234678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_7_1234678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_7_1234678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_7_1234678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_7_1234678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_7_1234678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_7_1234678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_7_1235678( A&); +two sink_7_1235678(const A&); +three sink_7_1235678(volatile A&); +five sink_7_1235678( A&&); +six sink_7_1235678(const A&&); +seven sink_7_1235678(volatile A&&); +eight sink_7_1235678(const volatile A&&); + +int test7_1235678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_1235678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_7_1235678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_7_1235678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_7_1235678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_7_1235678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_7_1235678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_7_1235678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_7_1245678( A&); +two sink_7_1245678(const A&); +four sink_7_1245678(const volatile A&); +five sink_7_1245678( A&&); +six sink_7_1245678(const A&&); +seven sink_7_1245678(volatile A&&); +eight sink_7_1245678(const volatile A&&); + +int test7_1245678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_1245678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_7_1245678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_7_1245678(va)) == 4 * sizeof(long)> t3; + sa<sizeof(sink_7_1245678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_7_1245678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_7_1245678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_7_1245678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_7_1245678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +one sink_7_1345678( A&); +three sink_7_1345678(volatile A&); +four sink_7_1345678(const volatile A&); +five sink_7_1345678( A&&); +six sink_7_1345678(const A&&); +seven sink_7_1345678(volatile A&&); +eight sink_7_1345678(const volatile A&&); + +int test7_1345678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_1345678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_7_1345678(ca)) == 4 * sizeof(long)> t2; + sa<sizeof(sink_7_1345678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_7_1345678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_7_1345678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_7_1345678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_7_1345678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_7_1345678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +two sink_7_2345678(const A&); +three sink_7_2345678(volatile A&); +four sink_7_2345678(const volatile A&); +five sink_7_2345678( A&&); +six sink_7_2345678(const A&&); +seven sink_7_2345678(volatile A&&); +eight sink_7_2345678(const volatile A&&); + +int test7_2345678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_7_2345678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_7_2345678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_7_2345678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_7_2345678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_7_2345678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_7_2345678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_7_2345678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test7_1234567() + test7_1234568() + test7_1234578() + test7_1234678() + + test7_1235678() + test7_1245678() + test7_1345678() + test7_2345678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv8p.C b/gcc/testsuite/g++.dg/cpp0x/rv8p.C new file mode 100644 index 000000000..fb9ec4ce7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv8p.C @@ -0,0 +1,62 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test overload resolution among reference types + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; +struct three {long x[3];}; +struct four {long x[4];}; +struct five {long x[5];}; +struct six {long x[6];}; +struct seven {long x[7];}; +struct eight {long x[8];}; + +struct A +{ + A(); + A(const volatile A&&); +}; + + A source(); +const A c_source(); + volatile A v_source(); +const volatile A cv_source(); + +// 8 at a time + +one sink_8_12345678( A&); +two sink_8_12345678(const A&); +three sink_8_12345678(volatile A&); +four sink_8_12345678(const volatile A&); +five sink_8_12345678( A&&); +six sink_8_12345678(const A&&); +seven sink_8_12345678(volatile A&&); +eight sink_8_12345678(const volatile A&&); + +int test8_12345678() +{ + A a; + const A ca; + volatile A va; + const volatile A cva; + sa<sizeof(sink_8_12345678(a)) == 1 * sizeof(long)> t1; + sa<sizeof(sink_8_12345678(ca)) == 2 * sizeof(long)> t2; + sa<sizeof(sink_8_12345678(va)) == 3 * sizeof(long)> t3; + sa<sizeof(sink_8_12345678(cva)) == 4 * sizeof(long)> t4; + sa<sizeof(sink_8_12345678(source())) == 5 * sizeof(long)> t5; + sa<sizeof(sink_8_12345678(c_source())) == 6 * sizeof(long)> t6; + sa<sizeof(sink_8_12345678(v_source())) == 7 * sizeof(long)> t7; + sa<sizeof(sink_8_12345678(cv_source())) == 8 * sizeof(long)> t8; + return 0; +} + +int main() +{ + return test8_12345678(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rv9p.C b/gcc/testsuite/g++.dg/cpp0x/rv9p.C new file mode 100644 index 000000000..ec08a8248 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv9p.C @@ -0,0 +1,22 @@ +// PR c++/36744 +// { dg-options "-std=c++0x" } +// { dg-do run } + +struct S +{ + S(): i(2) {} + S(S const&s): i(s.i) {} + int i; +}; + +void f(S x) { x.i = 0; } + +extern "C" void abort (void); +int main() +{ + S y; + f(static_cast<S&&>(y)); + if (y.i != 2) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/rvo.C b/gcc/testsuite/g++.dg/cpp0x/rvo.C new file mode 100644 index 000000000..d4459af64 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rvo.C @@ -0,0 +1,25 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +// Contributed by Sylvain Pion +static int rvalue_constructions = 0; + +struct A { + A () { } + A (const A&) { } + A (A&&) { ++rvalue_constructions; } + ~A () { } +}; + +A f() { return A(); } + +extern "C" { + void abort(void); +} + +int main() +{ + A c = f(); + + if (rvalue_constructions != 0) + abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/scoped_enum.C b/gcc/testsuite/g++.dg/cpp0x/scoped_enum.C new file mode 100644 index 000000000..c52a3fe76 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/scoped_enum.C @@ -0,0 +1,76 @@ +// { dg-options "-std=c++0x" } +enum class Color1 { + Red, + Green, + Blue +}; + +enum struct Color2 { + Red, // { dg-error "previously declared here" } + Orange, + Yellow, + Green, + Blue, + Indigo = Green + 2, + Violet, + Red // { dg-error "redefinition" } +}; + +enum Color { + Red, Green, Blue +}; + +enum class Color3 { + Red +}; + +enum Color color; +enum Color3 color3; + +void f(int); +void f2(Color3); + +void g() +{ + int i = 0; + f(color); // okay: unscoped enum + f(color3); // { dg-error "cannot convert" } + f2(color); // { dg-error "cannot convert" } + f2(color3); + f2(i); // { dg-error "cannot convert" } + i = color3; // { dg-error "cannot convert" } + color3 = i; // { dg-error "cannot convert" } + f(static_cast<int>(color3)); // okay + + int a[5]; + a[color3]; // { dg-error "array subscript is not an integer" } + + bool b = color3; // { dg-error "cannot convert" } +} + +void h() +{ + Color1 c1 = Color1::Red; + Color2 c2 = Color1::Red; // { dg-error "cannot convert" } + c2 = Color1::Red; // { dg-error "cannot convert" } + + c2 = Color2::Red; + int c3 = Color::Red; +} + +template<typename T, T value> +struct constant { }; + +template<typename T> +int& sfinae(constant<T, T::Green>*); + +float& sfinae(void*); + +void sfinae_test() +{ + int& test1 = sfinae((constant<Color1, Color1::Green>*)0); + int& test2 = sfinae((constant<Color2, Color2::Green>*)0); + float& test3 = sfinae((constant<Color1, Color1::Red>*)0); + int& test4 = sfinae((constant<Color, Green>*)0); + float& test5 = sfinae((constant<Color, Red>*)0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C b/gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C new file mode 100644 index 000000000..e87b36a27 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C @@ -0,0 +1,11 @@ +// { dg-options -std=c++0x } + +enum class E { e = 10 }; +enum E2 { e2 = 10 }; + +struct C { + int arr[E::e]; // { dg-error "non-integral type" } + int arr2[E2::e2]; // OK + int i: E::e; // { dg-error "non-integral type" } + int i2: E2::e2; // OK +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/scoped_enum_98.C b/gcc/testsuite/g++.dg/cpp0x/scoped_enum_98.C new file mode 100644 index 000000000..8c24e86ba --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/scoped_enum_98.C @@ -0,0 +1,4 @@ +// { dg-do compile } +// { dg-options "-std=c++98" } +enum class E1 { e1 }; // { dg-warning "scoped enums" } +enum E2 : char { e2 }; // { dg-warning "scoped enums" } diff --git a/gcc/testsuite/g++.dg/cpp0x/scoped_enum_examples.C b/gcc/testsuite/g++.dg/cpp0x/scoped_enum_examples.C new file mode 100644 index 000000000..67c3fcbeb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/scoped_enum_examples.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } +enum class Col { red, yellow, green }; + +int x = Col::red; // { dg-error "cannot convert" } +Col y = Col::red; + +void f() +{ + if (y) { } // { dg-error "could not convert" } +} + +enum direction { left='l', right='r' }; +void g() { + // OK + direction d; + // OK + d = left; + // OK + d = direction::right; +} +enum class altitude { high='h', low='l' }; +void h() { + altitude a; + a = high; // { dg-error "not declared in this scope" } + a = altitude::low; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae1.C b/gcc/testsuite/g++.dg/cpp0x/sfinae1.C new file mode 100644 index 000000000..292d8ae04 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae1.C @@ -0,0 +1,11 @@ +// { dg-options "-std=c++0x" } + +template< typename T_VECTOR > +void f(const T_VECTOR &a, decltype(a[0]) t = 0); +template< typename T > +void f(const T &a, decltype(a*1) t = 0); + +int main() { + int c; + f(c); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae10.C b/gcc/testsuite/g++.dg/cpp0x/sfinae10.C new file mode 100644 index 000000000..72dbce080 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae10.C @@ -0,0 +1,16 @@ +// PR c++/48452 +// { dg-options -std=c++0x } +namespace std { + template <class T> T&& declval(); +} + +template<class T, class... Args> +decltype(T(std::declval<Args>()...), char()) f(int); + +template<class, class...> +char (&f(...))[2]; + +struct B {}; + +static_assert(sizeof(f<B, void, int>(0)) != 1, "Error"); // b +static_assert(sizeof(f<void, int, int>(0)) != 1, "Error"); // c diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae11.C b/gcc/testsuite/g++.dg/cpp0x/sfinae11.C new file mode 100644 index 000000000..a3ffc34f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae11.C @@ -0,0 +1,56 @@ +// PR c++/48468 +// { dg-options -std=c++0x } +// { dg-prune-output "note" } + +template<class T> +T&& declval() noexcept; + +template< class T > +inline void f1( T& x ) noexcept( noexcept( declval<T&>().foo() ) ) +{ + x.foo(); +} + +template< class T, + bool Noexcept = noexcept( declval<T&>().foo() ) +> +inline void f2( T& x ) noexcept( Noexcept ) +{ + x.foo(); +} + +// a common and trivial mistake +template< class T > +inline void f3( T& x ) noexcept( declval<T&>().foo() ) +{ + x.foo(); +} + +struct X +{ + void foo(); +}; + +struct Y +{ + void foo() noexcept; +}; + +struct Z {}; + +int main() +{ + X x; Y y; Z z; + + static_assert( !noexcept( f1(x) ), "OK." ); + static_assert( !noexcept( f2(x) ), "OK." ); + // static_assert( !noexcept( f3(x) ), "shall be ill-formed(OK)." ); + + static_assert( noexcept( f1(y) ), "OK." ); + static_assert( noexcept( f2(y) ), "OK." ); + // static_assert( noexcept( f3(y) ), "shall be ill-formed(OK)." ); + + static_assert( noexcept( f1(z) ), "shall be ill-formed." ); // { dg-error "no match" } + static_assert( noexcept( f2(z) ), "shall be ill-formed." ); // { dg-error "no match" } + static_assert( !noexcept( f3(z) ), "shall be ill-formed." ); // { dg-error "no match" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae2.C b/gcc/testsuite/g++.dg/cpp0x/sfinae2.C new file mode 100644 index 000000000..b9ef70d99 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae2.C @@ -0,0 +1,39 @@ +// PR c++/44967 +// { dg-options -std=c++0x } + +template <typename T> T&& declval(); + +template<typename T1, typename T2, typename... Args> +struct has_construct +{ + typedef char one; + typedef struct {char _m[2]; } two; + + template<typename U1, typename U2, typename... Args2> + static decltype(declval<U1>().construct(declval<U2*>(), declval<Args2>()...), one()) test(int); + template<typename, typename, typename...> + static two test(...); + + static const bool value = sizeof(test<T1, T2, Args...>(0)) == 1; +}; + + +struct A0 +{}; + +struct A1 +{ + void construct(int*, int); +}; + +template<typename _Tp> +struct A2 +{ + template<typename _Tp1, typename... _Args> + void construct(_Tp1*, _Args&&...) {} +}; + +#define SA(X) static_assert(X,#X) +SA((!has_construct<A0, int, int>::value)); // ok +SA((has_construct<A1, int, int>::value)); // bang +SA((has_construct<A2<int>, int>::value)); // bang diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae22.C b/gcc/testsuite/g++.dg/cpp0x/sfinae22.C new file mode 100644 index 000000000..2b9351a97 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae22.C @@ -0,0 +1,23 @@ +// PR c++/48745 +// { dg-options -std=c++0x } + +template<class T> +struct add_rval_ref { + typedef T&& type; +}; + +template<> +struct add_rval_ref<void> { + typedef void type; +}; + +template<class T> +typename add_rval_ref<T>::type create(); + +template<class T, class... Args> +decltype(T{create<Args>()...}, char()) f(int); + +template<class, class...> +char (&f(...))[2]; + +static_assert(sizeof(f<int, void>(0)) != 1, "Error"); // { dg-bogus "void value" "" { xfail *-*-* } } diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae23.C b/gcc/testsuite/g++.dg/cpp0x/sfinae23.C new file mode 100644 index 000000000..4e2ea88b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae23.C @@ -0,0 +1,28 @@ +// PR c++/48647 +// { dg-options -std=c++0x } + +template< class T > +T&& declval(); + +template< class T, class U > +decltype( true ? declval<T>() : declval<U>() ) test( int ); + +template< class T, class U > +void test( ... ); + + +template< class T, class U > +struct is_same { + static const bool value = false; +}; + +template< class T > +struct is_same<T, T> { + static const bool value = true; +}; + +#define SA(X) static_assert ((X),#X) + +typedef decltype( test<int*, double*>(0) ) void_expected; +SA ((is_same<void_expected, void>::value)); +SA ((!is_same<void_expected, void*>::value)); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae26.C b/gcc/testsuite/g++.dg/cpp0x/sfinae26.C new file mode 100644 index 000000000..6a4f679ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae26.C @@ -0,0 +1,40 @@ +// PR c++/49229 +// { dg-options -std=c++0x } + +extern void* enabler; + +template<bool, class = void> +struct enable_if {}; + +template<class T> +struct enable_if<true, T> { + typedef T type; +}; + +template<class... Bn> +struct and_; + +template<class B1> +struct and_<B1> : B1 {}; + +template<class, class> +struct is_same { + static constexpr bool value = false; +}; + +template<class T> +struct is_same<T, T> { + static constexpr bool value = true; +}; + +template<class... T> +struct S { + template<class... U, + typename enable_if<and_<is_same<T, U>...>::value>::type*& = enabler + > + S(U...){} // # +}; + +S<bool> s(0); // { dg-error "no match" } + +// { dg-prune-output "note" } diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae27.C b/gcc/testsuite/g++.dg/cpp0x/sfinae27.C new file mode 100644 index 000000000..93327ba9c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae27.C @@ -0,0 +1,20 @@ +// PR c++/50157 +// { dg-options -std=c++0x } + +template<class T> +T val(); + +template<class T, class Arg, class = + decltype(::new T(val<Arg>())) +> +auto test(int) -> char; + +template<class, class> +auto test(...) -> char (&)[2]; + +struct P { + explicit operator bool(); // (#13) +}; + +typedef decltype(test<bool, P>(0)) type; // OK +typedef decltype(test<float, P>(0)) type2; // Error (#17) diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae3.C b/gcc/testsuite/g++.dg/cpp0x/sfinae3.C new file mode 100644 index 000000000..8582ba777 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae3.C @@ -0,0 +1,56 @@ +// { dg-options -std=c++0x } + +namespace std { template <class T> T&& declval(); } + +template<typename _Tp, typename... _Args> + class is_constructible_mini + { + typedef char __one; + typedef struct { char __arr[2]; } __two; + + template<typename _Tp1, typename... _Args1> + static decltype(::new _Tp1(std::declval<_Args1>()...), __one()) + __test(int); + + template<typename, typename...> + static __two __test(...); + + public: + static const bool value = sizeof(__test<_Tp, _Args...>(0)) == 1; + }; + +/* +template<typename _Tp> + class is_constructible_mini<_Tp> + { + typedef char __one; + typedef struct { char __arr[2]; } __two; + + template<typename _Tp1> + static decltype(::new _Tp1, __one()) __test(int); + + template<typename> + static __two __test(...); + + public: + static const bool value + = sizeof(__test<typename std::remove_cv<_Tp>::type>(0)) == 1; + }; +*/ + +struct A +{ + A(int); +}; + +struct B { }; + +static_assert( is_constructible_mini<A, int>::value, ""); +static_assert( is_constructible_mini<A, A>::value, ""); +static_assert( !is_constructible_mini<A, int, double>::value, ""); + +static_assert( !is_constructible_mini<A>::value, ""); // doesn't compile without the + // partial specialization + +static_assert( is_constructible_mini<B>::value, ""); +static_assert( is_constructible_mini<const B>::value, ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae4.C b/gcc/testsuite/g++.dg/cpp0x/sfinae4.C new file mode 100644 index 000000000..b66483124 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae4.C @@ -0,0 +1,23 @@ +// { dg-options -std=c++0x } + +namespace std { template <class T> T&& declval(); } + +template<typename _Tp, typename... _Args> + class is_constructible_mini + { + typedef char __one; + typedef struct { char __arr[2]; } __two; + + template<typename _Tp1, typename... _Args1> + static decltype(::new _Tp1(std::declval<_Args1>()...), __one()) + __test(int); + + template<typename, typename...> + static __two __test(...); + + public: + static const bool value = sizeof(__test<_Tp, _Args...>(0)) == 1; + }; + +static_assert( !is_constructible_mini<int[], int>::value, ""); +static_assert( !is_constructible_mini<void, int>::value, ""); diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae5.C b/gcc/testsuite/g++.dg/cpp0x/sfinae5.C new file mode 100644 index 000000000..8474fb314 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae5.C @@ -0,0 +1,16 @@ +// { dg-options -std=c++0x } + +template<class T> +T&& create(); + +template <class T, class U, + class = decltype(create<T>() = create<U>()) + > +char test(int); + +template <class, class> +double test(...); + +int main() { + test<int[], int[]>(0); // #1 +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae6.C b/gcc/testsuite/g++.dg/cpp0x/sfinae6.C new file mode 100644 index 000000000..401d5362d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae6.C @@ -0,0 +1,31 @@ +// PR c++/48113 +// { dg-options -std=c++0x } + +template<typename T> T declval(); + +struct tuple { }; + +struct F1 +{ + void operator()(tuple, int); +}; + +typedef void (*F2)(tuple, int); + +template<typename F, typename T> +struct Bind +{ + template<typename A, + typename R = decltype( F()(declval<T&>(), A()) )> + R f(A); + + template<typename A, + typename R = decltype( F()(declval<volatile T&>(), A()) )> + R f(A) volatile; +}; + +int main() +{ + Bind<F1, tuple>().f(0); // OK + Bind<F2, tuple>().f(0); // ERROR, should be OK +} diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae7.C b/gcc/testsuite/g++.dg/cpp0x/sfinae7.C new file mode 100644 index 000000000..0a95a9644 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae7.C @@ -0,0 +1,20 @@ +// { dg-options -std=c++0x } + +struct A +{ + void f(); + void f(int); + typedef int g; +}; + +template <class T> decltype (T::f) f(); +template <class T> void f(); + +template <class T> decltype (T::g) g(); +template <class T> void g(); + +int main() +{ + f<A>(); + g<A>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert1.C b/gcc/testsuite/g++.dg/cpp0x/static_assert1.C new file mode 100644 index 000000000..a54617598 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert1.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } +void foo() +{ + static_assert(1, "okay"); + static_assert (0 == 1, "zero is never equal to one"); // { dg-error "never equal" } +} + +class X { + static_assert(1, "okay"); + static_assert (0 == 1, "zero is never equal to one"); // { dg-error "never equal" } +}; + +static_assert(1, "okay"); +static_assert (0 == 1, "zero is never equal to one"); // { dg-error "never equal" } diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert2.C b/gcc/testsuite/g++.dg/cpp0x/static_assert2.C new file mode 100644 index 000000000..3e74bb1b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert2.C @@ -0,0 +1,35 @@ +// { dg-options "-std=c++0x" } +template<int I> +struct accept_evens { + static_assert( I % 2 == 0, "I must be an even number"); // { dg-error "even number" } +}; + +template<int I> +struct accept_evens_ok { + static_assert( I % 2 == 0, "I must be an even number"); +}; + +template<int I> +void accept_odds() { + static_assert( I % 2 == 1, "I must be an odd number"); // { dg-error "odd number" } +} + +template<int I> +void accept_odds_ok() { + static_assert( I % 2 == 1, "I must be an odd number"); +} + +void f() +{ + accept_odds<1>(); + accept_odds<2>(); + accept_odds<3>(); + accept_odds_ok<5>(); + accept_odds_ok<7>(); +} + +accept_evens<0> ok0; +accept_evens<1> error1; +accept_evens<2> ok2; +accept_evens_ok<4> ok4; +accept_evens_ok<6> ok6; diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert3.C b/gcc/testsuite/g++.dg/cpp0x/static_assert3.C new file mode 100644 index 000000000..1ff2ffc94 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert3.C @@ -0,0 +1,4 @@ +// { dg-options "-std=c++0x" } +static_assert(7 / 0, "X"); // { dg-error "non-constant condition" } +// { dg-warning "division by zero" "" { target *-*-* } 2 } +// { dg-error "7 / 0.. is not a constant expression" "" { target *-*-* } 2 } diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert4.C b/gcc/testsuite/g++.dg/cpp0x/static_assert4.C new file mode 100644 index 000000000..b0818873f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert4.C @@ -0,0 +1,15 @@ +// { dg-options "-std=c++0x --param ggc-min-heapsize=0 --param ggc-min-expand=0 " } +// PR C++/30033 +// Make sure that the static assert does not crash the GC. + +template <class T> +struct default_delete +{ + void + operator() (T * ptr) const + { + static_assert (sizeof (T) > 0, "Can't delete pointer to incomplete type"); + } +}; + + diff --git a/gcc/testsuite/g++.dg/cpp0x/std-layout1.C b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C new file mode 100644 index 000000000..bdad82111 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C @@ -0,0 +1,91 @@ +// { dg-options "-std=c++0x" } + +// [basic.types]/10: +// Scalar types, standard-layout class types (Clause 9), arrays of such +// types and cv-qualified versions of these types (3.9.3) are collectively +// called standard-layout types. + +// [class]/7: +// A standard-layout class is a class that: +// * has no non-static data members of type non-standard-layout class (or +// array of such types) or reference, +// * has no virtual functions (10.3) and no virtual base classes (10.1), +// * has the same access control (Clause 11) for all non-static data members, +// * has no non-standard-layout base classes, +// * either has no non-static data members in the most-derived class and at +// most one base class with non-static data members, or has no base classes +// with non-static data members, and +// * has no base classes of the same type as the first non-static data member. + +#include <type_traits> + +#define TRY(expr) static_assert (expr, #expr) +#define YES(type) TRY(std::is_standard_layout<type>::value); \ + TRY(std::is_standard_layout<type[]>::value); \ + TRY(std::is_standard_layout<const volatile type>::value); +#define NO(type) TRY(!std::is_standard_layout<type>::value); \ + TRY(!std::is_standard_layout<type[]>::value); \ + TRY(!std::is_standard_layout<const volatile type>::value); +#define NONPOD(type) TRY(!std::is_pod<type>::value); \ + TRY(!std::is_pod<type[]>::value); \ + TRY(!std::is_pod<const volatile type>::value); + +struct A; + +YES(int); +YES(__complex int); +YES(void *); +YES(int A::*); +typedef int (A::*pmf)(); +YES(pmf); + +struct A { ~A(); }; +YES(A); +NONPOD(A); +struct F: public A { int i; }; +YES(F); +NONPOD(F); +struct G: public A { A a; }; +NO(G); +struct M { A a; }; +YES(M); + +class B +{ + int i; + __complex int c; + void *p; + double ar[4]; + int A::* pm; + int (A::*pmf)(); +}; +YES(B); +struct D: public B { }; +YES(D); +struct E: public B { int q; }; +NO(E); +struct D2: public B { }; +YES(D2); +struct I: public D, public D2 { }; +NO(I); + +struct C +{ + int i; +private: + int j; +}; +NO(C); +struct H: public C { }; +NO(H); +struct N { C c; }; +NO(N); + +struct J { virtual void f(); }; +struct J2: J { }; +NO(J); +NO(J2); +struct K { }; +struct L: virtual K {}; +YES(K); +NO(L); diff --git a/gcc/testsuite/g++.dg/cpp0x/syntax-err1.C b/gcc/testsuite/g++.dg/cpp0x/syntax-err1.C new file mode 100644 index 000000000..ce1c9eea5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/syntax-err1.C @@ -0,0 +1,8 @@ +// PR c++/47198 +// { dg-options -std=c++0x } + +struct S +{ + template < int > sometype foo (); // { dg-error "sometype. does not name a type" } + S () = default; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/temp-constructor-bug.C b/gcc/testsuite/g++.dg/cpp0x/temp-constructor-bug.C new file mode 100644 index 000000000..a06720702 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/temp-constructor-bug.C @@ -0,0 +1,15 @@ +// { dg-options "--std=c++0x" } + +struct S { }; + +struct T +{ + S s; +}; + +void f(T const &); + +void g() +{ + f((T){S()}); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/temp-va-arg-bug.C b/gcc/testsuite/g++.dg/cpp0x/temp-va-arg-bug.C new file mode 100644 index 000000000..085915f90 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/temp-va-arg-bug.C @@ -0,0 +1,11 @@ +// { dg-options "--std=c++0x" } +// { dg-options "-Wno-abi --std=c++0x" { target arm_eabi } } +#include <stdarg.h> + +struct S { }; +void f(S const &); + +void g(va_list args) +{ + f(va_arg(args, S)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/temp_default1.C b/gcc/testsuite/g++.dg/cpp0x/temp_default1.C new file mode 100644 index 000000000..dfa2cfb7b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/temp_default1.C @@ -0,0 +1,32 @@ +// { dg-options "-std=c++0x" } + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +template<typename T = int> void f() +{ + static_assert(is_same<T, int>::value, + "T can only be instantiated with an int"); +} + +template<typename T = int, typename U> +void f(U) +{ + static_assert(is_same<T, int>::value, + "T can only be instantiated with an int"); +} + +void g() +{ + float pi = 3.14159; + f(); + f(pi); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/temp_default2.C b/gcc/testsuite/g++.dg/cpp0x/temp_default2.C new file mode 100644 index 000000000..fa2bb6aed --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/temp_default2.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } + +template <class T, class U = double> +void f(T t = 0, U u = 0); // { dg-message "note" } + +void g() +{ + f(1, 'c'); // f<int,char>(1,'c') + f(1); // f<int,double>(1,0) + f(); // { dg-error "no matching function" } + // { dg-message "candidate" "candidate note" { target *-*-* } 10 } + f<int>(); // f<int,double>(0,0) + f<int,char>(); // f<int,char>(0,0) +} diff --git a/gcc/testsuite/g++.dg/cpp0x/temp_default3.C b/gcc/testsuite/g++.dg/cpp0x/temp_default3.C new file mode 100644 index 000000000..f71fe0f43 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/temp_default3.C @@ -0,0 +1,16 @@ +// { dg-options "-std=c++0x" } + +template<typename T, typename U = typename T::value_type> +void f(T); + +void f(...); + +struct X { + typedef int value_type; +}; + +void g() +{ + f(X()); // okay + f(17); // okay? +} diff --git a/gcc/testsuite/g++.dg/cpp0x/temp_default4.C b/gcc/testsuite/g++.dg/cpp0x/temp_default4.C new file mode 100644 index 000000000..f1e254c40 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/temp_default4.C @@ -0,0 +1,11 @@ +// { dg-options "-std=c++0x" } + +class X { + template<typename T = int> friend void f(X) { } + template<typename T> friend void g(X); // { dg-error "previously declared here" } + template<typename T = int> friend void h(X); // { dg-error "function template friend" } +}; + +template<typename T = int> void g(X) // { dg-error "default template argument" } +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/template_deduction.C b/gcc/testsuite/g++.dg/cpp0x/template_deduction.C new file mode 100644 index 000000000..c1eace6fa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/template_deduction.C @@ -0,0 +1,68 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test the "Augmented" template argument deduction when binding an lvalue to an rvalue reference. + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +template <class T, T v> +struct integral_constant +{ + static const T value = v; + typedef T value_type; + typedef integral_constant<T, v> type; +}; + +typedef integral_constant<bool, true> true_type; +typedef integral_constant<bool, false> false_type; + +template <class T> struct is_lvalue_reference : public integral_constant<bool, false> {}; +template <class T> struct is_lvalue_reference<T&> : public integral_constant<bool, true> {}; + +template <class T> struct is_rvalue_reference : public integral_constant<bool, false> {}; +template <class T> struct is_rvalue_reference<T&&> : public integral_constant<bool, true> {}; + +template <bool is_lvalue_ref, bool is_rvalue_ref, class T> +void +test1(T&&) +{ + sa<is_lvalue_reference<T&&>::value == is_lvalue_ref> t1; + sa<is_rvalue_reference<T&&>::value == is_rvalue_ref> t2; +} + +template <bool is_lvalue_ref, bool is_rvalue_ref, class T> +void +test2(const T&&) // { dg-error "argument" } +{ + sa<is_lvalue_reference<const T&&>::value == is_lvalue_ref> t1; + sa<is_rvalue_reference<const T&&>::value == is_rvalue_ref> t2; +} + +template <bool is_lvalue_ref, bool is_rvalue_ref, class T> +void +test3(T*&&) +{ + sa<is_lvalue_reference<T*&&>::value == is_lvalue_ref> t1; + sa<is_rvalue_reference<T*&&>::value == is_rvalue_ref> t2; +} + +struct A {}; + +A a; + +A source() {return A();} +A* sourcep() {return 0;} + +int main() +{ + test1<true, false>(a); + test1<false, true>(source()); + test2<false, true>(a); // { dg-error "lvalue" } + test2<false, true>(source()); + test3<false, true>(&a); + test3<false, true>(sourcep()); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing1.C b/gcc/testsuite/g++.dg/cpp0x/trailing1.C new file mode 100644 index 000000000..f637857b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing1.C @@ -0,0 +1,117 @@ +// Tests for late-specified return type. +// { dg-options "-std=c++0x -fabi-version=5" } + +auto f() -> int +{ + return 0; +} + +template<class T, class U> +auto add(T t, U u) -> decltype (t+u) +{ + return t+u; +} + +template<class T, class U> +decltype(T()+U()) add2(T t, U u) +{ + return t+u; +} + +template <class T, class U> +U ag (T, U) +{ + return U(); +} + +template<class T, class U> +auto add3(T t, U u) -> decltype (ag(t,u)) +{ + return ag(t,u); +} + +template<class T, class U> +decltype(*(T*)0+*(U*)0) add4(T t, U u) +{ + return t+u; +} + +template <class T> +struct A +{ + T f() {} + template <class U> + T g() {} + template <class V> + struct B + { + int MEM; + }; +}; + +template <class T> +auto f(T* t) -> decltype (t->f()) +{ + return t->f(); +} + +template <class T> +auto g(T t) -> decltype (t.f()) +{ + return t.f(); +} + +template <class T, class U> +auto h(T t, U u) -> decltype (t.template g<U>()) +{ + return t.template g<U>(); +} + +struct D { }; +struct C: public A<int>::B<D> +{ +}; + +template <class T, class U, class V> +auto k(T t, U u, V v) -> decltype (t.U::template B<V>::MEM) +{ + return t.U::template B<V>::MEM; +} + +template <class T> +auto l(T t) -> decltype (t) +{ + return t; +} + +template <class T, T u> +auto m(T t) -> decltype (u) +{ + return t; +} + +A<int> a, *p; + +int main() +{ + // { dg-final { scan-assembler "_Z3addIidEDTplfp_fp0_ET_T0_" } } + auto i = add(1, 2.0); + // { dg-final { scan-assembler "_Z4add4IidEDTpldecvPT_Li0EdecvPT0_Li0EES0_S2_" } } + auto i4 = add4(1, 2.0); + // { dg-final { scan-assembler "_Z4add2IidEDTplcvT__EcvT0__EES0_S1_" } } + auto i2 = add2(1, 2.0); + // { dg-final { scan-assembler "_Z4add3IidEDTcl2agfp_fp0_EET_T0_" } } + auto i3 = add3(1, 2.0); + // { dg-final { scan-assembler "_Z1fI1AIiEEDTclptfp_1fEEPT_" } } + f(p); + // { dg-final { scan-assembler "_Z1gI1AIiEEDTcldtfp_1fEET_" } } + g(a); + // { dg-final { scan-assembler "_Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_" } } + h(a,1.0); + // { dg-final { scan-assembler "_Z1kI1C1AIiE1DEDtdtfp_srNT0_1BIT1_EE3MEMET_S4_S6_" } } + k( C(), A<int>(), D() ); + // { dg-final { scan-assembler "_Z1lIiEDtfp_ET_" } } + l(1); + // { dg-final { scan-assembler "_Z1mIiLi1EEDtT0_ET_" } } + m<int,1>(1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing2.C b/gcc/testsuite/g++.dg/cpp0x/trailing2.C new file mode 100644 index 000000000..e45204fe7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing2.C @@ -0,0 +1,16 @@ +// PR c++/37967 +// Negative test for auto +// { dg-options "-std=c++0x" } + +auto f1 () -> int; +auto f2 (); // { dg-error "without late return type" } +int f3 () -> int; // { dg-error "late return type" } +auto *f4 () -> int; // { dg-error "late return type" } + +struct A +{ + auto f5 () const -> int; + auto f6 (); // { dg-error "without late return type" } + int f7 () -> int; // { dg-error "late return type" } + auto *f8 () -> int; // { dg-error "late return type" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing3.C b/gcc/testsuite/g++.dg/cpp0x/trailing3.C new file mode 100644 index 000000000..82d36f0d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing3.C @@ -0,0 +1,63 @@ +// More auto/decltype mangling tests. +// { dg-options "-std=c++0x" } + +template <class T> +struct B +{ + static int i; +}; + +int&& x(); + +template <class T> +struct A +{ + static int i; + static int &ir; + static int &&irr; + template <class U> + auto f(U u) -> decltype (u + i); + template <class U> + auto fr(U u) -> decltype (u + ir); + template <class U> + auto frr(U u) -> decltype (u + irr); + template <class U> + auto g(U u) -> decltype (u + sizeof (i)); + template <class U> + auto h(U u) -> decltype (u + B<U>::i); + template <class U> + auto j(U u) -> decltype (u + x()); +}; + +template<class T> template<class U> +auto A<T>::f(U u) -> decltype (u + i) +{ + return u + i; +} + +template <class... Args> +int f (Args... args); + +template <class... Args> +auto g (Args... args) -> decltype (f ((args+1)...)) +{ + return (f ((args+1)...)); +} + +int main() +{ + // { dg-final { scan-assembler "_ZN1AIiE1fIiEEDTplfp_L_ZNS0_1iEEET_" } } + A<int>().f(1); + // { dg-final { scan-assembler "_ZN1AIiE2frIiEEDTplfp_L_ZNS0_2irEEET_" } } + A<int>().fr(1); + // { dg-final { scan-assembler "_ZN1AIiE3frrIiEEDTplfp_L_ZNS0_3irrEEET_" } } + A<int>().frr(1); + // { dg-final { scan-assembler "_ZN1AIiE1gIiEEDTplfp_szL_ZNS0_1iEEET_" } } + A<int>().g(1); + // { dg-final { scan-assembler "_ZN1AIiE1hIiEEDTplfp_sr1BIT_E1iES3_" } } + A<int>().h(1); + // { dg-final { scan-assembler "_ZN1AIiE1jIiEEDTplfp_clL_Z1xvEEET_" } } + A<int>().j(1); + // { dg-final { scan-assembler "_Z1gIIidEEDTcl1fspplfp_Li1EEEDpT_" } } + g(42, 1.0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing4.C b/gcc/testsuite/g++.dg/cpp0x/trailing4.C new file mode 100644 index 000000000..d67b3b611 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing4.C @@ -0,0 +1,12 @@ +// PR c++/38597 +// { dg-options "-std=c++0x" } + +template<class T, class U> +auto f(T,U) -> decltype(T() + U()) +{ return T() + U(); } + +template<class T> void g(T){} // { dg-message "note" } + +int main() { g(f); } // { dg-error "no matching function" } +// { dg-message "candidate" "candidate note" { target *-*-* } 10 } + diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing5.C b/gcc/testsuite/g++.dg/cpp0x/trailing5.C new file mode 100644 index 000000000..b97d362be --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trailing5.C @@ -0,0 +1,10 @@ +// PR c++/38798, DR 770 +// { dg-options -std=c++0x } + +struct A {}; +auto foo() -> struct A {} + +enum B {}; +auto bar() -> enum B {} + +auto baz() -> struct C {} {} // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/cpp0x/trivial1.C b/gcc/testsuite/g++.dg/cpp0x/trivial1.C new file mode 100644 index 000000000..109c8ccdb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trivial1.C @@ -0,0 +1,86 @@ +// { dg-options "-std=c++0x" } + +// [basic.types]/10: +// Scalar types, trivial class types (Clause 9), arrays of such types and +// cv-qualified versions of these types (3.9.3) are collectively called +// trivial types. + +// [class]/6: +// A trivially copyable class is a class that: +// * has no non-trivial copy constructors (12.8), +// * has no non-trivial copy assignment operators (13.5.3, 12.8), and +// * has a trivial destructor (12.4). +// A trivial class is a class that has a trivial default constructor (12.1) +// and is trivially copyable. + +#include <type_traits> + +#define TRY(expr) static_assert (expr, #expr) +#define YES(type) TRY(std::is_trivial<type>::value); \ + TRY(std::is_trivial<type[]>::value); \ + TRY(std::is_trivial<const volatile type>::value); +#define NO(type) TRY(!std::is_trivial<type>::value); \ + TRY(!std::is_trivial<type[]>::value); \ + TRY(!std::is_trivial<const volatile type>::value); + +struct A; + +YES(int); +YES(__complex int); +YES(void *); +YES(int A::*); +typedef int (A::*pmf)(); +YES(pmf); + +struct A { ~A(); }; +NO(A); +struct F: public A { int i; }; +NO(F); +struct G: public A { A a; }; +NO(G); +struct M { A a; }; +NO(M); + +class B +{ + int i; + __complex int c; + void *p; + double ar[4]; + int A::* pm; + int (A::*pmf)(); +}; +YES(B); +struct D: public B { }; +YES(D); +struct E: public B { int q; }; +YES(E); +struct D2: public B { }; +YES(D2); +struct I: public D, public D2 { }; +YES(I); + +struct C +{ + int i; +private: + int j; +}; +YES(C); +struct H: public C { }; +YES(H); +struct N { C c; }; +YES(N); + +struct J { virtual void f(); }; +struct J2: J { }; +NO(J); +NO(J2); +struct K { }; +struct L: virtual K {}; +YES(K); +NO(L); + +// PR c++/41421 +struct O { O(int); }; +NO(O); diff --git a/gcc/testsuite/g++.dg/cpp0x/union1.C b/gcc/testsuite/g++.dg/cpp0x/union1.C new file mode 100644 index 000000000..291853d5a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union1.C @@ -0,0 +1,34 @@ +// Negative test for C++0x unrestricted unions +// { dg-options -std=c++0x } +// { dg-prune-output "implicitly deleted because" } + +struct A +{ + A(); + A(const A&); + ~A(); +}; + +union B +{ + A a; // { dg-error "union member" } +}; + +B b; // { dg-error "B::B\\(\\)" } +B b2(b); // { dg-error "B::B\\(const B&\\)" } + +struct C +{ + union + { + A a; // { dg-error "union member" } + }; +}; + +C c; // { dg-error "C::C\\(\\)" } +C c2(c); // { dg-error "C::C\\(const C&\\)" } + +// { dg-error "B::~B" "" { target *-*-* } 17 } +// { dg-error "B::~B" "" { target *-*-* } 18 } +// { dg-error "C::~C" "" { target *-*-* } 28 } +// { dg-error "C::~C" "" { target *-*-* } 29 } diff --git a/gcc/testsuite/g++.dg/cpp0x/union2.C b/gcc/testsuite/g++.dg/cpp0x/union2.C new file mode 100644 index 000000000..4f193e281 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union2.C @@ -0,0 +1,34 @@ +// Positive test for C++0x unrestricted unions +// { dg-options -std=c++0x } + +struct A +{ + A(); + A(const A&); + ~A(); +}; + +union B +{ + A a; + B(); + B(const B&); + ~B(); +}; + +B b; +B b2(b); + +struct C +{ + union + { + A a; + }; + C(); + C(const C&); + ~C(); +}; + +C c; +C c2(c); diff --git a/gcc/testsuite/g++.dg/cpp0x/union3.C b/gcc/testsuite/g++.dg/cpp0x/union3.C new file mode 100644 index 000000000..f1e8ddb61 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union3.C @@ -0,0 +1,69 @@ +// Runtime test for C++0x unrestricted unions +// { dg-options -std=c++0x } +// { dg-do run } + +int c, d; +struct A +{ + int i; + A(): i(1) { ++c; } + A(const A&): i(2) { ++c; } + ~A() { ++d; } +}; + +union B +{ + A a; + B() { } + B(const B& b) { } + ~B() { } +}; + +struct C +{ + union { A a; }; + C() { } + C(const C&) { } + ~C() { } +}; + +union D +{ + A a; + D(): a() { } + D(const D& d): a(d.a) { } + ~D() { a.~A(); } +}; + +struct E +{ + union { A a; }; + E(): a() { } + E(const E& e): a (e.a) { } + ~E() { a.~A(); } +}; + +int main() +{ + { + B b1; + B b2(b1); + + C c1; + C c2(c1); + } + + if (c != 0 || d != 0) + return c+d*10; + + { + D d1; + D d2(d1); + + E e1; + E e2(e1); + } + + if (c != 4 || d != 4) + return c*100+d*1000; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/union4.C b/gcc/testsuite/g++.dg/cpp0x/union4.C new file mode 100644 index 000000000..07050475d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union4.C @@ -0,0 +1,17 @@ +// PR c++/48537 +// { dg-options -std=c++0x } + +struct SFoo +{ + SFoo() =delete; // { dg-error "declared" } +}; + +union UFoo // { dg-error "deleted" } +{ + SFoo foo; +}; + +int main() +{ + UFoo(); // { dg-error "deleted" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/union5.C b/gcc/testsuite/g++.dg/cpp0x/union5.C new file mode 100644 index 000000000..423b34823 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/union5.C @@ -0,0 +1,23 @@ +// PR c++/49803 +// { dg-options -std=c++0x } + +struct X +{ + X() = delete; +}; + +union Y +{ + // N3291=11-0061 12.6.2/8 says no initialization of + // of other variant members (i.e. m_x) should + // be performed. + Y() : m_char1{ } + { } + + struct + { + char m_char1; + }; + + X m_x; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C b/gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C new file mode 100644 index 000000000..c59667645 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/unnamed_refs.C @@ -0,0 +1,35 @@ +// I, Howard Hinnant, hereby place this code in the public domain. + +// Test: Unamed rvalue references are treated as lvalues. + +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <bool> struct sa; +template <> struct sa<true> {}; + +struct one {long x[1];}; +struct two {long x[2];}; + +struct A {}; + +one foo(const A&) {return one();} +two foo(A&&) {return two();} + +template<typename _Tp> +inline _Tp&& +movel(_Tp& __t) +{ return static_cast<_Tp&&>(__t); } + +A&& source() {static A a; return movel(a);} + +int test1() +{ + sa<sizeof(foo(source())) == 2 * sizeof(long)> t1; + return 0; +} + +int main() +{ + return test1(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-104.C b/gcc/testsuite/g++.dg/cpp0x/variadic-104.C new file mode 100644 index 000000000..c693b33f9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-104.C @@ -0,0 +1,16 @@ +// PR c++/45236 +// { dg-options -std=c++0x } + +template <class T, class S> class foo; + +template<template<int...> class C, int... II, class S> +struct foo<C<II...>,S> +{ + template <class U> + struct bar { typedef int type; }; +}; + +template <int... I> +struct A {}; + +foo<A<3>, float>::bar<int> x; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-bind.C b/gcc/testsuite/g++.dg/cpp0x/variadic-bind.C new file mode 100644 index 000000000..abe445d43 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-bind.C @@ -0,0 +1,476 @@ +// { dg-do run } +// { dg-options "-std=gnu++0x" } +// A basic implementation of TR1's bind using variadic teplates +// Contributed by Douglas Gregor <doug.gregor@gmail.com> +#include <cassert> + +// Trivial reference_wrapper +template<typename T> +struct reference_wrapper +{ + reference_wrapper(T& x) : ptr(&x) { } + + operator T&() const { return *ptr; } + + T& get() const { return *ptr; } + + T* ptr; +}; + +template<typename T> reference_wrapper<T> ref(T& x) { return x; } +template<typename T> reference_wrapper<const T> cref(const T& x) { return x; } + +// Simple type-traits we'll need +template<typename T> +struct add_reference +{ + typedef T& type; +}; + +template<typename T> +struct add_reference<T&> +{ + typedef T& type; +}; + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +// For creating the constructor parameters of tuple<> +template<typename T> +struct add_const_reference +{ + typedef const T& type; +}; + +template<typename T> +struct add_const_reference<T&> +{ + typedef T& type; +}; + +// 6.1.3 Class template tuple: Needed for bind() implementation +template<typename... Values> +class tuple; + +template<> class tuple<> { }; + +template<typename Head, typename... Tail> +class tuple<Head, Tail...> + : private tuple<Tail...> +{ + typedef tuple<Tail...> inherited; + + public: + tuple() { } + + // implicit copy-constructor is okay + + tuple(typename add_const_reference<Head>::type v, + typename add_const_reference<Tail>::type... vtail) + : m_head(v), inherited(vtail...) { } + + template<typename... VValues> + tuple(const tuple<VValues...>& other) + : m_head(other.head()), inherited(other.tail()) { } + + template<typename... VValues> + tuple& operator=(const tuple<VValues...>& other) + { + m_head = other.head(); + tail() = other.tail(); + return *this; + } + + typename add_reference<Head>::type head() { return m_head; } + typename add_reference<const Head>::type head() const { return m_head; } + inherited& tail() { return *this; } + const inherited& tail() const { return *this; } + + protected: + Head m_head; +}; + +template<typename T> +struct make_tuple_result +{ + typedef T type; +}; + +template<typename T> +struct make_tuple_result<reference_wrapper<T> > +{ + typedef T& type; +}; + +// 6.1.3.2 Tuple creation functions +struct ignore_t { + template<typename T> ignore_t& operator=(const T&) { return *this; } +} ignore; + +template<typename... Values> +tuple<typename make_tuple_result<Values>::type...> +make_tuple(const Values&... values) +{ + return tuple<typename make_tuple_result<Values>::type...>(values...); +} + +template<typename... Values> +tuple<Values&...> tie(Values&... values) +{ + return tuple<Values&...>(values...); +} + +// 6.1.3.3 Tuple helper classes +template<typename Tuple> +struct tuple_size; + +template<> +struct tuple_size<tuple<> > +{ + static const __SIZE_TYPE__ value = 0; +}; + +template<typename Head, typename... Tail> +struct tuple_size<tuple<Head, Tail...> > +{ + static const __SIZE_TYPE__ value = 1 + tuple_size<tuple<Tail...> >::value; +}; + +template<int I, typename Tuple> +struct tuple_element; + +template<int I, typename Head, typename... Tail> +struct tuple_element<I, tuple<Head, Tail...> > +{ + typedef typename tuple_element<I-1, tuple<Tail...> >::type type; +}; + +template<typename Head, typename... Tail> +struct tuple_element<0, tuple<Head, Tail...> > +{ + typedef Head type; +}; + +// 6.1.3.4 Element access +template<int I, typename Tuple> +class get_impl; + +template<int I, typename Head, typename... Values> +class get_impl<I, tuple<Head, Values...> > +{ + typedef typename tuple_element<I-1, tuple<Values...> >::type Element; + typedef typename add_reference<Element>::type RJ; + typedef typename add_const_reference<Element>::type PJ; + typedef get_impl<I-1, tuple<Values...> > Next; + + public: + static RJ get(tuple<Head, Values...>& t) + { return Next::get(t.tail()); } + + static PJ get(const tuple<Head, Values...>& t) + { return Next::get(t.tail()); } +}; + +template<typename Head, typename... Values> +class get_impl<0, tuple<Head, Values...> > +{ + typedef typename add_reference<Head>::type RJ; + typedef typename add_const_reference<Head>::type PJ; + + public: + static RJ get(tuple<Head, Values...>& t) { return t.head(); } + static PJ get(const tuple<Head, Values...>& t) { return t.head(); } +}; + +template<int I, typename... Values> +typename add_reference< + typename tuple_element<I, tuple<Values...> >::type + >::type +get(tuple<Values...>& t) +{ + return get_impl<I, tuple<Values...> >::get(t); +} + +template<int I, typename... Values> +typename add_const_reference< + typename tuple_element<I, tuple<Values...> >::type + >::type +get(const tuple<Values...>& t) +{ + return get_impl<I, tuple<Values...> >::get(t); +} + +// 6.1.3.5 Relational operators +inline bool operator==(const tuple<>&, const tuple<>&) { return true; } + +template<typename T, typename... TTail, typename U, typename... UTail> +bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) +{ + return t.head() == u.head() && t.tail() == u.tail(); +} + +template<typename... TValues, typename... UValues> +bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return !(t == u); +} + +inline bool operator<(const tuple<>&, const tuple<>&) { return false; } + +template<typename T, typename... TTail, typename U, typename... UTail> +bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) +{ + return (t.head() < u.head() || + (!(t.head() < u.head()) && t.tail() < u.tail())); +} + +template<typename... TValues, typename... UValues> +bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return u < t; +} + +template<typename... TValues, typename... UValues> +bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return !(u < t); +} + +template<typename... TValues, typename... UValues> +bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return !(t < u); +} + +// enable_if, the breakfast of champions +template<bool Cond, typename Type = void> +struct enable_if { + typedef Type type; +}; + +template<typename Type> +struct enable_if<false, Type> { }; + +// 3.6 Function object binders + +// 3.6.1 Class template is_bind_expression +template<typename T> +struct is_bind_expression { + static const bool value = false; +}; + +// 3.6.2 Class template is_placeholder +template<typename T> +struct is_placeholder { + static const int value = 0; +}; + +// 3.6.3 Function template bind +template<int I> struct placeholder {} ; + +template<int N> struct int_c { }; + +// A tuple of integer values +template<int...> struct int_tuple {}; + +// make_indexes_impl is a helper for make_indexes +template<int I, typename IntTuple, typename... Types> +struct make_indexes_impl; + + +template<int I, int... Indexes, typename T, typename... Types> +struct make_indexes_impl<I, int_tuple<Indexes...>, T, Types...> +{ + typedef typename make_indexes_impl<I+1, + int_tuple<Indexes..., I>, + Types...>::type type; +}; + +template<int I, int... Indexes> +struct make_indexes_impl<I, int_tuple<Indexes...> > { + typedef int_tuple<Indexes...> type; +}; + +// make_indexes takes a variable-length number of N types and +// generates an int_tuple that contains <0, 1, 2, ..., N-1>. These can +// be used as indexes for tuple's get or tuple_element operation. +template<typename... Types> +struct make_indexes : make_indexes_impl<0, int_tuple<>, Types...> { }; + +// Get the Ith tuple element, but only if I is in bounds. +template<int I, typename Tuple, typename = void> +struct safe_tuple_element{ }; + +template<int I, typename... Values> +struct safe_tuple_element<I, tuple<Values...>, + typename enable_if<(I >= 0 && + I < tuple_size<tuple<Values...> >::value) + >::type> +{ + typedef typename tuple_element<I, tuple<Values...> >::type type; +}; + +// mu maps a bound argument to an actual argument, given a tuple of +// the arguments passed to the function object returned by bind(). + +// Return the stored reference from reference_wrapper +template<typename T, typename... Args> +inline T& mu(reference_wrapper<T>& bound_arg, const tuple<Args&...>&) +{ + return bound_arg.get(); +} + +// Unwrap a tuple into separate arguments and forward to the function +// object f. +template<typename F, int... Indexes, typename... Args> +inline typename F::result_type +unwrap_and_forward(F& f, int_tuple<Indexes...>, const tuple<Args&...>& args) +{ + return f(get<Indexes>(args)...); +} + +// Evaluate the inner bind expression +template<typename Bound, typename... Args> +inline typename enable_if<is_bind_expression<Bound>::value, + typename Bound::result_type>::type +mu(Bound& bound_arg, const tuple<Args&...>& args) +{ + typedef typename make_indexes<Args...>::type Indexes; + return unwrap_and_forward(bound_arg, Indexes(), args); +} + +// Retrieve the Ith argument from args +template<typename Bound, typename... Args> +inline typename safe_tuple_element<is_placeholder<Bound>::value - 1, + tuple<Args...> >::type +mu(Bound& bound_arg, const tuple<Args&...>& args) +{ + return get<is_placeholder<Bound>::value-1>(args); +} + +// Return the stored value. +template<typename T> +struct is_reference_wrapper { + static const bool value = false; +}; + +template<typename T> +struct is_reference_wrapper<reference_wrapper<T> > { + static const bool value = true; +}; + +template<typename Bound, typename... Args> +inline typename enable_if<(!is_bind_expression<Bound>::value + && !is_placeholder<Bound>::value + && !is_reference_wrapper<Bound>::value), + Bound&>::type +mu(Bound& bound_arg, const tuple<Args&...>&) +{ + return bound_arg; +} + +// +template<typename F, typename... BoundArgs, int... Indexes, typename... Args> +typename F::result_type +apply_functor(F& f, tuple<BoundArgs...>& bound_args, int_tuple<Indexes...>, + const tuple<Args&...>& args) +{ + return f(mu(get<Indexes>(bound_args), args)...); +} + +template<typename F, typename... BoundArgs> +class bound_functor +{ + typedef typename make_indexes<BoundArgs...>::type indexes; + + public: + typedef typename F::result_type result_type; + + explicit bound_functor(const F& f, const BoundArgs&... bound_args) + : f(f), bound_args(bound_args...) { } + + template<typename... Args> + typename F::result_type operator()(Args&... args) { + return apply_functor(f, bound_args, indexes(), tie(args...)); + } + + private: + F f; + tuple<BoundArgs...> bound_args; +}; + +template<typename F, typename... BoundArgs> +struct is_bind_expression<bound_functor<F, BoundArgs...> > { + static const bool value = true; +}; + +template<typename F, typename... BoundArgs> +inline bound_functor<F, BoundArgs...> +bind(const F& f, const BoundArgs&... bound_args) +{ + return bound_functor<F, BoundArgs...>(f, bound_args...); +} + + +// 3.6.4 Placeholders +template<int I> +struct is_placeholder<placeholder<I> > { + static const int value = I; +}; + +placeholder<1> _1; +placeholder<2> _2; +placeholder<3> _3; +placeholder<4> _4; +placeholder<5> _5; +placeholder<6> _6; +placeholder<7> _7; +placeholder<8> _8; +placeholder<9> _9; + +// Test code +template<typename T> +struct plus { + typedef T result_type; + + T operator()(T x, T y) { return x + y; } +}; + +template<typename T> +struct multiplies { + typedef T result_type; + + T operator()(T x, T y) { return x * y; } +}; + +template<typename T> +struct negate { + typedef T result_type; + + T operator()(T x) { return -x; } +}; + +int main() +{ + int seventeen = 17; + int forty_two = 42; + + assert(bind(plus<int>(), _1, _2)(seventeen, forty_two) == 59); + assert(bind(plus<int>(), _1, _1)(seventeen, forty_two) == 34); + assert(bind(plus<int>(), _2, _1)(seventeen, forty_two) == 59); + assert(bind(plus<int>(), 5, _1)(seventeen, forty_two) == 22); + assert(bind(plus<int>(), ref(seventeen), _2)(seventeen, forty_two) == 59); + assert(bind(plus<int>(), bind(multiplies<int>(), 3, _1), _2)(seventeen, forty_two) + == 93); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-crash1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-crash1.C new file mode 100644 index 000000000..f26aee2a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-crash1.C @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +#define ONE +#define TWO +#define THREE + +struct Something {}; +Something ___; + +template <class F> +struct Trial +{ + F f; +public: + Trial() : f() {} + Trial( const F& ff ) : f(ff) { } + template <typename... Args> + struct Sig { typedef int ResultType; }; + + template <typename... Args> + struct Sig<Something,Args...> { typedef int ResultType; }; + +#ifdef ONE + +template <typename... Args> +typename Sig<Something,Args...>::ResultType operator()(const Something& s, const Args&... args) const +{ + return f(args...); +} +#endif +#ifdef TWO +template <typename... Args> +typename Sig<Args...>::ResultType operator()(const Args&... args) const +{ + return f(args...); +} +#endif +}; + +struct Internal +{ + +template <typename... Args> +struct Sig { typedef int ResultType; }; + +template <typename... Args> +struct Sig<Something,Args...> { typedef int ResultType; }; + +template <typename... Args> +int operator()(const Args&... args) const +{ + int n = sizeof...(Args); + return n; +} + + static Trial<Internal>& full() { static Trial<Internal> f; return f; } +}; + +static Trial<Internal>& internal = Internal::full(); + +int main() +{ + int n = 0; +#ifdef ONE + n = internal(___,1,2); +#endif +#ifdef THREE + n = internal(___,1,2,3); + n = internal(___,1,2,3,4); +#endif + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C new file mode 100644 index 000000000..f46b8e534 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-crash2.C @@ -0,0 +1,20 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin: PR c++/39637 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<class... Types> +void +f(Types...) +{ + enum {e = sizeof(Types)}; // { dg-error "parameter packs not expanded with '...'" } + enum {e1 = sizeof...(Types)}; +} + +int +main() +{ + f(0); +} + +// { dg-message "note" "Types" { target *-*-* } 10 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C new file mode 100644 index 000000000..485fffa47 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C @@ -0,0 +1,4 @@ +// { dg-options "-std=gnu++0x" } +template<typename ... Elements> class Tuple; +Tuple<>* t; // OK: Elements is empty +Tuple* u; // { dg-error "template-name" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C new file mode 100644 index 000000000..a392bd7d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex10.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Types> struct Tuple { }; + +Tuple<> t0; // Types contains no arguments +Tuple<int> t1; // Types contains one argument: int +Tuple<int, float> t2; // Types contains two arguments: int and float +Tuple<0> error; // { dg-error "mismatch" } +// { dg-error "expected a type" "" { target *-*-* } 7 } +// { dg-error "in declaration" "" { target *-*-* } 7 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C new file mode 100644 index 000000000..57ef2a3d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex11.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Types> + void f(Types... args); + +void g() { + f(); // okay: args contains no arguments + f(1); // okay: args contains one int argument + (2, 1.0); // okay: args contains two arguments, an int and a double +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C new file mode 100644 index 000000000..b97df3102 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex12.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Types> + void f(Types... rest); + +template<typename... Types> + void g(Types... rest) { + f(&rest...); // ``&rest...'' is a pack expansion, ``&rest'' is its pattern + } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C new file mode 100644 index 000000000..b742cb1d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex13.C @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } + +template<typename T, typename U> struct is_same { + static const bool value = false; +}; + +template<typename T> struct is_same<T, T> { + static const bool value = true; +}; + +template<typename...> struct Tuple {}; +template<typename T1, typename T2> struct Pair {}; + +template<typename... Args1> + struct zip { + template<typename... Args2> + struct with { + typedef Tuple<Pair<Args1, Args2>...> type; // { dg-error "mismatched argument pack" } + }; + }; + +static_assert + (is_same<zip<short, int>::with<unsigned short, unsigned>::type, + Tuple<Pair<short, unsigned short>, Pair<int, unsigned> > >::value, + "zip"); + +typedef zip<short>::with<unsigned short, unsigned>::type T2; // error: different number of arguments specified + // for Args1 and Args2 + +template<typename... Args> void f(Args...); + +template<typename... Args> void g(Args... args) +{ + f(const_cast<const Args*>(&args)...); // okay: ``Args'' and ``args'' are expanded + f(5 ...); // { dg-error "contains no argument packs" } + f(args); // { dg-error "parameter packs not expanded" } + // { dg-message "args" "note" { target *-*-* } 36 } + f(h(args...) + args...); // okay: first ``args'' expanded within h, second ``args'' expanded within f. +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C new file mode 100644 index 000000000..f33ca0e86 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex14.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } + +template<class T> class A { /* ... */ }; +template<class T, class U = T> class B { /* ... */ }; +template<class... Types> class C { /* ... */ }; + +template<template<class> class P> class X { /* ... */ }; +template<template<class...> class Q> class Y { /* ... */ }; + +X<A> xA; // okay +X<B> xB; // { dg-error "mismatch" } +// { dg-error "expected a template" "" { target *-*-* } 11 } +// { dg-error "invalid type" "" { target *-*-* } 11 } +X<C> xC; // { dg-error "mismatch" } +// { dg-error "expected a template" "" { target *-*-* } 14 } +// { dg-error "invalid type" "" { target *-*-* } 14 } +Y<A> yA; +Y<B> yB; +Y<C> yC; // okay diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C new file mode 100644 index 000000000..ca5fa2716 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template<class... Types> struct B { // { dg-error "declaration of" } + void f3(); + void f4(); +}; + +template<class... Types> void B<Types...>::f3() { } // OK +template<class... Types> void B<Types>::f4() { } // { dg-error "invalid" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C new file mode 100644 index 000000000..bd973055d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex3.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template<class X, class Y, class... Z> X f(Y); // { dg-message "note" } +void g() +{ + int i = f<int>(5.6); + int j = f(5.6); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 6 } + f<void>(f<int, bool>); + f<void>(f<int>); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 9 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C new file mode 100644 index 000000000..5bf211696 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex4.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +template<class X, class Y, class Z> X f(Y,Z); // { dg-message "note" } +template<class... Args> void f2(); +void g() +{ + f<int,const char*,double>("aa",3.0); + f<int,const char*>("aa",3.0); // Z is deduced to be double + f<int>("aa",3.0); // Y is deduced to be char*, and + // Z is deduced to be double + f("aa",3.0); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 10 } + f2<char, short, int, long>(); // okay +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C new file mode 100644 index 000000000..2439a51c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex5.C @@ -0,0 +1,7 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Types> void f(Types... values); + +void g() +{ + f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C new file mode 100644 index 000000000..87b1bf205 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex6.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +template<class...> struct Tuple { }; + +template<class... Types> void f(Types&...); +template<class... Types1, class... Types2> void g(Tuple<Types1...>, Tuple<Types2...>); + +void h(int x, float& y) +{ + const int z = x; + f(x, y, z); // Types is deduced to int, const int, float + g(Tuple<short, int, long>(), Tuple<float, double>()); // Types1 is deduced to short, int long + // Types2 is deduced to float, double +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C new file mode 100644 index 000000000..7ca31f9c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex7.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +template<typename...> struct Tuple { }; +template<typename... Types> char& g(Tuple<Types...>); // #1 +template<typename T1, typename... Types> short& g(Tuple<T1, Types...>); // #2 +template<typename T1, typename... Types> int& g(Tuple<T1, Types&...>); // #3 + +void f() { + // char& x1 = g(Tuple<>()); // calls #1 + short& y1 = g(Tuple<int, float>()); // calls #2 + // int& z1 = g(Tuple<int, float&>()); // calls #3 + // int& z2 = g(Tuple<int>()); // calls #3 + // int& z3 = g(Tuple<int>()); // calls #3 +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C new file mode 100644 index 000000000..03d28b825 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex8.C @@ -0,0 +1,18 @@ +// { dg-options "-std=gnu++0x" } +template<class> struct X { static const bool primary = true; }; +template<class R, class... ArgTypes> struct X<R(int, ArgTypes...)> { + static const bool primary = false; +}; +template<class... Types> struct Y { static const bool primary = true; }; +template<class T, class... Types> struct Y<T, Types&...> { + static const bool primary = false; +}; + +static_assert (X<int>::primary, "uses primary template"); +static_assert (!X<int(int, float, double)>::primary, + "uses partial specialization"); +static_assert (X<int(float, int)>::primary, "uses primary template"); +static_assert (Y<>::primary, "uses primary template"); +static_assert (!Y<int&, float&, double&>::primary, + "uses partial specialization"); +static_assert (Y<int, float, double>::primary, "uses primary template"); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C new file mode 100644 index 000000000..74215c997 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex9.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> char& f(Args... args); // #1 +template<typename T1, typename... Args> short& f(T1 a1, Args... args); // #2 +template<typename T1, typename T2> int& f(T1 a2, T2 a3); // #3 + +void g() { + char& x = f(); // calls #1 + short& y = f(1, 2, 3); // calls #2 + int& z = f(1, 2); // calls #3 +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-function.C b/gcc/testsuite/g++.dg/cpp0x/variadic-function.C new file mode 100644 index 000000000..eeb137705 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-function.C @@ -0,0 +1,96 @@ +// { dg-do run } +// { dg-options "-std=gnu++0x" } +// A basic implementation of TR1's function using variadic teplates +// Contributed by Douglas Gregor <doug.gregor@gmail.com> +#include <cassert> + +template<typename Signature> +class function; + +template<typename R, typename... Args> +class invoker_base +{ + public: + virtual ~invoker_base() { } + virtual R invoke(Args...) = 0; + virtual invoker_base* clone() = 0; +}; + +template<typename F, typename R, typename... Args> +class functor_invoker : public invoker_base<R, Args...> +{ + public: + explicit functor_invoker(const F& f) : f(f) { } + R invoke(Args... args) { return f(args...); } + functor_invoker* clone() { return new functor_invoker(f); } + + private: + F f; +}; + +template<typename R, typename... Args> +class function<R (Args...)> { + public: + typedef R result_type; + + function() : invoker (0) { } + + function(const function& other) : invoker(0) { + if (other.invoker) + invoker = other.invoker->clone(); + } + + template<typename F> + function(const F& f) : invoker(0) { + invoker = new functor_invoker<F, R, Args...>(f); + } + + ~function() { + if (invoker) + delete invoker; + } + + function& operator=(const function& other) { + function(other).swap(*this); + return *this; + } + + template<typename F> + function& operator=(const F& f) { + function(f).swap(*this); + return *this; + } + + void swap(function& other) { + invoker_base<R, Args...>* tmp = invoker; + invoker = other.invoker; + other.invoker = tmp; + } + + result_type operator()(Args... args) const { + assert(invoker); + return invoker->invoke(args...); + } + + private: + invoker_base<R, Args...>* invoker; +}; + +struct plus { + template<typename T> T operator()(T x, T y) { return x + y; } +}; + +struct multiplies { + template<typename T> T operator()(T x, T y) { return x * y; } +}; + +int main() +{ + function<int(int, int)> f1 = plus(); + assert(f1(3, 5) == 8); + + f1 = multiplies(); + assert(f1(3, 5) == 15); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-init.C b/gcc/testsuite/g++.dg/cpp0x/variadic-init.C new file mode 100644 index 000000000..34ade85e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-init.C @@ -0,0 +1,56 @@ +// { dg-do run } +// { dg-options "-std=gnu++0x" } + +// PR c++/33510 +#define SIZE_FROM_CTOR +extern "C" void abort (); + +template<int M, int N> struct pair +{ + int i, j; + pair () : i (M), j (N) {} +}; + +template<int... M> struct S +{ + template<int... N> static int *foo () + { +#ifdef SIZE_FROM_CTOR + static int x[] = { (M + N)..., -1 }; +#else + static int x[1 + sizeof... N] = { (M + N)..., -1 }; +#endif + return x; + } +}; + +template<typename... M> struct R +{ + template<typename... N> static int *foo () + { +#ifdef SIZE_FROM_CTOR + static int x[] = { (sizeof(M) + sizeof(N))..., -1 }; +#else + static int x[1 + sizeof... N] = { (sizeof(M) + sizeof(N))..., -1 }; +#endif + return x; + } +}; + +int *bar () +{ + return S<0, 1, 2>::foo<0, 1, 2> (); +} + +int *baz () +{ + return R<char, short, int>::foo<float, double, long> (); +} + + +int main () +{ + int *p = bar (); + if (p[0] != 0 || p[1] != 2 || p[2] != 4 || p[3] != -1) + abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-lambda.C b/gcc/testsuite/g++.dg/cpp0x/variadic-lambda.C new file mode 100644 index 000000000..705d44149 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-lambda.C @@ -0,0 +1,79 @@ +// { dg-options "-std=c++0x" } + +struct int_placeholder; + +template<typename T> +struct do_replace +{ + typedef T type; +}; + +template<> +struct do_replace<int_placeholder> +{ + typedef int type; +}; + +template<typename T> struct lambdalike +{ + typedef T type; +}; + +template<template<typename...> class TT, typename... Args> +struct lambdalike<TT<Args...> > { + typedef TT<typename do_replace<Args>::type...> type; +}; + + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +template<typename... Elements> struct tuple; +template<typename T1, typename T2> struct pair; + +static_assert(is_same<lambdalike<tuple<float, int_placeholder, double>>::type, + tuple<float, int, double>>::value, + "MPL lambda-like replacement on tuple"); +static_assert(is_same<lambdalike<pair<float, int_placeholder>>::type, + pair<float, int>>::value, + "MPL lambda-like replacement on pair"); + + +struct _1 {}; + +template<typename Arg0, typename Lambda> +struct eval +{ + typedef Lambda type; +}; + +template<typename Arg0> +struct eval<Arg0, _1> +{ + typedef Arg0 type; +}; + +template<typename Arg0, template<typename...> class T, typename... Pack> +struct eval<Arg0, T<Pack...> > +{ + typedef T< typename eval<Arg0, Pack>::type... > type; +}; + +static_assert(is_same<eval<int, tuple<float, _1, double>>::type, + tuple<float, int, double>>::value, "eval tuple"); +static_assert(is_same<eval<int, pair<_1, double>>::type, + pair<int, double>>::value, "eval pair"); +static_assert(is_same<eval<int, + tuple<pair<_1, _1>, pair<float, float>, + pair<double, _1>>>::type, + tuple<pair<int, int>, pair<float, float>, pair<double, int>>>::value, + "recursive eval"); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C b/gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C new file mode 100644 index 000000000..51c5c79ef --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-mem_fn.C @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do run } +// A basic implementation of TR1's mem_fn using variadic teplates +// Contributed by Douglas Gregor <doug.gregor@gmail.com> +#include <cassert> + +template<typename R, typename Class, typename... Args> +class Mem_fn +{ + public: + explicit Mem_fn(R (Class::*pmf)(Args...)) : pmf(pmf) { } + + R operator()(Class& object, Args... args) + { + return (object.*pmf)(args...); + } + + R operator()(Class* object, Args... args) + { + return (object->*pmf)(args...); + } + + R (Class::*pmf)(Args...); +}; + +template<typename R, typename Class, typename... Args> +inline Mem_fn<R, Class, Args...> +mem_fn(R (Class::* pmf)(Args...)) +{ + return Mem_fn<R, Class, Args...>(pmf); +} + +class X { + public: + int negate(int x) { return -x; } + int plus(int x, int y) { return x + y; } +}; + +int main() +{ + X x; + X* xp = &x; + + assert(mem_fn(&X::negate)(x, 17) == -17); + assert(mem_fn(&X::negate)(xp, 17) == -17); + assert(mem_fn(&X::plus)(x, 17, 25) == 42); + assert(mem_fn(&X::plus)(xp, 17, 25) == 42); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-new.C b/gcc/testsuite/g++.dg/cpp0x/variadic-new.C new file mode 100644 index 000000000..5bbb9c81b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-new.C @@ -0,0 +1,19 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +// Contributed by Peter Dimov +// PR c++/32597 +#include <assert.h> +#include <new> + +int k = 5; + +template< class... Args > void f( Args... args ) +{ + new( &k ) int( args... ); +} + +int main() +{ + f(); + assert( k == 0 ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-new2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-new2.C new file mode 100644 index 000000000..81d333398 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-new2.C @@ -0,0 +1,24 @@ +// { dg-do run } +// { dg-options "-std=c++0x" } +// PR c++/32597 +#include <assert.h> +#include <new> + +template< class... Args > void f( Args... args ) +{ + { + int x = 17; + (void)x; + } + + { + int y(args...); + assert(y == 0); + } + +} + +int main() +{ + f(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-rref.C b/gcc/testsuite/g++.dg/cpp0x/variadic-rref.C new file mode 100644 index 000000000..08221b460 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-rref.C @@ -0,0 +1,36 @@ +// { dg-options "-std=c++0x" } +// PR c++/33939 +template<typename T> +struct refs_only; + +template<typename T> +struct refs_only<T &> +{}; + +template<typename T> +refs_only<T> foo( T && t) +{ + return refs_only<T>(); +} + +template<typename... T> +struct va_refs_only; + +template<typename T> +struct va_refs_only<T> + : refs_only<T> +{}; + +template<typename... T> +va_refs_only<T...> bar( T &&... t) +{ + return va_refs_only<T...>(); +} + +int main() +{ + int j = 0; + foo(j); + bar(j); // error: invalid use of incomplete type 'struct refs_only<int>' +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C b/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C new file mode 100644 index 000000000..8363c2a73 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-throw.C @@ -0,0 +1,26 @@ +// { dg-options -std=c++0x } +// { dg-prune-output "note" } +// PR c++/33509 +template<int M, int N> struct pair +{ + int i, j; + pair() : i(M), j(N) {} +}; + +template<int... M> struct S +{ + template<int... N> static int foo() throw (pair <M, N>...) // { dg-error "mismatched" } + { + return 1; + } +}; + +int bar () +{ + return S<0, 1, 2>::foo<0, 1, 3> (); +} + +int wibble() +{ + return S<0, 1, 2>::foo<0, 1> (); // { dg-error "no matching" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C new file mode 100644 index 000000000..41f1c1db4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ttp.C @@ -0,0 +1,12 @@ +// { dg-options -std=c++0x } +// PR c++/34101 +template<typename> struct A {}; + +template<template<typename> class...> struct B {}; + +template<template<typename> class T> void foo(const B<T>&); + +void bar() +{ + foo(B<A>()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C b/gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C new file mode 100644 index 000000000..11ce14af2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-tuple.C @@ -0,0 +1,294 @@ +// { dg-do run } +// { dg-options "-std=gnu++0x" } +// An implementation of TR1's <tuple> using variadic teplates +// Contributed by Douglas Gregor <doug.gregor@gmail.com> + +#include <string> +#include <cassert> +#include <cstring> + +// Trivial reference_wrapper +template<typename T> +struct reference_wrapper +{ + reference_wrapper(T& x) : ptr(&x) { } + + operator T&() const { return *ptr; } + + T* ptr; +}; + +template<typename T> reference_wrapper<T> ref(T& x) { return x; } +template<typename T> reference_wrapper<const T> cref(const T& x) { return x; } + +// Simple type-traits we'll need +template<typename T> +struct add_reference +{ + typedef T& type; +}; + +template<typename T> +struct add_reference<T&> +{ + typedef T& type; +}; + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +// For creating the constructor parameters of tuple<> +template<typename T> +struct add_const_reference +{ + typedef const T& type; +}; + +template<typename T> +struct add_const_reference<T&> +{ + typedef T& type; +}; + +// 6.1.3 Class template tuple +template<typename... Values> +class tuple; + +template<> class tuple<> { }; + +template<typename Head, typename... Tail> +class tuple<Head, Tail...> + : private tuple<Tail...> +{ + typedef tuple<Tail...> inherited; + + public: + tuple() { } + + // implicit copy-constructor is okay + + tuple(typename add_const_reference<Head>::type v, + typename add_const_reference<Tail>::type... vtail) + : m_head(v), inherited(vtail...) { } + + template<typename... VValues> + tuple(const tuple<VValues...>& other) + : m_head(other.head()), inherited(other.tail()) { } + + template<typename... VValues> + tuple& operator=(const tuple<VValues...>& other) + { + m_head = other.head(); + tail() = other.tail(); + return *this; + } + + typename add_reference<Head>::type head() { return m_head; } + typename add_reference<const Head>::type head() const { return m_head; } + inherited& tail() { return *this; } + const inherited& tail() const { return *this; } + + protected: + Head m_head; +}; + +template<typename T> +struct make_tuple_result +{ + typedef T type; +}; + +template<typename T> +struct make_tuple_result<reference_wrapper<T> > +{ + typedef T& type; +}; + +// 6.1.3.2 Tuple creation functions +struct ignore_t { + template<typename T> ignore_t& operator=(const T&) { return *this; } +} ignore; + +template<typename... Values> +tuple<typename make_tuple_result<Values>::type...> +make_tuple(const Values&... values) +{ + return tuple<typename make_tuple_result<Values>::type...>(values...); +} + +template<typename... Values> +tuple<Values&...> tie(Values&... values) +{ + return tuple<Values&...>(values...); +} + +// 6.1.3.3 Tuple helper classes +template<typename Tuple> +struct tuple_size; + +template<> +struct tuple_size<tuple<> > +{ + static const std::size_t value = 0; +}; + +template<typename Head, typename... Tail> +struct tuple_size<tuple<Head, Tail...> > +{ + static const std::size_t value = 1 + tuple_size<tuple<Tail...> >::value; +}; + +template<int I, typename Tuple> +struct tuple_element; + +template<int I, typename Head, typename... Tail> +struct tuple_element<I, tuple<Head, Tail...> > +{ + typedef typename tuple_element<I-1, tuple<Tail...> >::type type; +}; + +template<typename Head, typename... Tail> +struct tuple_element<0, tuple<Head, Tail...> > +{ + typedef Head type; +}; + +// 6.1.3.4 Element access +template<int I, typename Tuple> +class get_impl; + +template<int I, typename Head, typename... Values> +class get_impl<I, tuple<Head, Values...> > +{ + typedef typename tuple_element<I-1, tuple<Values...> >::type Element; + typedef typename add_reference<Element>::type RJ; + typedef typename add_const_reference<Element>::type PJ; + typedef get_impl<I-1, tuple<Values...> > Next; + + public: + static RJ get(tuple<Head, Values...>& t) + { return Next::get(t.tail()); } + + static PJ get(const tuple<Head, Values...>& t) + { return Next::get(t.tail()); } +}; + +template<typename Head, typename... Values> +class get_impl<0, tuple<Head, Values...> > +{ + typedef typename add_reference<Head>::type RJ; + typedef typename add_const_reference<Head>::type PJ; + + public: + static RJ get(tuple<Head, Values...>& t) { return t.head(); } + static PJ get(const tuple<Head, Values...>& t) { return t.head(); } +}; + +template<int I, typename... Values> +typename add_reference< + typename tuple_element<I, tuple<Values...> >::type + >::type +get(tuple<Values...>& t) +{ + return get_impl<I, tuple<Values...> >::get(t); +} + +template<int I, typename... Values> +typename add_const_reference< + typename tuple_element<I, tuple<Values...> >::type + >::type +get(const tuple<Values...>& t) +{ + return get_impl<I, tuple<Values...> >::get(t); +} + +// 6.1.3.5 Relational operators +inline bool operator==(const tuple<>&, const tuple<>&) { return true; } + +template<typename T, typename... TTail, typename U, typename... UTail> +bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) +{ + return t.head() == u.head() && t.tail() == u.tail(); +} + +template<typename... TValues, typename... UValues> +bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return !(t == u); +} + +inline bool operator<(const tuple<>&, const tuple<>&) { return false; } + +template<typename T, typename... TTail, typename U, typename... UTail> +bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) +{ + return (t.head() < u.head() || + (!(t.head() < u.head()) && t.tail() < u.tail())); +} + +template<typename... TValues, typename... UValues> +bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return u < t; +} + +template<typename... TValues, typename... UValues> +bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return !(u < t); +} + +template<typename... TValues, typename... UValues> +bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) +{ + return !(t < u); +} + +int a0[tuple_size<tuple<> >::value == 0? 1 : -1]; +int a1[tuple_size<tuple<int, float, double> >::value == 3? 1 : -1]; +int a2a[is_same<tuple_element<0, tuple<int, float, double> >::type, int> + ::value? 1 : -1]; +int a2b[is_same<tuple_element<1, tuple<int, float, double> >::type, float> + ::value? 1 : -1]; +int a2c[is_same<tuple_element<2, tuple<int, float, double> >::type, double> + ::value? 1 : -1]; + +int main() +{ + tuple<> t0; + tuple<int> t1(1); + tuple<int, float> t2(1, 3.14159f); + tuple<int, float, const char*> t3a(1, 3.14159f, "Hello, world!"); + tuple<long, double, std::string> t3b(t3a); + t3b = t3a; + // t3a = t3b; DPG: triggers an error, as it should. + + tuple<int, float, std::string> t3c = + make_tuple(17, 2.718281828, std::string("Fun")); + + int seventeen = 17; + double pi = 3.14159; + tuple<int&, double&> seventeen_pi = make_tuple(ref(seventeen), ref(pi)); + tuple<int&, const double&> seventeen_pi2 = + make_tuple(ref(seventeen), cref(pi)); + tuple<int&, double&> seventeen_pi_tied = tie(seventeen, pi); + assert(get<0>(t3a) == 1); + assert(get<1>(t3a) == 3.14159f); + assert(std::strcmp(get<2>(t3a), "Hello, world!") == 0); + + assert(t3a == t3b); + assert(!(t3a != t3b)); + assert(!(t3a < t3b)); + assert(!(t3a > t3b)); + assert(t3a <= t3b && t3b <= t3a); + assert(t3a >= t3b && t3b >= t3a); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-unify-2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-unify-2.C new file mode 100644 index 000000000..80c9f5d2c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-unify-2.C @@ -0,0 +1,14 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin: PR c++/40155 +// { dg-options "-std=c++0x" } +// { dg-do compile } + +template <typename T> struct identity +{ typedef T type; }; + +template <typename RT, typename... A> +int forward_call(RT (*) (A...), typename identity<A>::type...); + +int g (double); + +int i = forward_call(&g, 0); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-unify.C b/gcc/testsuite/g++.dg/cpp0x/variadic-unify.C new file mode 100644 index 000000000..54234391e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-unify.C @@ -0,0 +1,15 @@ +// { dg-options "-std=c++0x" } +template<typename...> struct tuple { }; + +template<typename... Args1, typename... Args2> +void foo(tuple<Args1..., Args2...>, tuple<Args1...>, tuple<Args2...>); + +struct X{ }; + +void bar() +{ + tuple<int, float> tif; + tuple<double, X> tdx; + tuple<int, float, double, X> tall; + foo(tall, tif, tdx); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-unresolved.C b/gcc/testsuite/g++.dg/cpp0x/variadic-unresolved.C new file mode 100644 index 000000000..a8463de19 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-unresolved.C @@ -0,0 +1,12 @@ +// PR c++/50086 +// { dg-options -std=c++0x } + +template<typename T> void tfun(); +template<typename T> void fun1(T); +template<typename... Types> void fun2(Types... args); + +int main() +{ + fun1(tfun<int>); // ok + fun2(tfun<int>); // error: unresolved overloaded function type +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-value1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-value1.C new file mode 100644 index 000000000..301bd5463 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-value1.C @@ -0,0 +1,24 @@ +// PR c++/52796 +// { dg-options "-std=c++0x -pedantic-errors" } + +inline void *operator new(__SIZE_TYPE__ s, void *p) { return p; } + +struct A +{ + int i; + template<class... Ts> + A(Ts&&... ts): i(ts...) { } +}; + +static union { + unsigned char c[sizeof(A)]; + int i; +}; + +int main() +{ + i = 0xdeadbeef; + new(c) A; + if (i != 0) + __builtin_abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic1.C b/gcc/testsuite/g++.dg/cpp0x/variadic1.C new file mode 100644 index 000000000..f87d53ca3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic1.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename...> +class tuple; + +template<typename... Args> +class tuple { }; + +template<typename T1, class... Args> +class tuple1p { }; + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic10.C b/gcc/testsuite/g++.dg/cpp0x/variadic10.C new file mode 100644 index 000000000..5f73eba8d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic10.C @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++0x" } +template<typename T1, typename T2> +struct pair {}; + +template<typename... Args> +struct tuple { + static const int value = 0; +}; + +template<> +struct tuple<pair<int, float> > { }; + +template<typename... Outer> +struct X { + template<typename... Inner> + struct Y + { + typedef tuple<pair<Outer, Inner>...> type; // { dg-error "mismatched argument pack lengths" } + }; +}; + +X<int, double>::Y<short, char, double>::type honk; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic100.C b/gcc/testsuite/g++.dg/cpp0x/variadic100.C new file mode 100644 index 000000000..a364bbc91 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic100.C @@ -0,0 +1,15 @@ +// PR c++/43143 +// { dg-options "-std=c++0x" } + +template<typename T> +T&& declval(); + +template<class T, class... Args> +void test() { + T t(declval<Args>()...); +} + +int main() { + test<const int>(); // OK + test<int[23]>(); // Error +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic101.C b/gcc/testsuite/g++.dg/cpp0x/variadic101.C new file mode 100644 index 000000000..445a770af --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic101.C @@ -0,0 +1,23 @@ +// PR c++/43382 +// { dg-options "-std=c++0x" } + +template<class T> +struct Container +{ T f() const; }; + +template<class T> +T deref(const T& t) +{ return t; } + + +template <class T, class... Args> +auto +deref(const T& u, int r, Args... args) +-> decltype(deref(u.f(), args...)) +{ return deref(u.f(), args...); } + +int main(void) +{ + Container<Container<int>> v; + deref(v,1,2); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic102.C b/gcc/testsuite/g++.dg/cpp0x/variadic102.C new file mode 100644 index 000000000..dc9c4aea8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic102.C @@ -0,0 +1,19 @@ +// { dg-options "-std=c++0x" } + +struct nAny { + template<class... T> + nAny(T&&...); +}; + +template<class T> +T&& create(); + +template<class T, class... Args> +void test() { + T t(create<Args>()...); + (void) t; +} + +int main() { + test<nAny>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic103.C b/gcc/testsuite/g++.dg/cpp0x/variadic103.C new file mode 100644 index 000000000..9d6b5ea20 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic103.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } + +template<class T> +T&& create(); + +template<class T, class... Args> +void test() { + T t(create<Args>()...); // { dg-error "incomplete" } + (void) t; +} + +int main() { + test<int[]>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic105.C b/gcc/testsuite/g++.dg/cpp0x/variadic105.C new file mode 100644 index 000000000..24d7e15be --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic105.C @@ -0,0 +1,24 @@ +// PR c++/47289 +// { dg-options -std=c++0x } +// { dg-prune-output "note" } + +template <template <typename... __ARGS> class _F, typename... _ARGS> +auto reverse (_ARGS... args) -> decltype(_F<_ARGS...>::call_function(args...)) { + return _F<_ARGS...>::call_function(args...); +} + +template <typename _T> +_T sum(_T x) { return x; } + +template <typename _T, typename... _ARGS> +_T sum(_T x, _ARGS... args) { return x + sum(args...); } + +template <typename _T, typename... _ARGS> +struct call_sum { + static _T call_function(_T x1, _ARGS... args) { return sum(x1, args...); } +}; + +int main() { + // This shouldn't be an error; this is bug 35722. + reverse<call_sum>(1,2); // { dg-bogus "no match" "" { xfail *-*-* } } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic106.C b/gcc/testsuite/g++.dg/cpp0x/variadic106.C new file mode 100644 index 000000000..80ec0844f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic106.C @@ -0,0 +1,22 @@ +// Origin: PR c++/47326 +// { dg-options "-std=c++0x" } +// { dg-do compile } + +template <int _N> +struct A +{ + typedef int value_type; +}; + +template <typename... _ARGS> +auto +f (_ARGS... args) -> typename A<sizeof...(args)>::value_type +{ + return 12; +} + +int +main() +{ + f(1,2); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic108.C b/gcc/testsuite/g++.dg/cpp0x/variadic108.C new file mode 100644 index 000000000..3ad5af457 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic108.C @@ -0,0 +1,10 @@ +// PR c++/48736 +// { dg-options -std=c++0x } + +template<class T> +T&& create(); + +template<class T, class... Args, + class = decltype(T{create<Args>()...}) // Line X +> +char f(int); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic109.C b/gcc/testsuite/g++.dg/cpp0x/variadic109.C new file mode 100644 index 000000000..0ec69af81 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic109.C @@ -0,0 +1,17 @@ +// PR c++/48292 +// { dg-options -std=c++0x } + +template <typename... Args> int g(Args...); + +template <int N = 0> +struct A +{ + template <typename... Args> + static auto f(Args... args) -> decltype(g(args...)); +}; + +int main() +{ + A<>::f(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic11.C b/gcc/testsuite/g++.dg/cpp0x/variadic11.C new file mode 100644 index 000000000..3c27de0fb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic11.C @@ -0,0 +1,18 @@ +// { dg-options "-std=gnu++0x" } +template<typename...> struct count; + +template<> +struct count<> { + static const int value = 0; +}; + +template<typename T, typename... Args> +struct count<T, Args...> { + static const int value = 1 + count<Args...>::value; +}; + +int a0[count<>::value == 0? 1 : -1]; +int a1[count<char>::value == 1? 1 : -1]; +int a2[count<char, short>::value == 2? 1 : -1]; +int a3[count<char, short, int>::value == 3? 1 : -1]; +int a4[count<char, short, int, long>::value == 4? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic110.C b/gcc/testsuite/g++.dg/cpp0x/variadic110.C new file mode 100644 index 000000000..86f1bb154 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic110.C @@ -0,0 +1,15 @@ +// PR c++/45698 +// { dg-options -std=c++0x } + +template <class... Ts> struct tuple { }; + +template<class... Ts> +struct A { + template<typename T> struct N { }; + tuple<N<Ts>...> tup; +}; + +int main() +{ + A<int, double> a; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic111.C b/gcc/testsuite/g++.dg/cpp0x/variadic111.C new file mode 100644 index 000000000..378162e16 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic111.C @@ -0,0 +1,19 @@ +// PR c++/48424 +// { dg-options -std=c++0x } + +template<typename... Args1> +struct S +{ + template<typename... Args2> + void f(Args1... args1, Args2&&... args2) + { + } +}; + +int main() +{ + S<int, double> s; + s.f(1,2.0,false,'a'); +} + +// { dg-final { scan-assembler "_ZN1SIIidEE1fIIbcEEEvidDpOT_" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic113.C b/gcc/testsuite/g++.dg/cpp0x/variadic113.C new file mode 100644 index 000000000..3f1bb2ad0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic113.C @@ -0,0 +1,20 @@ +// PR c++/49251 +// { dg-options "-std=c++0x -Wunused-parameter" } + +struct A {}; +template <int> int f(A); + +template< int... Indices > +struct indices {}; + +template< class... Args > +void sink( Args&&... ) {} + +template< class T, int... Indices > +void unpack_test( T && t, indices<Indices...> ) { + sink( f<Indices>(t)... ); +} + +int main() { + unpack_test( A(), indices<>() ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic114.C b/gcc/testsuite/g++.dg/cpp0x/variadic114.C new file mode 100644 index 000000000..3ffede5c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic114.C @@ -0,0 +1,27 @@ +// PR c++/49785 +// { dg-options -std=c++0x } + +template <typename, typename ...> struct B { }; +template <typename> class A; + +template <typename R, typename ... S> +struct A <R (S ...)> : public B <R, S ...> +{ + struct C {}; + template <typename D> A (D, C = C ()) { } + R operator () (...); +}; + +template <typename R, typename ... S, typename T> +auto operator >> (A <R (S ...)>, T)->A <R (S ...)> +{ + []() {}; +} + +int +main () +{ + A <int (int, int)> a = [](int, int) {}; + auto b = []{}; + (a >> b) (3, 5); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic115.C b/gcc/testsuite/g++.dg/cpp0x/variadic115.C new file mode 100644 index 000000000..fa032e3b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic115.C @@ -0,0 +1,19 @@ +// PR c++/49593 +// { dg-options -std=c++0x } + +template<typename... T> void f(T...) { } + +template<typename... Args> +static void +g(Args&&... args) +{ + f( static_cast<Args>(args)... ); + f( (Args)args... ); + f( Args(args)... ); + f( Args{args}... ); +} + +int main() +{ + g(1, '2', 3.0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic116.C b/gcc/testsuite/g++.dg/cpp0x/variadic116.C new file mode 100644 index 000000000..079d751cb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic116.C @@ -0,0 +1,32 @@ +// Origin: PR c++/48320 +// { dg-options -std=c++0x } + +template<class... T> +struct tuple +{ + typedef int type; +}; + +template<int... Indices> +struct indices +{ +}; + +template<unsigned i, class Tuple> +struct tuple_element +{ + typedef Tuple type; +}; + +template<class Tuple, + int... Indices, + class Result = tuple<typename tuple_element<Indices, Tuple>::type...> > +Result +f(Tuple&&, indices<Indices...>); + + +void +foo() +{ + f(tuple<int, char, unsigned> (), indices<2, 1, 0> ()); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic12.C b/gcc/testsuite/g++.dg/cpp0x/variadic12.C new file mode 100644 index 000000000..30108c999 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic12.C @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// A tuple type +template<typename... Args> struct tuple { }; + +// Determine if two types are the same +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +// Append 'T' to the end of Tuple +template<typename T, typename Tuple> +struct append_to_tuple; + +template<typename T, typename... Args> +struct append_to_tuple<T, tuple<Args...> > { + typedef tuple<Args..., T> type; +}; + +// Reverse a sequence of arguments (and return the result as a tuple) +template<typename... Args> struct reverse; + +template<typename T, typename... Args> +struct reverse<T, Args...> { + typedef typename append_to_tuple<T, typename reverse<Args...>::type>::type + type; +}; + +template<> +struct reverse<> { + typedef tuple<> type; +}; + +int a0[is_same<reverse<>::type, tuple<> >::value? 1 : -1]; +int a1[is_same<reverse<int>::type, tuple<int> >::value? 1 : -1]; +int a2[is_same<reverse<char, int>::type, tuple<int, char> >::value? 1 : -1]; +int a3[is_same<reverse<char, int, long>::type, tuple<long, int, char> >::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic13.C b/gcc/testsuite/g++.dg/cpp0x/variadic13.C new file mode 100644 index 000000000..7794e8a3d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic13.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> struct tuple1 { }; +template<typename... Args> struct tuple2 { }; + +template<typename T, typename U> +struct same_tuple_args { + static const bool value = false; +}; + +template<typename... Args> +struct same_tuple_args<tuple1<Args...>, tuple2<Args...> > { + static const bool value = true; +}; + +int same0[same_tuple_args<tuple1<>, tuple2<> >::value? 1 : -1]; +int same1[same_tuple_args<tuple1<int>, tuple2<int> >::value? 1 : -1]; +int same2[same_tuple_args<tuple1<float, int>, tuple2<float, int> >::value? 1 : -1]; +int diff0[!same_tuple_args<tuple1<>, tuple2<int> >::value? 1 : -1]; +int diff1[!same_tuple_args<tuple1<int, float>, tuple2<float, int> >::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic134.C b/gcc/testsuite/g++.dg/cpp0x/variadic134.C new file mode 100644 index 000000000..b7ec40c04 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic134.C @@ -0,0 +1,17 @@ +// PR c++/53862 +// { dg-options "-std=c++0x" } + +typedef unsigned long size_t; + +template<typename> struct is_scalar { static const bool value = true; }; +template<bool, typename T> struct enable_if { typedef T type; }; + +template <size_t N, typename... Args> +void f(Args...) {} + +template <size_t N, typename T, typename... Args> +typename enable_if<is_scalar<T>::value, void>::type f(T, Args...) {} + +int main() { + f<1>(1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic14.C b/gcc/testsuite/g++.dg/cpp0x/variadic14.C new file mode 100644 index 000000000..3c1bb0d6d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic14.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template<typename R, typename... ArgTypes> +struct make_function_type +{ + typedef R type(ArgTypes...); +}; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +int a0[is_same<make_function_type<int>::type, int()>::value? 1 : -1]; +int a1[is_same<make_function_type<int, float>::type, int(float)>::value? 1 : -1]; +int a2[is_same<make_function_type<int, float>::type, int(float)>::value? 1 : -1]; +int a3[is_same<make_function_type<int, float, double>::type, int(float, double)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic15.C b/gcc/testsuite/g++.dg/cpp0x/variadic15.C new file mode 100644 index 000000000..68786cb82 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic15.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template<typename R, typename... ArgTypes> +struct make_function_type +{ + typedef R type(const ArgTypes&...); +}; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +int a0[is_same<make_function_type<int>::type, int()>::value? 1 : -1]; +int a1[is_same<make_function_type<int, float>::type, int(const float&)>::value? 1 : -1]; +int a2[is_same<make_function_type<int, float>::type, int(const float&)>::value? 1 : -1]; +int a3[is_same<make_function_type<int, float, double>::type, int(const float&, double const&)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic16.C b/gcc/testsuite/g++.dg/cpp0x/variadic16.C new file mode 100644 index 000000000..001919d46 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic16.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template<typename R, typename... ArgTypes> +struct make_function_type +{ + typedef R type(const ArgTypes&... args); +}; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +int a0[is_same<make_function_type<int>::type, int()>::value? 1 : -1]; +int a1[is_same<make_function_type<int, float>::type, int(const float&)>::value? 1 : -1]; +int a2[is_same<make_function_type<int, float>::type, int(const float&)>::value? 1 : -1]; +int a3[is_same<make_function_type<int, float, double>::type, int(const float&, double const&)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic17.C b/gcc/testsuite/g++.dg/cpp0x/variadic17.C new file mode 100644 index 000000000..986721bbe --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic17.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template<typename R, typename... ArgTypes> +struct make_function_type +{ + typedef R type(const ArgTypes&......); +}; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +int a0[is_same<make_function_type<int>::type, int(...)>::value? 1 : -1]; +int a1[is_same<make_function_type<int, float>::type, int(const float&...)>::value? 1 : -1]; +int a2[is_same<make_function_type<int, float>::type, int(const float&,...)>::value? 1 : -1]; +int a3[is_same<make_function_type<int, float, double>::type, int(const float&, double const&...)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic18.C b/gcc/testsuite/g++.dg/cpp0x/variadic18.C new file mode 100644 index 000000000..147ed8e4b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic18.C @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +template<typename...> class tuple { }; + +template<typename T, template<typename T> class... Metafunctions> +struct apply_all +{ + typedef tuple<typename Metafunctions<T>::type...> type; +}; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +template<typename T> +struct add_pointer { + typedef T* type; +}; + +template<typename T> +struct add_pointer<T&> +{ + typedef T& type; +}; + +template<typename T> +struct add_reference { + typedef T& type; +}; + +template<typename T> +struct add_reference<T&> +{ + typedef T& type; +}; + +int a0[is_same<apply_all<int>::type,tuple<> >::value? 1 : -1]; +int a1[is_same<apply_all<int, add_pointer>::type,tuple<int*> >::value? 1 : -1]; +int a2[is_same<apply_all<int, add_pointer, add_reference>::type,tuple<int*, int&> >::value? 1 : -1]; +int a3[is_same<apply_all<int&, add_pointer, add_reference>::type,tuple<int&, int&> >::value? 1 : -1]; + + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic19.C b/gcc/testsuite/g++.dg/cpp0x/variadic19.C new file mode 100644 index 000000000..92e7a953a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic19.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +struct tuple { + static const int value = 0; +}; + +template<typename T, template<class T> class... Metafunctions> +struct tuple<Metafunctions<T>...> { + static const int value = 1; +}; + +template<typename T> struct add_pointer; +template<typename T> struct add_reference; + +int a0[tuple<int, float>::value == 0? 1 : -1]; +int a1[tuple<add_pointer<int>, add_pointer<float> >::value == 0? 1 : -1]; +int a2[tuple<>::value == 0? 1 : -1]; +int a3[tuple<add_pointer<int> >::value == 1? 1 : -1]; +int a4[tuple<add_pointer<int>, add_reference<int> >::value == 1? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic2.C b/gcc/testsuite/g++.dg/cpp0x/variadic2.C new file mode 100644 index 000000000..d62a54245 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic2.C @@ -0,0 +1,17 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args = int> // { dg-error "default argument" } +class tuple2; + +template<typename... = int> // { dg-error "default argument" } +class tuple3; + +template<typename T1, typename T2, typename... Rest> +struct two_or_more {}; // { dg-error "provided for" } + +typedef two_or_more<int> bad; // { dg-error "2 or more" } +// { dg-error "invalid type" "" { target *-*-* } 11 } + +void f() +{ + two_or_more<int, float> z = 5; // { dg-error "two_or_more<int, float>" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic20.C b/gcc/testsuite/g++.dg/cpp0x/variadic20.C new file mode 100644 index 000000000..7f2446e55 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic20.C @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +template<typename T> struct add_pointer; +template<typename T> struct add_reference; + +template<template<class T> class... Metafunctions> +struct metatuple { + static const int value = 0; +}; + +template<> +struct metatuple<add_pointer> { + static const int value = 1; +}; + +template<template<class T> class Meta> +struct metatuple<Meta, Meta> { // { dg-error "candidates" } + static const int value = 2; +}; + +template<template<class T> class... Metafunctions> +struct metatuple<add_pointer, Metafunctions...> { // { dg-error "" } + static const int value = 3; +}; + +template<template<class T> class First, + template<class T> class... Metafunctions> +struct metatuple<First, Metafunctions...> { // { dg-error "struct" } + static const int value = 4; +}; + +template<template<class T> class First, + template<class T> class Second, + template<class T> class... Metafunctions> +struct metatuple<First, Second, Metafunctions...> { // { dg-error "struct" } + static const int value = 5; +}; + +int a0[metatuple<>::value == 0? 1 : -1]; +int a1[metatuple<add_pointer>::value == 1? 1 : -1]; +int a2a[metatuple<add_pointer, add_pointer>::value == 2? 1 : -1]; // { dg-error "ambiguous|array bound" } +int a2b[metatuple<add_reference, add_reference>::value == 2? 1 : -1]; +int a3[metatuple<add_pointer, add_reference>::value == 3? 1 : -1]; // { dg-error "ambiguous|array bound" } +int a4[metatuple<add_reference>::value == 4? 1 : -1]; +int a5[metatuple<add_reference, add_pointer>::value == 5? 1 : -1]; + +// { dg-error "incomplete" "" { target *-*-* } 40 } +// { dg-error "incomplete" "" { target *-*-* } 42 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic21.C b/gcc/testsuite/g++.dg/cpp0x/variadic21.C new file mode 100644 index 000000000..b65e995b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic21.C @@ -0,0 +1,7 @@ +// { dg-options "-std=gnu++0x" } +template<typename T, int... Dims> +struct array { }; + +array<int> a0; +array<int, 1> a1; +array<int, 1, 2, 3, 4> a1234; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic22.C b/gcc/testsuite/g++.dg/cpp0x/variadic22.C new file mode 100644 index 000000000..1d26e40d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic22.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +template<typename R, typename... ArgTypes> +struct make_function_type +{ + typedef R type(ArgTypes... args); +}; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +int a0[is_same<make_function_type<int>::type, int()>::value? 1 : -1]; +int a1[is_same<make_function_type<int, float>::type, int(float)>::value? 1 : -1]; +int a2[is_same<make_function_type<int, float>::type, int(float)>::value? 1 : -1]; +int a3[is_same<make_function_type<int, float, double>::type, int(float, double const)>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic23.C b/gcc/testsuite/g++.dg/cpp0x/variadic23.C new file mode 100644 index 000000000..43309a1e1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic23.C @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +template<typename T, int... Dims> +struct array { + static const int value = 0; +}; + +template<> +struct array<int, 17> { + static const int value = 1; +}; + +template<int... Dims> +struct array<float, 1, Dims...> { + static const int value = 2; +}; + +template<typename T, int... Dims> +struct array<T, 1, Dims...> { + static const int value = 3; +}; + +int a0[array<int>::value == 0? 1 : -1]; +int a1[array<int, 17>::value == 1? 1 : -1]; +int a2[array<float, 1, 2, 3>::value == 2? 1 : -1]; +int a3[array<double, 1, 2, 3>::value == 3? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic24.C b/gcc/testsuite/g++.dg/cpp0x/variadic24.C new file mode 100644 index 000000000..6ef8e8a77 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic24.C @@ -0,0 +1,6 @@ +// { dg-options "-std=gnu++0x" } +template<typename T, T... Values> +struct vector_c { }; + +vector_c<int, 17, 42> intvec; +vector_c<char, 'a', 'b', 'c'> charvec; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic25.C b/gcc/testsuite/g++.dg/cpp0x/variadic25.C new file mode 100644 index 000000000..6589e7f60 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic25.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +template<int... Values> +struct sum; + +template<> +struct sum<> { + static const int value = 0; +}; + +template<int Value, int... Values> +struct sum<Value, Values...> { + static const int value = Value + sum<Values...>::value; +}; + +int a0[sum<>::value == 0? 1 : -1]; +int a1[sum<1, 2, 3, 4, 5>::value == 15? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic26.C b/gcc/testsuite/g++.dg/cpp0x/variadic26.C new file mode 100644 index 000000000..7f9f6bc80 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic26.C @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +template<template<int, int> class Meta, int Initial, int... Values> +struct accumulate { + static const int value = Initial; +}; + +template<template<int, int> class Meta, int Initial, int Value, int... Rest> +struct accumulate<Meta, Initial, Value, Rest...> { + static const int value = + Meta<Value, accumulate<Meta, Initial, Rest...>::value>::value; +}; + +template<int X, int Y> +struct sum { + static const int value = X + Y; +}; + +template<int X, int Y> +struct prod { + static const int value = X * Y; +}; + +int a0[accumulate<sum,0,1,2,3,4,5>::value == 15? 1 : -1]; +int a1[accumulate<prod,1,1,2,3,4,5>::value == 120? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic27.C b/gcc/testsuite/g++.dg/cpp0x/variadic27.C new file mode 100644 index 000000000..45a897ce2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic27.C @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++0x" } +template<typename Signature> +struct function_traits; + +template<typename R, typename... ArgTypes> +struct function_traits<R(ArgTypes...)> { + typedef R result_type; +}; + +template<typename T, typename U> +struct same_type { + static const bool value = false; +}; + +template<typename T> +struct same_type<T, T> { + static const bool value = true; +}; + +int a0[same_type<function_traits<int()>::result_type, int>::value? 1 : -1]; +int a1[same_type<function_traits<int(float)>::result_type, int>::value? 1 : -1]; +int a2[same_type<function_traits<int(double, char)>::result_type, int>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic28.C b/gcc/testsuite/g++.dg/cpp0x/variadic28.C new file mode 100644 index 000000000..167088b49 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic28.C @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +template<typename Signature> +struct function_traits; + +template<typename R, typename... ArgTypes> +struct function_traits<R(ArgTypes......)> { + typedef R result_type; +}; + +template<typename T, typename U> +struct same_type { + static const bool value = false; +}; + +template<typename T> +struct same_type<T, T> { + static const bool value = true; +}; + +int a0[same_type<function_traits<int(double, char...)>::result_type, int>::value? 1 : -1]; +int a1[same_type<function_traits<int(double, char,...)>::result_type, int>::value? 1 : -1]; +int a2[same_type<function_traits<int(char,...)>::result_type, int>::value? 1 : -1]; +int a3[same_type<function_traits<int(...)>::result_type, int>::value? 1 : -1]; +int a4[same_type<function_traits<int(double x, char...)>::result_type, int>::value? 1 : -1]; +int a5[same_type<function_traits<int(double, char y...)>::result_type, int>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic29.C b/gcc/testsuite/g++.dg/cpp0x/variadic29.C new file mode 100644 index 000000000..aaed59583 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic29.C @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +template<typename Signature> +struct function_traits; + +template<typename R, typename... ArgTypes> +struct function_traits<R(ArgTypes...)> { + typedef R result_type; +}; + +template<typename R, typename Class, typename... ArgTypes> +struct function_traits<R (Class::*)(ArgTypes...)> { + typedef R result_type; +}; + +template<typename R, typename Class, typename... ArgTypes> +struct function_traits<R (Class::*)(ArgTypes...) const> { + typedef R result_type; +}; + +template<typename T, typename U> +struct same_type { + static const bool value = false; +}; + +template<typename T> +struct same_type<T, T> { + static const bool value = true; +}; + +struct X {}; + +int a0[same_type<function_traits<int (X::*)()>::result_type, int>::value? 1 : -1]; +int a1[same_type<function_traits<int (X::*)(float)>::result_type, int>::value? 1 : -1]; +int a2[same_type<function_traits<int (X::*)(double, char)>::result_type, int>::value? 1 : -1]; +int a3[same_type<function_traits<int (X::*)(double, char) const>::result_type, int>::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic3.C b/gcc/testsuite/g++.dg/cpp0x/variadic3.C new file mode 100644 index 000000000..42ba8ab47 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic3.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +class tuple {}; + +void f() +{ + tuple<> x; + tuple<int> y; + tuple<int, float> z; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic30.C b/gcc/testsuite/g++.dg/cpp0x/variadic30.C new file mode 100644 index 000000000..66cbe9f62 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic30.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template<typename... T> +void eat(T...); + +void f() +{ + eat(); + eat(1); + eat(1, 2); + eat(17, 3.14159, "Hello, World!"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic31.C b/gcc/testsuite/g++.dg/cpp0x/variadic31.C new file mode 100644 index 000000000..db8daa898 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic31.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x -g" } +template<typename... T> +void eat(T...) { } + +void f() +{ + eat(); + eat(1); + eat(1, 2); + eat(17, 3.14159, "Hello, World!"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic32.C b/gcc/testsuite/g++.dg/cpp0x/variadic32.C new file mode 100644 index 000000000..c5bee55cc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic32.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template<typename... T> +void eat(const T&...) { } + +void f() +{ + eat(); + eat(1); + eat(1, 2); + eat(17, 3.14159, "Hello, World!"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic33.C b/gcc/testsuite/g++.dg/cpp0x/variadic33.C new file mode 100644 index 000000000..5784be887 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic33.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +void print_all() {} + +template<typename T, typename... Rest> +void print_all(const T& t, const Rest&... rest) +{ + print_all(rest...); +} + +void f() +{ + print_all(); + print_all(1); + print_all(1, 3.14159); + print_all("Hello, World!", 17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic34.C b/gcc/testsuite/g++.dg/cpp0x/variadic34.C new file mode 100644 index 000000000..5eee3f13c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic34.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template<int I, typename... Args> +void get_ith(const Args&... args); + +void f() +{ + get_ith<1>(1, 2, 3); + get_ith<1, int>(1, 2.0, 'x'); + get_ith<1, int, double>(1, 2.0, 'x'); + get_ith<1, int, double, char>(1, 2.0, 'x'); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic35.C b/gcc/testsuite/g++.dg/cpp0x/variadic35.C new file mode 100644 index 000000000..1f21976e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic35.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<int I, typename... Args> +void get_ith(const Args&... args); // { dg-message "note" } + +void f() +{ + get_ith<1, float>(1, 2.0, 'x'); + get_ith<1, int, double, char, int>(1, 2.0, 'x'); // { dg-error "no matching function" } + // { dg-message "candidate" "candidate note" { target *-*-* } 8 } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic36.C b/gcc/testsuite/g++.dg/cpp0x/variadic36.C new file mode 100644 index 000000000..906360204 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic36.C @@ -0,0 +1,15 @@ +// { dg-options "-std=gnu++0x" } +template<typename T, typename... Args> +void f(const T&, const Args&... args) +{ + f(args); // { dg-error "packs not expanded" } +} + +template<typename... Values> +struct tuple_base { }; + +template<typename... Values> +struct tuple : tuple_base<Values> { }; // { dg-error "packs not expanded" } + +// { dg-message "args" "note" { target *-*-* } 5 } +// { dg-message "Values" "note" { target *-*-* } 12 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic37.C b/gcc/testsuite/g++.dg/cpp0x/variadic37.C new file mode 100644 index 000000000..a6e5f613f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic37.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Values> +struct tuple +{ + static const __SIZE_TYPE__ length = sizeof...(Values); +}; + +int a0[tuple<>::length == 0? 1 : -1]; +int a1[tuple<int>::length == 1? 1 : -1]; +int a2[tuple<int, float>::length == 2? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic38.C b/gcc/testsuite/g++.dg/cpp0x/variadic38.C new file mode 100644 index 000000000..e4ae4a630 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic38.C @@ -0,0 +1,6 @@ +// { dg-options "-std=gnu++0x" } +template<int... Values> +struct int_vec {}; + +template<int... Values> +struct int_vec<0, (Values+1)...> {}; // { dg-error "involves template parameter" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic39.C b/gcc/testsuite/g++.dg/cpp0x/variadic39.C new file mode 100644 index 000000000..bd656ba85 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic39.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +struct tuple {}; + +template<typename T, typename... Args> +struct tuple<Args..., T> { }; // { dg-error "end" } + + +template<int... Values> +struct int_vec { }; + +template<int I, int... Values> +struct int_vec<Values..., I> { }; // { dg-error "end" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic4.C b/gcc/testsuite/g++.dg/cpp0x/variadic4.C new file mode 100644 index 000000000..9257a92d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic4.C @@ -0,0 +1,15 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +template<typename... Args> +class tuple {}; + +void f_none(tuple<>) {} +void f_one(tuple<int>) {} +void f_two(tuple<int, float>) {} +void f_nested(tuple<int, tuple<double, char>, float>) { } + + +// { dg-final { scan-assembler "_Z6f_none5tupleIIEE" } } +// { dg-final { scan-assembler "_Z5f_one5tupleIIiEE" } } +// { dg-final { scan-assembler "_Z5f_two5tupleIIifEE" } } +// { dg-final { scan-assembler "_Z8f_nested5tupleIIiS_IIdcEEfEE" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic40.C b/gcc/testsuite/g++.dg/cpp0x/variadic40.C new file mode 100644 index 000000000..6cc9273a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic40.C @@ -0,0 +1,3 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Values, typename T> +struct backward_tuple {}; // { dg-error "end" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic41.C b/gcc/testsuite/g++.dg/cpp0x/variadic41.C new file mode 100644 index 000000000..9cfd847f3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic41.C @@ -0,0 +1,14 @@ +// A function parameter pack is only deduced if it's at the end +// { dg-options "-std=gnu++0x" } +template<typename... Args> +void f(const Args&... args, int oops); + +int main() +{ + f<>(1); + f(1); + f<int>(1,2); + f(1,2); // { dg-error "no match" } +} + +// { dg-prune-output "note" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic42.C b/gcc/testsuite/g++.dg/cpp0x/variadic42.C new file mode 100644 index 000000000..47d9b66da --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic42.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +template<typename... Args> +void f(Args...) { } + +void g() +{ + f<int*, float*, double*>(0, 0, 0); + f<int*>(0,0,0); +} +// { dg-final { scan-assembler "_Z1fIIPiPfPdEEvDpT_" } } +// { dg-final { scan-assembler "_Z1fIIPiiiEEvDpT_" } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic43.C b/gcc/testsuite/g++.dg/cpp0x/variadic43.C new file mode 100644 index 000000000..fce81ae0d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic43.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +int f(const Args&...); + +void g() +{ + int (*fp)(const int&, const float&) = &f; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic44.C b/gcc/testsuite/g++.dg/cpp0x/variadic44.C new file mode 100644 index 000000000..8452a96cc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic44.C @@ -0,0 +1,13 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +template<typename... Args> +int f(const Args&...); + +template<typename T> void g(T) { } + +void h() +{ + g(&f<int, float>); +} + +// { dg-final { scan-assembler "_Z1gIPFiRKiRKfEEvT_"} } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic45.C b/gcc/testsuite/g++.dg/cpp0x/variadic45.C new file mode 100644 index 000000000..c5a66ab20 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic45.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +int& f(Args...); + +template<typename T1, typename T2> +float& f(T1, T2); + +float& g() { + return f(17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic46.C b/gcc/testsuite/g++.dg/cpp0x/variadic46.C new file mode 100644 index 000000000..8b81a363b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic46.C @@ -0,0 +1,11 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +int& f(Args&...); + +template<typename... Args> +float& f(const Args&...); + +int& g(int x, float y) +{ + return f(x, y); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic47.C b/gcc/testsuite/g++.dg/cpp0x/variadic47.C new file mode 100644 index 000000000..d80371c0e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic47.C @@ -0,0 +1,18 @@ +// { dg-options "-std=gnu++0x" } +template<typename T> struct wrap { }; + +template<typename... Args> +int& f(const Args&...); + +template<typename... Args> +float& f(const wrap<Args>&...); + +int& g(int x, float y, double z) +{ + return f(x, y, z); +} + +float& h(wrap<int> x, wrap<float> y, wrap<double> z) +{ + return f(x, y, z); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic48.C b/gcc/testsuite/g++.dg/cpp0x/variadic48.C new file mode 100644 index 000000000..ab3f777f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic48.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename T, typename... Args> +int& f(const T&, Args...); + +template<typename T> +float& f(const T&); + +float& g() { + return f(17); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic49.C b/gcc/testsuite/g++.dg/cpp0x/variadic49.C new file mode 100644 index 000000000..7e2215f2c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic49.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +int& f(...); + +template<typename... Args> +float& f(Args...); + +float& g() { + return f(17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic5.C b/gcc/testsuite/g++.dg/cpp0x/variadic5.C new file mode 100644 index 000000000..d1f333566 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic5.C @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +struct tuple { + static const int value = 0; +}; + +template<> +struct tuple<> { + static const int value = 1; +}; + +template<> +struct tuple<int> { + static const int value = 2; +}; + + +template<> +struct tuple<int, float> { + static const int value = 3; +}; + +template<typename T> +struct tuple<T, T> { + static const int value = 4; +}; + +template<> +struct tuple<float, float> { + static const int value = 5; +}; + +int a0[tuple<float>::value == 0? 1 : -1]; +int a1[tuple<>::value == 1? 1 : -1]; +int a2[tuple<int>::value == 2? 1 : -1]; +int a3[tuple<int, float>::value == 3? 1 : -1]; +int a4[tuple<int, int>::value == 4? 1 : -1]; +int a5[tuple<float, float>::value == 5? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic50.C b/gcc/testsuite/g++.dg/cpp0x/variadic50.C new file mode 100644 index 000000000..a2c3b7c90 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic50.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } +int& f(int, double, ...); + +template<typename... Args> +float& f(Args...); + +float& g() { + return f(17, 3.14159, 3); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic51.C b/gcc/testsuite/g++.dg/cpp0x/variadic51.C new file mode 100644 index 000000000..e2e2d630a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic51.C @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++0x" } +template<typename T1, typename T2> +float& f(T1, T2); + +template<typename... Args> +int& f(Args...); + +float& g() { + return f(17, 3.14159); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic52.C b/gcc/testsuite/g++.dg/cpp0x/variadic52.C new file mode 100644 index 000000000..12b121fe4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic52.C @@ -0,0 +1,7 @@ +// { dg-options "-std=gnu++0x" } +template<typename T, T... Values> +struct vector_c { }; + +vector_c<int, 1, 2, 3> v1; +vector_c<char, 'a', 'b', 'c'> v2; +vector_c<long, 1u, 2, 3l> v3; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic53.C b/gcc/testsuite/g++.dg/cpp0x/variadic53.C new file mode 100644 index 000000000..09a3879b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic53.C @@ -0,0 +1,17 @@ +// { dg-options "-std=gnu++0x" } +template<typename F, typename... BoundArgs> +class bound_functor +{ + public: + typedef typename F::result_type result_type; + + template<typename... Args> + typename F::result_type operator()(Args&... args); +}; + +template<typename F, typename... BoundArgs> +template<typename... Args> +typename F::result_type +bound_functor<F, BoundArgs...>::operator()(Args&... args) +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic54.C b/gcc/testsuite/g++.dg/cpp0x/variadic54.C new file mode 100644 index 000000000..db750d765 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic54.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template<typename F, typename... BoundArgs> +class bound_functor +{ + public: + bound_functor(); +}; + +template<typename F, typename... BoundArgs> +bound_functor<F, BoundArgs...>::bound_functor() +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic55.C b/gcc/testsuite/g++.dg/cpp0x/variadic55.C new file mode 100644 index 000000000..b9c8cffb0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic55.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template<typename F, typename... BoundArgs> +class bound_functor +{ + public: + bound_functor(const BoundArgs&... bound_args); +}; + +template<typename F, typename... BoundArgs> +bound_functor<F, BoundArgs...>::bound_functor(const BoundArgs&...) +{ +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic56.C b/gcc/testsuite/g++.dg/cpp0x/variadic56.C new file mode 100644 index 000000000..77846e513 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic56.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Elements> +struct tuple { }; + +template<typename T, typename... Elements> +struct tuple<T, Elements...> { + int foo(); +}; + +template<typename T, typename... Elements> +struct tuple<T*, Elements...> { + int bar(); +}; + +template<typename T, typename... Elements> +int tuple<T, Elements...>::foo() { return 0; } + +template<typename T, typename... Elements> +int tuple<T*, Elements...>::bar() { return 0; } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic57.C b/gcc/testsuite/g++.dg/cpp0x/variadic57.C new file mode 100644 index 000000000..9833b1bb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic57.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +template<typename T, int... Dims> +struct array { + int foo(); +}; + +template<typename T> +struct array<T, 0> { + int bar(); +}; + +template<typename T, int... Dims> +int array<T, Dims...>::foo() { } + +template<typename T> +int array<T, 0>::bar() { } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic58.C b/gcc/testsuite/g++.dg/cpp0x/variadic58.C new file mode 100644 index 000000000..5da0730b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic58.C @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++0x" } +#include <typeinfo> + +template<typename... Args> +void foo(Args...) { } + +template<typename... Args> +void bar(Args... args) { + foo(Args()...); + foo(args = args...); + foo(reinterpret_cast<void*>(&args)...); + foo(const_cast<const Args>(args)...); + foo(static_cast<void*>(&args)...); + foo(dynamic_cast<void*>(&args)...); + foo(typeid(Args)...); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic59.C b/gcc/testsuite/g++.dg/cpp0x/variadic59.C new file mode 100644 index 000000000..6d6e52f93 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic59.C @@ -0,0 +1,4 @@ +// { dg-options "-std=gnu++0x" } +template<class T, typename... VarArgs> +void print(T t, VarArgs args); // { dg-error "packs not expanded" } +// { dg-message "VarArgs" "note" { target *-*-* } 3 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic6.C b/gcc/testsuite/g++.dg/cpp0x/variadic6.C new file mode 100644 index 000000000..105550bb9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic6.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template<typename ... Args> +struct tuple_base {}; + +template<typename ... Args> +struct tuple : public tuple_base<Args...> +{ +}; + +tuple<> zero; +tuple<int> one; +tuple<float, int> two; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic60.C b/gcc/testsuite/g++.dg/cpp0x/variadic60.C new file mode 100644 index 000000000..b86711ff6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic60.C @@ -0,0 +1 @@ +template<typename... Args> class tuple; // { dg-error "variadic templates" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic61.C b/gcc/testsuite/g++.dg/cpp0x/variadic61.C new file mode 100644 index 000000000..d06c5f6b9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic61.C @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++98 -pedantic" } +template<typename... Args> class tuple; // { dg-warning "variadic templates" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic62.C b/gcc/testsuite/g++.dg/cpp0x/variadic62.C new file mode 100644 index 000000000..010b3a5d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic62.C @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++98 -pedantic-errors" } +template<typename... Args> class tuple; // { dg-error "variadic templates" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic63.C b/gcc/testsuite/g++.dg/cpp0x/variadic63.C new file mode 100644 index 000000000..359def1cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic63.C @@ -0,0 +1,2 @@ +// { dg-options "-std=gnu++0x -pedantic" } +template<typename... Args> class tuple; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic64.C b/gcc/testsuite/g++.dg/cpp0x/variadic64.C new file mode 100644 index 000000000..c9212e2e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic64.C @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++0x" } +template<int... Indexes> + struct _Index_tuple { }; + +template<int _Num, typename _Tuple = _Index_tuple<> > +struct _Build_index_tuple; + +template<int _Num, int... _Indexes> +struct _Build_index_tuple<_Num, _Index_tuple<_Indexes...> > + : _Build_index_tuple<_Num - 1, + _Index_tuple<_Indexes..., sizeof...(_Indexes)> > +{ +}; + +template<int... _Indexes> +struct _Build_index_tuple<0, _Index_tuple<_Indexes...> > +{ + typedef _Index_tuple<_Indexes...> __type; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic65.C b/gcc/testsuite/g++.dg/cpp0x/variadic65.C new file mode 100644 index 000000000..1c815d1d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic65.C @@ -0,0 +1,8 @@ +// { dg-options "-std=gnu++0x" } +struct unused; +template<typename T1 = unused, typename T2 = unused, typename T3 = unused, + typename T4 = unused, typename T5 = unused, typename T6 = unused> +struct tuple {}; + +template<typename... Args> +void foo(tuple<Args...>) { } // { dg-bogus "cannot expand" "" { xfail *-*-* } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic66.C b/gcc/testsuite/g++.dg/cpp0x/variadic66.C new file mode 100644 index 000000000..5c31ae06f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic66.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++0x" } + +template<typename Result, typename Functor, typename... ArgTypes> +Result bind(Functor, ArgTypes...) { } + +void f() +{ + bind<int>(17, 20, 22); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic67.C b/gcc/testsuite/g++.dg/cpp0x/variadic67.C new file mode 100644 index 000000000..e496bfc17 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic67.C @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Elements> struct tuple {}; + +template<typename... Args> +struct nested +{ + typedef tuple<tuple<Args, Args...>...> type; +}; + +template<typename T, typename U> +struct is_same +{ + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> +{ + static const bool value = true; +}; + +int a0[is_same<nested<int, float>::type, + tuple<tuple<int, int, float>, + tuple<float, int, float> > >::value? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic68.C b/gcc/testsuite/g++.dg/cpp0x/variadic68.C new file mode 100644 index 000000000..07cf8e389 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic68.C @@ -0,0 +1,23 @@ +// { dg-do run } +// { dg-options "-std=gnu++0x" } +extern "C" void abort(); + +template<typename T, T... Values> +void f(T* expected_values, int n) +{ + if (sizeof...(Values) != n) + abort (); + + T values[] = { Values... }; + for (int i = 0; i < n; ++i) + if (values[i] != expected_values[i]) + abort(); +} + +int main() +{ + int test_arr1[3] = { 1, 2, 3 }; + f<int, 1, 2, 3>(test_arr1, 3); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic69.C b/gcc/testsuite/g++.dg/cpp0x/variadic69.C new file mode 100644 index 000000000..5fe9a1950 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic69.C @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +template<typename T> +struct stored_value +{ + explicit stored_value() : value() { } + + explicit stored_value(const T& value) : value(value) { } + + stored_value(int, const T& value) : value(value) { } + + T value; +}; + +template<typename... Values> +struct myclass : public stored_value<Values>... +{ + myclass() { } + + explicit myclass(const Values&... values) + : stored_value<Values>(values)... { } + + explicit myclass(int x, const Values&... values) + : stored_value<Values>(x, values)... { } + +}; + +void f() +{ + int i; + float f; + myclass<int*, float*> ifp1; + myclass<int*, float*> ifp2(&i, &f); + myclass<int*, float*> ifp3(1, &i, &f); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic7.C b/gcc/testsuite/g++.dg/cpp0x/variadic7.C new file mode 100644 index 000000000..3ba37bfb6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic7.C @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +struct tuple_base { + static const int value = 0; +}; + +template<> +struct tuple_base<int> { + static const int value = 1; +}; + +template<> +struct tuple_base<int, float> { + static const int value = 2; +}; + +template<> +struct tuple_base<float, int> { + static const int value = 3; +}; + +template<typename... Args> +struct int_tuple : tuple_base<int, Args...> { }; + +template<typename... Args> +struct tuple_int : tuple_base<Args..., int> { }; + +int a0a[int_tuple<int>::value == 0? 1 : -1]; +int a0b[int_tuple<int>::value == 0? 1 : -1]; +int a1a[int_tuple<>::value == 1? 1 : -1]; +int a1b[tuple_int<>::value == 1? 1 : -1]; +int a2[int_tuple<float>::value == 2? 1 : -1]; +int a3[tuple_int<float>::value == 3? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic70.C b/gcc/testsuite/g++.dg/cpp0x/variadic70.C new file mode 100644 index 000000000..15bed461d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic70.C @@ -0,0 +1,22 @@ +// { dg-do run } +// { dg-options "-std=gnu++0x" } +template <typename T, T... Args> struct bomb; + +template <typename T> +struct bomb<T> { + static const T value = 0; +}; + +template <typename T, T v, T... Args> +struct bomb<T, v, Args...> { + static const T value = v + bomb<T, Args...>::value; +}; + +extern "C" void abort(); + +int main() { + bomb<int, 1, 2, 3, 4> b; + if (b.value != 10) + abort(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic71.C b/gcc/testsuite/g++.dg/cpp0x/variadic71.C new file mode 100644 index 000000000..bea3cc346 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic71.C @@ -0,0 +1,12 @@ +// { dg-options "-std=gnu++0x" } +template<typename...> struct list {}; + +template<typename Sequence, typename Head> +struct push_front; + +template<typename... Elements, typename Head> +struct push_front<list<Elements...>, Head> { + typedef list<Head, Elements> type; // { dg-error "parameter packs not expanded" } +}; + +// { dg-message "Elements" "note" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic72.C b/gcc/testsuite/g++.dg/cpp0x/variadic72.C new file mode 100644 index 000000000..b1a620d53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic72.C @@ -0,0 +1,21 @@ +// { dg-options "-std=gnu++0x" } +struct A {}; +struct B {}; +struct C {}; + +template<typename... Mixins> +struct mixed_up : public Mixins... +{ +}; + +void fA(A); +void fB(B); +void fC(C); + +void g() +{ + mixed_up<A, B, C> m; + fA(m); + fB(m); + fC(m); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic73.C b/gcc/testsuite/g++.dg/cpp0x/variadic73.C new file mode 100644 index 000000000..05925e7aa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic73.C @@ -0,0 +1,33 @@ +// { dg-do run } +// { dg-options "-std=gnu++0x" } +struct A {}; +struct B {}; +struct C {}; + +template<typename... Exceptions> void f(int idx) throw(Exceptions...) { + if (idx == 0) throw A(); + else if (idx == 1) throw B(); + else if (idx == 2) throw C(); +} + +extern "C" void abort(); + +int main() +{ + try { + f<A, B, C>(0); + abort(); + } catch (A) { + } + try { + f<A, B, C>(1); + abort(); + } catch (B) { + } + try { + f<A, B, C>(2); + abort(); + } catch (C) { + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic74.C b/gcc/testsuite/g++.dg/cpp0x/variadic74.C new file mode 100644 index 000000000..19b6b11d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic74.C @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +template <class... Types> class A +{ +public: + template <Types... Values> class X { /* ... */ }; // { dg-error "not a valid type for a template constant parameter" } +}; + +template<class... Types> class B +{ +public: + template <Types*... Values> class X { + typename A<Types*...>::template X<Values...> foo; + }; +}; + +int i; +float f; + +A<int*, float*>::X<&i, &f> apple1; +B<int, float>::X<&i, &f> banana1; + +A<int*, float*>::X<&i> apple2; // { dg-error "wrong number of template arguments" } +// { dg-error "invalid type" "" { target *-*-* } 22 } +A<int*, float*>::X<&i, &f, &f> apple3; // { dg-error "wrong number of template arguments" } +// { dg-error "invalid type" "" { target *-*-* } 24 } +A<int, float> apple4; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic75.C b/gcc/testsuite/g++.dg/cpp0x/variadic75.C new file mode 100644 index 000000000..f57f8b3ef --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic75.C @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } + +template<typename...> struct tuple { }; + +template<template<typename T> class Meta, typename... Values> +struct apply_all +{ + typedef tuple<typename Meta<Values>::type...> type; +}; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +template<typename T> +struct add_reference { + typedef T& type; +}; + +template<typename T> +struct add_reference<T&> { + typedef T& type; +}; + +static_assert(is_same<apply_all<add_reference, int, int&, float>::type, + tuple<int&, int&, float&> >::value, + "check apply"); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic76.C b/gcc/testsuite/g++.dg/cpp0x/variadic76.C new file mode 100644 index 000000000..a9f8eabb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic76.C @@ -0,0 +1,13 @@ +// PR c++/33496 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<int... N> int foo () +{ + return sizeof... N (); // { dg-error "cannot be used as a function" } +} + +int bar () +{ + return foo<0> (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic77.C b/gcc/testsuite/g++.dg/cpp0x/variadic77.C new file mode 100644 index 000000000..43f2d1e43 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic77.C @@ -0,0 +1,22 @@ +// PR c++/33496 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<int M, int N> struct pair +{ + int i, j; + pair () : i (M), j (N) {} +}; + +template<int... M> struct S +{ + template<int... N> static int foo () + { + return sizeof... (pair<M, N>); // { dg-error "mismatched argument pack lengths" } + } +}; + +int bar () +{ + return S<0, 1, 2>::foo<0, 1> (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic78.C b/gcc/testsuite/g++.dg/cpp0x/variadic78.C new file mode 100644 index 000000000..9e2b84ad0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic78.C @@ -0,0 +1,23 @@ +// PR c++/33496 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<int M, int N> struct pair +{ + int i, j; + pair () : i (M), j (N) {} +}; + +template<int... M> struct S +{ + template<int... N> static int *foo () + { + static int x[] = { (M + N)... }; // { dg-error "mismatched argument pack lengths" } + return x; + } +}; + +int *bar () +{ + return S<0, 1, 2>::foo<0, 1> (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic79.C b/gcc/testsuite/g++.dg/cpp0x/variadic79.C new file mode 100644 index 000000000..c6479e04f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic79.C @@ -0,0 +1,7 @@ +// PR c++/33213 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<template<typename> class...> struct A; + +template<template<typename...> class... B> struct A<B...> {}; // { dg-error "mismatch|'template<class ...> class ... B ...'" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic8.C b/gcc/testsuite/g++.dg/cpp0x/variadic8.C new file mode 100644 index 000000000..c3a1340cf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic8.C @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +template<typename... Args> +struct tuple_base { + static const int value = 0; +}; + +template<> +struct tuple_base<int*> +{ + static const int value = 1; +}; + +template<typename T> +struct tuple_base<T*> +{ + static const int value = 2; +}; + +template<typename... Args> +struct tuple_of_pointers : tuple_base<Args*...> { }; + +int a1[tuple_of_pointers<int>::value == 1? 1 : -1]; +int a2[tuple_of_pointers<float>::value == 2? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic80.C b/gcc/testsuite/g++.dg/cpp0x/variadic80.C new file mode 100644 index 000000000..a56cdb404 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic80.C @@ -0,0 +1,28 @@ +// PR c++/31434 +// { dg-do run } +// { dg-options "-std=c++0x" } + +extern "C" void abort (); + +template<typename... T> inline int foo (const T...) { return 1; } +template<typename... T> inline int foo (const T *...) { return 2; } + +void +bar (int *a) +{ + a[0] = foo (0); + a[1] = foo (*a); + a[2] = foo<int> (a); + a[3] = foo<int> (2, 3, 4, 5); + a[4] = foo<int> (a, a + 1, a + 2); +} + +int +main () +{ + int a[5]; + bar (a); + if (a[0] != 1 || a[1] != 1 || a[2] != 2 || a[3] != 1 || a[4] != 2) + abort (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic81.C b/gcc/testsuite/g++.dg/cpp0x/variadic81.C new file mode 100644 index 000000000..cce61b316 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic81.C @@ -0,0 +1,11 @@ +// PR c++/33461 +// { dg-options "-std=gnu++0x" } + +template<typename> struct A; + +template<typename... T> struct A<T*> // { dg-error "not expanded|T|not used|T" } +{ + struct B; +}; + +A<void*> a; // { dg-error "incomplete" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic82.C b/gcc/testsuite/g++.dg/cpp0x/variadic82.C new file mode 100644 index 000000000..fb3ddb3c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic82.C @@ -0,0 +1,11 @@ +// PR c++/33461 +// { dg-options "-std=gnu++0x" } + +template<typename> struct A; + +template<typename... T> struct A<T*...> // { dg-bogus "cannot expand" "" { xfail *-*-* } } +{ + struct B; +}; + +A<void*> a; // { dg-bogus "incomplete type" "" { xfail *-*-* } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic83.C b/gcc/testsuite/g++.dg/cpp0x/variadic83.C new file mode 100644 index 000000000..2613d625f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic83.C @@ -0,0 +1,8 @@ +// PR c++/31441 +// { dg-options "-std=gnu++0x" } + +template<typename> struct A; + +template<typename... T> struct A<T...> { }; // { dg-bogus "cannot expand" "" { xfail *-*-* } } + +A<int> a; // { dg-bogus "incomplete type" "" { xfail *-*-* } } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic84.C b/gcc/testsuite/g++.dg/cpp0x/variadic84.C new file mode 100644 index 000000000..ce3126795 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic84.C @@ -0,0 +1,26 @@ +// PR c++/32565 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename...> struct A1; +template<template<int...> class T> struct A1<T<0> > {}; +template<typename...> struct A2; +template<template<int...> class T> struct A2<T<0, 1> > {}; +template<typename...> struct A3; +template<template<int, int...> class T> struct A3<T<0, 1> > {}; +template<typename...> struct A4; +template<template<typename...> class T> struct A4<T<int> > {}; +template<typename...> struct A5; +template<template<typename...> class T> struct A5<T<int, long> > {}; +template<typename...> struct A6; +template<template<typename, typename...> class T> struct A6<T<int, long> > {}; +template<int> struct B1 {}; +template<int, int> struct B2 {}; +template<typename> struct B3 {}; +template<typename, typename> struct B4 {}; +A1<B1<0> > a1; +A2<B2<0, 1> > a2; +A3<B2<0, 1> > a3; +A4<B3<int> > a4; +A5<B4<int, long> > a5; +A6<B4<int, long> > a6; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic85.C b/gcc/testsuite/g++.dg/cpp0x/variadic85.C new file mode 100644 index 000000000..facb26391 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic85.C @@ -0,0 +1,10 @@ +// PR c++/32565 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename...> struct A1; +template<template<int, int...> class T> struct A1<T<0, 1> > {}; +template<int, int, int...> struct B1 {}; +A1<B1<0, 1> > a1; +template<int...> struct B2 {}; +A1<B2<0, 1> > a2; // { dg-error "incomplete type" } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic86.C b/gcc/testsuite/g++.dg/cpp0x/variadic86.C new file mode 100644 index 000000000..d8fcd620e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic86.C @@ -0,0 +1,19 @@ +// PR c++/33943 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template<typename... A> struct foo {}; + +template<typename A0, typename... A1> struct bar {}; + +template<typename U> struct baz; + +template<template<typename...> class T, typename... U> struct baz< T<U...> > +{}; + +template<template<typename, typename...> class T, typename U, typename... V> +struct baz< T<U, V...> > +{}; + +baz< foo<int, short> > b1; +baz< bar<int, short> > b2; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic87.C b/gcc/testsuite/g++.dg/cpp0x/variadic87.C new file mode 100644 index 000000000..1defa23da --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic87.C @@ -0,0 +1,23 @@ +// PR c++/33965 +// { dg-options -std=c++0x } +template<typename T> +struct foo +{ + static bool const value = false; +}; + +template<template<typename...> class T, typename... Args> +struct foo<T<Args...> > +{ + static bool const value = true; +}; + +template<int I> +struct int_ +{}; + +int main() +{ + static_assert(foo<int_<0> >::value == false, + "picked up partial specialization, but should not have"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic88.C b/gcc/testsuite/g++.dg/cpp0x/variadic88.C new file mode 100644 index 000000000..b14cabe32 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic88.C @@ -0,0 +1,23 @@ +// { dg-options "-std=c++0x" } + +template<template<typename...> class TT> +TT<int, float, double> foo(TT<int, float>) +{ + return TT<int, float, double>(); +} + +template<typename T> +int& foo(T) +{ + static int i = 0; return i; +} + +template<typename T, typename U> +struct pair {}; + +void bar() +{ + pair<int, float> p; + int& i = foo(p); +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic89.C b/gcc/testsuite/g++.dg/cpp0x/variadic89.C new file mode 100644 index 000000000..b943771a6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic89.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } +// Contributed by Eric Niebler +template<typename T, typename U> +struct pair +{}; + +template<typename T> +struct test; + +template<template<typename...> class T, typename... Args> +struct test<T<Args...> > +{}; + +test<pair<int, double> > t; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic9.C b/gcc/testsuite/g++.dg/cpp0x/variadic9.C new file mode 100644 index 000000000..c5db6af6a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic9.C @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +template<typename T1, typename T2> +struct pair {}; + +template<typename... Args> +struct tuple { + static const int value = 0; +}; + +template<> +struct tuple<pair<int, float> > { + static const int value = 1; +}; + +template<typename U> +struct tuple<pair<int, U> > { + static const int value = 2; +}; + +template<typename T, typename U> +struct tuple<pair<T, U>, pair<T, U> > { + static const int value = 3; +}; + + +template<typename... Outer> +struct X { + template<typename... Inner> + struct Y + { + typedef tuple<pair<Outer, Inner>...> type; + }; +}; + +int a0[X<int, double>::Y<short, char>::type::value == 0? 1 : -1]; +int a1[X<int>::Y<float>::type::value == 1? 1 : -1]; +int a2[X<int>::Y<double>::type::value == 2? 1 : -1]; +int a3[X<int, int>::Y<double, double>::type::value == 3? 1 : -1]; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic90.C b/gcc/testsuite/g++.dg/cpp0x/variadic90.C new file mode 100644 index 000000000..632e166c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic90.C @@ -0,0 +1,8 @@ +// { dg-options "-std=c++0x" } + +template<template<typename...> class TT> +struct X { }; + +template<typename T, typename U> struct pair { }; + +X<pair> x; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic91.C b/gcc/testsuite/g++.dg/cpp0x/variadic91.C new file mode 100644 index 000000000..d78b791fb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic91.C @@ -0,0 +1,17 @@ +// { dg-options "-std=c++0x" } +template<int N> struct Int2Type { }; + +template<typename... T> +struct Outer { + template<typename... U> + void foo(Int2Type<sizeof...(T)>, Int2Type<sizeof...(U)>); +}; + + +Outer<short, int, long> outer; + +void g4() { + outer.foo<float, double>(Int2Type<3>(), Int2Type<2>()); +} + +template<typename... T, template<T...> class X> void f1(); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic92.C b/gcc/testsuite/g++.dg/cpp0x/variadic92.C new file mode 100644 index 000000000..d382912c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic92.C @@ -0,0 +1,70 @@ +// Various tests for variadic templates and partial specialization. +// { dg-options "-std=c++0x" } + +// PR c++/36846 +template<typename A, typename B> +struct pair; + +template<typename... T> +struct pairs; + +template<typename... AS, typename... BS> +struct pairs<pair<AS, BS>...> { + struct mismatched_packs {}; +}; + +template class pairs< + pair<int, int>, + pair<int, int> +>; + +template<int A, int B> +struct point; + +template<typename... T> +struct points; + +template<int... AS, int... BS> +struct points<point<AS, BS>...> { + struct mismatched_packs {}; +}; + +template class points< + point<0, 1>, + point<0, 1> +>; + +// PR c++/35477 +template <class...ARGS> struct tuple {}; +template <class A, class B> struct test {}; +template <class... ARGS, class B> struct test<B, tuple<ARGS...>> +{ + template <class T> struct inside {}; +}; + +// PR c++/38276 +template<typename...> struct A; + +template<typename, typename> struct B; + +template<typename... T, typename... U> struct B<A<T...>, A<U...> > +{ + static int i; +}; + +B<A<>, A<int> > b1; + +B<A<int>, A<> > b2; + +// PR c++/35784 +template <typename...> struct p; + +template <typename, typename> struct d; + +template <typename... A, typename... B> +struct d<p<A...>, p<B...> > { typedef int t; }; + +typedef d<p<>, p<int, float> >::t q; +typedef d<q, d<p<int>, p<float> >::t> r; // * + +typedef d<d<p<>, p<int, float> >::t, d<p<>, p<> >::t> s; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic93.C b/gcc/testsuite/g++.dg/cpp0x/variadic93.C new file mode 100644 index 000000000..7d8c3298e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic93.C @@ -0,0 +1,11 @@ +// PR c++/35297 +// { dg-options "-std=c++0x" } + +template <class T=int, class... ARGS> +struct test2 {}; + +int main() +{ + test2<> a; + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic94.C b/gcc/testsuite/g++.dg/cpp0x/variadic94.C new file mode 100644 index 000000000..8420f73a6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic94.C @@ -0,0 +1,33 @@ +// PR c++/40595 +// { dg-options "-std=c++0x" } + +template<int N> +struct S +{ + typedef int type; +}; + +template<typename T> +struct Get +{ + static T get(); +}; + +template<typename F> +struct B +{ + template<typename ... Args> + typename S<sizeof( Get<F>::get() (Get<Args>::get() ...) )>::type + f(Args&& ... a); +}; + +struct X +{ + bool operator()(int) const; +}; + +int main() +{ + B<X> b; + b.f(1); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic95.C b/gcc/testsuite/g++.dg/cpp0x/variadic95.C new file mode 100644 index 000000000..ebb04ebc1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic95.C @@ -0,0 +1,17 @@ +// PR c++/39863 +// { dg-options -std=c++0x } + +template <typename... T> +struct A {}; + +template <typename T, typename U> +struct S {}; + +template <typename... T, typename... U> +A< S<T, U>... > f(U... u) +{ return A< S<T, U>... >(); } + +int main() +{ + f<int>(0.0); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic96.C b/gcc/testsuite/g++.dg/cpp0x/variadic96.C new file mode 100644 index 000000000..d4709d074 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic96.C @@ -0,0 +1,26 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin: PR c++/41785 +// { dg-options -std=c++0x } + +struct a {}; + +template < typename T, typename ENCLOSING > +struct base; + +template < typename... T > +struct derived + : public base< T, derived< T... > >... +{}; + +template < typename... T> +struct base< a, derived< T... > > +{ + typedef derived< T... > + Derived; +}; + +int main() +{ + derived< a > instance; +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic97.C b/gcc/testsuite/g++.dg/cpp0x/variadic97.C new file mode 100644 index 000000000..a2070319e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic97.C @@ -0,0 +1,35 @@ +// PR c++/42266 +// { dg-options -std=c++0x } + +template<typename... _Elements> + class tuple; + +template<typename _Arg> + class _Mu; + +template<typename _Signature> + struct _Bind; + +template<typename _Functor, typename... _Bound_args> + class _Bind<_Functor(_Bound_args...)> + { + template<typename... _Args, typename + = decltype(_Functor()(_Mu<_Bound_args>()(_Bound_args(), + tuple<_Args...>())...) )> + void __call() { } + }; + +template<typename _Functor, typename _Arg> + _Bind<_Functor(_Arg)> + bind(_Functor, _Arg) { } + +struct State +{ + bool ready() { return true; } + + void f() + { + bind(&State::ready, this); + } +}; + diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic98.C b/gcc/testsuite/g++.dg/cpp0x/variadic98.C new file mode 100644 index 000000000..6af599fca --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic98.C @@ -0,0 +1,411 @@ +// PR c++/42358 +// { dg-do assemble } +// { dg-options -std=c++0x } + +typedef __PTRDIFF_TYPE__ ptrdiff_t; +typedef __SIZE_TYPE__ size_t; +namespace std __attribute__ ((__visibility__ ("default"))) { + using ::size_t; +} +namespace std __attribute__ ((__visibility__ ("default"))) { + struct __sfinae_types { + typedef char __one; + typedef struct { + } __two; + }; + template<typename _Tp, _Tp __v> struct integral_constant { + static const _Tp value = __v; + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; + }; + typedef integral_constant<bool, false> false_type; + template<typename> struct remove_cv; + template<typename> struct __is_void_helper : public false_type { + }; + template<typename _Tp> struct is_void : public integral_constant<bool, (__is_void_helper<typename remove_cv<_Tp>::type>::value)> { + }; + template<typename> struct is_array : public false_type { + }; + template<typename> struct is_function : public false_type { + }; + template<typename, unsigned _Uint = 0> struct extent : public integral_constant<std::size_t, 0> { + }; + template<typename _Tp> struct remove_const { + typedef _Tp type; + }; + template<typename _Tp> struct remove_volatile { + typedef _Tp type; + }; + template<typename _Tp> struct remove_cv { + typedef typename remove_const<typename remove_volatile<_Tp>::type>::type type; + }; + template<typename> struct is_lvalue_reference : public false_type { + }; + template<typename> struct is_rvalue_reference : public false_type { + }; + template<typename _Tp> struct is_reference : public integral_constant<bool, (is_lvalue_reference<_Tp>::value || is_rvalue_reference<_Tp>::value)> { + }; + template<typename _Tp> struct remove_reference { + typedef _Tp type; + }; + template<typename _Tp, bool = !is_reference<_Tp>::value && !is_void<_Tp>::value> struct __add_rvalue_reference_helper { + typedef _Tp type; + }; + template<typename _Tp> struct add_rvalue_reference : public __add_rvalue_reference_helper<_Tp> { + }; + template<typename _Tp> typename add_rvalue_reference<_Tp>::type declval(); + template<typename _From, typename _To, bool = (is_void<_From>::value || is_void<_To>::value || is_function<_To>::value || is_array<_To>::value)> struct __is_convertible_helper { + }; + template<typename _From, typename _To> struct __is_convertible_helper<_From, _To, false> : public __sfinae_types { + static __one __test(_To); + static __two __test(...); + static const bool __value = sizeof(__test(declval<_From>())) == 1; + }; + template<typename _From, typename _To> struct is_convertible : public integral_constant<bool, __is_convertible_helper<_From, _To>::__value> { + }; + template<bool, typename _Tp = void> struct enable_if { + }; + template<typename _Tp> struct enable_if<true, _Tp> { + typedef _Tp type; + }; + template<typename _Tp> struct identity { + typedef _Tp type; + }; + template<typename _Tp> inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type forward(typename std::identity<_Tp>::type& __t) { + } + template<typename _Tp> inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type forward(typename std::identity<_Tp>::type __t) { + } + template<typename _Tp> inline typename std::remove_reference<_Tp>::type&& move(_Tp&& __t) { + } + template<class _T1, class _T2> struct pair { + typedef _T1 first_type; + typedef _T2 second_type; + _T1 first; + _T2 second; + template<class _U1, class = typename std::enable_if<std::is_convertible<_U1, _T1>::value>::type> pair(_U1&& __x, const _T2& __y) : first(std::forward<_U1>(__x)), second(__y) { + } + template<class _U2, class = typename std::enable_if<std::is_convertible<_U2, _T2>::value>::type> pair(const _T1& __x, _U2&& __y) : first(__x), second(std::forward<_U2>(__y)) { + } + template<class _U1, class _U2, class = typename std::enable_if<std::is_convertible<_U1, _T1>::value && std::is_convertible<_U2, _T2>::value>::type> pair(_U1&& __x, _U2&& __y) : first(std::forward<_U1>(__x)), second(std::forward<_U2>(__y)) { + } + template<class _U1, class _U2> pair(pair<_U1, _U2>&& __p) : first(std::move(__p.first)), second(std::move(__p.second)) { + } + template<class _U1, class _U2> pair& operator=(pair<_U1, _U2>&& __p) { + } + }; + struct input_iterator_tag { + }; + struct output_iterator_tag { + }; + struct forward_iterator_tag : public input_iterator_tag { + }; + struct bidirectional_iterator_tag : public forward_iterator_tag { + }; + template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, typename _Pointer = _Tp*, typename _Reference = _Tp&> struct iterator { + typedef _Category iterator_category; + typedef _Tp value_type; + typedef _Distance difference_type; + typedef _Pointer pointer; + typedef _Reference reference; + }; + template<typename _Iterator> struct iterator_traits { + typedef typename _Iterator::iterator_category iterator_category; + typedef typename _Iterator::value_type value_type; + typedef typename _Iterator::difference_type difference_type; + typedef typename _Iterator::pointer pointer; + typedef typename _Iterator::reference reference; + }; + template<typename _Iter> inline typename iterator_traits<_Iter>::iterator_category __iterator_category(const _Iter&) { + } + template<typename _InputIterator> inline typename iterator_traits<_InputIterator>::difference_type __distance(_InputIterator __first, _InputIterator __last, input_iterator_tag) { + } + template<typename _InputIterator> inline typename iterator_traits<_InputIterator>::difference_type distance(_InputIterator __first, _InputIterator __last) { + return std::__distance(__first, __last, std::__iterator_category(__first)); + } + template<typename _Iterator> class reverse_iterator : public iterator<typename iterator_traits<_Iterator>::iterator_category, typename iterator_traits<_Iterator>::value_type, typename iterator_traits<_Iterator>::difference_type, typename iterator_traits<_Iterator>::pointer, typename iterator_traits<_Iterator>::reference> { + }; + template<typename _Container> class back_insert_iterator : public iterator<output_iterator_tag, void, void, void, void> { + }; +} +namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) { + template<typename _Tp> class new_allocator { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + new_allocator() throw() { + } + new_allocator(const new_allocator&) throw() { + } + template<typename _Tp1> new_allocator(const new_allocator<_Tp1>&) throw() { + } + template<typename... _Args> void construct(pointer __p, _Args&&... __args) { + } + }; +} +namespace std __attribute__ ((__visibility__ ("default"))) { + template<typename _Tp> class allocator: public __gnu_cxx::new_allocator<_Tp> { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp* pointer; + typedef const _Tp* const_pointer; + typedef _Tp& reference; + typedef const _Tp& const_reference; + typedef _Tp value_type; + template<typename _Tp1> struct rebind { + typedef allocator<_Tp1> other; + }; + allocator() throw() { + } + template<typename _Tp1> allocator(const allocator<_Tp1>&) throw() { + } + }; + extern template class allocator<char>; + extern template class allocator<wchar_t>; + template<typename _Arg, typename _Result> struct unary_function { + typedef _Arg argument_type; + typedef _Result result_type; + }; + template<typename _Arg1, typename _Arg2, typename _Result> struct binary_function { + typedef _Arg1 first_argument_type; + typedef _Arg2 second_argument_type; + typedef _Result result_type; + }; + template<typename _Tp> struct less : public binary_function<_Tp, _Tp, bool> { + bool operator()(const _Tp& __x, const _Tp& __y) const { + } + }; + template<typename _Pair> struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { + const typename _Pair::first_type& operator()(const _Pair& __x) const { + } + }; + struct _Rb_tree_node_base { + typedef _Rb_tree_node_base* _Base_ptr; + typedef const _Rb_tree_node_base* _Const_Base_ptr; + }; + template<typename _Val> struct _Rb_tree_node : public _Rb_tree_node_base { + typedef _Rb_tree_node<_Val>* _Link_type; + _Val _M_value_field; + template<typename... _Args> _Rb_tree_node(_Args&&... __args) : _Rb_tree_node_base(), _M_value_field(std::forward<_Args>(__args)...) { + } + }; + template<typename _Tp> struct _Rb_tree_iterator { + typedef _Tp value_type; + typedef _Tp& reference; + typedef _Tp* pointer; + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef _Rb_tree_iterator<_Tp> _Self; + typedef _Rb_tree_node_base::_Base_ptr _Base_ptr; + typedef _Rb_tree_node<_Tp>* _Link_type; + _Base_ptr _M_node; + }; + template<typename _Tp> struct _Rb_tree_const_iterator { + typedef _Tp value_type; + typedef const _Tp& reference; + typedef const _Tp* pointer; + typedef _Rb_tree_iterator<_Tp> iterator; + typedef bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef _Rb_tree_const_iterator<_Tp> _Self; + typedef _Rb_tree_node_base::_Const_Base_ptr _Base_ptr; + typedef const _Rb_tree_node<_Tp>* _Link_type; + explicit _Rb_tree_const_iterator(_Link_type __x) : _M_node(__x) { + } + _Rb_tree_const_iterator(const iterator& __it) : _M_node(__it._M_node) { + } + _Base_ptr _M_node; + }; + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc = allocator<_Val> > class _Rb_tree { + typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other _Node_allocator; + typedef _Rb_tree_node_base* _Base_ptr; + typedef const _Rb_tree_node_base* _Const_Base_ptr; + public: + typedef _Key key_type; + typedef _Val value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef _Rb_tree_node<_Val>* _Link_type; + typedef const _Rb_tree_node<_Val>* _Const_Link_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Alloc allocator_type; + _Node_allocator& _M_get_Node_allocator() { + } + _Link_type _M_get_node() { + } + template<typename... _Args> _Link_type _M_create_node(_Args&&... __args) { + _Link_type __tmp = _M_get_node(); + try { + _M_get_Node_allocator().construct(__tmp, std::forward<_Args>(__args)...); + } + catch(...) { + } + } + template<typename _Key_compare, bool _Is_pod_comparator = __is_pod(_Key_compare)> struct _Rb_tree_impl : public _Node_allocator { + _Key_compare _M_key_compare; + _Rb_tree_node_base _M_header; + size_type _M_node_count; + _Rb_tree_impl(const _Key_compare& __comp, const _Node_allocator& __a) : _Node_allocator(__a), _M_key_compare(__comp), _M_header(), _M_node_count(0) { + } + void _M_initialize() { + } + }; + _Rb_tree_impl<_Compare> _M_impl; + _Base_ptr& _M_rightmost() { + } + _Link_type _M_begin() { + } + _Link_type _M_end() { + } + _Const_Link_type _M_end() const { + } + static _Link_type _S_right(_Base_ptr __x) { + } + static const_reference _S_value(_Const_Base_ptr __x) { + } + static const _Key& _S_key(_Const_Base_ptr __x) { + return _KeyOfValue()(_S_value(__x)); + } + typedef _Rb_tree_iterator<value_type> iterator; + typedef _Rb_tree_const_iterator<value_type> const_iterator; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + iterator _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __y, const value_type& __v); + iterator _M_insert_lower(_Base_ptr __x, _Base_ptr __y, const value_type& __v); + iterator _M_insert_equal_lower(const value_type& __x); + iterator _M_lower_bound(_Link_type __x, _Link_type __y, const _Key& __k); + iterator _M_upper_bound(_Link_type __x, _Link_type __y, const _Key& __k); + _Rb_tree(const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_impl(__comp, __a) { + } + iterator end() { + } + iterator _M_insert_equal_(const_iterator __position, const value_type& __x); + template<typename _InputIterator> void _M_insert_unique(_InputIterator __first, _InputIterator __last); + template<typename _InputIterator> void _M_insert_equal(_InputIterator __first, _InputIterator __last); + size_type count(const key_type& __k) const; + pair<iterator, iterator> equal_range(const key_type& __k); + pair<const_iterator, const_iterator> equal_range(const key_type& __k) const; + }; + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v) { + _Link_type __z = _M_create_node(__v); + } + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_lower(_Base_ptr __x, _Base_ptr __p, const _Val& __v) { + _Link_type __z = _M_create_node(__v); + } + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_equal_lower(const _Val& __v) { + _Link_type __x = _M_begin(); + _Link_type __y = _M_end(); + return _M_insert_lower(__x, __y, __v); + } + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: equal_range(const _Key& __k) { + _Link_type __x = _M_begin(); + _Link_type __y = _M_end(); + while (__x != 0) { + if (_M_impl._M_key_compare(_S_key(__x), __k)) __x = _S_right(__x); + else { + _Link_type __xu(__x), __yu(__y); + return pair<iterator, iterator>(_M_lower_bound(__x, __y, __k), _M_upper_bound(__xu, __yu, __k)); + } + } + } + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> pair<typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator> _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: equal_range(const _Key& __k) const { + _Const_Link_type __y = _M_end(); + return pair<const_iterator, const_iterator>(const_iterator(__y), const_iterator(__y)); + } + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: _M_insert_equal_(const_iterator __position, const _Val& __v) { + if (__position._M_node == _M_end()) { + if (__position._M_node == _M_rightmost()) return _M_insert_(0, _M_rightmost(), __v); + else return _M_insert_equal_lower(__v); + } + } + template<typename _Key, typename _Val, typename _KoV, typename _Cmp, typename _Alloc> template<class _II> void _Rb_tree<_Key, _Val, _KoV, _Cmp, _Alloc>:: _M_insert_equal(_II __first, _II __last) { + for (; + __first != __last; + ++__first) _M_insert_equal_(end(), *__first); + } + template<typename _Key, typename _Val, typename _KeyOfValue, typename _Compare, typename _Alloc> typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: count(const _Key& __k) const { + pair<const_iterator, const_iterator> __p = equal_range(__k); + const size_type __n = std::distance(__p.first, __p.second); + } + template<class _E> class initializer_list { + public: + typedef _E value_type; + typedef const _E& reference; + typedef const _E& const_reference; + typedef size_t size_type; + typedef const _E* iterator; + typedef const _E* const_iterator; + iterator _M_array; + size_type _M_len; + initializer_list(const_iterator __a, size_type __l) : _M_array(__a), _M_len(__l) { + } + const_iterator begin() const { + } + const_iterator end() const { + } + }; + template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>, typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > > class multimap { + typedef _Key key_type; + typedef _Tp mapped_type; + typedef std::pair<const _Key, _Tp> value_type; + typedef _Compare key_compare; + typedef _Alloc allocator_type; + typedef typename _Alloc::value_type _Alloc_value_type; + typedef typename _Alloc::template rebind<value_type>::other _Pair_alloc_type; + typedef _Rb_tree<key_type, value_type, _Select1st<value_type>, key_compare, _Pair_alloc_type> _Rep_type; + _Rep_type _M_t; + public: + typedef typename _Pair_alloc_type::pointer pointer; + typedef typename _Pair_alloc_type::const_pointer const_pointer; + typedef typename _Pair_alloc_type::reference reference; + typedef typename _Pair_alloc_type::const_reference const_reference; + typedef typename _Rep_type::iterator iterator; + typedef typename _Rep_type::const_iterator const_iterator; + typedef typename _Rep_type::size_type size_type; + typedef typename _Rep_type::difference_type difference_type; + typedef typename _Rep_type::reverse_iterator reverse_iterator; + typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; + multimap(initializer_list<value_type> __l, const _Compare& __comp = _Compare(), const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) { + _M_t._M_insert_equal(__l.begin(), __l.end()); + } + template<typename _InputIterator> multimap(_InputIterator __first, _InputIterator __last) : _M_t() { + } + template<typename _InputIterator> multimap(_InputIterator __first, _InputIterator __last, const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) { + } + template<typename _InputIterator> void insert(_InputIterator __first, _InputIterator __last) { + } + size_type count(const key_type& __x) const { + return _M_t.count(__x); + } + std::pair<iterator, iterator> equal_range(const key_type& __x) { + return _M_t.equal_range(__x); + } + template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool operator==(const multimap<_K1, _T1, _C1, _A1>&, const multimap<_K1, _T1, _C1, _A1>&); + template<typename _K1, typename _T1, typename _C1, typename _A1> friend bool operator<(const multimap<_K1, _T1, _C1, _A1>&, const multimap<_K1, _T1, _C1, _A1>&); + }; +} +extern "C" { + extern void __assert_fail (__const char *__assertion, __const char *__file, unsigned int __line, __const char *__function) throw () __attribute__ ((__noreturn__)); +} +using namespace std; +int test01() { + typedef multimap<int,double> Container; + typedef Container::iterator iterator; + typedef pair<iterator,iterator> itpair; + Container m({ + { + 1, 1.0 } + } + ); + itpair ip = m.equal_range(1); + ((distance(ip.first, ip.second) == 3) ? static_cast<void> (0) : __assert_fail ("distance(ip.first, ip.second) == 3", "/home/richard/src/trunk/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc", 36, __PRETTY_FUNCTION__)); + ((m.count(7) == 2) ? static_cast<void> (0) : __assert_fail ("m.count(7) == 2", "/home/richard/src/trunk/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc", 54, __PRETTY_FUNCTION__)); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic99.C b/gcc/testsuite/g++.dg/cpp0x/variadic99.C new file mode 100644 index 000000000..457212712 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic99.C @@ -0,0 +1,22 @@ +// PR c++/43054 +// { dg-options "-std=c++0x" } + +template<typename R> struct future { }; + +template<typename Fn, typename... Args> + auto + async(Fn&& fn, Args&&... args) + -> future<decltype(fn(args...))>; + +template<typename Fn, typename... Args> + auto + async(Fn&& fn, Args&&... args) + -> future<decltype(fn(args...))>; + +int work2(int value); + +void work(int value) +{ + async(work2, value); +} + diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-33964.C b/gcc/testsuite/g++.dg/cpp0x/vt-33964.C new file mode 100644 index 000000000..0b84b6cec --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-33964.C @@ -0,0 +1,20 @@ +// { dg-options "-std=c++0x" } +template<typename ... Args> +struct foo +{ + static bool const value = true; +}; + +template<typename ... Args> +struct foo< typename Args::is_applied... > // { dg-error "not used|Args" } +{ + static bool const value = false; +}; + +struct not_applied { typedef void is_applied; }; +struct applied { typedef applied is_applied; }; + +int main() +{ + foo<applied, applied> i; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34050.C b/gcc/testsuite/g++.dg/cpp0x/vt-34050.C new file mode 100644 index 000000000..cb19b3914 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34050.C @@ -0,0 +1,9 @@ +// { dg-options "-std=c++0x" } +struct A {}; + +template<typename... T> struct B : T... +{ + B() : T()... {} +}; + +B<A> b; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34051-2.C b/gcc/testsuite/g++.dg/cpp0x/vt-34051-2.C new file mode 100644 index 000000000..2c7bb50f0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34051-2.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +template<typename... T> struct A +{ + int i __attribute__((aligned(__alignof(T)))); // { dg-error "parameter packs|T" } +}; + +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34051.C b/gcc/testsuite/g++.dg/cpp0x/vt-34051.C new file mode 100644 index 000000000..88ae56703 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34051.C @@ -0,0 +1,12 @@ +// { dg-options "-std=c++0x" } +struct A +{ + operator int(); +}; + +template <typename... T> struct B : A +{ + using A::operator T; // { dg-error "parameter packs|T" } +}; + +B<int> b; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34052.C b/gcc/testsuite/g++.dg/cpp0x/vt-34052.C new file mode 100644 index 000000000..15310cfe7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34052.C @@ -0,0 +1,8 @@ +// { dg-options "-std=c++0x" } +template<typename... T, typename = T> struct A {}; // { dg-error "must be at the end" } + + +template<template<typename... T, typename = T> class U> struct B // { dg-error "must be at the end" } +{ + template<int> U<int> foo(); // { dg-error "mismatch|constant|invalid|invalid" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34055.C b/gcc/testsuite/g++.dg/cpp0x/vt-34055.C new file mode 100644 index 000000000..c50778430 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34055.C @@ -0,0 +1,31 @@ +// { dg-options "-std=c++0x" } +// PR c++/34055 +template<typename...> struct A; + +template<typename...T> struct A<T*> // { dg-error "parameter packs|T" } +{ + void foo(); +}; + +template<typename...T> void A<T*>::foo() {} // { dg-error "invalid declarator" } + + + +template<typename...> struct B; + +template<typename...T> struct B<T&> // { dg-error "parameter packs|T" } +{ + void foo(); +}; + +template<typename...T> void B<T&>::foo() {} // { dg-error "invalid declarator" } + + +template<typename...> struct C; + +template<typename...T> struct C<T()> // { dg-error "parameter packs|T" } +{ + void foo(); +}; + +template<typename...T> void C<T()>::foo() {} // { dg-error "invalid declarator" } diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34102.C b/gcc/testsuite/g++.dg/cpp0x/vt-34102.C new file mode 100644 index 000000000..00f0b4f4a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34102.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +// PR c++/34102 +struct A {}; + +template<typename> struct B : virtual A {}; + +template<typename...T> struct C : B<T> {}; // { dg-error "parameter packs|T" } diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34103.C b/gcc/testsuite/g++.dg/cpp0x/vt-34103.C new file mode 100644 index 000000000..3bbbb46a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34103.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +// PR c++/34103 +template<typename> struct A {}; + +template<typename...T> void foo(A<T>, A<T>); // { dg-error "parameter packs|T" } + +template<typename...T> void foo(A<T>, A<T>) {} // { dg-error "parameter packs|T" } diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34219-2.C b/gcc/testsuite/g++.dg/cpp0x/vt-34219-2.C new file mode 100644 index 000000000..193bc0c6c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34219-2.C @@ -0,0 +1,22 @@ +// { dg-options "-std=c++0x" } +template<template<typename... T> class Comp, typename... T> void f( T... Value) +{ + static_assert( Comp<T>::value > 0, "" ); // { dg-error "parameter packs|T" } +} + +template<template<typename... T> class Comp, typename... T> void g( T... Value) +{ + static_assert( Comp<T...>::value > 0, "" ); +} + +template <typename... T> +struct Foo +{ + static const int value=1; +}; + +int main() +{ + f<Foo>( 2 ); + g<Foo>( 2 ); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34219.C b/gcc/testsuite/g++.dg/cpp0x/vt-34219.C new file mode 100644 index 000000000..fb3584ea8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34219.C @@ -0,0 +1,15 @@ +// { dg-options "-std=c++0x" } +template<typename T, T a, T... Params> +struct max +{ + static const T value = a > max<T, Params>::value ? a : max<T, Params>::value; // { dg-error "not expanded|Params" } +}; + +template<typename T, T a, T b> +struct max<T, a, b> +{ + static const T value = a > b ? a : b; +}; + +static const int value1 = max< int, 1, 2>::value; +static const int value2 = max< int, 1, 3, 5>::value; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34314.C b/gcc/testsuite/g++.dg/cpp0x/vt-34314.C new file mode 100644 index 000000000..4a935b367 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34314.C @@ -0,0 +1,50 @@ +// { dg-options "-std=c++0x" } + +template<typename Fun, typename... Args> // { dg-error "template parameter" } +struct call; + +template<typename Fun, typename Arg0> +struct call // { dg-error "redeclared here" } +{ + template<typename Sig> + struct result; + + template<typename X, typename Y> + struct result<X(Y)> + { + typedef X type; + }; +}; + + +template<typename Fun, int... N> // { dg-error "template parameter" } +struct call2; + +template<typename Fun, int N> +struct call2 // { dg-error "redeclared here" } +{ + template<typename Sig> + struct result; + + template<typename X, typename Y> + struct result<X(Y)> + { + typedef X type; + }; +}; + +template<typename Fun, template<typename> class... TT> // { dg-error "template parameter" } +struct call3; + +template<typename Fun, template<typename> class TT> +struct call3 // { dg-error "redeclared here" } +{ + template<typename Sig> + struct result; + + template<typename X, typename Y> + struct result<X(Y)> + { + typedef X type; + }; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34399.C b/gcc/testsuite/g++.dg/cpp0x/vt-34399.C new file mode 100644 index 000000000..542fae586 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34399.C @@ -0,0 +1,10 @@ +// { dg-options "-std=c++0x" } +template<int...> struct A +{ + void foo(); +}; + +struct B +{ + template<int N> friend void A<N>::A::foo(); // { dg-error "declared as friend" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34606.C b/gcc/testsuite/g++.dg/cpp0x/vt-34606.C new file mode 100644 index 000000000..467943354 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34606.C @@ -0,0 +1,9 @@ +// { dg-options "-std=c++0x" } +template<typename...> struct A; + +template<typename T, typename... U> struct A<T, U> // { dg-error "parameter packs|U" } +{ + template<typename> struct B; + + template<typename X> struct B<X*> {}; +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34751.C b/gcc/testsuite/g++.dg/cpp0x/vt-34751.C new file mode 100644 index 000000000..e3ca39e79 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34751.C @@ -0,0 +1,19 @@ +// { dg-options "-std=c++0x" } +// PR c++/34751 +struct A {}; + +template<typename... Args = int> // { dg-error "cannot have a default" } +void f(Args... args = 0); // { dg-error "cannot have a default argument" } + +template<typename... Args> +void g(Args... = 0); // { dg-error "cannot have a default argument" } + + +template<int, typename T = A, int T::*...p = 0 > struct B {}; // { dg-error "cannot have a default argument|no default argument" } + +B<0> b; + +template<int, typename T = A, int T::*... = 0 > struct C {}; // { dg-error "cannot have a default argument|no default argument" } + +C<0> c; + diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34753.C b/gcc/testsuite/g++.dg/cpp0x/vt-34753.C new file mode 100644 index 000000000..15eaebebc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34753.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } +template<typename... T> struct A +{ + template<T> struct B {}; // { dg-error "not expanded|T" } +}; + +A<int>::B<0> b; + +template<typename... T> struct B +{ + template<T> B(); // { dg-error "not expanded|T" } +}; + +B<int> c; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34754.C b/gcc/testsuite/g++.dg/cpp0x/vt-34754.C new file mode 100644 index 000000000..97c006532 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34754.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x" } +template<template<int> class... T> struct A +{ + void foo(T<0>); // { dg-error "not expanded|T" } + void bar(T<0>); // { dg-error "not expanded|T" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34755.C b/gcc/testsuite/g++.dg/cpp0x/vt-34755.C new file mode 100644 index 000000000..9d5a3d1ca --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34755.C @@ -0,0 +1,6 @@ +// { dg-options "-std=c++0x" } +template<typename> struct A {}; + +template<template<typename> class... T> void foo(T<int>) {} // { dg-error "not expanded|T" } + +template void foo<A>(A<int>); // { dg-error "does not match" } diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34919.C b/gcc/testsuite/g++.dg/cpp0x/vt-34919.C new file mode 100644 index 000000000..829579918 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34919.C @@ -0,0 +1,13 @@ +// { dg-options "-std=c++0x" } +template<int... N> struct A +{ + static void foo() + { + int i = N; // { dg-error "not expanded|N" } + } +}; + +void bar() +{ + A<0>::foo(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-34961.C b/gcc/testsuite/g++.dg/cpp0x/vt-34961.C new file mode 100644 index 000000000..3a872146e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-34961.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +template<typename... T> struct A +{ + static const int i __attribute__((aligned(__alignof(T)))) = 0; // { dg-error "not expanded|T" } +}; + +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35023.C b/gcc/testsuite/g++.dg/cpp0x/vt-35023.C new file mode 100644 index 000000000..9db20503e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35023.C @@ -0,0 +1,11 @@ +// { dg-options "-std=c++0x" } +template<typename... T> int foo() +{ + T t; // { dg-error "parameter packs|T" } + return t; +} + +void bar() +{ + foo<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35024.C b/gcc/testsuite/g++.dg/cpp0x/vt-35024.C new file mode 100644 index 000000000..77f0b66bd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35024.C @@ -0,0 +1,11 @@ +// { dg-options "-std=c++0x" } +template<typename... T> int foo() +{ + typename T::X x; // { dg-error "parameter packs|T" } + return x; +} + +void bar() +{ + foo<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35026.C b/gcc/testsuite/g++.dg/cpp0x/vt-35026.C new file mode 100644 index 000000000..643a416c5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35026.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +template<typename... T> struct A +{ + T* x[1]; // { dg-error "parameter packs|T" } +}; + +A<int> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35147.C b/gcc/testsuite/g++.dg/cpp0x/vt-35147.C new file mode 100644 index 000000000..fecb36ec8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35147.C @@ -0,0 +1,18 @@ +// { dg-options "-std=c++0x" } + +template<typename _Tp> + _Tp&& forward(_Tp&& __t) { return __t; } // { dg-message "note" } + +void f(...); + +template<typename... Args> +void g(Args&&... args) +{ + f(forward<Args...>(args...)); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 11 } +} + +void h() +{ + g(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35242.C b/gcc/testsuite/g++.dg/cpp0x/vt-35242.C new file mode 100644 index 000000000..9cc859b87 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35242.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +struct A +{ + template<typename... T> struct B; +}; + +template<typename... T> struct A::B<T*> {}; // { dg-error "parameter packs|T" } diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35243.C b/gcc/testsuite/g++.dg/cpp0x/vt-35243.C new file mode 100644 index 000000000..4b5557442 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35243.C @@ -0,0 +1,9 @@ +// { dg-options "-std=c++0x" } +struct A {}; + +template<typename... T> struct B : T... +{ + B() : T(x)... {} // { dg-error "not declared" } +}; + +B<A> b; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-35331.C b/gcc/testsuite/g++.dg/cpp0x/vt-35331.C new file mode 100644 index 000000000..0add9819b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-35331.C @@ -0,0 +1,7 @@ +// { dg-options "-std=c++0x" } +template<typename...> struct A; + +template<typename...T> struct A<T*> // { dg-error "not expanded|T" } +{ + friend void foo(); +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-37737-1.C b/gcc/testsuite/g++.dg/cpp0x/vt-37737-1.C new file mode 100644 index 000000000..de11b1651 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-37737-1.C @@ -0,0 +1,12 @@ +// { dg-options "-std=c++0x" } +// { dg-prune-output "note" } + +void f() { } + +template<class U, class... T> +void f(){ f<T...>(); } // { dg-error "no matching" } + +int main() +{ + f<char>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-37737-2.C b/gcc/testsuite/g++.dg/cpp0x/vt-37737-2.C new file mode 100644 index 000000000..2ff7e5b0b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-37737-2.C @@ -0,0 +1,16 @@ +// { dg-options "-std=c++0x" } + +template<class U, class... T> +void f() // { dg-message "note" } +{ + f<T...>(); // { dg-error "no matching" } + // { dg-message "candidate" "candidate note" { target *-*-* } 6 } +} + +template<> +void f() { } // { dg-error "template-id" } + +int main() +{ + f<char>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/vt-40092.C b/gcc/testsuite/g++.dg/cpp0x/vt-40092.C new file mode 100644 index 000000000..ecb698061 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/vt-40092.C @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +template <typename... Types> struct package {}; + +template <int ArgGen> struct wrapper_gen {}; + +template <int ArgNest> struct wrapper_nest +{ + typedef wrapper_gen<ArgNest> type_nest; +}; + +template <int... ArgPack> +struct wrapper_pack +{ + typedef package<wrapper_gen <ArgPack>...> type_pack; + // incorrect error: expansion pattern 'wrapper_gen<ArgNest>' + // contains no argument packs +}; + + diff --git a/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x.C b/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x.C new file mode 100644 index 000000000..5ad9b61b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x.C @@ -0,0 +1,9 @@ +// { dg-options "-std=gnu++98 -Wc++0x-compat" } +int static_assert; // { dg-warning "will become a keyword" } +int nullptr; // { dg-warning "will become a keyword" } + +void foo() +{ + static_assert = 5; + nullptr = 5; +} |