diff options
Diffstat (limited to 'libstdc++-v3/testsuite/20_util')
13 files changed, 322 insertions, 20 deletions
diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc b/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc index 40d8219093e..56b4e4f413e 100644 --- a/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc @@ -26,7 +26,7 @@ void test01() { - std::chrono::duration<int> d1(1.0); + std::chrono::duration<int> d1(1.0); // { dg-error "no matching" } } void @@ -35,11 +35,7 @@ test02() using namespace std::chrono; duration<int, std::micro> d2(8); - duration<int, std::milli> d2_copy(d2); + duration<int, std::milli> d2_copy(d2); // { dg-error "no matching" } } -// { dg-error "instantiated from here" "" { target *-*-* } 29 } -// { dg-error "instantiated from here" "" { target *-*-* } 38 } -// { dg-error "not exactly representable" "" { target *-*-* } 227 } -// { dg-error "integral duration with floating point" "" { target *-*-* } 217 } -// { dg-excess-errors "In instantiation of" } +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc b/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc new file mode 100644 index 00000000000..4466d30097a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 20.8.3.1 duration constructors [time.duration.cons] + +#include <chrono> + +// DR 974. +void test01() +{ + using namespace std::chrono; + + duration<double> d(3.5); + duration<int> i = d; // { dg-error "conversion" } +} diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc index e8b6d33a1ea..297b5cb690d 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -31,6 +31,6 @@ void test01() test_type d; } -// { dg-error "rep cannot be a duration" "" { target *-*-* } 202 } +// { dg-error "rep cannot be a duration" "" { target *-*-* } 203 } // { dg-error "instantiated from here" "" { target *-*-* } 31 } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc index 91081836779..b83bf494db5 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -32,6 +32,6 @@ void test01() test_type d; } -// { dg-error "must be a specialization of ratio" "" { target *-*-* } 203 } +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 204 } // { dg-error "instantiated from here" "" { target *-*-* } 32 } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc index 540d72dde46..b4224401d47 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -33,6 +33,6 @@ void test01() test_type d; } -// { dg-error "period must be positive" "" { target *-*-* } 205 } +// { dg-error "period must be positive" "" { target *-*-* } 206 } // { dg-error "instantiated from here" "" { target *-*-* } 33 } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..646c4b25b0a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_convertible<test_type, test_type>; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc new file mode 100644 index 00000000000..1e8deb511c8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::is_convertible<int, int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc new file mode 100644 index 00000000000..6ec22d024a9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc @@ -0,0 +1,102 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_convertible; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_relationship<is_convertible, int, int>(true)) ); + VERIFY( (test_relationship<is_convertible, int, const int>(true)) ); + VERIFY( (test_relationship<is_convertible, volatile int, const int>(true)) ); + VERIFY( (test_relationship<is_convertible, int, float>(true)) ); + VERIFY( (test_relationship<is_convertible, double, float>(true)) ); + VERIFY( (test_relationship<is_convertible, float, int>(true)) ); + VERIFY( (test_relationship<is_convertible, int*, const int*>(true)) ); + VERIFY( (test_relationship<is_convertible, int*, void*>(true)) ); + VERIFY( (test_relationship<is_convertible, int[4], int*>(true)) ); + VERIFY( (test_relationship<is_convertible, float&, int>(true)) ); + VERIFY( (test_relationship<is_convertible, int, const int&>(true)) ); + VERIFY( (test_relationship<is_convertible, const int&, int>(true)) ); + VERIFY( (test_relationship<is_convertible, float, const int&>(true)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(*)(int)>(true)) ); + VERIFY( (test_relationship<is_convertible, int(&)(int), int(*)(int)>(true)) ); + VERIFY( (test_relationship<is_convertible, EnumType, int>(true)) ); + VERIFY( (test_relationship<is_convertible, ClassType, ClassType>(true)) ); + VERIFY( (test_relationship<is_convertible, DerivedType, ClassType>(true)) ); + VERIFY( (test_relationship<is_convertible, DerivedType*, ClassType*>(true)) ); + VERIFY( (test_relationship<is_convertible, DerivedType&, ClassType&>(true)) ); + + VERIFY( (test_relationship<is_convertible, const int, const int&>(true)) ); + + VERIFY( (test_relationship<is_convertible, void, void>(true)) ); + VERIFY( (test_relationship<is_convertible, const void, void>(true)) ); + VERIFY( (test_relationship<is_convertible, void, volatile void>(true)) ); + + // Negative tests. + VERIFY( (test_relationship<is_convertible, const int*, int*>(false)) ); + VERIFY( (test_relationship<is_convertible, int*, float*>(false)) ); + VERIFY( (test_relationship<is_convertible, const int[4], int*>(false)) ); + VERIFY( (test_relationship<is_convertible, int[4], int[4]>(false)) ); + VERIFY( (test_relationship<is_convertible, const int&, int&>(false)) ); + VERIFY( (test_relationship<is_convertible, float&, int&>(false)) ); + VERIFY( (test_relationship<is_convertible, float, volatile int&>(false)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(int)>(false)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(*)(void)>(false)) ); + VERIFY( (test_relationship<is_convertible, int(*)(int), + int(&)(int)>(false)) ); + VERIFY( (test_relationship<is_convertible, int, EnumType>(false)) ); + VERIFY( (test_relationship<is_convertible, int, ClassType>(false)) ); + VERIFY( (test_relationship<is_convertible, ClassType, DerivedType>(false)) ); + VERIFY( (test_relationship<is_convertible, ClassType*, + DerivedType*>(false)) ); + VERIFY( (test_relationship<is_convertible, ClassType&, + DerivedType&>(false)) ); + + VERIFY( (test_relationship<is_convertible, void, int>(false)) ); + VERIFY( (test_relationship<is_convertible, void, float>(false)) ); + VERIFY( (test_relationship<is_convertible, void, int(*)(int)>(false)) ); + + // C++0x + VERIFY( (test_relationship<is_convertible, int, void>(false)) ); + VERIFY( (test_relationship<is_convertible, int[4], void>(false)) ); + + VERIFY( (test_relationship<is_convertible, int, int&>(false)) ); + VERIFY( (test_relationship<is_convertible, float, + volatile float&>(false)) ); + VERIFY( (test_relationship<is_convertible, const volatile int, + const volatile int&>(false)) ); + VERIFY( (test_relationship<is_convertible, volatile int, + volatile int&>(false)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(&)(int)>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 3455462869b..2ae375454e0 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -3,7 +3,7 @@ // 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> // -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 570 } -// { dg-error "declaration of" "" { target *-*-* } 532 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 547 } +// { dg-error "declaration of" "" { target *-*-* } 509 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 3d3a10a9ba8..5bf030cabcb 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -3,7 +3,7 @@ // 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> // -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 491 } -// { dg-error "declaration of" "" { target *-*-* } 453 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 468 } +// { dg-error "declaration of" "" { target *-*-* } 430 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/pair/40925.cc b/libstdc++-v3/testsuite/20_util/pair/40925.cc new file mode 100644 index 00000000000..6abeb617fa0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/40925.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <utility> + +struct X +{ + explicit X(int, int) { } + +private: + X(const X&) = delete; +}; + +struct move_only +{ + move_only() { } + move_only(move_only&&) { } + +private: + move_only(const move_only&) = delete; +}; + +// libstdc++/40925 +void test01() +{ + int *ip = 0; + int X::*mp = 0; + + std::pair<int*, int*> p1(0, 0); + std::pair<int*, int*> p2(ip, 0); + std::pair<int*, int*> p3(0, ip); + std::pair<int*, int*> p4(ip, ip); + + std::pair<int X::*, int*> p5(0, 0); + std::pair<int X::*, int X::*> p6(mp, 0); + std::pair<int X::*, int X::*> p7(0, mp); + std::pair<int X::*, int X::*> p8(mp, mp); + + std::pair<int*, move_only> p9(0, move_only()); + std::pair<int X::*, move_only> p10(0, move_only()); + std::pair<move_only, int*> p11(move_only(), 0); + std::pair<move_only, int X::*> p12(move_only(), 0); + + std::pair<int*, move_only> p13(ip, move_only()); + std::pair<int X::*, move_only> p14(mp, move_only()); + std::pair<move_only, int*> p15(move_only(), ip); + std::pair<move_only, int X::*> p16(move_only(), mp); + + std::pair<move_only, move_only> p17(move_only(), move_only()); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc new file mode 100644 index 00000000000..6bd405c093b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// Tuple + +#include <tuple> + +class A {}; +class B : public A {}; + +// PR libstdc++/41530 +void test01() +{ + std::tuple<B*> b; + std::tuple<A*> a1(b); + std::tuple<A*> a2(std::move(b)); +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc index f0236eb2637..bf49aa6b080 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc @@ -49,10 +49,13 @@ test03() std::unique_ptr<int[2]> p2 = p1; } +// { dg-error "deleted function" "" { target *-*-* } 358 } // { dg-error "used here" "" { target *-*-* } 42 } // { dg-error "no matching" "" { target *-*-* } 48 } -// { dg-error "used here" "" { target *-*-* } 49 } -// { dg-error "candidates are" "" { target *-*-* } 213 } +// { dg-warning "candidates are" "" { target *-*-* } 119 } +// { dg-warning "note" "" { target *-*-* } 112 } +// { dg-warning "note" "" { target *-*-* } 107 } +// { dg-warning "note" "" { target *-*-* } 102 } +// { dg-warning "note" "" { target *-*-* } 96 } // { dg-error "deleted function" "" { target *-*-* } 213 } -// { dg-error "deleted function" "" { target *-*-* } 358 } -// { dg-excess-errors "note" } +// { dg-error "used here" "" { target *-*-* } 49 } |