diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/libstdc++-v3/testsuite/20_util | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/libstdc++-v3/testsuite/20_util')
671 files changed, 36767 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_const/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_const/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..77675ee92 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_const/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 add_const<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_const/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_const/value.cc new file mode 100644 index 000000000..8c35ec8ca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_const/value.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::add_const; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<add_const<int>::type, const int>::value, ""); + static_assert(is_same<add_const<volatile int>::type, + const volatile int>::value, ""); + static_assert(is_same<add_const<int*>::type, int* const>::value, ""); + static_assert(is_same<add_const<int&>::type, int&>::value, ""); + static_assert(is_same<add_const<int (int)>::type, int (int)>::value, ""); + static_assert(is_same<add_const<const int>::type, const int>::value, ""); + static_assert(is_same<add_const<ClassType>::type, + const ClassType>::value, ""); + static_assert(is_same<add_const<volatile ClassType>::type, + const volatile ClassType>::value, ""); + static_assert(is_same<add_const<ClassType*>::type, + ClassType* const>::value, ""); + static_assert(is_same<add_const<ClassType&>::type, ClassType&>::value, ""); + static_assert(is_same<add_const<ClassType (ClassType)>::type, + ClassType (ClassType)>::value, ""); + static_assert(is_same<add_const<const ClassType>::type, + const ClassType>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_cv/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_cv/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..bc0f0394d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_cv/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 add_cv<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_cv/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_cv/value.cc new file mode 100644 index 000000000..727a22d9d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_cv/value.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::add_cv; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<add_cv<int>::type, const volatile int>::value, ""); + static_assert(is_same<add_cv<const int>::type, + const volatile int>::value, ""); + static_assert(is_same<add_cv<int*>::type, int* const volatile>::value, ""); + static_assert(is_same<add_cv<int&>::type, int&>::value, ""); + static_assert(is_same<add_cv<int (int)>::type, int (int)>::value, ""); + static_assert(is_same<add_cv<const volatile int>::type, + const volatile int>::value, ""); + static_assert(is_same<add_cv<ClassType>::type, + const volatile ClassType>::value, ""); + static_assert(is_same<add_cv<volatile ClassType>::type, + const volatile ClassType>::value, ""); + static_assert(is_same<add_cv<ClassType*>::type, + ClassType* const volatile>::value, ""); + static_assert(is_same<add_cv<ClassType&>::type, ClassType&>::value, ""); + static_assert(is_same<add_cv<ClassType (ClassType)>::type, + ClassType (ClassType)>::value, ""); + static_assert(is_same<add_cv<const volatile ClassType>::type, + const volatile ClassType>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d5fb35265 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 add_lvalue_reference<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..b1685442f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +static_assert( is_same<typename add_lvalue_reference<long>::type, + add_lvalue_reference_t<long>>(), + "add_lvalue_reference_t" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc new file mode 100644 index 000000000..784e1186a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_lvalue_reference/value.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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_tr1.h> + +void test01() +{ + using std::add_lvalue_reference; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<add_lvalue_reference<int>::type, int&>::value, ""); + static_assert(is_same<add_lvalue_reference<int&>::type, int&>::value, "" ); + static_assert(is_same<add_lvalue_reference<const int>::type, + const int&>::value, ""); + static_assert(is_same<add_lvalue_reference<int*>::type, int*&>::value, ""); + static_assert(is_same<add_lvalue_reference<ClassType&>::type, + ClassType&>::value, ""); + static_assert(is_same<add_lvalue_reference<ClassType>::type, + ClassType&>::value, ""); + static_assert(is_same<add_lvalue_reference<int(int)>::type, + int(&)(int)>::value, ""); + static_assert(is_same<add_lvalue_reference<int&&>::type, int&>::value, ""); + static_assert(is_same<add_lvalue_reference<ClassType&&>::type, + ClassType&>::value, ""); + static_assert(is_same<add_lvalue_reference<void>::type, void>::value, ""); + static_assert(is_same<add_lvalue_reference<const void>::type, + const void>::value, ""); + static_assert(is_same<add_lvalue_reference<bool(int) const>::type, + bool(int) const>::value, ""); + static_assert(is_same<add_lvalue_reference<bool(int) &>::type, + bool(int) &>::value, ""); + static_assert(is_same<add_lvalue_reference<bool(int) const &&>::type, + bool(int) const &&>::value, ""); + static_assert(is_same<add_lvalue_reference<bool(int)>::type, + bool(&)(int)>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_pointer/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..105fe84de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 add_pointer<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_pointer/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_pointer/value.cc new file mode 100644 index 000000000..797edcbd8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_pointer/value.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::add_pointer; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<add_pointer<int>::type, int*>::value, ""); + static_assert(is_same<add_pointer<int*>::type, int**>::value, ""); + static_assert(is_same<add_pointer<const int>::type, const int*>::value, ""); + static_assert(is_same<add_pointer<int&>::type, int*>::value, ""); + static_assert(is_same<add_pointer<ClassType*>::type, + ClassType**>::value, ""); + static_assert(is_same<add_pointer<ClassType>::type, ClassType*>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..def40603d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 add_rvalue_reference<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..ac1ecef88 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +static_assert( is_same<typename add_rvalue_reference<long>::type, + add_rvalue_reference_t<long>>(), + "add_rvalue_reference_t" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc new file mode 100644 index 000000000..c769a2f39 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_rvalue_reference/value.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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_tr1.h> + +void test01() +{ + using std::add_rvalue_reference; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<add_rvalue_reference<int>::type, int&&>::value, ""); + static_assert(is_same<add_rvalue_reference<int&&>::type, int&&>::value, ""); + static_assert(is_same<add_rvalue_reference<int&>::type, int&>::value, ""); + static_assert(is_same<add_rvalue_reference<const int>::type, + const int&&>::value, ""); + static_assert(is_same<add_rvalue_reference<int*>::type, int*&&>::value, ""); + static_assert(is_same<add_rvalue_reference<ClassType&&>::type, + ClassType&&>::value, ""); + static_assert(is_same<add_rvalue_reference<ClassType>::type, + ClassType&&>::value, ""); + static_assert(is_same<add_rvalue_reference<int(int)>::type, + int(&&)(int)>::value, ""); + static_assert(is_same<add_rvalue_reference<void>::type, void>::value, ""); + static_assert(is_same<add_rvalue_reference<const void>::type, + const void>::value, ""); + static_assert(is_same<add_rvalue_reference<bool(int) const>::type, + bool(int) const>::value, ""); + static_assert(is_same<add_rvalue_reference<bool(int) &>::type, + bool(int) &>::value, ""); + static_assert(is_same<add_rvalue_reference<bool(int) const &&>::type, + bool(int) const &&>::value, ""); + static_assert(is_same<add_rvalue_reference<bool(int)>::type, + bool(&&)(int)>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_volatile/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_volatile/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..78929d10f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_volatile/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 add_volatile<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/add_volatile/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_volatile/value.cc new file mode 100644 index 000000000..b44b1d980 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/add_volatile/value.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::add_volatile; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<add_volatile<int>::type, volatile int>::value, ""); + static_assert(is_same<add_volatile<const int>::type, + const volatile int>::value, ""); + static_assert(is_same<add_volatile<int*>::type, int* volatile>::value, ""); + static_assert(is_same<add_volatile<int&>::type, int&>::value, ""); + static_assert(is_same<add_volatile<int (int)>::type, int (int)>::value, ""); + static_assert(is_same<add_volatile<volatile int>::type, + volatile int>::value, ""); + static_assert(is_same<add_volatile<ClassType>::type, + volatile ClassType>::value, ""); + static_assert(is_same<add_volatile<const ClassType>::type, + const volatile ClassType>::value, ""); + static_assert(is_same<add_volatile<ClassType*>::type, + ClassType* volatile>::value, ""); + static_assert(is_same<add_volatile<ClassType&>::type, ClassType&>::value, ""); + static_assert(is_same<add_volatile<ClassType (ClassType)>::type, + ClassType (ClassType)>::value, ""); + static_assert(is_same<add_volatile<volatile ClassType>::type, + volatile ClassType>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/addressof/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/addressof/1.cc new file mode 100644 index 000000000..2a5d30e7e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/addressof/1.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +void f1(int) { } + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace __gnu_test; + + OverloadedAddress* ao1 = new OverloadedAddress(); + OverloadedAddress& o1 = *ao1; + + VERIFY( std::addressof(o1) == ao1 ); + + const OverloadedAddress* ao2 = new OverloadedAddress(); + const OverloadedAddress& o2 = *ao2; + + VERIFY( std::addressof(o2) == ao2 ); + + VERIFY( std::addressof(f1) == &f1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..5adb20310 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/addressof/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 utility with NO OTHER INCLUDES. + +#include <memory> + +namespace std +{ + typedef short test_type; + template short* addressof(short&); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..ad15d9cca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/aligned_storage/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-09-17 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 aligned_storage<1, alignment_of<test_type>::value>; + template struct aligned_storage<2>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc new file mode 100644 index 000000000..0f949db63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/aligned_storage/value.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-09-17 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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_tr1.h> + +struct MSAlignType { } __attribute__((__aligned__)); + +void test01() +{ + using std::aligned_storage; + using std::alignment_of; + using namespace __gnu_test; + + const std::size_t align_c = alignment_of<char>::value; + static_assert(sizeof(aligned_storage<4, align_c>::type) >= 4, ""); + static_assert(__alignof__(aligned_storage<4, align_c>::type) == align_c, ""); + + const std::size_t align_s = alignment_of<short>::value; + static_assert(sizeof(aligned_storage<1, align_s>::type) >= 1, ""); + static_assert(__alignof__(aligned_storage<1, align_s>::type) == align_s, ""); + + const std::size_t align_i = alignment_of<int>::value; + static_assert(sizeof(aligned_storage<7, align_i>::type) >= 7, ""); + static_assert(__alignof__(aligned_storage<7, align_i>::type) == align_i, ""); + + const std::size_t align_d = alignment_of<double>::value; + static_assert(sizeof(aligned_storage<2, align_d>::type) >= 2, ""); + static_assert(__alignof__(aligned_storage<2, align_d>::type) == align_d, ""); + + const std::size_t align_ai = alignment_of<int[4]>::value; + static_assert(sizeof(aligned_storage<20, align_ai>::type) >= 20, ""); + static_assert(__alignof__(aligned_storage<20, align_ai>::type) == align_ai, + ""); + + const std::size_t align_ct = alignment_of<ClassType>::value; + static_assert(sizeof(aligned_storage<11, align_ct>::type) >= 11, ""); + static_assert(__alignof__(aligned_storage<11, align_ct>::type) == align_ct, + ""); + + const std::size_t align_msa = alignment_of<MSAlignType>::value; + static_assert(sizeof(aligned_storage<5>::type) >= 5, ""); + static_assert(__alignof__(aligned_storage<5>::type) == align_msa, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..9d80c5a89 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 alignment_of<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/requirements/typedefs.cc new file mode 100644 index 000000000..7f2b1b899 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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::alignment_of<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/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/value.cc new file mode 100644 index 000000000..5ad741d8b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/alignment_of/value.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::alignment_of; + using namespace __gnu_test; + + static_assert(test_property<alignment_of, char>(__alignof__(char)), ""); + static_assert(test_property<alignment_of, short>(__alignof__(short)), ""); + static_assert(test_property<alignment_of, int>(__alignof__(int)), ""); + static_assert(test_property<alignment_of, double>(__alignof__(double)), ""); + static_assert(test_property<alignment_of, int[4]>(__alignof__(int[4])), ""); + static_assert(test_property<alignment_of, + ClassType>(__alignof__(ClassType)), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/1.cc new file mode 100644 index 000000000..4cd11eaaa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/1.cc @@ -0,0 +1,65 @@ +// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.4.1.1 allocator members + +#include <memory> +#include <stdexcept> +#include <cstdlib> +#include <testsuite_hooks.h> + +struct gnu { }; + +bool check_new = false; +bool check_delete = false; + +void* +operator new(std::size_t n) throw(std::bad_alloc) +{ + check_new = true; + return std::malloc(n); +} + +void operator delete(void *v) throw() +{ + check_delete = true; + return std::free(v); +} + +void test01() +{ + bool test __attribute__((unused)) = true; + std::allocator<gnu> obj; + + // NB: These should work for various size allocation and + // deallocations. Currently, they only work as expected for sizes > + // _MAX_BYTES as defined in stl_alloc.h, which happes to be 128. + gnu* pobj = obj.allocate(256); + VERIFY( check_new ); + + obj.deallocate(pobj, 256); + VERIFY( check_delete ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/10378.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/10378.cc new file mode 100644 index 000000000..5a141362f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/10378.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2003-2014 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/>. + +// 20.1.5 allocator requirements / 20.4.1.1 allocator members + +#include <list> +#include <cstdlib> +#include <testsuite_hooks.h> + +class Bob +{ +public: + static void* operator new(size_t sz) + { return std::malloc(sz); } +}; + +// libstdc++/10378 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + list<Bob> uniset; + uniset.push_back(Bob()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/14176.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/14176.cc new file mode 100644 index 000000000..9283d3d88 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/14176.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2004-2014 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/>. + +// 20.4.1.1 allocator members + +#include <memory> +#include <testsuite_hooks.h> + +// libstdc++/14176 +void test02() +{ + unsigned int len = 0; + std::allocator<int> a; + int* p = a.allocate(len); + a.deallocate(p, len); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/33807.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/33807.cc new file mode 100644 index 000000000..187e66416 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/33807.cc @@ -0,0 +1,32 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <list> + +// libstdc++/33807 +template <class T> +bool operator != (const T& x, const T& y) { return !(x == y); } + +struct foo { }; + +void fnx() +{ + std::list<foo> l1, l2; + l1 = l2; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/8230.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/8230.cc new file mode 100644 index 000000000..9446cf1a3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/8230.cc @@ -0,0 +1,53 @@ +// 2001-06-14 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.4.1.1 allocator members + +#include <memory> +#include <stdexcept> +#include <testsuite_hooks.h> + +// libstdc++/8230 +void test02() +{ + bool test __attribute__((unused)) = true; + try + { + std::allocator<int> alloc; + const std::allocator<int>::size_type n = alloc.max_size(); + int* p = alloc.allocate(n + 1); + p[n] = 2002; + } + catch(const std::bad_alloc& e) + { + // Allowed. + test = true; + } + catch(...) + { + test = false; + } + VERIFY( test ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..177ca637b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <memory> + +template class std::allocator<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc new file mode 100644 index 000000000..8954ce517 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <memory> +#include <type_traits> + +// Check std::allocator for required typedefs. + +using std::is_same; +using std::allocator; + +static_assert( is_same<allocator<int>::size_type, std::size_t>::value, + "size_type" ); +static_assert( is_same<allocator<int>::difference_type, std::ptrdiff_t>::value, + "difference_type" ); +static_assert( is_same<allocator<int>::pointer, int*>::value, + "pointer" ); +static_assert( is_same<allocator<int>::const_pointer, const int*>::value, + "const_pointer" ); +static_assert( is_same<allocator<int>::reference, int&>::value, + "reference" ); +static_assert( is_same<allocator<int>::const_reference, const int&>::value, + "const_reference" ); +static_assert( is_same<allocator<int>::value_type, int>::value, + "value_type" ); + +static_assert( is_same<allocator<int>::rebind<char>::other, + allocator<char>>::value, + "rebind::other" ); + +static_assert( is_same<allocator<int>::propagate_on_container_move_assignment, + std::true_type>::value, + "propagate_on_container_move_assignment" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/allocate_hint.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/allocate_hint.cc new file mode 100644 index 000000000..31ba9b615 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/allocate_hint.cc @@ -0,0 +1,90 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <cstddef> +#include <testsuite_hooks.h> + +struct X { }; + +template<typename T> +struct hintable_allocator +{ + typedef T value_type; + struct const_void_pointer { }; + typedef unsigned size_type; + + hintable_allocator() : called(false) { } + + bool called; + + // this is the overload that should get called: + T* allocate(size_type n, const_void_pointer) { called = true; return 0; } + + // none of these should get called: + T* allocate(size_type n); + T* allocate(size_type n, void*); + T* allocate(size_type n, const void*); + T* allocate(size_type n, const_void_pointer) const; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::allocator_traits<hintable_allocator<X>> traits_type; + traits_type::allocator_type a; + traits_type::const_void_pointer v; + X* p __attribute__((unused)) = traits_type::allocate(a, 1, v); + VERIFY( a.called ); +} + +template<typename T> +struct unhintable_allocator +{ + typedef T value_type; + typedef unsigned size_type; + + unhintable_allocator() : called(false) { } + + bool called; + + // this is the overload that should get called: + T* allocate(size_type n) { called = true; return 0; } + + // this should not get called: + T* allocate(size_type n, void*); +}; + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::allocator_traits<unhintable_allocator<X>> traits_type; + traits_type::allocator_type a; + traits_type::const_void_pointer v; + X* p __attribute__((unused)) = traits_type::allocate(a, 1, v); + VERIFY( a.called ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc new file mode 100644 index 000000000..b5883dccc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2014 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 <memory> +#include <testsuite_allocator.h> + +// User-defined pointer type with non-trivial destructor. +template<typename T> +struct Pointer : __gnu_test::PointerBase<Pointer<T>, T> +{ + using __gnu_test::PointerBase<Pointer<T>, T>::PointerBase; + + ~Pointer() { /* non-trivial */ } +}; + +// Minimal allocator with user-defined pointer type. +template<typename T> +struct Alloc +{ + typedef T value_type; + typedef Pointer<T> pointer; + + Alloc() = default; + + template<typename U> + Alloc(const Alloc<U>&) { } + + pointer allocate(std::size_t n) // does not take a hint + { return pointer(std::allocator<T>().allocate(n)); } + + void deallocate(pointer p, std::size_t n) + { std::allocator<T>().deallocate(p.value, n); } +}; + +template<typename T> +bool operator==(Alloc<T> l, Alloc<T> r) { return true; } + +template<typename T> +bool operator!=(Alloc<T> l, Alloc<T> r) { return false; } + +void test01() +{ + typedef std::allocator_traits<Alloc<int>> traits_type; + traits_type::allocator_type a; + traits_type::const_void_pointer v; + traits_type::pointer p = traits_type::allocate(a, 1, v); + traits_type::deallocate(a, p, 1); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/construct.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/construct.cc new file mode 100644 index 000000000..9f4503331 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/construct.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <cstddef> +#include <testsuite_hooks.h> + +struct X +{ + static int counter; + X() { } + X(const X&) { ++counter; } + explicit X(int) { ++counter; } + X(int, int) { ++counter; } + X(int, int, int) { ++counter; } +}; + +int X::counter = 0; + +template<typename T> +struct fake_allocator +{ + typedef T value_type; + + fake_allocator() : counter() {} + + int counter; + + T* allocate(std::size_t n) { return (T*)new char[n*sizeof(T)]; } + void deallocate(T* p, std::size_t) { delete[] (char*)p; } + + // don't actually construct anything when these are called + void construct(T* p) { ++counter; } + void construct(T* p, int, int) { ++counter; } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::allocator_traits<fake_allocator<X>> traits_type; + traits_type::allocator_type a; + X* p = traits_type::allocate(a, 1); + traits_type::construct(a, p); + VERIFY( a.counter == 1 ); + traits_type::construct(a, p, 1); + VERIFY( a.counter == 1 ); + VERIFY( X::counter == 1 ); + traits_type::destroy(a, p); + traits_type::construct(a, p, 1, 1); + VERIFY( a.counter == 2 ); + VERIFY( X::counter == 1 ); + traits_type::construct(a, p, 1, 1, 1); + VERIFY( a.counter == 2 ); + VERIFY( X::counter == 2 ); + traits_type::destroy(a, p); + traits_type::deallocate(a, p, 1); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/destroy.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/destroy.cc new file mode 100644 index 000000000..8cd704e15 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/destroy.cc @@ -0,0 +1,83 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <new> +#include <testsuite_hooks.h> + +struct X +{ + static int counter; + ~X() { ++counter; } +}; + +int X::counter = 0; + +template<typename T> +struct allocator_with_destroy +{ + typedef T value_type; + + allocator_with_destroy() : called() { } + + void destroy(T* p) { called = true; } + + int called; +}; + +template<typename T> +struct allocator_without_destroy +{ + typedef T value_type; + + allocator_without_destroy() : called() { } + + int called; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::allocator_traits<allocator_with_destroy<X>> traits_type; + traits_type::allocator_type a; + X* p = 0; + traits_type::destroy(a, p); + VERIFY( a.called ); + VERIFY( X::counter == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::allocator_traits<allocator_without_destroy<X>> traits_type; + traits_type::allocator_type a; + char buf[sizeof(X)]; + X* p = ::new (static_cast<void*>(buf)) X(); + traits_type::destroy(a, p); + VERIFY( !a.called ); + VERIFY( X::counter == 1 ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/max_size.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/max_size.cc new file mode 100644 index 000000000..e42b1531e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/max_size.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <limits> +#include <type_traits> +#include <testsuite_hooks.h> + +struct X { }; + +template<typename T> +struct maxsize_allocator +{ + typedef T value_type; + typedef unsigned size_type; + + size_type max_size() const { return 100; } +}; + +template<typename T> +struct unsized_allocator +{ + typedef T value_type; +}; + + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::allocator_traits<maxsize_allocator<X>> traits_type; + traits_type::allocator_type a; + auto size = a.max_size(); + VERIFY( traits_type::max_size(a) == size ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + typedef std::allocator_traits<unsized_allocator<X>> traits_type; + traits_type::allocator_type a; + auto size = std::numeric_limits<traits_type::size_type>::max(); + VERIFY( traits_type::max_size(a) == size ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/select.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/select.cc new file mode 100644 index 000000000..29ceb67de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/members/select.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <testsuite_hooks.h> + +struct X { }; + +template<typename T> +struct alloc1 +{ + typedef T value_type; + + int id; +}; + +template<typename T> +struct alloc2 +{ + typedef T value_type; + + int id; + + alloc2 select_on_container_copy_construction() const + { return alloc2{id+1}; } +}; + + +void test01() +{ + typedef std::allocator_traits<alloc1<X>> traits_type; + traits_type::allocator_type a{1}; + const traits_type::allocator_type& a2 + = traits_type::select_on_container_copy_construction(a); + VERIFY( a2.id == a.id ); +} + +void test02() +{ + typedef std::allocator_traits<alloc2<X>> traits_type; + traits_type::allocator_type a{1}; + const traits_type::allocator_type& a2 + = traits_type::select_on_container_copy_construction(a); + VERIFY( a2.id != a.id ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..2c379ccd9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 memory with NO OTHER INCLUDES. + +#include <memory> + +typedef short test_type; + +template<typename T> + struct minimal_allocator + { + typedef T value_type; + minimal_allocator(); + template <typename U> + minimal_allocator(const minimal_allocator<U>&); + T* allocate(std::size_t); + void deallocate(T*, std::size_t); + }; + +namespace std +{ + template struct allocator_traits<std::allocator<test_type>>; + template struct allocator_traits<minimal_allocator<test_type>>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/typedefs.cc new file mode 100644 index 000000000..4c7270b39 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/typedefs.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 memory with NO OTHER INCLUDES. + +#include <memory> + +// { dg-do compile } + +template<typename T> +void test01() +{ + // Check for required typedefs + typedef std::allocator_traits<T> test_type; + typedef typename test_type::allocator_type allocator_type; + typedef typename test_type::value_type value_type; + typedef typename test_type::pointer pointer; + typedef typename test_type::const_pointer const_pointer; + typedef typename test_type::void_pointer void_pointer; + typedef typename test_type::const_void_pointer const_void_pointer; + typedef typename test_type::difference_type difference_type; + typedef typename test_type::size_type size_type; + typedef typename test_type::propagate_on_container_copy_assignment + propagate_on_container_copy_assignment; + typedef typename test_type::propagate_on_container_move_assignment + propagate_on_container_move_assignment; + typedef typename test_type::propagate_on_container_swap + propagate_on_container_swap; +} + +struct S { }; + +int main() +{ + test01<std::allocator<int>>(); + test01<std::allocator<S>>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/typedefs2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/typedefs2.cc new file mode 100644 index 000000000..04521a269 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/allocator_traits/requirements/typedefs2.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013 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 <memory> +#include <testsuite_allocator.h> + +// { dg-do compile } + +template<typename T> +struct ptr +{ + ptr() = default; + template<typename U> + ptr(ptr<U> const& p) { } +}; + +// This doesn't meet the allocator requirements, it's only to check +// that allocator_traits finds the right nested types. +template<typename T> +struct alloc +{ + typedef T value_type; + + typedef ptr<T> pointer; + typedef ptr<const T> const_pointer; + typedef ptr<void> void_pointer; + typedef ptr<const void> const_void_pointer; + typedef int difference_type; + typedef int size_type; + + typedef std::false_type propagate_on_container_copy_assignment; + typedef std::false_type propagate_on_container_move_assignment; + typedef std::false_type propagate_on_container_swap; +}; + +typedef alloc<int> alloc_type; +typedef std::allocator_traits<alloc_type> traits; + +using std::is_same; + +static_assert( is_same<traits::pointer, alloc_type::pointer>::value, + "pointer" ); + +static_assert( is_same<traits::const_pointer, + alloc_type::const_pointer>::value, + "const_pointer" ); + +static_assert( is_same<traits::void_pointer, alloc_type::void_pointer>::value, + "void_pointer" ); + +static_assert( is_same<traits::const_void_pointer, + alloc_type::const_void_pointer>::value, + "const_void_pointer"); + +static_assert( is_same<traits::difference_type, + alloc_type::difference_type>::value, + "difference_type" ); + +static_assert( is_same<traits::size_type, alloc_type::size_type>::value, + "size_type" ); + +static_assert( is_same<traits::size_type, alloc_type::size_type>::value, + "size_type" ); + +static_assert( is_same<traits::propagate_on_container_copy_assignment, + alloc_type::propagate_on_container_copy_assignment + >::value, + "propagate_on_container_copy_assignment" ); + +static_assert( is_same<traits::propagate_on_container_move_assignment, + alloc_type::propagate_on_container_move_assignment + >::value, + "propagate_on_container_move_assignment" ); + +static_assert( is_same<traits::propagate_on_container_swap, + alloc_type::propagate_on_container_swap>::value, + "propagate_on_container_swap" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc new file mode 100644 index 000000000..e7c82864f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/1.cc @@ -0,0 +1,94 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.4.5.1 auto_ptr constructors [lib.auto.ptr.cons] + +// Construction from pointer +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::auto_ptr<A> A_from_A(new A); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::auto_ptr<A> A_from_B(new B); + VERIFY( A_from_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc new file mode 100644 index 000000000..4b7ba1bd2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/2.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// Construction from std::auto_ptr +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<B> B_from_B(new B); + + std::auto_ptr<A> A_from_ptr_A(A_from_A); + std::auto_ptr<A> A_from_ptr_B(B_from_B); + VERIFY( A_from_A.get() == 0 ); + VERIFY( B_from_B.get() == 0 ); + VERIFY( A_from_ptr_A.get() != 0 ); + VERIFY( A_from_ptr_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc new file mode 100644 index 000000000..fd24c5510 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/3.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// Assignment from std::auto_ptr +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_from_ptr_A; + std::auto_ptr<A> A_from_ptr_B; + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<B> B_from_B(new B); + + A_from_ptr_A = A_from_A; + A_from_ptr_B = B_from_B; + VERIFY( A_from_A.get() == 0 ); + VERIFY( B_from_B.get() == 0 ); + VERIFY( A_from_ptr_A.get() != 0 ); + VERIFY( A_from_ptr_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc new file mode 100644 index 000000000..3e040bff5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/3946.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr<Derived> +conversiontest08() { return std::auto_ptr<Derived>(new Derived); } + +void +test08() +{ + std::auto_ptr<Base> ptr; + ptr = conversiontest08(); +} + + +int +main() +{ + test08(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc new file mode 100644 index 000000000..df8972db0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/4.cc @@ -0,0 +1,82 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// Destruction +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + {/*lifetine scope*/ + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<A> A_from_B(new B); + std::auto_ptr<B> B_from_B(new B); + }/*destructors called here*/ + + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 3 ); + VERIFY( B::ctor_count == 2 ); + VERIFY( B::dtor_count == 2 ); + + return 0; +} + +int +main() +{ + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc new file mode 100644 index 000000000..a3e178129 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/5.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// Class member construction/destruction +template <typename T> +class pimpl +{ +public: + pimpl() : p_impl(new T) {} +private: + std::auto_ptr<T> p_impl; +}; + +int +test05() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + pimpl<A>(); + pimpl<B>(); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); + return 0; +} + +int +main() +{ + test05(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc new file mode 100644 index 000000000..0b8d79f29 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/6.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.4.5.2 auto_ptr members [lib.auto.ptr.members] + +// Member access +int +test06() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> A_from_A(new A); + std::auto_ptr<A> A_from_A_ptr(A_from_A.release()); + VERIFY( A_from_A.get() == 0 ); + VERIFY( A_from_A_ptr.get() != 0 ); + VERIFY( A_from_A_ptr->ctor_count == 1 ); + VERIFY( (*A_from_A_ptr).dtor_count == 0 ); + + A* A_ptr = A_from_A_ptr.get(); + + A_from_A_ptr.reset(A_ptr); + VERIFY( A_from_A_ptr.get() == A_ptr ); + VERIFY( A_from_A_ptr->ctor_count == 1 ); + VERIFY( (*A_from_A_ptr).dtor_count == 0 ); + + A_from_A_ptr.reset(new A); + VERIFY( A_from_A_ptr.get() != A_ptr ); + VERIFY( A_from_A_ptr->ctor_count == 2 ); + VERIFY( (*A_from_A_ptr).dtor_count == 1 ); + return 0; +} + +int +main() +{ + test06(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc new file mode 100644 index 000000000..50553d6ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/7.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2000-2014 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/>. + +// 20.4.5 Template class auto_ptr [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.4.5.3 auto_ptr conversions [lib.auto.ptr.conv] + +// Parameters and return values +template <typename T> +static std::auto_ptr<T> source() +{ + return std::auto_ptr<T>(new T); +} + +template <typename T> +static void drain(std::auto_ptr<T>) +{} + +int +test07() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + drain(source<A>()); + // The resolution of core issue 84, now a DR, breaks this call. + // drain<A>(source<B>()); + drain(source<B>()); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); + return 0; +} + +int +main() +{ + test07(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc new file mode 100644 index 000000000..c88d4a291 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/assign_neg.cc @@ -0,0 +1,51 @@ +// { dg-do compile } + +// Copyright (C) 2002-2014 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/>. + +// 20.4.5 Template class auto_ptr negative tests [lib.auto.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +// via Jack Reeves <jack_reeves@hispeed.ch> +// libstdc++/3946 +// http://gcc.gnu.org/ml/libstdc++/2002-07/msg00024.html +struct Base { }; +struct Derived : public Base { }; + +std::auto_ptr<Derived> +foo() { return std::auto_ptr<Derived>(new Derived); } + +int +test01() +{ + std::auto_ptr<Base> ptr2; + ptr2 = new Base; // { dg-error "no match" } + // { dg-error "candidate" "candidate note" { target *-*-* } 38 } + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-error "::auto_ptr|no known conversion" "" { target *-*-* } 136 } +// { dg-error "note" "" { target *-*-* } 154 } +// { dg-error "::auto_ptr|no known conversion" "" { target *-*-* } 264 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..dd9b6c5a2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <memory> + +template class std::auto_ptr<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc new file mode 100644 index 000000000..c6c34ab67 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bad_function_call/cons_virtual_derivation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 <functional> +#include <testsuite_api.h> + +int main() +{ + typedef std::bad_function_call test_type; + __gnu_test::diamond_derivation<test_type, true>::test(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bad_function_call/what.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bad_function_call/what.cc new file mode 100644 index 000000000..4302169c3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bad_function_call/what.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 <functional> +#include <testsuite_hooks.h> + +int main() +{ + try + { + std::function<void()>{}(); + } + catch (const std::exception& e) + { + VERIFY( e.what() == std::string("bad_function_call") ); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/35569.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/35569.cc new file mode 100644 index 000000000..5f1f2b55b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/35569.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010-2014 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/>. + +// 20.7.11 Function template bind + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <functional> + +using namespace std; +using namespace std::placeholders; + +void test01() +{ + bind(multiplies<int>(),4,_1)(5); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/38889.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/38889.cc new file mode 100644 index 000000000..fdff30267 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/38889.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2010-2014 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/>. + +// 20.7.11 Function template bind + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <functional> + +void goo(int); +void foo() { + std::bind (goo,1)(); + std::bind (goo,std::placeholders::_1)(1); +} + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/42593.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/42593.cc new file mode 100644 index 000000000..4bae9e132 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/42593.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2010-2014 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/>. + +// 20.7.11 Function template bind + +#include <functional> + +void f( int ) {} + +void test01() +{ + std::function< void( int ) > pf = std::bind( &f, std::placeholders::_1 ); + pf(1); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/45924.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/45924.cc new file mode 100644 index 000000000..15905805c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/45924.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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 <functional> + +// PR libstdc++/45924 + +struct f +{ + int operator()(int, int) const { return 0; } +}; + +void test01() +{ + int i = 0; + using namespace std::placeholders; + auto b = std::bind<int>(f(), _1, _2); + auto const bc(b); + b(i, i); + bc(i, i); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/48698.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/48698.cc new file mode 100644 index 000000000..2dd5fa12d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/48698.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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/>. + +// 20.7.11 Function template bind + +#include <functional> + +int f(int i); + +// Don't want placeholders to interfere with a possibly-versioned namespace. +void g() +{ + std::bind(f, std::placeholders::_6); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/49058_1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/49058_1.cc new file mode 100644 index 000000000..826f4301e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/49058_1.cc @@ -0,0 +1,34 @@ +// { dg-options "-pedantic -std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <functional> + +// PR libstdc++/49058 + +struct F +{ + void + operator()(); +}; + +void f() +{ + std::bind( F() ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/49058_2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/49058_2.cc new file mode 100644 index 000000000..3cdd212cc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/49058_2.cc @@ -0,0 +1,28 @@ +// { dg-options "-pedantic -std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <functional> + +// PR libstdc++/49058 + +void f() +{ + std::bind( []{} ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/57899.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/57899.cc new file mode 100644 index 000000000..d46d53e83 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/57899.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2010-2014 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/>. + +// 20.7.11 Function template bind + +// PR c++/57899 +// { dg-do compile } +// { dg-options -std=c++11 } + +#include <functional> +using std::bind; +using std::placeholders::_1; + +struct S { int i; }; + +struct P { S s; }; + +struct get_s +{ + const S& operator()(const P& p) const { return p.s; } +} gs; + +int gi(const S& s) { return s.i; } + +bool cmp(int, int) { return true; } + +int main() +{ + P p{}; + auto f1 = bind(gs, _1); + auto f2 = bind(gi, f1); + auto f3 = bind(cmp, f2, 5); + f3(p); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/all_bound.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/all_bound.cc new file mode 100644 index 000000000..55fe74631 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/all_bound.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009-2014 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/>. + +// 20.7.11 Function template bind + +#include <functional> +#include <testsuite_hooks.h> + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( std::bind(std::plus<int>(), 3, 5)() == 8 ); + VERIFY( std::bind(std::minus<int>(), 3, 5)() == -2 ); + VERIFY( std::bind<int>(std::plus<int>(), 3, 5)() == 8 ); + VERIFY( std::bind<int>(std::minus<int>(), 3, 5)() == -2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/conv_result.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/conv_result.cc new file mode 100644 index 000000000..2b2ea367f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/conv_result.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009-2014 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/>. + +// 20.7.11 Function template bind + +#include <functional> +#include <testsuite_hooks.h> + +struct X +{ + typedef int result_type; + int operator()(int i) const { return i+1; } + bool b; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::bind; + using std::ref; + ::X x = { true }; + + // test bind<R> form + bind<void>(ref(x), 1)(); + VERIFY( bind<long>(ref(x), 1)() == 2 ); + bind<void>(&::X::b, ref(x))(); + VERIFY( bind<int>(&::X::b, ref(x))() == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc new file mode 100644 index 000000000..b83f35803 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals.cc @@ -0,0 +1,119 @@ +// Copyright (C) 2010-2014 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/>. + +// 20.7.11 Function template bind + +// { dg-options "-std=gnu++0x" } + +#include <functional> +#include <testsuite_hooks.h> + +// target must be invoked with cv-quals of call wrapper + +struct X +{ + int operator()() { return 0; } + int operator()() const { return 1; } + int operator()() volatile { return 2; } + int operator()() const volatile { return 3; } + + int operator()(int, int, int) { return 0; } + int operator()(int, int, int) const { return 1; } + int operator()(int, int, int) volatile { return 2; } + int operator()(int, int, int) const volatile { return 3; } +}; + +using std::placeholders::_1; +using std::placeholders::_2; + +void test01() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind(X()); + VERIFY( b0() == 0 ); + + const auto b1 = std::bind(X()); + VERIFY( b1() == 1 ); + + volatile auto b2 = std::bind(X()); + VERIFY( b2() == 2 ); + + const volatile auto b3 = std::bind(X()); + VERIFY( b3() == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind<int>(X()); + VERIFY( b0() == 0 ); + + const auto b1 = std::bind<int>(X()); + VERIFY( b1() == 1 ); + + volatile auto b2 = std::bind<int>(X()); + VERIFY( b2() == 2 ); + + const volatile auto b3 = std::bind<int>(X()); + VERIFY( b3() == 3 ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind(X(), 0, _1, _2); + VERIFY( b0(0, 0) == 0 ); + + const auto b1 = std::bind(X(), _1, 0, _2); + VERIFY( b1(0, 0) == 1 ); + + volatile auto b2 = std::bind(X(), _1, _2, 0); + VERIFY( b2(0, 0) == 2 ); + + const volatile auto b3 = std::bind(X(), _1, 0, _2); + VERIFY( b3(0, 0) == 3 ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + auto b0 = std::bind<int>(X(), 0, _1, _2); + VERIFY( b0(0, 0) == 0 ); + + const auto b1 = std::bind<int>(X(), _1, 0, _2); + VERIFY( b1(0, 0) == 1 ); + + volatile auto b2 = std::bind<int>(X(), _1, _2, 0); + VERIFY( b2(0, 0) == 2 ); + + const volatile auto b3 = std::bind<int>(X(), _1, 0, _2); + VERIFY( b3(0, 0) == 3 ); +} + + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc new file mode 100644 index 000000000..75c0d6ebc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2011-2014 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/>. + +// { dg-options "-std=gnu++0x" } + +#include <functional> +#include <testsuite_hooks.h> + +struct X +{ + int operator()() const { return 0; } + int operator()() volatile { return 1; } + int operator()() const volatile { return 2; } + void operator()() { }; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + const auto b0 = std::bind(X()); + VERIFY( b0() == 0 ); + + volatile auto b1 = std::bind(X()); + VERIFY( b1() == 1 ); + + const volatile auto b2 = std::bind(X()); + VERIFY( b2() == 2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals_3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals_3.cc new file mode 100644 index 000000000..3dcecd9fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/cv_quals_3.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2011-2014 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/>. + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <functional> + +struct X +{ + int operator()() const { return 0; } + int operator()() volatile { return 1; } + int operator()() const volatile { return 2; } + void operator()() { }; +}; + +void test01() +{ + static_assert( std::is_placeholder<decltype(std::placeholders::_1)>::value, + "decltype(_1) is a placeholder type" ); + + const auto b0 = std::bind(X()); + static_assert( std::is_bind_expression<decltype(b0)>::value, + "const-qualified wrapper is a bind expression" ); + + volatile auto b1 = std::bind(X()); + static_assert( std::is_bind_expression<decltype(b1)>::value, + "volatile-qualified wrapper is a bind expression" ); + + const volatile auto b2 = std::bind(X()); + static_assert( std::is_bind_expression<decltype(b2)>::value, + "const-volatile-qualified wrapper is a bind expression" ); + + const auto b3 = std::bind<int>(X()); + static_assert( std::is_bind_expression<decltype(b3)>::value, + "const-qualified wrapper is a bind expression" ); + + volatile auto b4 = std::bind<int>(X()); + static_assert( std::is_bind_expression<decltype(b4)>::value, + "volatile-qualified wrapper is a bind expression" ); + + const volatile auto b5 = std::bind<int>(X()); + static_assert( std::is_bind_expression<decltype(b5)>::value, + "const-volatile-qualified wrapper is a bind expression" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/move.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/move.cc new file mode 100644 index 000000000..0f7ef052b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/move.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <functional> +#include <testsuite_hooks.h> + +// PR libstdc++/45924 + +struct f +{ + f() : i(0) { } + f(f&& r) : i(1) { r.i = -1; } + f(const f&) = delete; + int operator()() { return i; } + int i; +}; + +void test01() +{ + auto b = std::bind(f()); + VERIFY( b() == 1 ); + auto bc(std::move(b)); + VERIFY( bc() == 1 ); + VERIFY( b() == -1 ); +} + +void test02() +{ + auto b = std::bind<int>(f()); + VERIFY( b() == 1 ); + auto bc(std::move(b)); + VERIFY( bc() == 1 ); + VERIFY( b() == -1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/nested.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/nested.cc new file mode 100644 index 000000000..8deac6f94 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/nested.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009-2014 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/>. + +// 20.7.11 Function template bind + +#include <functional> +#include <testsuite_hooks.h> + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::placeholders; + + int five = 5; + int seven = 7; + VERIFY( std::bind(std::multiplies<int>(), _1, + std::bind(std::minus<int>(), 6, _2))(five, seven) == -5 ); + VERIFY( std::bind(std::multiplies<int>(), _1, + std::bind(std::minus<int>(), 6, _2))(seven, five) == 7 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/placeholders.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/placeholders.cc new file mode 100644 index 000000000..4c7851306 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/placeholders.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009-2014 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/>. + +// 20.7.11 Function template bind + +#include <functional> +#include <testsuite_hooks.h> + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::placeholders; + + int five = 5; + int seven = 7; + VERIFY( std::bind(std::minus<int>(), _1, _2)(five, seven) == -2 ); + VERIFY( std::bind(std::minus<int>(), _2, _1)(five, seven) == 2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref.cc new file mode 100644 index 000000000..cdfbe2d5d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2009-2014 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/>. + +// 20.7.11 Function template bind + +#include <functional> +#include <testsuite_hooks.h> + +struct X +{ + X() : bar(17) {} + + int foo(int x, int y) { return bar + x + y; } + + int bar; + +private: + X(const X&); + X& operator=(const X&); +}; + +// Operations on empty function<> objects +void test01() +{ + bool test __attribute__((unused)) = true; + using std::bind; + using std::ref; + ::X x; + + VERIFY( bind(&::X::foo, ref(x), 1, 2)() == 20 ); + VERIFY( bind<int>(&::X::foo, ref(x), 1, 2)() == 20 ); + VERIFY( bind(&::X::bar, ref(x))() == 17 ); + VERIFY( bind<int>(&::X::bar, ref(x))() == 17 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref2.cc new file mode 100644 index 000000000..e697fac1e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref2.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2010-2014 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/>. + +// 20.7.11 Function template bind + +// { dg-options "-std=gnu++0x" } + +#include <functional> +#include <testsuite_hooks.h> + +using namespace std::placeholders; + +int inc(int& i) { return ++i; } + +void test01() +{ + bool test __attribute__((unused)) = true; + + int counter = 0; + std::bind(&inc, _1)(counter); + VERIFY(counter == 1 ); + std::bind(&inc, std::ref(counter))(); + VERIFY(counter == 2 ); +} + +struct Inc +{ + int operator()(int& i) const { return ++i; } + void operator()(int&&) const { } + + int f(int& i) const { return ++i; } +}; + +void test02() +{ + bool test __attribute__((unused)) = true; + + int counter = 0; + std::bind(Inc(), _1)(counter); + VERIFY(counter == 1 ); + std::bind(&Inc::f, Inc(), std::ref(counter))(); + VERIFY(counter == 2 ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc new file mode 100644 index 000000000..5a466178a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2010-2014 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/>. + +// 20.8.9 Function template bind + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <functional> + +using namespace std::placeholders; + +int inc(int& i) { return ++i; } + +void test01() +{ + const int dummy = 0; + std::bind(&inc, _1)(0); // { dg-error "no match" } + // { dg-error "rvalue|const" "" { target *-*-* } 1315 } + // { dg-error "rvalue|const" "" { target *-*-* } 1329 } + // { dg-error "rvalue|const" "" { target *-*-* } 1343 } + // { dg-error "rvalue|const" "" { target *-*-* } 1357 } + std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" } +} + +struct Inc +{ + int operator()(int& i) const { return ++i; } + void operator()(int&&) const { } + + int f(int&& i) const { return ++i; } +}; + +void test02() +{ + const int dummy = 0; + std::bind(Inc(), _1)(dummy); // { dg-error "no match" } + std::bind(&Inc::f, Inc(), std::ref(dummy))(); // { dg-error "no match" } +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/socket.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/socket.cc new file mode 100644 index 000000000..39b61dcc0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/bind/socket.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011-2014 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/>. + +// 20.8.9 Function template bind + +// Verify that calls to bind() in BSD sockets API do not match std::bind() +// (this is a GNU extension) + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <functional> + +struct my_sockaddr { }; +typedef long my_socklen_t; +int bind(int, const my_sockaddr*, my_socklen_t); + +using namespace std; + +int test01() +{ + int fd = 1; + my_sockaddr sa; // N.B. non-const + size_t len = sizeof(sa); // N.B. size_t not my_socklen_t + return bind(fd, &sa, len); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d8f47e7f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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 int test_type1; + typedef int& test_type2; + typedef double test_type3; + typedef float test_type4; + typedef void test_type5; + typedef const void test_type6; + + template struct common_type<test_type1>; + template struct common_type<test_type1, test_type2>; + template struct common_type<test_type1, test_type2, test_type3>; + template struct common_type<test_type1, test_type2, test_type3, test_type4>; + + template struct common_type<test_type5>; + template struct common_type<test_type5, test_type6>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc new file mode 100644 index 000000000..84420e4f2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_1.cc @@ -0,0 +1,341 @@ +// { dg-options "-std=c++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <initializer_list> + +//TODO: Uncomment this once gcc bug 53000 has been resolved: +//#define HAS_53000_FIXED + +// Helper types: +struct has_type_impl +{ + template<typename T, typename = typename T::type> + static std::true_type test(int); + template<typename> + static std::false_type test(...); +}; + +template<typename T> +struct has_type : public decltype(has_type_impl::test<T>(0)) +{}; + +template<typename T, typename Expected> +struct is_expected_type : public std::is_same<typename T::type, Expected> +{}; + +template<typename P1, typename P2> +struct and_ : public std::conditional<P1::value, P2, std::false_type>::type +{}; + +template<typename T, typename Expected> +struct is_type : public and_<has_type<T>, is_expected_type<T, Expected>> +{}; + +// Inspection types: + +struct S {}; + +struct B {}; +struct D : B {}; + +struct F1 { operator void*(); }; +struct F2 { operator void*(); }; + +struct G1 { operator const void*(); }; +struct G2 { operator volatile void*(); }; + +template<typename T> +struct ImplicitTo +{ + operator T(); +}; + +template<typename T> +struct ExplicitTo +{ + explicit operator T(); +}; + +template<typename T> +struct PrivateImplicitTo +{ +private: + operator T(); +}; + +auto lmd1 = [](int, double) {}; +auto lmd2 = [](int, double) {}; + +struct Abstract +{ + virtual ~Abstract() = 0; +}; + +enum class ScEn; + +enum UnscEn : int; + +struct Ukn; + +union U +{ + int i; +}; + +union U2 +{ + long i; +}; + +union UConv1 +{ + operator Abstract*(); +}; + +union UConv2 +{ + operator Abstract*(); +}; + +struct X1 {}; +struct X2 {}; +struct RX12 {}; +struct RX21 {}; +struct Y1 {}; +struct Y2 {}; +struct Y3 {}; +struct Y4 {}; + +namespace std { + + template<> + struct common_type<X1, X2> + { + typedef RX12 type; + }; + + template<> + struct common_type<X2, X1> + { + typedef RX21 type; + }; + + template<> + struct common_type<RX12, X1> + { + typedef Y1 type; + }; + + template<> + struct common_type<X1, RX12> + { + typedef Y2 type; + }; + + template<> + struct common_type<RX21, X1> + { + typedef Y3 type; + }; + + template<> + struct common_type<X1, RX21> + { + typedef Y4 type; + }; +} + +static_assert(is_type<std::common_type<int, int>, int>(), ""); +static_assert(is_type<std::common_type<ScEn, ScEn>, ScEn>(), ""); +static_assert(is_type<std::common_type<UnscEn, UnscEn>, UnscEn>(), ""); +static_assert(is_type<std::common_type<UnscEn, int>, int>(), ""); +static_assert(is_type<std::common_type<int, int, int>, int>(), ""); +static_assert(is_type<std::common_type<int, int, int, int>, int>(), ""); +static_assert(is_type<std::common_type<int, int, int, int, int>, int>(), ""); +static_assert(is_type<std::common_type<S, S>, S>(), ""); +static_assert(is_type<std::common_type<const S, const S>, S>(), ""); +static_assert(is_type<std::common_type<std::initializer_list<int>, + std::initializer_list<int>>, std::initializer_list<int>>(), ""); +static_assert(is_type<std::common_type<B, D>, B>(), ""); +static_assert(is_type<std::common_type<D, B>, B>(), ""); +static_assert(is_type<std::common_type<F1, F2>, void*>(), ""); +static_assert(is_type<std::common_type<F2, F1>, void*>(), ""); +static_assert(is_type<std::common_type<G1, G2>, const volatile void*>(), ""); +static_assert(is_type<std::common_type<G2, G1>, const volatile void*>(), ""); +static_assert(is_type<std::common_type<int*, const volatile int*>, + const volatile int*>(), ""); +static_assert(is_type<std::common_type<void*, const volatile int*>, + const volatile void*>(), ""); +static_assert(is_type<std::common_type<void, void>, void>(), ""); +static_assert(is_type<std::common_type<const void, const void>, void>(), ""); +static_assert(is_type<std::common_type<int&, int&&>, int>(), ""); +static_assert(is_type<std::common_type<int&, int&>, int>(), ""); +static_assert(is_type<std::common_type<int&&, int&&>, int>(), ""); +static_assert(is_type<std::common_type<int&&, const int&&>, int>(), ""); +static_assert(is_type<std::common_type<U&, const U&&>, U>(), ""); +static_assert(is_type<std::common_type<U&, U&>, U>(), ""); +static_assert(is_type<std::common_type<U&&, U&&>, U>(), ""); +static_assert(is_type<std::common_type<int B::*, int D::*>, int D::*>(), ""); +static_assert(is_type<std::common_type<int D::*, int B::*>, int D::*>(), ""); +static_assert(is_type<std::common_type<const int B::*, volatile int D::*>, + const volatile int D::*>(), ""); +static_assert(is_type<std::common_type<int (B::*)(), int (D::*)()>, + int (D::*)()>(), ""); +static_assert(is_type<std::common_type<int (B::*)() const, int (D::*)() const>, + int (D::*)() const>(), ""); +static_assert(is_type<std::common_type<int[3], int[3]>, int*>(), ""); +static_assert(is_type<std::common_type<int[1], const int[3]>, + const int*>(), ""); +static_assert(is_type<std::common_type<void(), void()>, void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&)(), void(&)()>, void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&)(), void(&&)()>, + void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&&)(), void(&)()>, + void(*)()>(), ""); +static_assert(is_type<std::common_type<void(&&)(), void(&&)()>, + void(*)()>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<int>, int>, int>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<int>, ImplicitTo<int>>, + ImplicitTo<int>>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<int>, int, + ImplicitTo<int>>, int>(), ""); +static_assert(is_type<std::common_type<ExplicitTo<int>, ExplicitTo<int>>, + ExplicitTo<int>>(), ""); +static_assert(is_type<std::common_type<decltype(lmd1), decltype(lmd1)>, + decltype(lmd1)>(), ""); +static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd1)&>, + decltype(lmd1)>(), ""); +static_assert(is_type<std::common_type<decltype(lmd1)&, decltype(lmd2)&>, + void(*)(int, double)>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), void*>, void*>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), int*>, int*>(), ""); +static_assert(is_type<std::common_type<const decltype(nullptr)&, int*>, + int*>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), const volatile int*>, + const volatile int*>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), int (B::*)()>, + int (B::*)()>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), int (B::*)() const>, + int (B::*)() const>(), ""); +static_assert(is_type<std::common_type<decltype(nullptr), const int B::*>, + const int B::*>(), ""); +static_assert(is_type<std::common_type<Abstract&, Abstract&>, Abstract>(), ""); +static_assert(is_type<std::common_type<Ukn&, Ukn&>, Ukn>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<B&>, B&>, B>(), ""); +static_assert(is_type<std::common_type<ImplicitTo<B&>&, B&&>, B>(), ""); +static_assert(is_type<std::common_type<UConv1, const Abstract*&>, + const Abstract*>(), ""); +static_assert(is_type<std::common_type<UConv1, UConv2>, Abstract*>(), ""); +static_assert(is_type<std::common_type<UConv1&, UConv2&>, Abstract*>(), ""); + +#ifdef HAS_53000_FIXED +static_assert(is_type<std::common_type<Abstract&&, Abstract&&>, + Abstract>(), ""); +static_assert(is_type<std::common_type<const Abstract&&, + volatile Abstract&&>, Abstract>(), ""); +static_assert(is_type<std::common_type<Ukn&&, Ukn&&>, Ukn>(), ""); +static_assert(is_type<std::common_type<const Ukn&&, volatile Ukn&&>, + Ukn>(), ""); +#endif + +static_assert(is_type<std::common_type<X1, X2>, RX12>(), ""); +static_assert(is_type<std::common_type<X2, X1>, RX21>(), ""); + +static_assert(is_type<std::common_type<X1, X2, X1>, Y1>(), ""); +static_assert(is_type<std::common_type<X2, X1, X1>, Y3>(), ""); + +static_assert(is_type<std::common_type<X1, X1, X2>, RX12>(), ""); +static_assert(is_type<std::common_type<X1, X1, X2, X1>, Y1>(), ""); + +static_assert(!has_type<std::common_type<>>(), ""); +static_assert(!has_type<std::common_type<int, S>>(), ""); +static_assert(!has_type<std::common_type<U, S>>(), ""); +static_assert(!has_type<std::common_type<U, U2>>(), ""); +static_assert(!has_type<std::common_type<const ImplicitTo<int>, int>>(), ""); +static_assert(!has_type<std::common_type<PrivateImplicitTo<int>, int>>(), ""); +static_assert(!has_type<std::common_type<const PrivateImplicitTo<int>, + int>>(), ""); +static_assert(!has_type<std::common_type<int, Ukn>>(), ""); +static_assert(!has_type<std::common_type<int, Abstract>>(), ""); +static_assert(!has_type<std::common_type<Ukn, Abstract>>(), ""); +static_assert(!has_type<std::common_type<int, void>>(), ""); +static_assert(!has_type<std::common_type<int, const volatile void>>(), ""); +static_assert(!has_type<std::common_type<Abstract, void>>(), ""); +static_assert(!has_type<std::common_type<Ukn, void>>(), ""); +static_assert(!has_type<std::common_type<int[4], void>>(), ""); +static_assert(!has_type<std::common_type<ScEn, void>>(), ""); +static_assert(!has_type<std::common_type<UnscEn, void>>(), ""); +static_assert(!has_type<std::common_type<U, void>>(), ""); +static_assert(!has_type<std::common_type<std::initializer_list<int>, + void>>(), ""); +static_assert(!has_type<std::common_type<int, int, int, S>>(), ""); +static_assert(!has_type<std::common_type<int, int, S, int>>(), ""); +static_assert(!has_type<std::common_type<int, S, int, int>>(), ""); +static_assert(!has_type<std::common_type<S, int, int, int>>(), ""); +static_assert(!has_type<std::common_type<int, int, void, int, int>>(), ""); +static_assert(!has_type<std::common_type<B, S>>(), ""); +static_assert(!has_type<std::common_type<int, B, S>>(), ""); +static_assert(!has_type<std::common_type<B, int, S>>(), ""); +static_assert(!has_type<std::common_type<B, S, int>>(), ""); +static_assert(!has_type<std::common_type<int*, double*>>(), ""); +static_assert(!has_type<std::common_type<void*, void(*)(...)>>(), ""); +static_assert(!has_type<std::common_type<void(*)(), void(*)(...)>>(), ""); +static_assert(!has_type<std::common_type<void(*)(), void(S::*)()>>(), ""); +static_assert(!has_type<std::common_type<void(S::*)() const, + void(S::*)()>>(), ""); +static_assert(!has_type<std::common_type<int S::*, long S::*>>(), ""); +static_assert(!has_type<std::common_type<int S::*, void(S::*)()>>(), ""); +static_assert(!has_type<std::common_type<int (B::*)(), + int (D::*)() const>>(), ""); +static_assert(!has_type<std::common_type<int (B::*)() const, + int (D::*)()>>(), ""); +static_assert(!has_type<std::common_type<int, ExplicitTo<int>>>(), ""); +static_assert(!has_type<std::common_type<ImplicitTo<int>, + ExplicitTo<int>>>(), ""); +static_assert(!has_type<std::common_type<ScEn, int>>(), ""); +static_assert(!has_type<std::common_type<ScEn, UnscEn>>(), ""); +static_assert(!has_type<std::common_type<U, S, Abstract, void, D, + int (B::*)(), int[5]>>(), ""); +static_assert(!has_type<std::common_type<UConv1, Abstract&&>>(), ""); +static_assert(!has_type<std::common_type<std::initializer_list<int>, + std::initializer_list<long>>>(), ""); + +void test(int i) +{ + auto local_lmd1 = [=](int, double) { return i + i; }; + auto local_lmd2 = [=](int, double) { return i - i; }; + + static_assert(is_type<std::common_type<decltype(local_lmd1), + decltype(local_lmd1)>, decltype(local_lmd1)>(), ""); + static_assert(is_type<std::common_type<decltype(local_lmd1)&, + decltype(local_lmd1)>, decltype(local_lmd1)>(), ""); + static_assert(is_type<std::common_type<decltype(local_lmd1)&, + decltype(local_lmd1)&>, decltype(local_lmd1)>(), ""); + + static_assert(!has_type<std::common_type<decltype(local_lmd1), + decltype(lmd1)>>(), ""); + static_assert(!has_type<std::common_type<decltype(local_lmd1)&, + decltype(lmd1)&>>(), ""); + static_assert(!has_type<std::common_type<decltype(local_lmd1), + decltype(local_lmd2)>>(), ""); + static_assert(!has_type<std::common_type<decltype(local_lmd1)&, + decltype(local_lmd2)&>>(), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc new file mode 100644 index 000000000..cf35ac973 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/sfinae_friendly_2.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=c++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <array> +#include <utility> + +template<typename... Args> +constexpr +std::array<typename std::common_type<Args...>::type, + sizeof...(Args)> +make_array(Args&&... args) // { dg-error "invalid use" } +{ + typedef typename std::common_type<Args...>::type CT; + return std::array<CT, sizeof...(Args)>{static_cast<CT> + (std::forward<Args>(args))...}; +} + +void test01() +{ + constexpr auto a1 = make_array(0); + constexpr auto a2 = make_array(0, 1.2); + constexpr auto a3 = make_array(5, true, 3.1415f, 'c'); + + int i{}; + double d{1.2}; + float f{3.1415f}; + + auto b1 = make_array(i); + auto b2 = make_array(i, 1.2); + auto b3 = make_array(i, d); + auto b4 = make_array(0, d); + auto b5 = make_array(i, true, f, 'c'); + + static_assert(std::is_same<decltype(a1), const std::array<int, 1>>(), ""); + static_assert(std::is_same<decltype(a2), const std::array<double, 2>>(), ""); + static_assert(std::is_same<decltype(a3), const std::array<float, 4>>(), ""); + + static_assert(std::is_same<decltype(b1), std::array<int, 1>>(), ""); + static_assert(std::is_same<decltype(b2), std::array<double, 2>>(), ""); + static_assert(std::is_same<decltype(b3), std::array<double, 2>>(), ""); + static_assert(std::is_same<decltype(b4), std::array<double, 2>>(), ""); + static_assert(std::is_same<decltype(b5), std::array<float, 4>>(), ""); +} + +void test02() +{ + make_array(); // { dg-error "no matching function" } +} +// { dg-prune-output "substitution" } +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc new file mode 100644 index 000000000..ba4e57f31 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-1.cc @@ -0,0 +1,117 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2008-2014 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> + +#define JOIN( X, Y ) DO_JOIN( X, Y ) +#define DO_JOIN( X, Y ) DO_JOIN2(X,Y) +#define DO_JOIN2( X, Y ) X##Y + +#define COMMON_TYPE_TEST_1(type1, uid) \ + typedef common_type<type1>::type JOIN(test_t,uid); \ + VERIFY( (is_same<JOIN(test_t,uid), JOIN(test_t,uid)>::value) ); \ + typedef common_type<const type1>::type JOIN(test_t,JOIN(uid,c)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,c)), \ + JOIN(test_t,JOIN(uid,c))>::value) ); \ + typedef common_type<volatile type1>::type JOIN(test_t,JOIN(uid,v)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,v)), \ + JOIN(test_t,JOIN(uid,v))>::value) ); \ + typedef common_type<const volatile type1>::type JOIN(test_t,JOIN(uid,cv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,cv)), \ + JOIN(test_t,JOIN(uid,cv))>::value) ); \ + typedef common_type<type1 &>::type JOIN(test_t,JOIN(uid,l)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,l)), \ + JOIN(test_t,JOIN(uid,l))>::value) ); \ + typedef common_type<const type1 &>::type JOIN(test_t,JOIN(uid,lc)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,lc)), \ + JOIN(test_t,JOIN(uid,lc))>::value) ); \ + typedef common_type<volatile type1 &>::type JOIN(test_t,JOIN(uid,lv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,lv)), \ + JOIN(test_t,JOIN(uid,lv))>::value) ); \ + typedef common_type<const volatile type1 &>::type JOIN(test_t,JOIN(uid,lcv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,lcv)), \ + JOIN(test_t,JOIN(uid,lcv))>::value) ); \ + typedef common_type<type1 &&>::type JOIN(test_t,JOIN(uid,r)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,r)), \ + JOIN(test_t,JOIN(uid,r))>::value) ); \ + typedef common_type<const type1 &&>::type JOIN(test_t,JOIN(uid,rc)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,rc)), \ + JOIN(test_t,JOIN(uid,rc))>::value) ); \ + typedef common_type<volatile type1 &&>::type JOIN(test_t,JOIN(uid,rv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,rv)), \ + JOIN(test_t,JOIN(uid,rv))>::value) ); \ + typedef common_type<const volatile type1 &&>::type JOIN(test_t,JOIN(uid,rcv)); \ + VERIFY( (is_same<JOIN(test_t,JOIN(uid,rcv)), \ + JOIN(test_t,JOIN(uid,rcv))>::value) ) + +struct A { }; +struct B : A { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::common_type; + using std::is_same; + + // Positive tests. + COMMON_TYPE_TEST_1(int, 1); + COMMON_TYPE_TEST_1(double, 2); + COMMON_TYPE_TEST_1(A, 3); + COMMON_TYPE_TEST_1(B, 4); +} + +#define COMMON_TYPE_TEST_2_IMPL(type1, type2, type3, uid) \ + typedef common_type<type1, type2>::type JOIN(JOIN(test, uid),_t1); \ + typedef common_type<type2, type1>::type JOIN(JOIN(test, uid),_t2); \ + VERIFY( (is_same<JOIN(JOIN(test, uid),_t1), type3>::value) ); \ + VERIFY( (is_same<JOIN(JOIN(test, uid),_t2), type3>::value) ) + +#define NO_CV + +#define COMMON_TYPE_TEST_2(cv_qual, type1, type2, type3, uid) \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1 &, type2, type3, JOIN(uid,l)); \ + COMMON_TYPE_TEST_2_IMPL(cv_qual type1 &&, type2, type3, JOIN(uid,r)) + +#define COMMON_TYPE_TEST_ALL_2(type1, type2, type3, uid) \ + COMMON_TYPE_TEST_2(NO_CV, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(const, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(volatile, type1, type2, type3, uid); \ + COMMON_TYPE_TEST_2(const volatile, type1, type2, type3, uid) + +void test02() +{ + bool test __attribute__((unused)) = true; + using std::common_type; + using std::is_same; + + COMMON_TYPE_TEST_ALL_2(int, int, int, 1); + COMMON_TYPE_TEST_ALL_2(int, double, double, 2); + COMMON_TYPE_TEST_2(NO_CV, A, A, A, 3); + COMMON_TYPE_TEST_2(const, A, A, A, 4); + COMMON_TYPE_TEST_2(NO_CV, B, A, A, 5); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc new file mode 100644 index 000000000..fa25058c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// 2009-11-12 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009-2014 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> + +// DR 1255. +void test01() +{ + using std::common_type; + using std::is_same; + + static_assert( is_same<common_type<void>::type, void>(), + "common_type<void>" ); + static_assert( is_same<common_type<const void>::type, void>(), + "common_type<const void>" ); + static_assert( is_same<common_type<volatile void>::type, void>(), + "common_type<volatile void>" ); + static_assert( is_same<common_type<const volatile void>::type, void>(), + "common_type<const volatile void>" ); + + static_assert( is_same<common_type<void, void>::type, void>(), + "common_type<void, void>" ); + static_assert( is_same<common_type<void, const void>::type, void>(), + "common_type<void, const void>" ); + static_assert( is_same<common_type<void, volatile void>::type, void>(), + "common_type<void, volatile void>" ); + static_assert( is_same<common_type<void, const volatile void>::type, void>(), + "common_type<void, const volatile void>" ); + static_assert( is_same<common_type<const void, void>::type, void>(), + "common_type<const void, void>" ); + static_assert( is_same<common_type<const void, const void>::type, void>(), + "common_type<const void, const void>" ); + static_assert( is_same<common_type<const void, volatile void>::type, void>(), + "common_type<const void, volatile void>" ); + static_assert( is_same<common_type<const void, const volatile void>::type, + void>(), "common_type<const void, const volatile void>" ); + static_assert( is_same<common_type<volatile void, void>::type, void>(), + "common_type<volatile void, void>" ); + static_assert( is_same<common_type<volatile void, volatile void>::type, + void>(), "common_type<volatile void, volatile void>" ); + static_assert( is_same<common_type<volatile void, const void>::type, + void>(), "common_type<volatile void, const void>" ); + static_assert( is_same<common_type<volatile void, const volatile void>::type, + void>(), "common_type<volatile void, const volatile void>" ); + static_assert( is_same<common_type<const volatile void, void>::type, void>(), + "common_type<const volatile void, const volatile void>" ); + static_assert( is_same<common_type<const volatile void, const void>::type, + void>(), "common_type<const volatile void, const void>" ); + static_assert( is_same<common_type<const volatile void, volatile void>::type, + void>(), "common_type<const volatile void, volatile void>" ); + static_assert( is_same<common_type<const volatile void, const volatile void>::type, + void>(), + "common_type<const volatile void, const volatile void>" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-3.cc new file mode 100644 index 000000000..63f594501 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-3.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } +// +// Copyright (C) 2013-2014 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> + +using namespace std; + +static_assert( is_same<common_type<int, long, char, unsigned>::type, + common_type_t<int, long, char, unsigned>>(), + "common_type_t" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..84944c3c8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 conditional<true, test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs-2.cc new file mode 100644 index 000000000..a64538b3d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs-2.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +static_assert( is_same<typename conditional<true, long, void>::type, + conditional_t<true, long, void>>(), + "conditional_t<true, ...>" ); +static_assert( is_same<typename conditional<false, long, void>::type, + conditional_t<false, long, void>>(), + "conditional_t<false, ...>" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc new file mode 100644 index 000000000..feb708421 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::conditional; + + typedef conditional<true, char, int>::type test1_type; + VERIFY( (std::is_same<test1_type, char>::value) ); + + typedef conditional<false, char, int>::type test2_type; + VERIFY( (std::is_same<test2_type, int>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..ff51fdec5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 decay<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs-2.cc new file mode 100644 index 000000000..468ba814b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs-2.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +template<typename Trait, typename Result> + using test = is_same<typename Trait::type, Result>; + +static_assert( test<decay<bool>, decay_t<bool>>(), "decay<bool>" ); +static_assert( test<decay<const int>, decay_t<const int>>(), + "decay<const int>" ); +static_assert( test<decay<int[4]>, decay_t<int[4]>>(), "decay<int[4]>" ); +typedef void (fn_type) (); +static_assert( test<decay<fn_type>, decay_t<fn_type>>(), "decay<fn_type>" ); +typedef void (cfn_type) () const; +static_assert( test<decay<cfn_type>, decay_t<cfn_type>>(), "decay<cfn_type>" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc new file mode 100644 index 000000000..057d6efb7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +void test01() +{ + using std::decay; + using std::is_same; + + // Positive tests. + typedef decay<bool>::type test1_type; + static_assert( is_same<test1_type, bool>(), "decay<bool>" ); + + // NB: DR 705. + typedef decay<const int>::type test2_type; + static_assert( is_same<test2_type, int>(), "decay<const int>" ); + + typedef decay<int[4]>::type test3_type; + static_assert( is_same<test3_type, std::remove_extent<int[4]>::type*>(), + "decay<int[4]>" ); + + typedef void (fn_type) (); + typedef decay<fn_type>::type test4_type; + static_assert( is_same<test4_type, std::add_pointer<fn_type>::type>(), + "decay<fn_type>" ); + + typedef void (cfn_type) () const; + typedef decay<cfn_type>::type test5_type; + static_assert( is_same<test5_type, cfn_type>(), "decay<cfn_type>" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/declval/requirements/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/declval/requirements/1.cc new file mode 100644 index 000000000..a1df5e6a7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/declval/requirements/1.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2009-11-12 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009-2014 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> + +template<typename From, typename To> + struct is_convertible_mini + { + private: + typedef char one; + typedef struct { char arr[2]; } two; + + static one test(To); + static two test(...); + + public: + static const bool value = sizeof(test(std::declval<From>())) == 1; +}; + +template<typename From, typename To> + const bool is_convertible_mini<From, To>::value; + +void test01() +{ + static_assert(is_convertible_mini<int*, const int*>::value, "#1"); + static_assert(!is_convertible_mini<const void*, void*>::value, "#2"); + static_assert(is_convertible_mini<float, double>::value, "#3"); + static_assert(!is_convertible_mini<bool, int*>::value, "#4"); + static_assert(is_convertible_mini<int(&)(int), int(*)(int)>::value, "#5"); + static_assert(!is_convertible_mini<void*, int*>::value, "#6"); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc new file mode 100644 index 000000000..a744d8326 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2009-11-12 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009-2014 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/>. + +// { dg-error "static assertion failed" "" { target *-*-* } 2003 } + +#include <utility> + +void test01() +{ + std::declval<int>(); // { dg-error "required from here" } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc new file mode 100644 index 000000000..a04b816cc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x " } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <memory> + +struct B { }; +struct D : B { }; + +// libstdc++/48631 +D d; +std::default_delete<B[]> db; +typedef decltype(db(&d)) type; // { dg-error "use of deleted function" } +// { dg-prune-output "declared" } +// { dg-prune-output "invalid" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc new file mode 100644 index 000000000..804499bad --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/cons/constexpr.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_defaulted_default_constructible test; + test.operator()<std::default_delete<int>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc new file mode 100644 index 000000000..7accadf78 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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/>. + +// 20.8.1.1 Default deleters [util.ptr.dltr] + +#include <memory> + +void test01() +{ + std::default_delete<void> d; + d(nullptr); // { dg-error "here" } + // { dg-error "incomplete" "" { target *-*-* } 72 } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc new file mode 100644 index 000000000..f68ae9e7f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/1.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.3 Class template duration [time.duration] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (unary member ops) +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(3); + duration<int> d1 = -d0; + VERIFY(d0.count() == 3); + VERIFY(d1.count() == -3); + + duration<int> d2 = (+d0); + VERIFY(d2.count() == 3); + + duration<int> d3(++d2); + VERIFY(d2.count() == 4); + VERIFY(d3.count() == 4); + + duration<int> d4(d3++); + VERIFY(d3.count() == 5); + VERIFY(d4.count() == 4); + + duration<int> d5(--d4); + VERIFY(d4.count() == 3); + VERIFY(d5.count() == 3); + + duration<int> d6(d5--); + VERIFY(d5.count() == 2); + VERIFY(d6.count() == 3); +} + +// 20.8.3.3 duration arithmetic [time.duration.arithmetic] (binary member ops) +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d7(3); + duration<int> d8(9); + d7 += d8; + VERIFY(d7.count() == 12); + VERIFY(d8.count() == 9); + + duration<int> d9(3); + duration<int> d10(9); + d9 -= d10; + VERIFY(d9.count() == -6); + VERIFY(d10.count() == 9); + + duration<int> d11(9); + int i = 3; + d11 *= i; + VERIFY(d11.count() == 27); + + duration<int> d12(12); + d12 /= i; + VERIFY(d12.count() == 4); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc new file mode 100644 index 000000000..4df6ac114 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/2.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.3 Class template duration [time.duration] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.3.5 duration non-member arithmetic [time.duration.nonmember] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(12); + duration<int> d1(3); + int i = 3; + + duration<int> d2 = d0 + d1; + VERIFY(d2.count() == 15); + + duration<int> d3 = d0 - d1; + VERIFY(d3.count() == 9); + + duration<int> d4 = d0 * i; + VERIFY(d4.count() == 36); + + duration<int> d5 = i * d0; + VERIFY(d5.count() == 36); + + duration<int> d6 = d0 / i; + VERIFY(d6.count() == 4); + + int j = d0 / d1; + VERIFY(j == 4); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/58850.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/58850.cc new file mode 100644 index 000000000..9b4386ac1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/58850.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } + +// Copyright (C) 2013-2014 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 <chrono> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + typedef duration<std::int64_t, std::ratio<36 * 24 * 36525>> Years; + Years galactic_empire_age( 12067 ); + + VERIFY( duration_cast<seconds>( galactic_empire_age ).count() + == duration_cast<minutes>( galactic_empire_age ).count() * 60 ); + VERIFY( duration_cast<minutes>( galactic_empire_age ).count() + == duration_cast<seconds>( galactic_empire_age ).count() / 60 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr.cc new file mode 100644 index 000000000..0981bf731 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <chrono> +#include <testsuite_common_types.h> + +int main() +{ + constexpr std::chrono::nanoseconds d1 { }; + constexpr auto d2(+d1); + constexpr auto d3(-d2); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr2020.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr2020.cc new file mode 100644 index 000000000..8b8b45aab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr2020.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2011-2014 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/>. + +// 20.11.5 Class template duration [time.duration] + +#include <chrono> +#include <testsuite_hooks.h> + +// DR 2020 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + constexpr duration<int> d0(12); + constexpr duration<int> d1(3); + constexpr int i = 5; + + constexpr auto d2 = d0 + d1; + VERIFY( d2.count() == 15 ); + + constexpr auto d3 = d0 - d1; + VERIFY( d3.count() == 9 ); + + constexpr auto d4 = d0 * i; + VERIFY( d4.count() == 60 ); + + constexpr auto d5 = i * d0; + VERIFY( d5.count() == 60 ); + + constexpr auto d6 = d0 % i; + VERIFY( d6.count() == 2 ); + + constexpr auto j = d0 % d1; + VERIFY( j.count() == 0 ); + + constexpr auto d7 = d0 / i; + VERIFY( d7.count() == 2 ); + + constexpr auto k = d0 / d1; + VERIFY( k == 4 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-1.cc new file mode 100644 index 000000000..7405e17f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-1.cc @@ -0,0 +1,48 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2009-2014 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 <chrono> + +class ClockTime +{ + typedef std::chrono::hours hours; + typedef std::chrono::minutes minutes; + typedef std::chrono::seconds seconds; + +public: + hours hours_; + minutes minutes_; + seconds seconds_; + + template<typename Rep, typename Period> + explicit + ClockTime(const std::chrono::duration<Rep, Period>& d) + : hours_ (std::chrono::duration_cast<hours> (d)), + minutes_(std::chrono::duration_cast<minutes>(d % hours(1))), + seconds_(std::chrono::duration_cast<seconds>(d % minutes(1))) { } +}; + +// DR 934. +void test01() +{ + std::chrono::duration<int> d; + ClockTime ct(d); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-2.cc new file mode 100644 index 000000000..a266f9acf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/arithmetic/dr934-2.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2009-2014 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 <chrono> +#include <testsuite_hooks.h> + +// DR 934. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + const duration<int> d0(17); + duration<int> d3(d0); + d3 %= 5; + VERIFY( d3.count() == 2 ); + + const duration<int> d4(7); + duration<int> d5(d0); + d5 %= d4; + VERIFY( d5.count() == 3 ); + + const duration<int> d6 = d0 % 6; + VERIFY( d6.count() == 5 ); + + const duration<int> d7(11); + const duration<int> d8 = d0 % d7; + VERIFY( d8.count() == 6 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc new file mode 100644 index 000000000..ad756a6ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/comparison_operators/1.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.3 Class template duration [time.duration] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.3.6 duration comparisons [time.duration.comparisons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(12); + duration<int> d1(3); + duration<int> d2(3); + + VERIFY(d1 < d0); + VERIFY(d0 > d1); + + VERIFY(d0 != d1); + VERIFY(d1 == d2); + + VERIFY(d1 <= d2); + VERIFY(d1 >= d2); + + VERIFY(d1 <= d0); + VERIFY(d0 >= d1); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc new file mode 100644 index 000000000..1b490c0f4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/comparison_operators/constexpr.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_comparison_operators test; + test.operator()<std::chrono::nanoseconds>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/1.cc new file mode 100644 index 000000000..76d84ebe5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/1.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.3 Class template duration [time.duration] + +#include <chrono> +#include <type_traits> +#include <testsuite_hooks.h> + +template<typename T> +struct type_emulator +{ + type_emulator() + : i(T(0)) { } + + type_emulator(T j) + : i(j) { } + + type_emulator(const type_emulator& e) + : i(e.i) { } + + type_emulator& + operator*=(type_emulator a) + { + i *= a.i; + return *this; + } + + type_emulator& + operator+=(type_emulator a) + { + i += a.i; + return *this; + } + + operator T () + { return i; } + + T i; +}; + +template<typename T> +bool +operator==(type_emulator<T> a, type_emulator<T> b) +{ return a.i == b.i; } + +template<typename T> +bool +operator<(type_emulator<T> a, type_emulator<T> b) +{ return a.i < b.i; } + +template<typename T> +type_emulator<T> +operator+(type_emulator<T> a, type_emulator<T> b) +{ return a += b; } + +template<typename T> +type_emulator<T> +operator*(type_emulator<T> a, type_emulator<T> b) +{ return a *= b; } + +namespace std +{ + template<typename T, typename U> + struct common_type<type_emulator<T>, U> + { typedef typename common_type<T,U>::type type; }; + + template<typename T, typename U> + struct common_type<U, type_emulator<T>> + { typedef typename common_type<U,T>::type type; }; + + template<typename T, typename U> + struct common_type<type_emulator<T>, type_emulator<U>> + { typedef typename common_type<T,U>::type type; }; + + namespace chrono + { + template<typename T> + struct treat_as_floating_point<type_emulator<T>> + : is_floating_point<T> + { }; + } +} + +typedef type_emulator<int> int_emulator; +typedef type_emulator<double> dbl_emulator; + +// 20.8.3.1 duration constructors [time.duration.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using std::chrono::duration; + + int r = 3; + duration<int> d1(r); + VERIFY(d1.count() == static_cast<duration<int>::rep>(r)); + + double s = 8.0; + duration<double> d2(s); + VERIFY(d2.count() == static_cast<duration<double>::rep>(s)); + + int_emulator ie(3); + duration<int_emulator> d3(ie); + VERIFY(d3.count() == static_cast<duration<int_emulator>::rep>(ie)); + + dbl_emulator de(4.0); + duration<dbl_emulator> d4(de); + VERIFY(d4.count() == static_cast<duration<dbl_emulator>::rep>(de)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc new file mode 100644 index 000000000..1e3ab0e7c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc @@ -0,0 +1,44 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.3.1 duration constructors [time.duration.cons] + +#include <chrono> + +void +test01() +{ + std::chrono::duration<int> d1(1.0); // { dg-error "no matching|no type" } +} + +void +test02() +{ + using namespace std::chrono; + + duration<int, std::micro> d2(8); + duration<int, std::milli> d2_copy(d2); // { dg-error "no matching|no type" } +} + +// { dg-prune-output "include" } + +// Discard a bogus warning showing up with -Wall. +// { dg-prune-output "suggest parentheses around" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/2.cc new file mode 100644 index 000000000..07cefac6e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/2.cc @@ -0,0 +1,119 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.3 Class template duration [time.duration] + +#include <chrono> +#include <type_traits> +#include <testsuite_hooks.h> + +template<typename T> +struct type_emulator +{ + type_emulator() : i(T(0)) { } + type_emulator(T j) : i(j) { } + type_emulator(const type_emulator& e) : i(e.i) { } + + type_emulator& operator*=(type_emulator a) + { i *= a.i; return *this; } + + type_emulator& operator+=(type_emulator a) + { i += a.i; return *this; } + + operator T () { return i; } + T i; +}; + +template<typename T> +bool operator==(type_emulator<T> a, type_emulator<T> b) +{ return a.i == b.i; } + +template<typename T> +bool operator<(type_emulator<T> a, type_emulator<T> b) +{ return a.i < b.i; } + +template<typename T> +type_emulator<T> operator+(type_emulator<T> a, type_emulator<T> b) +{ return a += b; } + +template<typename T> +type_emulator<T> operator*(type_emulator<T> a, type_emulator<T> b) +{ return a *= b; } + +namespace std +{ + template<typename T, typename U> + struct common_type<type_emulator<T>, U> + { typedef typename common_type<T,U>::type type; }; + + template<typename T, typename U> + struct common_type<U, type_emulator<T>> + { typedef typename common_type<U,T>::type type; }; + + template<typename T, typename U> + struct common_type<type_emulator<T>, type_emulator<U>> + { typedef typename common_type<T,U>::type type; }; + + namespace chrono + { + template<typename T> + struct treat_as_floating_point<type_emulator<T>> + : is_floating_point<T> + { }; + } +} + +typedef type_emulator<int> int_emulator; +typedef type_emulator<double> dbl_emulator; + +// 20.8.3.1 duration constructors [time.duration.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + duration<int> d0(3); + duration<int> d0_copy(d0); + VERIFY(d0_copy.count() == d0.count()); + + duration<int, std::milli> d1(5); + duration<int, std::micro> d1_copy(d1); + VERIFY(d1.count() * 1000 == d1_copy.count()); + + duration<double, std::micro> d2(8.0); + duration<double, std::milli> d2_copy(d2); + VERIFY(d2.count() == d2_copy.count() * 1000.0); + + duration<int_emulator, std::milli> d3(5); + duration<int_emulator, std::micro> d3_copy(d3); + VERIFY(d3.count() * 1000 == d3_copy.count()); + + duration<dbl_emulator, std::micro> d4(5.0); + duration<dbl_emulator, std::milli> d4_copy(d4); + VERIFY(d4.count() == d4_copy.count() * dbl_emulator(1000.0)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/54025.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/54025.cc new file mode 100644 index 000000000..4610dbcc1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/54025.cc @@ -0,0 +1,25 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } + +// Copyright (C) 2012-2014 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 <atomic> +#include <chrono> + +std::atomic<std::chrono::duration<long, std::micro>> dur; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc new file mode 100644 index 000000000..d4ae371a6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + struct Seconds + { + constexpr Seconds() = default; + std::chrono::seconds s{}; + }; + test1.operator()<std::chrono::duration<Seconds>>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<std::chrono::seconds, std::chrono::seconds>(); + test2.operator()<std::chrono::seconds, std::chrono::seconds::rep>(); + test2.operator()<std::chrono::minutes, std::chrono::hours>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/dr974_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/dr974_neg.cc new file mode 100644 index 000000000..3e6b42b1d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/cons/dr974_neg.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2009-2014 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/>. + +// 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/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/ns_detail.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/ns_detail.cc new file mode 100644 index 000000000..a5e21e9a3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/ns_detail.cc @@ -0,0 +1,7 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Test error: reference to '__detail' is ambiguous + +#include <chrono> +#include <random> diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/types.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/types.cc new file mode 100644 index 000000000..fc787bfed --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/types.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 <chrono> +#include <type_traits> + +void +test03() +{ + using namespace std::literals::chrono_literals; + + static_assert(std::is_same<decltype(1h), std::chrono::hours>::value, + "1h is std::chrono::hours"); + + static_assert(std::is_same<decltype(1.0h), + std::chrono::duration<long double, std::ratio<3600L, 1L>>>::value, + "1.0h is std::chrono::duration<long double, std::ratio<3600L, 1L>>"); + + static_assert(std::is_same<decltype(1min), std::chrono::minutes>::value, + "1min is std::chrono::minutes"); + + static_assert(std::is_same<decltype(1.0min), + std::chrono::duration<long double, std::ratio<60L, 1L>>>::value, + "1.0min is std::chrono::duration<long double, std::ratio<60L, 1L>>"); + + static_assert(std::is_same<decltype(1s), std::chrono::seconds>::value, + "1s is std::chrono::seconds"); + + static_assert(std::is_same<decltype(1.0s), + std::chrono::duration<long double, std::ratio<1L, 1L>>>::value, + "1.0s is std::chrono::duration<long double, std::ratio<1L, 1L>>"); + + static_assert(std::is_same<decltype(1ms), std::chrono::milliseconds>::value, + "1ms is std::chrono::milliseconds"); + + static_assert(std::is_same<decltype(1.0ms), + std::chrono::duration<long double, std::ratio<1L, 1000L>>>::value, + "1.0ms is std::chrono::duration<long double, std::ratio<1L, 1000L>>"); + + static_assert(std::is_same<decltype(1us), std::chrono::microseconds>::value, + "1us is std::chrono::microseconds"); + + static_assert(std::is_same<decltype(1.0us), + std::chrono::duration<long double, std::ratio<1L, 1000000L>>>::value, + "1.0us is std::chrono::duration<long double, std::ratio<1L, 1000000L>>"); + + static_assert(std::is_same<decltype(1ns), std::chrono::nanoseconds>::value, + "1ns is std::chrono::nanoseconds"); + + static_assert(std::is_same<decltype(1.0ns), + std::chrono::duration<long double, std::ratio<1L, 1000000000L>>>::value, + "1.0ns is std::chrono::duration<long double, std::ratio<1L, 1000000000L>>"); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/values.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/values.cc new file mode 100644 index 000000000..f55c32f02 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/literals/values.cc @@ -0,0 +1,65 @@ +// { dg-do run } +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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 <chrono> +#include <testsuite_hooks.h> + +void +test03() +{ + using namespace std::literals::chrono_literals; + + auto jiffy = 23ns; + VERIFY( jiffy == std::chrono::nanoseconds(23) ); + auto fjiffy = 23.0ns; + VERIFY( (fjiffy == std::chrono::duration<long double, std::nano>(23.0L)) ); + auto blip = 14us; + VERIFY( blip == std::chrono::microseconds(14) ); + auto fblip = 14.0us; + VERIFY( (fblip == std::chrono::duration<long double, std::micro>(14.0L)) ); + auto bit = 77ms; + VERIFY( bit == std::chrono::milliseconds(77) ); + auto fbit = 77.0ms; + VERIFY( (fbit == std::chrono::duration<long double, std::milli>(77.0L)) ); + auto warmup = 33s; + VERIFY( warmup == std::chrono::seconds(33) ); + auto fwarmup = 33.0s; + VERIFY( (fwarmup == std::chrono::duration<long double, std::ratio<1,1>>(33.0L)) ); + auto classtime = 50min; + VERIFY( classtime == std::chrono::minutes(50) ); + auto fclasstime = 50.0min; + VERIFY( (fclasstime == std::chrono::duration<long double, std::ratio<60,1>>(50.0L)) ); + auto longtime = 1h + 30min; + VERIFY( longtime == std::chrono::minutes(90) ); + auto flongtime = 1.0h + 30.0min; + VERIFY( (flongtime == std::chrono::duration<long double, std::ratio<3600,1>>(1.0L) + + std::chrono::duration<long double, std::ratio<60,1>>(30.0L)) ); + VERIFY( (flongtime == std::chrono::duration<long double, std::ratio<60,1>>(90.0L)) ); + auto workday = 8h; + VERIFY( workday == std::chrono::hours(8) ); + auto fworkday = 8.0h; + VERIFY( (fworkday == std::chrono::duration<long double, std::ratio<3600,1>>(8.0L)) ); +} + +int +main() +{ + test03(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/constexpr_functions.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/constexpr_functions.cc new file mode 100644 index 000000000..546312a3e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/constexpr_functions.cc @@ -0,0 +1,64 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + constexpr auto v3 __attribute__((unused)) + = _Ttesttype::zero(); + + constexpr _Ttesttype obj { }; + constexpr auto v4 __attribute__((unused)) + = obj.count(); + constexpr auto v5 __attribute__((unused)) + = -obj; + constexpr auto v6 __attribute__((unused)) + = +obj; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_functions test; + test.operator()<std::chrono::nanoseconds>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..ebb23565f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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 <ratio> +#include <chrono> + +template class std::chrono::duration<int>; +template class std::chrono::duration<float, std::ratio<2,3>>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc new file mode 100644 index 000000000..3bf16c4b3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/sfinae_friendly_1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=c++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <chrono> + +// Helper types: +struct has_type_impl +{ + template<typename T, typename = typename T::type> + static std::true_type test(int); + template<typename> + static std::false_type test(...); +}; + +template<typename T> +struct has_type : public decltype(has_type_impl::test<T>(0)) +{}; + +template<typename T, typename Expected> +struct is_expected_type : public std::is_same<typename T::type, Expected> +{}; + +template<typename P1, typename P2> +struct and_ : public std::conditional<P1::value, P2, std::false_type>::type +{}; + +template<typename T, typename Expected> +struct is_type : public and_<has_type<T>, is_expected_type<T, Expected>> +{}; + +// Inspection types: + +typedef std::chrono::duration<int, std::nano> din; +typedef std::chrono::duration<double, std::nano> ddn; +typedef std::chrono::duration<int, std::milli> dim; + +static_assert(is_type<std::common_type<din, din>, din>(), ""); +static_assert(is_type<std::common_type<din, din, din>, din>(), ""); + +static_assert(is_type<std::common_type<din, ddn>, ddn>(), ""); +static_assert(is_type<std::common_type<din, din, ddn>, ddn>(), ""); +static_assert(is_type<std::common_type<din, ddn>, ddn>(), ""); +static_assert(is_type<std::common_type<ddn, din, din>, ddn>(), ""); + +static_assert(!has_type<std::common_type<din, int>>(), ""); +static_assert(!has_type<std::common_type<din, din, int>>(), ""); +static_assert(!has_type<std::common_type<int, din, din>>(), ""); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc new file mode 100644 index 000000000..774885a2d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <chrono> + +void test01() +{ + // Check if rep is a duration type + typedef std::chrono::duration<int> rep_type; + typedef std::chrono::duration<rep_type> test_type; + test_type d; +} + +// { dg-error "rep cannot be a duration" "" { target *-*-* } 246 } +// { dg-error "required from here" "" { target *-*-* } 31 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc new file mode 100644 index 000000000..3ffaf40fd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <chrono> + +void test01() +{ + // Check if period is a ratio + typedef int rep_type; + typedef int period_type; + typedef std::chrono::duration<rep_type, period_type> test_type; + test_type d; // { dg-error "required from here" } +} + +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 247 } +// { dg-prune-output "not a member" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc new file mode 100644 index 000000000..7c9d127a1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// 2008-07-31 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <ratio> +#include <chrono> + +void test01() +{ + // Check if period is positive + typedef int rep_type; + typedef std::ratio<-1> period_type; + typedef std::chrono::duration<rep_type, period_type> test_type; + test_type d; +} + +// { dg-error "period must be positive" "" { target *-*-* } 249 } +// { dg-error "required from here" "" { target *-*-* } 33 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/duration_cast/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration_cast/constexpr.cc new file mode 100644 index 000000000..824aa7ffc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/duration_cast/constexpr.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +int main() +{ + using namespace std::chrono; + + // non-constexpr + minutes mn1(6000); + hours hr1 __attribute__((unused)) = duration_cast<hours>(mn1); + + // constexpr + constexpr minutes mn2(6000); + constexpr hours hr2 __attribute__((unused)) = duration_cast<hours>(mn2); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..96d72bed4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 enable_if<true>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs-2.cc new file mode 100644 index 000000000..4c46da991 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs-2.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +static_assert( is_same<enable_if<true>::type, enable_if_t<true>>(), + "enable_if_t<true>" ); +struct X; +static_assert( is_same<enable_if<true, X>::type, enable_if_t<true, X>>(), + "enable_if_t<true, X>" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc new file mode 100644 index 000000000..06c792744 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc @@ -0,0 +1,32 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Positive tests. + typedef enable_if<true, int>::type test1_type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc new file mode 100644 index 000000000..5d5f39b89 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Negative tests. + typedef enable_if<false, int>::type test2_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 32 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc new file mode 100644 index 000000000..bcb8251d9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/cons/constexpr.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt23enable_shared_from_thisIiEC2Ev" } } +// { dg-final { scan-assembler-not "_ZN7derivedC2Ev" } } + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_common_types.h> + +struct derived : public std::enable_shared_from_this<int> +{ + constexpr derived() { } +}; + +int main() +{ + __gnu_test::constexpr_default_constructible test; + test.operator()<derived>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/assign.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/assign.cc new file mode 100644 index 000000000..18ec53fa4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/assign.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 <memory> +#include <testsuite_hooks.h> + +struct X : public std::enable_shared_from_this<X> { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + auto x1 = std::make_shared<X>(), x2 = std::make_shared<X>(); + *x1 = *x2; + VERIFY( x1->shared_from_this() != x2->shared_from_this() ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/unique_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/unique_ptr.cc new file mode 100644 index 000000000..514d3c1fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/members/unique_ptr.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 <memory> +#include <ext/pointer.h> +#include <testsuite_hooks.h> + +struct X : public std::enable_shared_from_this<X> { }; + +void test01() +{ + std::unique_ptr<X> up(new X); + X* xp = up.get(); + std::shared_ptr<X> sp(std::move(up)); + VERIFY( xp->shared_from_this() != nullptr ); +} + +using __gnu_cxx::_Pointer_adapter; +using __gnu_cxx::_Std_pointer_impl; + +struct Deleter +{ + struct pointer : _Pointer_adapter<_Std_pointer_impl<X>> + { + using _Pointer_adapter::_Pointer_adapter; + operator X*() const noexcept { return this->get(); } + }; + + void operator()(pointer p) const noexcept { delete (X*)p; } +}; + +void test02() +{ + std::unique_ptr<X, Deleter> up(new X); + Deleter::pointer xp = up.get(); + // Creating shared_ptr from unique_ptr with custom pointer is an extension: + std::shared_ptr<X> sp(std::move(up)); + // but enable_shared_from_this should still work: + VERIFY( xp->shared_from_this() != nullptr ); +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..dc51ab32e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/enable_shared_from_this/requirements/explicit_instantiation.cc @@ -0,0 +1,23 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <memory> + +template class std::enable_shared_from_this<int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/exchange/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/exchange/1.cc new file mode 100644 index 000000000..923920edd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/exchange/1.cc @@ -0,0 +1,105 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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/>. + +// 20.2.3 exchange [utility.exchange] + +#include <utility> +#include <type_traits> +#include <testsuite_hooks.h> + +void +test01() +{ + const unsigned val = 4; + int i = 1; + auto prev = std::exchange(i, val); + static_assert( std::is_same<decltype(prev), int>::value, "return type" ); + VERIFY( i == 4 ); + VERIFY( prev == 1 ); + prev = std::exchange(i, 3); + VERIFY( i == 3 ); + VERIFY( prev == 4 ); +} + +// Default construction from empty braces +void +test02() +{ + bool test __attribute__((unused)) = true; + + struct DefaultConstructible + { + DefaultConstructible(int i = 0) : value(i) { } + int value; + }; + + DefaultConstructible x = 1; + auto old = std::exchange(x, {}); + VERIFY( x.value == 0 ); + VERIFY( old.value == 1 ); +} + +int f(int) { return 0; } + +double f(double) { return 0; } + +// Deduce type of overloaded function +void +test03() +{ + bool test __attribute__((unused)) = true; + + int (*fp)(int); + std::exchange(fp, &f); + VERIFY( fp != nullptr ); +} + +void test04() +{ + struct From { }; + struct To { + int value = 0; + To() = default; + To(const To&) = default; + To(const From&) = delete; + To& operator=(const From&) { value = 1; } + To& operator=(From&&) { value = 2; } + }; + + To t; + From f; + + auto prev = std::exchange(t, f); + VERIFY( t.value == 1 ); + VERIFY( prev.value == 0 ); + + prev = std::exchange(t, From{}); + VERIFY( t.value == 2 ); + VERIFY( prev.value == 1 ); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7a65cb588 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 extent<test_type, 2>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/requirements/typedefs.cc new file mode 100644 index 000000000..d29ae30ad --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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::extent<int, 1> 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/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/value.cc new file mode 100644 index 000000000..d40d27d92 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/extent/value.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::extent; + using namespace __gnu_test; + + static_assert(test_property<extent, int, 0>(0), ""); + static_assert(test_property<extent, int[2], 0>(2), ""); + static_assert(test_property<extent, int[2][4], 0>(2), ""); + static_assert(test_property<extent, int[][4], 0>(0), ""); + static_assert(extent<int, 1>::value == 0, ""); + static_assert(extent<int[2], 1>::value == 0, ""); + static_assert(extent<int[2][4], 1>::value == 4, ""); + static_assert(extent<int[][4], 1>::value == 4, ""); + static_assert(extent<int[10][4][6][8][12][2], 4>::value == 12, ""); + static_assert(test_property<extent, ClassType, 0>(0), ""); + static_assert(test_property<extent, ClassType[2], 0>(2), ""); + static_assert(test_property<extent, ClassType[2][4], 0>(2), ""); + static_assert(test_property<extent, ClassType[][4], 0>(0), ""); + static_assert(extent<ClassType, 1>::value == 0, ""); + static_assert(extent<ClassType[2], 1>::value == 0, ""); + static_assert(extent<ClassType[2][4], 1>::value == 4, ""); + static_assert(extent<ClassType[][4], 1>::value == 4, ""); + static_assert(extent<ClassType[10][4][6][8][12][2], 4>::value == 12, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/1.cc new file mode 100644 index 000000000..1f97a8006 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/1.cc @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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 <memory> +#include <utility> + +template<class T, class A1, class A2> + std::shared_ptr<T> + factory(A1&& a1, A2&& a2) + { + return std::shared_ptr<T>(new T(std::forward<A1>(a1), + std::forward<A2>(a2))); + } + +struct A +{ + A(int&, const double&); +}; + +void g() +{ + int i = 2; + std::shared_ptr<A> sp1 = factory<A>(i, 1.414); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/1_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/1_neg.cc new file mode 100644 index 000000000..06f7bcbdf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/1_neg.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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 <memory> +#include <utility> + +template<class T, class A1, class A2> + std::shared_ptr<T> + factory(A1&& a1, A2&& a2) + { + return std::shared_ptr<T>(new T(std::forward<A1>(a1), + std::forward<A2>(a2))); // { dg-error "no matching function" } + } + +struct A +{ + A(int&, const double&); +}; + +void g() +{ + std::shared_ptr<A> sp1 = factory<A>(2, 1.414); // { dg-error "required from here" } +} + +// Discard a bogus warning showing up with -Wall. +// { dg-prune-output "control reaches end of" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/a.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/a.cc new file mode 100644 index 000000000..dd64775a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/a.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <list> +#include <testsuite_hooks.h> + +template <class T> + struct C + { + T t_; + + template <class U, + class = typename std::enable_if + < + !std::is_lvalue_reference<U>::value + >::type> + C(U&& u) : t_(std::forward<T>(std::move(u).get())) {} + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) {} + + ~A() { data_ = -1; } + + void test() const + { + bool test __attribute__((unused)) = true; + VERIFY( data_ == 3 ); + } +}; + +class Awrap +{ + const A& a_; +public: + explicit Awrap(const A& a) : a_(a) { } + const A& get() const { return a_; } +}; + +template <class C> + void test(C c) + { + c.t_.test(); + } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test A. +int main() +{ + std::list<C<const A&> > list; + A a(3); + C<const A&> c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/b.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/b.cc new file mode 100644 index 000000000..17d9f13f4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/b.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <list> +#include <testsuite_hooks.h> + +template <class T> + struct C + { + T t_; + + template <class U, + class = typename std::enable_if + < + !std::is_lvalue_reference<U>::value + >::type> + C(U&& u) : t_(std::forward<T>(std::move(u).get())) {} + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + bool test __attribute__((unused)) = true; + VERIFY( data_ == 3 ); + } +}; + +class Awrap +{ + A a_; +public: + explicit Awrap(const A& a) : a_(a) { } + A get() const { return a_; } +}; + +template <class C> +void test(C c) +{ + c.t_.test(); +} + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test B. +int main() +{ + std::list<C<A> > list; + A a(3); + C<A> c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/c_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/c_neg.cc new file mode 100644 index 000000000..fb900e01c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/c_neg.cc @@ -0,0 +1,78 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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/>. + +// { dg-error "static assertion failed" "" { target *-*-* } 89 } + +#include <list> + +template <class T> + struct C + { + T t_; + + template <class U, + class = typename std::enable_if + < + !std::is_lvalue_reference<U>::value + >::type> + C(U&& u) : t_(std::forward<T>(std::move(u).get())) {} + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + __builtin_abort(); + } +}; + +class Awrap +{ + const A& a_; +public: + explicit Awrap(const A& a) : a_(a) {} + const A /* & */ get() const { return a_; } +}; + +template <class C> + void test(C c) + { + c.t_.test(); + } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test C. +int main() +{ + std::list<C<const A&> > list; + A a(3); + C<const A&> c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/d.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/d.cc new file mode 100644 index 000000000..9d9b1e0fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/d.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <list> +#include <testsuite_hooks.h> + +template <class T> + struct C + { + T t_; + + template <class U, + class = typename std::enable_if + < + !std::is_lvalue_reference<U>::value + >::type> + C(U&& u) : t_(std::forward<T>(std::move(u).get())) { } + }; + +class A +{ + int data_; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + bool test __attribute__((unused)) = true; + VERIFY( data_ == 3 ); + } +}; + +class Awrap +{ + A& a_; +public: + explicit Awrap(A& a) : a_(a) { } + const A& get() const { return a_; } + A& get() { return a_; } +}; + +template <class C> + void test(C c) + { + c.t_.test(); + } + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test D. +int main() +{ + std::list<C<const A&> > list; + A a(3); + C<const A&> c((Awrap(a))); + list.push_back(c); + test(c); + test(list.front()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/e.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/e.cc new file mode 100644 index 000000000..3838c9f9a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/e.cc @@ -0,0 +1,54 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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> + +template <class T> + struct C + { + T t_; + + C() { } + + template <class U, + class = typename std::enable_if + < + !std::is_lvalue_reference<U>::value + >::type> + C(U&& u) : t_(std::forward<T>(std::move(u).get())) { } + + C(C&& c) : t_(std::forward<T>(c.t_)) { } + }; + +template <class T> + struct Derived + : C<T> + { + Derived() { } + Derived(Derived&& d) : C<T>(std::forward<C<T>>(d)) { } + }; + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test E. +int main() +{ + Derived<int> d; + Derived<int> d2(std::move(d)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/f_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/f_neg.cc new file mode 100644 index 000000000..c4914f0f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/f_neg.cc @@ -0,0 +1,90 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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/>. + +// { dg-error "static assertion failed" "" { target *-*-* } 89 } + +#include <utility> + +template <class T> + struct C + { + T t_; + + C() {} + + explicit C(const T& t) : t_(t) { } + + template <class U, + class = typename std::enable_if + < + std::is_convertible<U, T>::value + >::type> + C(C<U>&& c) : t_(std::forward<T>(c.t_)) { } + }; + +class B; + +class A +{ + int data_; + + friend class B; +public: + explicit + A(int data = 1) + : data_(data) { } + + ~A() { data_ = -1; } + + void test() const + { + __builtin_abort(); + } +}; + +class B +{ + int data_; +public: + explicit + B(int data = 1) + : data_(data) { } + + B(const A& a) : data_(a.data_) { } + + B(A&& a) : data_(a.data_) { a.data_ = 100; } + + ~B() { data_ = -1; } + + void test() const + { + __builtin_abort(); + } +}; + +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2951.html +// Test F. +int main() +{ + A a(3); + C<A> ca(a); + C<const B&> cb(std::move(ca)); + cb.t_.test(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7a81e26a2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/forward/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 utility with NO OTHER INCLUDES. + +#include <utility> + +namespace std +{ + typedef short test_type; + template test_type&& forward<test_type>(test_type&&); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/1.cc new file mode 100644 index 000000000..611d6aab6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/1.cc @@ -0,0 +1,94 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Operations on empty function<> objects +void test01() +{ + using std::function; + using std::bad_function_call; + + // Default-construction + function<int(float)> f1; + VERIFY( ((bool)f1 == false) ); + VERIFY( !f1 ); + VERIFY( f1 == 0 ); + VERIFY( 0 == f1 ); + VERIFY( !(f1 != 0) ); + VERIFY( !(0 != f1) ); + + // Copy-construction + function<int(float)> f2(f1); + VERIFY( !f2 ); + + // Construct with NULL pointer + function<int(float)> f3(0); + VERIFY( !f3 ); + + // Assignment + f1 = f2; + VERIFY( !f1); + + // Assignment to NULL pointer + f1 = 0; + VERIFY( !f1 ); + + // Swap + swap(f1, f2); + VERIFY( !f1 ); + VERIFY( !f2 ); + + // Invocation should throw bad_function_call + bool thrown = false; + try + { + f1(3.14159f); + VERIFY( false ); + } + catch (bad_function_call) + { + thrown = true; + } + VERIFY( thrown ); + + // target_type returns typeid(void) + VERIFY( f1.target_type() == typeid(void) ); + + // target() always returns a NULL pointer + VERIFY( f1.target<int (*)(float)>() == 0); + + // Check const version + const function<int(float)>& f1c = f1; + VERIFY( f1c.target<int (*)(float)>() == 0 ); + VERIFY( !f1c ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/10.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/10.cc new file mode 100644 index 000000000..1d0d684f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/10.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2012-2014 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/>. + +// 20.8.11 polymorphic function object wrapper + +#include <functional> + +struct X { void f() { } }; + +void (X::*p)() = &X::f; +void (X::* volatile& vp)() = p; + +typedef std::function<void(X&)> function_type; + +void test01() +{ + function_type f( vp ); + function_type f2( std::ref(vp) ); + function_type f3( std::cref(vp) ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/2.cc new file mode 100644 index 000000000..78d1af35d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/2.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put function pointers into function<> wrappers +void test02() +{ + using std::function; + + function<int(float)> f1(truncate_float); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Copy-construction + function<int(float)> f2(f1); + VERIFY( f2 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + VERIFY( f2(3.1f) == 3 ); + + // Assignment to zero + f1 = 0; + VERIFY( !f1 ); + + // Swap + f1.swap(f2); + VERIFY( f1 ); + VERIFY( !f2 ); + VERIFY( f1(3.1f) == 3 ); + + // Assignment from a function pointer + f2 = truncate_float; + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function<int(float)>& f1c = f1; + VERIFY( typeid(int(*)(float)) == f1.target_type() ); + VERIFY( f2.target<int(*)(float)>() != 0 ); + VERIFY( *f2.target<int(*)(float)>() == &truncate_float ); + VERIFY( f1c.target<int(*)(float)>() != 0 ); + VERIFY( *f1c.target<int(*)(float)>() == &truncate_float ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/3.cc new file mode 100644 index 000000000..08f689cdd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/3.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put nearly-matching function pointers into function<> wrappers +void test03() +{ + using std::function; + + function<int(float)> f1(truncate_double); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Copy-construction + function<int(float)> f2(f1); + VERIFY( f2 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + VERIFY( f2(3.1f) == 3 ); + + // Assignment to zero + f1 = 0; + VERIFY( !f1 ); + + // Swap + f1.swap(f2); + VERIFY( f1 ); + VERIFY( !f2 ); + VERIFY( f1(3.1f) == 3 ); + + // Assignment from a function pointer + f2 = truncate_double; + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function<int(float)>& f1c = f1; + VERIFY( typeid(long(*)(double)) == f1.target_type() ); + VERIFY( f2.target<long(*)(double)>() != 0 ); + VERIFY( *f2.target<long(*)(double)>() == &truncate_double ); + VERIFY( f1c.target<long(*)(double)>() != 0 ); + VERIFY( *f1c.target<long(*)(double)>() == &truncate_double ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/4.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/4.cc new file mode 100644 index 000000000..4ee090ba9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/4.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put function objects into function<> wrappers +void test04() +{ + using std::function; + + do_truncate_float_t truncate_float; + + function<int(float)> f1(truncate_float); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Copy-construction + function<int(float)> f2(f1); + VERIFY( f2 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + VERIFY( f2(3.1f) == 3 ); + + // Assignment to zero + f1 = 0; + VERIFY( !f1 ); + + // Swap + f1.swap(f2); + VERIFY( f1 ); + VERIFY( !f2 ); + VERIFY( f1(3.1f) == 3 ); + + // Assignment from a function pointer + f2 = do_truncate_float_t(); + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function<int(float)>& f1c = f1; + VERIFY( typeid(do_truncate_float_t) == f1.target_type() ); + VERIFY( f2.target<do_truncate_float_t>() != 0 ); + VERIFY( f1c.target<do_truncate_float_t>() != 0 ); +} + +int main() +{ + test04(); + + VERIFY( do_truncate_double_t::live_objects == 0 ); + VERIFY( do_truncate_float_t::live_objects == 0 ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/43397.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/43397.cc new file mode 100644 index 000000000..b4633fbf6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/43397.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } +// Copyright (C) 2010-2014 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/>. + +// 20.8.15 polymorphic function object wrapper + +#include <functional> +#include <testsuite_hooks.h> + +struct Foo +{ + Foo() { } + short operator() ( int && ) { return 1; } + short operator() ( int && ) const { return 2; } + short operator() ( int && ) volatile { return 3; } + short operator() ( int && ) const volatile { return 4; } + short func( int && ) { return 5; } + short func_c( int && ) const { return 6; } + short func_v( int && ) volatile { return 7; } + short func_cv( int && ) const volatile { return 8; } +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + using std::function; + using std::ref; + + Foo foo; + Foo const foo_c; + Foo volatile foo_v; + Foo const volatile foo_cv; + + std::function< int ( int && ) > f1( ref(foo) ); + VERIFY( f1(0) == 1 ); + + std::function< int ( int && ) > f2( ref(foo_c) ); + VERIFY( f2(0) == 2 ); + + std::function< int ( int && ) > f3( ref(foo_v) ); + VERIFY( f3(0) == 3 ); + + std::function< int ( int && ) > f4( ref(foo_cv) ); + VERIFY( f4(0) == 4 ); + + std::function< int ( Foo &, int && ) > f5( &Foo::func ) ; + VERIFY( f5(foo, 0) == 5 ); + + std::function< int ( Foo const &, int && ) > f6( &Foo::func_c ) ; + VERIFY( f6(foo_c, 0) == 6 ); + + std::function< int ( Foo volatile &, int && ) > f7( &Foo::func_v ) ; + VERIFY( f7(foo_v, 0) == 7 ); + + std::function< int ( Foo const volatile &, int && ) > f8( &Foo::func_cv ) ; + VERIFY( f8(foo_cv, 0) == 8 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/48541.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/48541.cc new file mode 100644 index 000000000..cdac8d7a3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/48541.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// Copyright (C) 2011-2014 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/>. + +// libstdc++/48451 + +#include <functional> + +struct X { + void operator () () const { } + float operator & () const { return 1.2345; } +}; + +void test01() +{ + X x; + std::function<void()> f(x); + f(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/5.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/5.cc new file mode 100644 index 000000000..0cb70b676 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/5.cc @@ -0,0 +1,107 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put member pointers into function<> wrappers +void test05() +{ + using std::function; + + X x; + x.bar = 17; + + function<int(X&)> frm(&X::bar); + VERIFY( frm ); + VERIFY( frm(x) == 17 ); + VERIFY( typeid(int X::*) == frm.target_type() ); + VERIFY( *frm.target<int X::*>() == &X::bar ); + + function<int(X&)> fr(&X::foo); + VERIFY( fr ); + VERIFY( fr(x) == 1 ); + VERIFY( typeid(int (X::*)()) == fr.target_type() ); + VERIFY( *fr.target<int (X::*)()>() == &X::foo ); + + function<int(const X&)> frc(&X::foo_c); + VERIFY( frc ); + VERIFY( frc(x) == 2 ); + VERIFY( typeid(int (X::*)() const) == frc.target_type() ); + VERIFY( *frc.target<int (X::*)() const >() == &X::foo_c ); + + function<int(volatile X&)> frv(&X::foo_v); + VERIFY( frv ); + VERIFY( frv(x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == frv.target_type() ); + VERIFY( *frv.target<int (X::*)() volatile >() == &X::foo_v ); + VERIFY( frv.target<int (X::*)() const volatile>() == 0 ); + + function<int(const volatile X&)> frcv(&X::foo_cv); + VERIFY( frcv ); + VERIFY( frcv(x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == frcv.target_type() ); + VERIFY( *frcv.target<int (X::*)() const volatile >() == &X::foo_cv ); + VERIFY( frcv.target<int (X::*)() const>() == 0 ); + + function<int(X*)> grm(&X::bar); + VERIFY( grm ); + VERIFY( grm(&x) == 17 ); + VERIFY( typeid(int X::*) == grm.target_type() ); + VERIFY( *grm.target<int X::*>() == &X::bar ); + + function<int(X*)> gr(&X::foo); + VERIFY( gr ); + VERIFY( gr(&x) == 1 ); + VERIFY( typeid(int (X::*)()) == gr.target_type() ); + VERIFY( *gr.target<int (X::*)()>() == &X::foo ); + + function<int(const X*)> grc(&X::foo_c); + VERIFY( grc ); + VERIFY( grc(&x) == 2 ); + VERIFY( typeid(int (X::*)() const) == grc.target_type() ); + VERIFY( *grc.target<int (X::*)() const >() == &X::foo_c ); + + function<int(volatile X*)> grv(&X::foo_v); + VERIFY( grv ); + VERIFY( grv(&x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == grv.target_type() ); + VERIFY( *grv.target<int (X::*)() volatile >() == &X::foo_v ); + VERIFY( grv.target<int (X::*)() const volatile>() == 0 ); + + function<int(const volatile X*)> grcv(&X::foo_cv); + VERIFY( grcv ); + VERIFY( grcv(&x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == grcv.target_type() ); + VERIFY( *grcv.target<int (X::*)() const volatile >() == &X::foo_cv ); + VERIFY( grcv.target<int (X::*)() const>() == 0 ); +} + +int main() +{ + test05(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/58569.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/58569.cc new file mode 100644 index 000000000..f73d429bb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/58569.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// Copyright (C) 2013-2014 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/>. + +// libstdc++/58569 + +#include <functional> + +struct foo { + std::function<foo (int)> x; + std::function<foo ()> y; +}; + +foo a; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/6.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/6.cc new file mode 100644 index 000000000..bcfc2aec8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/6.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +struct secret {}; + +struct noncopyable_function_object_type +{ + noncopyable_function_object_type(secret) {} + + int operator()() const { return 42; } + int operator()() { return 17; } + + private: + noncopyable_function_object_type(); + noncopyable_function_object_type(const noncopyable_function_object_type&); + void operator=(const noncopyable_function_object_type&); +}; + +// Put reference_wrappers into function<> wrappers +void test06() +{ + using std::function; + using std::ref; + using std::cref; + + secret password; + noncopyable_function_object_type x(password); + + function<int()> f(ref(x)); + VERIFY( f ); + VERIFY( f() == 17 ); + VERIFY( f.target_type() == typeid(noncopyable_function_object_type) ); + VERIFY( f.target<noncopyable_function_object_type>() == &x ); + + function<int()> g = f; + VERIFY( g ); + VERIFY( g() == 17 ); + VERIFY( g.target_type() == typeid(noncopyable_function_object_type) ); + VERIFY( g.target<noncopyable_function_object_type>() == &x ); + + function<int()> h = cref(x); + VERIFY( h ); + VERIFY( h() == 42 ); + VERIFY( h.target_type() == typeid(noncopyable_function_object_type) ); + VERIFY( h.target<const noncopyable_function_object_type>() == &x ); + VERIFY( h.target<const noncopyable_function_object_type>() == &x ); + + const function<int()>& hc = h; + VERIFY( h.target<noncopyable_function_object_type>() == 0 ); + VERIFY( hc.target<noncopyable_function_object_type>() == &x ); +} + +int main() +{ + test06(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/7.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/7.cc new file mode 100644 index 000000000..fc582f5c6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/7.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put reference_wrappers to function pointers into function<> wrappers +void test07() +{ + using std::function; + using std::ref; + using std::cref; + + int (*fptr)(float) = truncate_float; + + function<int(float)> f1(ref(fptr)); + VERIFY( f1 ); + VERIFY( !!f1 ); + VERIFY( !(f1 == 0) ); + VERIFY( !(0 == f1) ); + VERIFY( f1 != 0 ); + VERIFY( 0 != f1 ); + + // Invocation + VERIFY( f1(3.1f) == 3 ); + + // target_type and target() functions + const function<int(float)>& f1c = f1; + VERIFY( typeid(int(*)(float)) == f1.target_type() ); + VERIFY( f1.target<int(*)(float)>() != 0 ); + VERIFY( f1.target<int(*)(float)>() == &fptr ); + VERIFY( f1c.target<int(*)(float)>() != 0 ); + VERIFY( f1c.target<int(*)(float)>() == &fptr ); + + function<int(float)> f2(cref(fptr)); + VERIFY( f2 ); + VERIFY( !!f2 ); + VERIFY( !(f2 == 0) ); + VERIFY( !(0 == f2) ); + VERIFY( f2 != 0 ); + VERIFY( 0 != f2 ); + + // Invocation + VERIFY( f2(3.1f) == 3 ); + + // target_type and target() functions + const function<int(float)>& f2c = f2; + VERIFY( typeid(int(*)(float)) == f2.target_type() ); + VERIFY( f2.target<int(*)(float)>() == 0 ); + VERIFY( f2.target<int(* const)(float)>() == &fptr ); + VERIFY( f2c.target<int(*)(float)>() != 0 ); + VERIFY( f2c.target<int(*)(float)>() == &fptr ); +} + +int main() +{ + test07(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/8.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/8.cc new file mode 100644 index 000000000..fd6c1ec76 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/8.cc @@ -0,0 +1,148 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put reference_wrappers to member pointers +void test08() +{ + using std::function; + using std::ref; + using std::cref; + + int X::* X_bar = &X::bar; + int (X::* X_foo)() = &X::foo; + int (X::* X_foo_c)() const = &X::foo_c; + int (X::* X_foo_v)() volatile = &X::foo_v; + int (X::* X_foo_cv)() const volatile = &X::foo_cv; + + X x; + x.bar = 17; + + function<int(X&)> frm(ref(X_bar)); + VERIFY( frm ); + VERIFY( frm(x) == 17 ); + VERIFY( typeid(int X::*) == frm.target_type() ); + VERIFY( frm.target<int X::*>() == &X_bar ); + + function<int(X&)> fr(ref(X_foo)); + VERIFY( fr ); + VERIFY( fr(x) == 1 ); + VERIFY( typeid(int (X::*)()) == fr.target_type() ); + VERIFY( fr.target<int (X::*)()>() == &X_foo ); + + function<int(const X&)> frc(ref(X_foo_c)); + VERIFY( frc ); + VERIFY( frc(x) == 2 ); + VERIFY( typeid(int (X::*)() const) == frc.target_type() ); + VERIFY( frc.target<int (X::*)() const >() == &X_foo_c ); + + function<int(volatile X&)> frv(ref(X_foo_v)); + VERIFY( frv ); + VERIFY( frv(x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == frv.target_type() ); + VERIFY( *frv.target<int (X::*)() volatile >() == X_foo_v ); + VERIFY( frv.target<int (X::*)() const volatile>() == 0 ); + + function<int(const volatile X&)> frcv(ref(X_foo_cv)); + VERIFY( frcv ); + VERIFY( frcv(x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == frcv.target_type() ); + VERIFY( *frcv.target<int (X::*)() const volatile >() == X_foo_cv ); + VERIFY( frcv.target<int (X::*)() const>() == 0 ); + + function<int(X*)> grm(ref(X_bar)); + VERIFY( grm ); + VERIFY( grm(&x) == 17 ); + VERIFY( typeid(int X::*) == grm.target_type() ); + VERIFY( *grm.target<int X::*>() == X_bar ); + + function<int(X*)> gr(ref(X_foo)); + VERIFY( gr ); + VERIFY( gr(&x) == 1 ); + VERIFY( typeid(int (X::*)()) == gr.target_type() ); + VERIFY( *gr.target<int (X::*)()>() == X_foo ); + + function<int(const X*)> grc(ref(X_foo_c)); + VERIFY( grc ); + VERIFY( grc(&x) == 2 ); + VERIFY( typeid(int (X::*)() const) == grc.target_type() ); + VERIFY( *grc.target<int (X::*)() const >() == X_foo_c ); + + function<int(volatile X*)> grv(ref(X_foo_v)); + VERIFY( grv ); + VERIFY( grv(&x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == grv.target_type() ); + VERIFY( *grv.target<int (X::*)() volatile >() == X_foo_v ); + VERIFY( grv.target<int (X::*)() const volatile>() == 0 ); + + function<int(const volatile X*)> grcv(ref(X_foo_cv)); + VERIFY( grcv ); + VERIFY( grcv(&x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == grcv.target_type() ); + VERIFY( *grcv.target<int (X::*)() const volatile >() == X_foo_cv ); + VERIFY( grcv.target<int (X::*)() const>() == 0 ); + + function<int(X&)> hrm(cref(X_bar)); + VERIFY( hrm ); + VERIFY( hrm(x) == 17 ); + VERIFY( typeid(int X::*) == hrm.target_type() ); + VERIFY( hrm.target<int X::*>() == 0 ); + VERIFY( hrm.target<int X::* const>() == &X_bar ); + + function<int(X&)> hr(cref(X_foo)); + VERIFY( hr ); + VERIFY( hr(x) == 1 ); + VERIFY( typeid(int (X::*)()) == hr.target_type() ); + VERIFY( hr.target<int (X::* const)()>() == &X_foo ); + + function<int(const X&)> hrc(cref(X_foo_c)); + VERIFY( hrc ); + VERIFY( hrc(x) == 2 ); + VERIFY( typeid(int (X::*)() const) == hrc.target_type() ); + VERIFY( hrc.target<int (X::* const)() const >() == &X_foo_c ); + + function<int(volatile X&)> hrv(cref(X_foo_v)); + VERIFY( hrv ); + VERIFY( hrv(x) == 3 ); + VERIFY( typeid(int (X::*)() volatile) == hrv.target_type() ); + VERIFY( hrv.target<int (X::* const)() volatile >() == &X_foo_v ); + VERIFY( hrv.target<int (X::* const)() const volatile>() == 0 ); + + function<int(const volatile X&)> hrcv(cref(X_foo_cv)); + VERIFY( hrcv ); + VERIFY( hrcv(x) == 4 ); + VERIFY( typeid(int (X::*)() const volatile) == hrcv.target_type() ); + VERIFY( hrcv.target<int (X::* const)() const volatile >() == &X_foo_cv ); + VERIFY( hrcv.target<int (X::* const)() const>() == 0 ); +} + +int main() +{ + test08(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/9.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/9.cc new file mode 100644 index 000000000..da44ef2d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/9.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-15 Douglas Gregor <dgregor@cs.indiana.edu> +// +// Copyright (C) 2005-2014 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/>. + +// 20.7.15 polymorphic function object wrapper +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +// Put function objects into a void-returning function<> wrapper +void test09() +{ + using std::function; + using std::ref; + using std::cref; + + int (X::*X_foo_c)() const = &X::foo_c; + function<void(X&)> f(&X::bar); + f = &X::foo; + f = ref(X_foo_c); + f = cref(X_foo_c); + + function<void(float)> g = &truncate_float; + g = do_truncate_float_t(); +} + +int main() +{ + test09(); + + VERIFY( do_truncate_double_t::live_objects == 0 ); + VERIFY( do_truncate_float_t::live_objects == 0 ); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/assign/move.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/assign/move.cc new file mode 100644 index 000000000..b78ea28d7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/assign/move.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 <functional> +#include <testsuite_hooks.h> + +int f1() { return 1; } +struct { int operator()() { return 2; } } f2; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::function<int()> function; + + function fo(f1); + function fo1; + fo1 = (std::move(fo)); + VERIFY( static_cast<bool>(fo1) ); + VERIFY( fo1() == 1 ); + + fo = function(f2); + function fo2; + fo2 = (std::move(fo)); + VERIFY( static_cast<bool>(fo2) ); + VERIFY( fo2() == 2 ); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/assign/move_target.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/assign/move_target.cc new file mode 100644 index 000000000..f20bcdc8c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/assign/move_target.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 <functional> + +struct moveable +{ + moveable() = default; + ~moveable() = default; + // target object must be CopyConstructible, + // but should not be copied during this test + moveable(const moveable& c) { throw "copied"; } + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } + + void operator()() const { } +}; + +void test01() +{ + std::function<void ()> f; + f = moveable(); + f(); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cmp/cmp_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cmp/cmp_neg.cc new file mode 100644 index 000000000..bdeb0ef63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cmp/cmp_neg.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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/>. + +// { dg-prune-output "include" } + +#include <functional> + +void test01() +{ + std::function<void()> f1; + std::function<void()> f2; + f1 == f2; // { dg-error "no match" } + f1 != f2; // { dg-error "no match" } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/55320.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/55320.cc new file mode 100644 index 000000000..8c5adfb63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/55320.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2012-2014 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/>. + +// libstdc++/55320 + +// { dg-options "-std=gnu++0x" } + +#include <functional> +#include <testsuite_hooks.h> + +struct X +{ + X() { ++count; } + X(const X&) { throw 1; } + ~X() { --count; } + void operator()() { } + static int count; +}; + +int X::count = 0; + +int main() +{ + try + { + std::function<void()> f = X(); + } + catch (int) + { + VERIFY( X::count == 0 ); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/57465.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/57465.cc new file mode 100644 index 000000000..2aadfba6a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/57465.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2013-2014 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/>. + +// libstdc++/57465 + +// { dg-options "-std=gnu++11" } + +#include <functional> +#include <testsuite_hooks.h> + +int main() +{ + using F = void(); + F* f = nullptr; + std::function<F> x(f); + VERIFY( !x ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/addressof.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/addressof.cc new file mode 100644 index 000000000..26514adca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/addressof.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2012-2014 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/>. + +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +#include <functional> + +struct F +{ + void operator()() { } + void operator&() const { } +}; + +void test01() +{ + F f; + std::function<void()> f1 = f; + std::function<void()> f2 = std::ref(f); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/callable.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/callable.cc new file mode 100644 index 000000000..140f8a36f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/callable.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <functional> + +void* f(std::function<void()>) { return nullptr; } +int f(std::function<void(int)>) { return 1; } + +void test01() +{ + void* p __attribute__((unused)); + int i __attribute__((unused)); + + p = f([] { }); + i = f([] (int) { }); +} + +void g(std::function<void()>) { } +void h(std::function<int(int)>) { } + +void test02() +{ + g([] { return "ignored"; }); + h([] (char c) { return c; }); +} + +int main() +{ + test01(); + test02(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/move.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/move.cc new file mode 100644 index 000000000..1cdda2b29 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/move.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 <functional> +#include <testsuite_hooks.h> + +int f1() { return 1; } +struct { int operator()() { return 2; } } f2; + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::function<int()> function; + + function fo(f1); + function fo1(std::move(fo)); + VERIFY( static_cast<bool>(fo1) ); + VERIFY( fo1() == 1 ); + + fo = function(f2); + function fo2(std::move(fo)); + VERIFY( static_cast<bool>(fo2) ); + VERIFY( fo2() == 2 ); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc new file mode 100644 index 000000000..b52c8d90f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 <functional> + +struct moveable +{ + moveable() = default; + ~moveable() = default; + // target object must be CopyConstructible, + // but should not be copied during this test + moveable(const moveable& c) { throw "copied"; } + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } + + void operator()() const { } +}; + +void test01() +{ + std::function<void ()> f = moveable(); + f(); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/invoke/move_only.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/invoke/move_only.cc new file mode 100644 index 000000000..ddcc3abb6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/invoke/move_only.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009-2014 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 <functional> + +struct moveable +{ + moveable() = default; + ~moveable() = default; + moveable(const moveable& c) = delete; + moveable& operator=(const moveable&) = delete; + moveable(moveable&&) { } +}; + +void f1(moveable) { } +void f2(moveable&&) { } +struct { void operator()(moveable&&) { } } f3; + +void test01() +{ + std::function<void (moveable)> fo1a(f1); + fo1a(moveable()); + + std::function<void (moveable)> fo2a(f2); + fo2a(moveable()); + + std::function<void (moveable)> fo3a(f3); + fo3a(moveable()); + + std::function<void (moveable&&)> fo1b(f1); + fo1b(moveable()); + + std::function<void (moveable&&)> fo2b(f2); + fo2b(moveable()); + + std::function<void (moveable&&)> fo3b(f3); + fo3b(moveable()); +} + +int main() +{ + test01(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc new file mode 100644 index 000000000..9f163ea91 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/null_pointer_comparisons.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 <functional> + +// libstdc++/40273 +int main() +{ + std::function<void* ()> f = 0; + if (f != 0) + { + } + + if (0 != f) + { + } + + if (f == 0) + { + } + + if (0 == f) + { + } + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..31a11f1f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function/requirements/explicit_instantiation.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 <functional> + +namespace std +{ + template class function<void* ()>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc new file mode 100644 index 000000000..ca6d3b8c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/binders/1.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2005-2014 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/>. + +// 20.3.6 Binders + +// { dg-do compile } + +#include <functional> +using namespace std; + +struct s +{ + void f_void_int_const(int) const {} + void f_void_int(int) {} + int f_int_int_const(int) const { return 1; } + int f_int_int(int) {return 1; } + void f_void_void_const() const {} + void f_void_void() {} + int f_int_void_const() const { return 1; } + int f_int_void() { return 1; } +}; + +void test01(s& a) +{ + mem_fun_t<void, s> p1(&s::f_void_void); + mem_fun_t<int, s> p2(&s::f_int_void); + p1(&a); + p2(&a); + mem_fun1_t<void, s, int> q1(&s::f_void_int); + mem_fun1_t<int, s, int> q2(&s::f_int_int); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void))(&a); + (mem_fun(&s::f_void_int))(&a,0); + (mem_fun(&s::f_int_void))(&a); + (mem_fun(&s::f_int_int))(&a,0); + + mem_fun_ref_t<void, s> ref1(&s::f_void_void); + mem_fun_ref_t<int, s> ref2(&s::f_int_void); + + ref1(a); + ref2(a); + + mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int); + mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void))(a); + (mem_fun_ref(&s::f_void_int))(a, 0); + (mem_fun_ref(&s::f_int_void))(a); + (mem_fun_ref(&s::f_int_int))(a, 0); +} + +void test02(const s& a) +{ + const_mem_fun_t<void, s> p1(&s::f_void_void_const); + const_mem_fun_t<int, s> p2(&s::f_int_void_const); + p1(&a); + p2(&a); + const_mem_fun1_t<void, s, int> q1(&s::f_void_int_const); + const_mem_fun1_t<int, s, int> q2(&s::f_int_int_const); + q1(&a,0); + q2(&a,0); + + (mem_fun(&s::f_void_void_const))(&a); + (mem_fun(&s::f_void_int_const))(&a, 0); + (mem_fun(&s::f_int_void_const))(&a); + (mem_fun(&s::f_int_int_const))(&a, 0); + + const_mem_fun_ref_t<void, s> ref1(&s::f_void_void_const); + const_mem_fun_ref_t<int, s> ref2(&s::f_int_void_const); + + ref1(a); + ref2(a); + + const_mem_fun1_ref_t<void, s, int> ref3(&s::f_void_int_const); + const_mem_fun1_ref_t<int, s, int> ref4(&s::f_int_int_const); + + ref3(a,0); + ref4(a,0); + + (mem_fun_ref(&s::f_void_void_const))(a); + (mem_fun_ref(&s::f_void_int_const))(a, 0); + (mem_fun_ref(&s::f_int_void_const))(a); + (mem_fun_ref(&s::f_int_int_const))(a, 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc new file mode 100644 index 000000000..1ce0b5afc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/binders/3113.cc @@ -0,0 +1,49 @@ +// 2001-06-11 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.3.6 Binders + +#include <vector> +#include <algorithm> // for_each +#include <functional> + +class Elem +{ +public: + void print(int) const { } + void modify(int) { } +}; + +// libstdc++/3113 +void test01() +{ + std::vector<Elem> coll(2); + // OK + std::for_each(coll.begin(), coll.end(), + std::bind2nd(std::mem_fun_ref(&Elem::print), 42)); + // OK + std::for_each(coll.begin(), coll.end(), + std::bind2nd(std::mem_fun_ref(&Elem::modify), 42)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc new file mode 100644 index 000000000..561bf336d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/comparisons.cc @@ -0,0 +1,52 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.3.3 Comparisons + +#include <functional> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator!=(const gnu_obj& rhs) const { return i != rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator!=(const gnu_t& rhs) const { return b != rhs.b; } + bool operator<(const gnu_t& rhs) const { return b == rhs.b; } + }; + +template struct std::not_equal_to<void*>; +template struct std::not_equal_to<gnu_obj>; +template struct std::not_equal_to<gnu_t<long> >; + +int main() +{ + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/comparisons_void.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/comparisons_void.cc new file mode 100644 index 000000000..4d749618a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/comparisons_void.cc @@ -0,0 +1,95 @@ +// { dg-options " -std=gnu++1y " } +// { dg-do compile } + +// Copyright (C) 2013-2014 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/>. + +// 20.3.3 Comparisons + +#include <functional> + +struct R { }; + +struct L +{ + L operator+(const R&) const { return *this; } + L operator-(const R&) const { return *this; } + L operator*(const R&) const { return *this; } + L operator/(const R&) const { return *this; } + L operator%(const R&) const { return *this; } + L operator-() const { return *this; } + + bool operator==(const R&) const { return true; } + bool operator!=(const R&) const { return false; } + bool operator<(const R&) const { return false; } + bool operator<=(const R&) const { return true; } + bool operator>(const R&) const { return false; } + bool operator>=(const R&) const { return true; } + + bool operator&&(const R&) const { return true; } + bool operator||(const R&) const { return true; } + bool operator!() const { return false; } + + int operator&(const R&) const { return 1; } + int operator|(const R&) const { return 1; } + int operator^(const R&) const { return 0; } + int operator~() const { return 0; } +}; + +L l; +R r; + +// test unary function objects +template<typename F, typename Check = typename F::is_transparent> +bool +test1(F f) +{ + f(l); + return true; +} + +// test binary function objects +template<typename F, typename Check = typename F::is_transparent> +bool +test2(F f) +{ + f(l, r); + return true; +} + +auto plus = test2( std::plus<>() ); +auto minus = test2( std::minus<>() ); +auto multiplies = test2( std::multiplies<>() ); +auto divides = test2( std::divides<>() ); +auto modulus = test2( std::modulus<>() ); +auto negate = test1( std::negate<>() ); + +auto equal_to = test2( std::equal_to<>() ); +auto not_equal_to = test2( std::not_equal_to<>() ); +auto greater = test2( std::greater<>() ); +auto less = test2( std::less<>() ); +auto greater_equal = test2( std::greater_equal<>() ); +auto less_equal = test2( std::less_equal<>() ); + +auto logical_and = test2( std::logical_and<>() ); +auto logical_or = test2( std::logical_or<>() ); +auto logical_not = test1( std::logical_not<>() ); + +auto bit_and = test2( std::bit_and<>() ); +auto bit_or = test2( std::bit_or<>() ); +auto bit_xor = test2( std::bit_xor<>() ); +auto bit_not = test1( std::bit_not<>() ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc new file mode 100644 index 000000000..262aac454 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/dr660.cc @@ -0,0 +1,41 @@ +// 2007-08-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 <functional> +#include <testsuite_hooks.cc> + +// DR 660. Missing Bitwise Operations. +void test01() +{ + bool test __attribute__((unused)) = true; + + for (int i1 = 0; i1 < 1000; ++i1) + for (int i2 = 0; i2 < 1000; ++i2) + { + VERIFY( std::bit_and<int>()(i1, i2) == (i1 & i2) ); + VERIFY( std::bit_or<int>()(i1, i2) == (i1 | i2) ); + VERIFY( std::bit_xor<int>()(i1, i2) == (i1 ^ i2) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55463.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55463.cc new file mode 100644 index 000000000..9c5dbcb55 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55463.cc @@ -0,0 +1,112 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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/>. + +// PR libstdc++/55463 Passing rvalue objects to std::mem_fn + +#include <functional> + +struct X +{ + int& func(); + char& func_c() const; + short& func_v() volatile; + double& func_cv() const volatile; + + int data; +}; + +struct Y : X { }; + +using CX = const X; +using CY = const Y; + +using X_ptr = X*; + +struct smart_ptr +{ + X& operator*() const; +}; + +std::reference_wrapper<X> ref(); +std::reference_wrapper<const X> cref(); +std::reference_wrapper<Y> yref(); + +void test01() +{ + int& i1 __attribute__((unused)) = std::mem_fn( &X::func )( X() ); + int& i2 __attribute__((unused)) = std::mem_fn( &X::func )( Y() ); + int& i3 __attribute__((unused)) = std::mem_fn( &X::func )( ref() ); + int& i4 __attribute__((unused)) = std::mem_fn( &X::func )( yref() ); + int& i5 __attribute__((unused)) = std::mem_fn( &X::func )( X_ptr() ); + int& i6 __attribute__((unused)) = std::mem_fn( &X::func )( smart_ptr() ); + + char& c1 __attribute__((unused)) = std::mem_fn( &X::func_c )( X() ); + char& c2 __attribute__((unused)) = std::mem_fn( &X::func_c )( CX() ); + char& c3 __attribute__((unused)) = std::mem_fn( &X::func_c )( Y() ); + char& c4 __attribute__((unused)) = std::mem_fn( &X::func_c )( ref() ); + char& c5 __attribute__((unused)) = std::mem_fn( &X::func_c )( cref() ); + char& c6 __attribute__((unused)) = std::mem_fn( &X::func_c )( yref() ); + char& c7 __attribute__((unused)) = std::mem_fn( &X::func_c )( X_ptr() ); + char& c8 __attribute__((unused)) = std::mem_fn( &X::func_c )( smart_ptr() ); + + short& s1 __attribute__((unused)) = std::mem_fn( &X::func_v )( X() ); + short& s2 __attribute__((unused)) = std::mem_fn( &X::func_v )( Y() ); + short& s3 __attribute__((unused)) = std::mem_fn( &X::func_v )( ref() ); + short& s4 __attribute__((unused)) = std::mem_fn( &X::func_v )( yref() ); + short& s5 __attribute__((unused)) = std::mem_fn( &X::func_v )( X_ptr() ); + short& s6 __attribute__((unused)) = std::mem_fn( &X::func_v )( smart_ptr() ); + + double& d1 __attribute__((unused)) = std::mem_fn( &X::func_cv )( X() ); + double& d2 __attribute__((unused)) = std::mem_fn( &X::func_cv )( CX() ); + double& d3 __attribute__((unused)) = std::mem_fn( &X::func_cv )( Y() ); + double& d4 __attribute__((unused)) = std::mem_fn( &X::func_cv )( ref() ); + double& d5 __attribute__((unused)) = std::mem_fn( &X::func_cv )( cref() ); + double& d6 __attribute__((unused)) = std::mem_fn( &X::func_cv )( yref() ); + double& d7 __attribute__((unused)) = std::mem_fn( &X::func_cv )( X_ptr() ); + double& d8 __attribute__((unused)) + = std::mem_fn( &X::func_cv )( smart_ptr() ); + + // [expr.mptr.oper] + // The result of a .* expression whose second operand is a pointer to a + // data member is of the same value category (3.10) as its first operand. + int&& rval __attribute__((unused)) = std::mem_fn( &X::data )( X() ); + const int&& crval __attribute__((unused)) = std::mem_fn( &X::data )( CX() ); + int&& yrval __attribute__((unused)) = std::mem_fn( &X::data )( Y() ); + const int&& ycrval __attribute__((unused)) = std::mem_fn( &X::data )( CY() ); + + int& val __attribute__((unused)) = std::mem_fn( &X::data )( ref() ); + const int& cval __attribute__((unused)) = std::mem_fn( &X::data )( cref() ); + int& yval __attribute__((unused)) = std::mem_fn( &X::data )( yref() ); + + int& pval __attribute__((unused)) = std::mem_fn( &X::data )( X_ptr() ); + int& sval __attribute__((unused)) = std::mem_fn( &X::data )( smart_ptr() ); +} + +void test02() +{ + std::reference_wrapper<X> r = ref(); + X& x1 __attribute__((unused)) + = std::mem_fn( &std::reference_wrapper<X>::get )( r ); + const std::reference_wrapper<X> cr = ref(); + const X& x3 __attribute__((unused)) + = std::mem_fn( &std::reference_wrapper<X>::get )( cr ); + X& x2 __attribute__((unused)) + = std::mem_fn( &std::reference_wrapper<X>::get )( ref() ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55908.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55908.cc new file mode 100644 index 000000000..875c6fa0e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55908.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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/>. + +// PR libstdc++/55908 calling const member function via const pointer + +#include <functional> + +struct foo +{ + void f(int) const { } + + void g() const + { + auto mf = std::mem_fn(&foo::f); + mf(this, 1); + } +}; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/adl.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/adl.cc new file mode 100644 index 000000000..0e2192663 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/adl.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <functional> + +namespace n { + struct X { int i; }; + void mem_fn(int X::*); +} + +using n::X; + +X x{}; +int X::* p = &X::i; + +int test01() +{ + auto ref = std::ref(p); + return ref(x); +} + +int test02() +{ + std::function<int(X)> fun(p); + return fun(x); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/forward.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/forward.cc new file mode 100644 index 000000000..594cf27bb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/function_objects/mem_fn/forward.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 <functional> +#include <testsuite_hooks.h> + +struct Counter +{ + Counter() = default; + Counter(const Counter&) { ++count; } + + static int count; +}; + +int Counter::count = 0; + +struct X +{ + int func(Counter, int i) { return i; } + char func_c(Counter, char c) const { return c; } + short func_v(Counter, short s) volatile { return s; } + double func_cv(Counter, double d) const volatile { return d; } +}; + +void test01() +{ + Counter c; + X x; + + std::mem_fn( &X::func )( x, c, 0 ); + VERIFY( Counter::count == 1 ); + + std::mem_fn( &X::func_c )( x, c, 0 ); + VERIFY( Counter::count == 2 ); + + std::mem_fn( &X::func_v )( x, c, 0 ); + VERIFY( Counter::count == 3 ); + + std::mem_fn( &X::func_cv )( x, c, 0 ); + VERIFY( Counter::count == 4 ); +} + +int main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..c25fecd6c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 has_trivial_copy_assign<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/typedefs.cc new file mode 100644 index 000000000..163f19085 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_copy_assign<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/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/value.cc new file mode 100644 index 000000000..28a0fc3b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_assign/value.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::has_trivial_copy_assign; + using namespace __gnu_test; + + static_assert(test_property<has_trivial_copy_assign, int>(true), ""); + static_assert(test_property<has_trivial_copy_assign, float>(true), ""); + static_assert(test_property<has_trivial_copy_assign, EnumType>(true), ""); + static_assert(test_property<has_trivial_copy_assign, int*>(true), ""); + static_assert(test_property<has_trivial_copy_assign, int(*)(int)>(true), ""); + static_assert(test_property<has_trivial_copy_assign, + int (ClassType::*)>(true), ""); + static_assert(test_property<has_trivial_copy_assign, + int (ClassType::*) (int)>(true), ""); + static_assert(test_property<has_trivial_copy_assign, int[2]>(true), ""); + static_assert(test_property<has_trivial_copy_assign, float[][3]>(true), ""); + static_assert(test_property<has_trivial_copy_assign, + EnumType[2][3][4]>(true), ""); + static_assert(test_property<has_trivial_copy_assign, int*[3]>(true), ""); + static_assert(test_property<has_trivial_copy_assign, + int(*[][2])(int)>(true), ""); + static_assert(test_property<has_trivial_copy_assign, + int (ClassType::*[2][3])>(true), ""); + static_assert(test_property<has_trivial_copy_assign, + int (ClassType::*[][2][3]) (int)>(true), ""); + + // Negative tests. + static_assert(test_property<has_trivial_copy_assign, void>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..ad93ff171 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 has_trivial_copy_constructor<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..03952e0a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_copy_constructor<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/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc new file mode 100644 index 000000000..d0ad79667 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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/>. + +// 4.5.3 Type properties + +#include <type_traits> +#include <testsuite_tr1.h> + +void test01() +{ + using std::has_trivial_copy_constructor; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<has_trivial_copy_constructor, int>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, float>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + EnumType>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, int*>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + int(*)(int)>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + int (ClassType::*)>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + int (ClassType::*) (int)>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, int[2]>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + float[][3]>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + EnumType[2][3][4]>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, int*[3]>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + int(*[][2])(int)>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + int (ClassType::*[2][3])>(true), ""); + static_assert(test_category<has_trivial_copy_constructor, + int (ClassType::*[][2][3]) (int)>(true), ""); + + // Negative tests. + static_assert(test_category<has_trivial_copy_constructor, void>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..e3de36bf9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 has_trivial_default_constructor<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc new file mode 100644 index 000000000..84e49d397 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_default_constructor<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/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc new file mode 100644 index 000000000..3adb7f4d4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2004-12-26 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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/>. + +// 4.5.3 Type properties + +#include <type_traits> +#include <testsuite_tr1.h> + +void test01() +{ + using std::has_trivial_default_constructor; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<has_trivial_default_constructor, int>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + float>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + EnumType>(true), ""); + static_assert(test_category<has_trivial_default_constructor, int*>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int(*)(int)>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int (ClassType::*)>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int (ClassType::*) (int)>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int[2]>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + float[][3]>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + EnumType[2][3][4]>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int*[3]>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int(*[][2])(int)>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int (ClassType::*[2][3])>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + int (ClassType::*[][2][3]) (int)>(true), ""); + static_assert(test_category<has_trivial_default_constructor, + ClassType>(true), ""); + + // Negative tests. + static_assert(test_category<has_trivial_default_constructor, + void>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..5edbbd0a4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 has_virtual_destructor<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/requirements/typedefs.cc new file mode 100644 index 000000000..b00698ba9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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::has_virtual_destructor<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/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/value.cc new file mode 100644 index 000000000..15c0eb2f8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/has_virtual_destructor/value.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 <iostream> +#include <testsuite_tr1.h> + +void test01() +{ + using std::has_virtual_destructor; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<has_virtual_destructor, + VirtualDestructorClass>(true), ""); + static_assert(test_category<has_virtual_destructor, std::iostream>(true), ""); + static_assert(test_category<has_virtual_destructor, + std::streambuf>(true), ""); + + // Negative tests. + static_assert(test_category<has_virtual_destructor, + PolymorphicClass>(false), ""); + static_assert(test_category<has_virtual_destructor, + DerivedPolymorphic>(false), ""); + static_assert(test_category<has_virtual_destructor, + AbstractClass>(false), ""); + static_assert(test_category<has_virtual_destructor, void>(false), ""); + static_assert(test_category<has_virtual_destructor, int (int)>(false), ""); + static_assert(test_category<has_virtual_destructor, int&>(false), ""); + static_assert(test_category<has_virtual_destructor, EnumType>(false), ""); + static_assert(test_category<has_virtual_destructor, ClassType>(false), ""); + static_assert(test_category<has_virtual_destructor, DerivedType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/52931.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/52931.cc new file mode 100644 index 000000000..e1357a6c7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/52931.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <functional> + +class S{}; // No hash specialization + +template<class T> +auto f(int) -> decltype(std::hash<T>(), std::true_type()); + +template<class T> +auto f(...) -> decltype(std::false_type()); + +static_assert(!decltype(f<S>(0))::value, ""); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_bit_flip_set.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_bit_flip_set.cc new file mode 100644 index 000000000..600dd730d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_bit_flip_set.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// Use smaller statistics when running on simulators, so it takes less time. +// { dg-options "-std=gnu++0x -DSAMPLES=30000" { target simulator } } + +// Copyright (C) 2010-2014 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 "chi2_quality.h" + +// Tests chi^2 for a distribution of strings that differ from each +// other by only a few bits. We start with an arbitrary base string, and +// flip three random bits for each member of the set. +void +test_bit_flip_set() +{ + bool test __attribute__((unused)) = true; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + const unsigned int len = 67; + const unsigned int bitlen = len * 8; + const unsigned int bits_to_flip = 3; + const char base[len+1] = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789!@#$%"; + + std::unordered_set<std::string> set; + while (set.size() < N) + { + std::string s(base, base+len); + for (unsigned int i = 0; i < bits_to_flip; ++i) + { + int bit = rand() % bitlen; + s[bit/8] ^= (1 << (bit%8)); + } + set.insert(s); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +int +main() +{ + test_bit_flip_set(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_bit_string_set.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_bit_string_set.cc new file mode 100644 index 000000000..eb9237f1f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_bit_string_set.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } +// Use smaller statistics when running on simulators, so it takes less time. +// For e.g. cris-elf, mipsisa32r2el-elf, powerpc-eabi and i386-linux-gnu, +// this test fails for SAMPLES=30000. +// { dg-options "-std=gnu++0x -DSAMPLES=35000" { target simulator } } + +// Copyright (C) 2010-2014 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 "chi2_quality.h" + +// Tests chi^2 for a set of strings that all consist of '1' and '0'. +void +test_bit_string_set() +{ + bool test __attribute__((unused)) = true; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + std::vector<std::string> set; + std::string s; + for (unsigned long i = 0; i < N; ++i) + { + s.clear(); + for (unsigned int j = 0; j < sizeof(unsigned long) * 8; ++j) + { + const bool bit = (1UL << j) & i; + s.push_back(bit ? '1' : '0'); + } + set.push_back(s); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +int +main() +{ + test_bit_string_set(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc new file mode 100644 index 000000000..384c724d0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc @@ -0,0 +1,52 @@ +// On some simulators, the workload is simply too large with values big +// enough for the test to pass the quality test, so just skip it altogether. +// { dg-do run { target { ! simulator } } } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 "chi2_quality.h" + +// Tests chi^2 for a set of words taken from a document written in English. +void +test_document_words() +{ + bool test __attribute__((unused)) = true; + const std::string f_name = "thirty_years_among_the_dead_preproc.txt"; + std::ifstream in(f_name); + VERIFY( in.is_open() ); + std::vector<std::string> words; + words.assign(std::istream_iterator<std::string>(in), + std::istream_iterator<std::string>()); + VERIFY( words.size() > 100000 ); + std::sort(words.begin(), words.end()); + auto it = std::unique(words.begin(), words.end()); + words.erase(it, words.end()); + VERIFY( words.size() > 5000 ); + + const unsigned long k = words.size() / 20; + double chi2 = chi2_hash(words, k); + VERIFY( chi2 < k*1.1 ); +} + +int +main() +{ + test_document_words(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_numeric_pattern_set.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_numeric_pattern_set.cc new file mode 100644 index 000000000..1840641d0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_numeric_pattern_set.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// Use smaller statistics when running on simulators, so it takes less time. +// For x86_64-linux-gnu SAMPLES=30000 fails, so increase slightly. +// { dg-options "-std=gnu++0x -DSAMPLES=35000" { target simulator } } + +// Copyright (C) 2010-2014 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 "chi2_quality.h" + +// Tests chi^2 of a set of strings that all have a similar pattern, +// intended to mimic some sort of ID string. +void +test_numeric_pattern_set() +{ + bool test __attribute__((unused)) = true; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + std::vector<std::string> set; + for (unsigned long i = 0; i < N; ++i) + { + long i1 = i % 100000; + long i2 = i / 100000; + char buf[16]; + std::sprintf(buf, "XX-%05lu-%05lu", i1, i2); + set.push_back(buf); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +int +main() +{ + test_numeric_pattern_set(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_uniform_random.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_uniform_random.cc new file mode 100644 index 000000000..5006afa6e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_q_uniform_random.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } +// Use smaller statistics when running on simulators, so it takes less time. +// For powerpc-eabi, SAMPLES=30000 fails. +// { dg-options "-std=gnu++0x -DSAMPLES=35000" { target simulator } } + +// Copyright (C) 2010-2014 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 "chi2_quality.h" + +// Tests chi^2 for a distribution of uniformly generated random strings. +void +test_uniform_random() +{ + bool test __attribute__((unused)) = true; + std::srand(137); + std::unordered_set<std::string> set; + std::string s; + const unsigned long N = SAMPLES; + const unsigned long k = N/100; + const unsigned int len = 25; + while (set.size() < N) + { + s.clear(); + for (unsigned int i = 0; i < len; ++i) + s.push_back(rand() % 128); + set.insert(s); + } + + double chi2 = chi2_hash(set, k); + VERIFY( chi2 < k*1.1 ); +} + +int +main() +{ + test_uniform_random(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_quality.h b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_quality.h new file mode 100644 index 000000000..58bd23b0d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/chi2_quality.h @@ -0,0 +1,74 @@ +// Copyright (C) 2010-2014 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/>. + +// This file uses the chi^2 test to measure the quality of a hash +// function, by computing the uniformity with which it distributes a set +// of N strings into k buckets (where k is significantly greater than N). +// +// Each bucket has B[i] strings in it. The expected value of each bucket +// for a uniform distribution is z = N/k, so +// chi^2 = Sum_i (B[i] - z)^2 / z. +// +// We check whether chi^2 is small enough to be consistent with the +// hypothesis of a uniform distribution. If F(chi^2, k-1) is close to +// 0 (where F is the cumulative probability distribution), we can +// reject that hypothesis. So we don't want F to be too small, which +// for large k, means we want chi^2 to be not too much larger than k. +// +// We use the chi^2 test for several sets of strings. Any non-horrible +// hash function should do well with purely random strings. A really +// good hash function will also do well with more structured sets, +// including ones where the strings differ by only a few bits. + +#include <algorithm> +#include <cstdlib> +#include <cstdio> +#include <fstream> +#include <functional> +#include <iostream> +#include <iterator> +#include <string> +#include <unordered_set> +#include <vector> +#include <testsuite_hooks.h> + +#ifndef SAMPLES +#define SAMPLES 300000 +#endif + +template <typename Container> + double + chi2_hash(const Container& c, long buckets) + { + std::vector<int> counts(buckets); + std::hash<std::string> hasher; + double elements = 0; + for (auto i = c.begin(); i != c.end(); ++i) + { + ++counts[hasher(*i) % buckets]; + ++elements; + } + + const double z = elements / buckets; + double sum = 0; + for (long i = 0; i < buckets; ++i) + { + double delta = counts[i] - z; + sum += delta*delta; + } + return sum/z; + } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc new file mode 100644 index 000000000..5033514d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2007-08-20 <benjamin@redhat.com> +// +// Copyright (C) 2007-2014 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 <functional> +#include <system_error> +#include <testsuite_hooks.h> + +template<typename T> + void + do_test() + { + bool test __attribute__((unused)) = true; + + typedef T value_type; + typedef std::hash<value_type> hash_type; + using std::size_t; + + value_type v; // default initialized is fine, same value all that matters. + hash_type h1; + size_t r1 = size_t(h1(v)); + + hash_type h2; + size_t r2 = size_t(h2(v)); + + VERIFY( r1 == r2 ); + } + +void test01() +{ + do_test<std::error_code>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/quality.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/quality.cc new file mode 100644 index 000000000..a3c064ba8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/quality.cc @@ -0,0 +1,172 @@ +// { dg-options "-std=gnu++0x" } +// { dg-options "-DNTESTS=1 -DNSTRINGS=100 -DSTRSIZE=21 -std=gnu++0x" { target simulator } } + +// Copyright (C) 2010-2014 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 <cstdlib> +#include <unordered_set> +#include <string> +#include <functional> +#include <vector> +#include <testsuite_hooks.h> + +using namespace std; + +#ifndef NTESTS +#define NTESTS 5 +#endif +#ifndef NSTRINGS +#define NSTRINGS 200 +#endif +#ifndef STRSIZE +#define STRSIZE 42 +#endif + +const unsigned int num_quality_tests = NTESTS; +const unsigned int num_strings_for_quality_tests = NSTRINGS; +const unsigned int string_size = STRSIZE; + +vector<string> +random_strings(unsigned int n, unsigned int len) +{ + string s(len, '\0'); + unordered_set<string> result_set; + while (result_set.size() < n) + { + result_set.insert(s); + unsigned int tmp = rand(); + tmp %= len * 256; + s[tmp / 256] = tmp % 256; + } + return vector<string>(result_set.begin(), result_set.end()); +} + +double +score_from_varying_position(string s, unsigned int index) +{ + bool test __attribute__((unused)) = true; + unsigned int bits_in_hash_code = sizeof(size_t) * 8; + + // We'll iterate through all 256 vals for s[index], leaving the rest + // of s fixed. Then, for example, out of the 128 times that + // s[index] has its 3rd bit equal to 0 we would like roughly half 1s + // and half 0s in bit 9 of the hash codes. + // + // Bookkeeping: Conceptually we want a 3D array of ints. We want to + // count the number of times each output position (of which there are + // bits_in_hash_code) is 1 for each bit position within s[index] (of + // which there are 8) and value of that bit (of which there are 2). + const unsigned int jj = 2; + const unsigned int kk = jj * bits_in_hash_code; + const unsigned int array_size = 8 * kk; + vector<int> ones(array_size, 0); + + for (int i = 0; i < 256; i++) + { + s[index] = i; + size_t h = hash<string>()(s); + for (int j = 0; h != 0; j++, h >>= 1) + { + if (h & 1) + { + for (int k = 0; k < 8; k++) + ++ones[k * kk + j * jj + ((i >> k) & 1)]; + } + } + } + + // At most, the innermost statement in the above loop nest can + // execute 256 * bits_in_hash_code * 8 times. If the hash is good, + // it'll execute about half that many times, with a pretty even + // spread across the elements of ones[]. + VERIFY( 256 * bits_in_hash_code * 8 / array_size == 128 ); + int max_ones_possible = 128; + int good = 0, bad = 0; + for (int bit = 0; bit <= 1; bit++) + { + for (unsigned int j = 0; j < bits_in_hash_code; j++) + { + for (int bitpos = 0; bitpos < 8; bitpos++) + { + int z = ones[bitpos * kk + j * jj + bit]; + if (z <= max_ones_possible / 6 + || z >= max_ones_possible * 5 / 6) + { + // The hash function screwed up, or was just unlucky, + // as 128 flips of a perfect coin occasionally yield + // far from 64 heads. + bad++; + } + else + good++; + } + } + } + return good / (double)(good + bad); +} + +double +score_from_varying_position(const vector<string>& v, unsigned int index) +{ + double score = 0; + for (unsigned int i = 0; i < v.size(); i++) + score += score_from_varying_position(v[i], index); + return score / v.size(); +} + +double +quality_test(unsigned int num_strings, unsigned int string_size) +{ + // Construct random strings. + vector<string> v = random_strings(num_strings, string_size); + double sum_of_scores = 0; + for (unsigned int i = 0; i < string_size; i++) + sum_of_scores += score_from_varying_position(v, i); + + // A good hash function should have a score very close to 1, and a bad + // hash function will have a score close to 0. + return sum_of_scores / string_size; +} + +void +quality_test() +{ + bool test __attribute__((unused)) = true; + srand(137); + double sum_of_scores = 0; + for (unsigned int i = 0; i < num_quality_tests; i++) + { + double score = quality_test(num_strings_for_quality_tests, + string_size); + sum_of_scores += score; + VERIFY( score > 0.99 ); + } + + if (num_quality_tests > 1) + { + double mean_quality = sum_of_scores / num_quality_tests; + VERIFY( mean_quality > 0.9999 ); + } +} + +int +main() +{ + quality_test(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..3026fc312 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <functional> +#include <string> +#include <system_error> + +// Verify that we can instantiate hash for every required type. +template class std::hash<bool>; +template class std::hash<char>; +template class std::hash<signed char>; +template class std::hash<unsigned char>; +template class std::hash<char16_t>; +template class std::hash<char32_t>; +template class std::hash<short>; +template class std::hash<int>; +template class std::hash<long>; +template class std::hash<unsigned short>; +template class std::hash<unsigned int>; +template class std::hash<unsigned long>; +template class std::hash<float>; +template class std::hash<double>; +template class std::hash<long double>; +template class std::hash<void*>; +template class std::hash<std::string>; +template class std::hash<std::error_code>; + +#ifdef _GLIBCXX_USE_WCHAR_T +template class std::hash<wchar_t>; +template class std::hash<std::wstring>; +#endif + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc new file mode 100644 index 000000000..db9d781f4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstdlib/functions_std.cc @@ -0,0 +1,28 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <cstdlib> + +namespace gnu +{ + using std::calloc; + using std::malloc; + using std::free; + using std::realloc; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc new file mode 100644 index 000000000..bad8f761d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/functions_std.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <cstring> + +namespace gnu +{ + using std::memchr; + using std::memcmp; + using std::memcpy; + using std::memmove; + using std::memset; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc new file mode 100644 index 000000000..fd5042ad0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <cstring> + +namespace gnu +{ +#ifndef NULL + #error "NULL_must_be_a_macro" +#endif +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc new file mode 100644 index 000000000..3cdeb6156 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/cstring/types_std.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <cstring> + +namespace gnu +{ + std::size_t s; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc new file mode 100644 index 000000000..1ee062397 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/functions_std.cc @@ -0,0 +1,33 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <ctime> + +namespace gnu +{ + using std::asctime; + using std::clock; + using std::difftime; + using std::localtime; + using std::strftime; + using std::ctime; + using std::gmtime; + using std::mktime; + using std::time; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc new file mode 100644 index 000000000..27457f5af --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/macros.cc @@ -0,0 +1,27 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <ctime> + +namespace gnu +{ +#ifndef NULL + #error "NULL_must_be_a_macro" +#endif +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc new file mode 100644 index 000000000..9a5abcfed --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/ctime/types_std.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <ctime> + +namespace gnu +{ + std::size_t s; + std::clock_t c; + std::time_t t; + + std::tm t2; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc new file mode 100644 index 000000000..1763eacb3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/synopsis.cc @@ -0,0 +1,100 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <functional> + +namespace std { + // lib.base, base: + template <class Arg, class Result> struct unary_function; + template <class Arg1, class Arg2, class Result> struct binary_function; + + // lib.arithmetic.operations, arithmetic operations: + template <class T> struct plus; + template <class T> struct minus; + template <class T> struct multiplies; + template <class T> struct divides; + template <class T> struct modulus; + template <class T> struct negate; + + // lib.comparisons, comparisons: + template <class T> struct equal_to; + template <class T> struct not_equal_to; + template <class T> struct greater; + template <class T> struct less; + template <class T> struct greater_equal; + template <class T> struct less_equal; + + // lib.logical.operations, logical operations: + template <class T> struct logical_and; + template <class T> struct logical_or; + template <class T> struct logical_not; + + // lib.negators, negators: + template <class Predicate> struct unary_negate; + template <class Predicate> + unary_negate<Predicate> not1(const Predicate&); + template <class Predicate> struct binary_negate; + template <class Predicate> + binary_negate<Predicate> not2(const Predicate&); + + // lib.binders, binders: + template <class Operation> class binder1st; + template <class Operation, class T> + binder1st<Operation> bind1st(const Operation&, const T&); + template <class Operation> class binder2nd; + template <class Operation, class T> + binder2nd<Operation> bind2nd(const Operation&, const T&); + + // lib.function.pointer.adaptors, adaptors: + template <class Arg, class Result> class pointer_to_unary_function; + template <class Arg, class Result> + pointer_to_unary_function<Arg,Result> ptr_fun(Result (*)(Arg)); + template <class Arg1, class Arg2, class Result> + class pointer_to_binary_function; + template <class Arg1, class Arg2, class Result> + pointer_to_binary_function<Arg1,Arg2,Result> + ptr_fun(Result (*)(Arg1,Arg2)); + + // lib.member.pointer.adaptors, adaptors: + template<class S, class T> class mem_fun_t; + template<class S, class T, class A> class mem_fun1_t; + template<class S, class T> + mem_fun_t<S,T> mem_fun(S (T::*f)()); + template<class S, class T, class A> + mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A)); + template<class S, class T> class mem_fun_ref_t; + template<class S, class T, class A> class mem_fun1_ref_t; + template<class S, class T> + mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); + template<class S, class T, class A> + mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A)); + + template <class S, class T> class const_mem_fun_t; + template <class S, class T, class A> class const_mem_fun1_t; + template <class S, class T> + const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); + template <class S, class T, class A> + const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const); + template <class S, class T> class const_mem_fun_ref_t; + template <class S, class T, class A> class const_mem_fun1_ref_t; + template <class S, class T> + const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); + template <class S, class T, class A> + const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc new file mode 100644 index 000000000..c4949ea02 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/types_std_c++0x.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <functional> + +namespace gnu +{ + using std::bad_function_call; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc new file mode 100644 index 000000000..5c51916b9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/functional/using_namespace_std_placeholders.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <functional> + +namespace gnu +{ + using namespace std::placeholders; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc new file mode 100644 index 000000000..8299ea64e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc @@ -0,0 +1,53 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <memory> + +namespace std { + // lib.default.allocator, the default allocator: + template <class T> class allocator; + template <> class allocator<void>; + template <class T, class U> + bool operator==(const allocator<T>&, const allocator<U>&) throw(); + template <class T, class U> + bool operator!=(const allocator<T>&, const allocator<U>&) throw(); + + // lib.storage.iterator, raw storage iterator: + template <class OutputIterator, class T> class raw_storage_iterator; + + // lib.temporary.buffer, temporary buffers: + template <class T> + pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n); + template <class T> + void return_temporary_buffer(T* p); + + // lib.specialized.algorithms, specialized algorithms: + template <class InputIterator, class ForwardIterator> + ForwardIterator + uninitialized_copy(InputIterator first, InputIterator last, + ForwardIterator result); + template <class ForwardIterator, class T> + void uninitialized_fill(ForwardIterator first, ForwardIterator last, + const T& x); + template <class ForwardIterator, class Size, class T> + void uninitialized_fill_n(ForwardIterator first, Size n, const T& x); + + // lib.auto.ptr, pointers: + template<class X> class auto_ptr; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc new file mode 100644 index 000000000..75444856f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/memory/types_std_c++0x.cc @@ -0,0 +1,26 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <memory> + +namespace gnu +{ + using std::bad_weak_ptr; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc new file mode 100644 index 000000000..da3cb9753 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// Copyright (C) 2007-2014 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> + +// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 } + + + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc new file mode 100644 index 000000000..fa19d10df --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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> + +namespace gnu +{ + using std::true_type; + using std::false_type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc new file mode 100644 index 000000000..0537380d7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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> + +namespace gnu +{ + // C++0x changes from TR1. + using std::has_trivial_constructor; + using std::has_nothrow_constructor; + using std::has_trivial_copy; + using std::has_nothrow_copy; +} + +// { dg-error "has not been declared" "" { target *-*-* } 26 } +// { dg-error "has not been declared" "" { target *-*-* } 27 } +// { dg-error "has not been declared" "" { target *-*-* } 28 } +// { dg-error "has not been declared" "" { target *-*-* } 29 } + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc new file mode 100644 index 000000000..ffd10a1f6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc @@ -0,0 +1,45 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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> + +namespace std { + // lib.operators, operators: + namespace rel_ops { + template<class T> bool operator!=(const T&, const T&); + template<class T> bool operator> (const T&, const T&); + template<class T> bool operator<=(const T&, const T&); + template<class T> bool operator>=(const T&, const T&); + } + + // lib.pairs, pairs: + template <class T1, class T2> struct pair; + template <class T1, class T2> + _GLIBCXX_CONSTEXPR bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + _GLIBCXX_CONSTEXPR bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + _GLIBCXX_CONSTEXPR bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + _GLIBCXX_CONSTEXPR bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + _GLIBCXX_CONSTEXPR bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); + template <class T1, class T2> + _GLIBCXX_CONSTEXPR bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc new file mode 100644 index 000000000..971c315e9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/headers/utility/using_namespace_std_rel_ops.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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> + +namespace gnu +{ + using namespace std::rel_ops; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integer_sequence/intseq.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integer_sequence/intseq.cc new file mode 100644 index 000000000..270f32597 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integer_sequence/intseq.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } +// +// Copyright (C) 2013-2014 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 <utility> + +using std::integer_sequence; + +static_assert( integer_sequence<int>::size() == 0, "size() == 0" ); +static_assert( integer_sequence<int, 0, 1, 2>::size() == 3, "size() == 3" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integer_sequence/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integer_sequence/requirements/typedefs.cc new file mode 100644 index 000000000..00b1962af --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integer_sequence/requirements/typedefs.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } +// +// Copyright (C) 2013-2014 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> +#include <type_traits> + +using std::is_same; +using std::integer_sequence; +using std::make_integer_sequence; +using std::index_sequence; +using std::make_index_sequence; +using std::index_sequence_for; + +static_assert( is_same<integer_sequence<int>::value_type, int>::value, + "int value_type"); + +static_assert( is_same<integer_sequence<short>::value_type, short>::value, + "short value_type"); + +static_assert( is_same<make_integer_sequence<int, 0>, + integer_sequence<int>>::value, + "make empty int seq" ); + +static_assert( is_same<make_integer_sequence<int, 2>, + integer_sequence<int, 0, 1>>::value, + "make non-empty int seq" ); + +static_assert( is_same<make_integer_sequence<unsigned, 0>, + integer_sequence<unsigned>>::value, + "make empty unsigned seq" ); + +static_assert( is_same<make_integer_sequence<unsigned, 2>, + integer_sequence<unsigned, 0, 1>>::value, + "make non-empty unsigned seq" ); + +static_assert( is_same<index_sequence<0, 1>, + integer_sequence<std::size_t, 0, 1>>::value, + "index seq" ); + +static_assert( is_same<make_index_sequence<2>, index_sequence<0, 1>>::value, + "make index seq" ); + +static_assert( is_same<index_sequence_for<char, int, void, double>, + index_sequence<0, 1, 2, 3>>::value, + "index_sequence_for" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/call_operator.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/call_operator.cc new file mode 100644 index 000000000..ff0881794 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/call_operator.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } +// +// Copyright (C) 2013-2014 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 <cassert> //testsuite_hooks.h> + +typedef std::integral_constant<int, 1> ic_one; +typedef std::integral_constant<int, 0> ic_zero; +typedef std::integral_constant<int, -1> ic_minus_one; + +typedef std::integral_constant<bool, true> ic_true; +typedef std::integral_constant<bool, false> ic_false; + +static_assert( ic_one{}() == 1, "1" ); +static_assert( ic_zero{}() == 0, "0" ); +static_assert( ic_minus_one{}() == -1, "-1" ); + +static_assert( ic_true{}() == true, "true" ); +static_assert( ic_false{}() == false, "false" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/operator_value_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/operator_value_type.cc new file mode 100644 index 000000000..2f9820894 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/operator_value_type.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013-2014 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 <cassert> //testsuite_hooks.h> + +typedef std::integral_constant<int, 1> ic_one; +typedef std::integral_constant<int, 0> ic_zero; +typedef std::integral_constant<int, -1> ic_minus_one; + +typedef std::integral_constant<bool, true> ic_true; +typedef std::integral_constant<bool, false> ic_false; + +static_assert( ic_one() == 1, "" ); +static_assert( ic_zero() == 0, "" ); +static_assert( ic_minus_one() == -1, "" ); + +static_assert( ic_true() == true, "" ); +static_assert( ic_false() == false, "" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/constexpr_data.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/constexpr_data.cc new file mode 100644 index 000000000..c581baf50 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/constexpr_data.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v __attribute__((unused)) (_Ttesttype::value); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + test.operator()<std::integral_constant<unsigned short, 69>>(); + test.operator()<std::integral_constant<bool, true>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..142bf7a57 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 integral_constant<test_type, -3>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/typedefs.cc new file mode 100644 index 000000000..818f35165 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::integral_constant<int, 1> 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/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/static_definition.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/static_definition.cc new file mode 100644 index 000000000..d90cea8c8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/static_definition.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013-2014 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> + +void test01() +{ + bool test __attribute__((unused)) = true; + const bool* p = &std::integral_constant<bool, true>::value; + VERIFY( p ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/true_false_type_typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/true_false_type_typedefs.cc new file mode 100644 index 000000000..0b9ad1d8f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/true_false_type_typedefs.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::true_type true_type; + typedef std::false_type false_type; + + typedef true_type::value_type true_value_type; + typedef true_type::type true_type; + typedef true_type::type::value_type true_type_value_type; + typedef true_type::type::type true_type_type; + + typedef false_type::value_type false_value_type; + typedef false_type::type false_type; + typedef false_type::type::value_type false_type_value_type; + typedef false_type::type::type false_type_type; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/true_false_value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/true_false_value.cc new file mode 100644 index 000000000..c03cff80d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/integral_constant/true_false_value.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013-2014 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> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::true_type; + using std::false_type; + + static_assert( true_type::value == true, "" ); + static_assert( false_type::value == false, "" ); + static_assert( true_type::type::value == true, "" ); + static_assert( false_type::type::value == false, "" ); + + VERIFY( true_type::value == true ); + VERIFY( false_type::value == false ); + VERIFY( true_type::type::value == true ); + VERIFY( false_type::type::value == false ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..124ca8c1d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_abstract<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/requirements/typedefs.cc new file mode 100644 index 000000000..d251ad83b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_abstract<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/value.cc new file mode 100644 index 000000000..05425efcf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_abstract/value.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_abstract; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_abstract, AbstractClass>(true), ""); + + // Negative tests. + static_assert(test_category<is_abstract, void>(false), ""); + static_assert(test_category<is_abstract, int (int)>(false), ""); + static_assert(test_category<is_abstract, int&>(false), ""); + + // Sanity check. + static_assert(test_category<is_abstract, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d50ced9c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_arithmetic<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/requirements/typedefs.cc new file mode 100644 index 000000000..9f336671b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_arithmetic<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/value.cc new file mode 100644 index 000000000..47c708cb3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_arithmetic/value.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_arithmetic; + using namespace __gnu_test; + + static_assert(test_category<is_arithmetic, void>(false), ""); + + static_assert(test_category<is_arithmetic, char>(true), ""); + static_assert(test_category<is_arithmetic, signed char>(true), ""); + static_assert(test_category<is_arithmetic, unsigned char>(true), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_arithmetic, wchar_t>(true), ""); +#endif + static_assert(test_category<is_arithmetic, short>(true), ""); + static_assert(test_category<is_arithmetic, unsigned short>(true), ""); + static_assert(test_category<is_arithmetic, int>(true), ""); + static_assert(test_category<is_arithmetic, unsigned int>(true), ""); + static_assert(test_category<is_arithmetic, long>(true), ""); + static_assert(test_category<is_arithmetic, unsigned long>(true), ""); + static_assert(test_category<is_arithmetic, long long>(true), ""); + static_assert(test_category<is_arithmetic, unsigned long long>(true), ""); + static_assert(test_category<is_arithmetic, float>(true), ""); + static_assert(test_category<is_arithmetic, double>(true), ""); + static_assert(test_category<is_arithmetic, long double>(true), ""); + + // Sanity check. + static_assert(test_category<is_arithmetic, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..43639b8c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_array<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/requirements/typedefs.cc new file mode 100644 index 000000000..bb847d325 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_array<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/value.cc new file mode 100644 index 000000000..c056a8e7c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_array/value.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_array; + using namespace __gnu_test; + + static_assert(test_category<is_array, int[2]>(true), ""); + static_assert(test_category<is_array, int[]>(true), ""); + static_assert(test_category<is_array, int[2][3]>(true), ""); + static_assert(test_category<is_array, int[][3]>(true), ""); + static_assert(test_category<is_array, float*[2]>(true), ""); + static_assert(test_category<is_array, float*[]>(true), ""); + static_assert(test_category<is_array, float*[2][3]>(true), ""); + static_assert(test_category<is_array, float*[][3]>(true), ""); + static_assert(test_category<is_array, ClassType[2]>(true), ""); + static_assert(test_category<is_array, ClassType[]>(true), ""); + static_assert(test_category<is_array, ClassType[2][3]>(true), ""); + static_assert(test_category<is_array, ClassType[][3]>(true), ""); + + // Sanity check. + static_assert(test_category<is_array, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..0c9357f7d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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_assignable<test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/requirements/typedefs.cc new file mode 100644 index 000000000..1edd4adb6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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_assignable<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/value.cc new file mode 100644 index 000000000..ddd73b48b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_assignable/value.cc @@ -0,0 +1,677 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <initializer_list> +#include <testsuite_tr1.h> + +using namespace __gnu_test::assign; + +static_assert(std::is_assignable<int&, int>::value, "Error"); +static_assert(std::is_assignable<int&, const int>::value, "Error"); +static_assert(std::is_assignable<int&, int&>::value, "Error"); +static_assert(std::is_assignable<int&, const int&>::value, "Error"); + +static_assert(!std::is_assignable<int, int>::value, "Error"); +static_assert(!std::is_assignable<int, const int>::value, "Error"); +static_assert(!std::is_assignable<int, int&>::value, "Error"); +static_assert(!std::is_assignable<int, const int&>::value, "Error"); + +static_assert(!std::is_assignable<const int, int>::value, "Error"); +static_assert(!std::is_assignable<const int, const int>::value, "Error"); +static_assert(!std::is_assignable<const int, int&>::value, "Error"); +static_assert(!std::is_assignable<const int, const int&>::value, "Error"); + +static_assert(!std::is_assignable<const int&, int>::value, "Error"); +static_assert(!std::is_assignable<const int&, const int>::value, "Error"); +static_assert(!std::is_assignable<const int&, int&>::value, "Error"); +static_assert(!std::is_assignable<const int&, const int&>::value, "Error"); + +static_assert(std::is_assignable<Empty&, Empty>::value, "Error"); +static_assert(std::is_assignable<Empty&, const Empty>::value, "Error"); +static_assert(std::is_assignable<Empty&, Empty&>::value, "Error"); +static_assert(std::is_assignable<Empty&, const Empty&>::value, "Error"); +static_assert(std::is_assignable<Empty, Empty>::value, "Error"); +static_assert(std::is_assignable<Empty, const Empty>::value, "Error"); +static_assert(std::is_assignable<Empty, Empty&>::value, "Error"); +static_assert(std::is_assignable<Empty, const Empty&>::value, "Error"); + +static_assert(std::is_assignable<B&, B>::value, "Error"); +static_assert(std::is_assignable<B&, const B>::value, "Error"); +static_assert(std::is_assignable<B&, B&>::value, "Error"); +static_assert(std::is_assignable<B&, const B&>::value, "Error"); +static_assert(std::is_assignable<B, B>::value, "Error"); +static_assert(std::is_assignable<B, const B>::value, "Error"); +static_assert(std::is_assignable<B, B&>::value, "Error"); +static_assert(std::is_assignable<B, const B&>::value, "Error"); + +static_assert(std::is_assignable<bool&, bool>::value, "Error"); +static_assert(std::is_assignable<bool&, const bool>::value, "Error"); +static_assert(std::is_assignable<bool&, bool&>::value, "Error"); +static_assert(std::is_assignable<bool&, const bool&>::value, "Error"); + +// bool is a fundamental type that does not allow assignment to an rvalue: +static_assert(!std::is_assignable<bool, bool>::value, "Error"); +static_assert(!std::is_assignable<bool, const bool>::value, "Error"); +static_assert(!std::is_assignable<bool, bool&>::value, "Error"); +static_assert(!std::is_assignable<bool, const bool&>::value, "Error"); + +static_assert(std::is_assignable<std::nullptr_t&, +std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<std::nullptr_t&, const +std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<std::nullptr_t&, +std::nullptr_t&>::value, "Error"); +static_assert(std::is_assignable<std::nullptr_t&, const +std::nullptr_t&>::value, "Error"); + +// std::nullptr_t is a fundamental type that does not allow +// assignment to an rvalue: +static_assert(!std::is_assignable<std::nullptr_t, +std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t, const +std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t, +std::nullptr_t&>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t, const +std::nullptr_t&>::value, "Error"); + +static_assert(std::is_assignable<E&, E>::value, "Error"); +static_assert(std::is_assignable<E&, const E>::value, "Error"); +static_assert(std::is_assignable<E&, E&>::value, "Error"); +static_assert(std::is_assignable<E&, const E&>::value, "Error"); + +static_assert(std::is_assignable<int&, E>::value, "Error"); +static_assert(std::is_assignable<int&, const E>::value, "Error"); +static_assert(std::is_assignable<int&, E&>::value, "Error"); +static_assert(std::is_assignable<int&, const E&>::value, "Error"); + +static_assert(!std::is_assignable<E&, int>::value, "Error"); +static_assert(!std::is_assignable<E&, const int>::value, "Error"); +static_assert(!std::is_assignable<E&, int&>::value, "Error"); +static_assert(!std::is_assignable<E&, const int&>::value, "Error"); + +static_assert(!std::is_assignable<E&, E2>::value, "Error"); +static_assert(!std::is_assignable<E&, const E2>::value, "Error"); +static_assert(!std::is_assignable<E&, E2&>::value, "Error"); +static_assert(!std::is_assignable<E&, const E2&>::value, "Error"); + +// E is not a class type and thus does not allow assignment to an rvalue: +static_assert(!std::is_assignable<E, E>::value, "Error"); +static_assert(!std::is_assignable<E, const E>::value, "Error"); +static_assert(!std::is_assignable<E, E&>::value, "Error"); +static_assert(!std::is_assignable<E, const E&>::value, "Error"); + +static_assert(std::is_assignable<SE&, SE>::value, "Error"); +static_assert(std::is_assignable<SE&, const SE>::value, "Error"); +static_assert(std::is_assignable<SE&, SE&>::value, "Error"); +static_assert(std::is_assignable<SE&, const SE&>::value, "Error"); + +static_assert(!std::is_assignable<int&, SE>::value, "Error"); +static_assert(!std::is_assignable<int&, const SE>::value, "Error"); +static_assert(!std::is_assignable<int&, SE&>::value, "Error"); +static_assert(!std::is_assignable<int&, const SE&>::value, "Error"); + +static_assert(!std::is_assignable<SE&, int>::value, "Error"); +static_assert(!std::is_assignable<SE&, const int>::value, "Error"); +static_assert(!std::is_assignable<SE&, int&>::value, "Error"); +static_assert(!std::is_assignable<SE&, const int&>::value, "Error"); + +// SE is not a class type and thus does not allow assignment to an rvalue: +static_assert(!std::is_assignable<SE, SE>::value, "Error"); +static_assert(!std::is_assignable<SE, const SE>::value, "Error"); +static_assert(!std::is_assignable<SE, SE&>::value, "Error"); +static_assert(!std::is_assignable<SE, const SE&>::value, "Error"); + +static_assert(std::is_assignable<AnyAssign&, int>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, E>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, SE>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, Empty>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, U>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, int&>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, std::nullptr_t&>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, E&>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, SE&>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, Empty&>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, U&>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, AnyAssign>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, +std::initializer_list<int>>::value, "Error"); + +static_assert(std::is_assignable<AnyAssign&, int[1]>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, +std::nullptr_t[1]>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, E[1]>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, SE[1]>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, int(&)[1]>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, +std::nullptr_t(&)[1]>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, E(&)[1]>::value, "Error"); +static_assert(std::is_assignable<AnyAssign&, SE(&)[1]>::value, "Error"); + +static_assert(std::is_assignable<int&, E>::value, "Error"); +static_assert(!std::is_assignable<int&, SE>::value, "Error"); +static_assert(std::is_assignable<bool&, E>::value, "Error"); +static_assert(!std::is_assignable<bool&, SE>::value, "Error"); +static_assert(std::is_assignable<bool&, void*>::value, "Error"); +static_assert(std::is_assignable<bool&, int B::*>::value, "Error"); +static_assert(std::is_assignable<bool&, void*>::value, "Error"); +static_assert(std::is_assignable<bool&, std::nullptr_t>::value, "Error"); + +static_assert(std::is_assignable<std::nullptr_t&, +std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<void*&, std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<int*&, std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<int B::*&, std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t&, bool>::value, "Error"); +static_assert(!std::is_assignable<void*&, bool>::value, "Error"); +static_assert(!std::is_assignable<E&, bool>::value, "Error"); +static_assert(!std::is_assignable<SE&, bool>::value, "Error"); + +static_assert(std::is_assignable<std::initializer_list<int>&, +std::initializer_list<int>>::value, "Error"); +static_assert(std::is_assignable<std::initializer_list<int>&, +std::initializer_list<int>&&>::value, "Error"); +static_assert(std::is_assignable<std::initializer_list<int>&, const +std::initializer_list<int>&&>::value, "Error"); +static_assert(std::is_assignable<std::initializer_list<int>&, +std::initializer_list<int>&>::value, "Error"); +static_assert(std::is_assignable<std::initializer_list<int>&, const +std::initializer_list<int>&>::value, "Error"); +static_assert(!std::is_assignable<const std::initializer_list<int>&, +std::initializer_list<int>>::value, "Error"); + +static_assert(!std::is_assignable<const AnyAssign&, int>::value, "Error"); +static_assert(!std::is_assignable<AnyAssign&, void>::value, "Error"); + +static_assert(!std::is_assignable<void, int>::value, "Error"); +static_assert(!std::is_assignable<const void, int>::value, "Error"); +static_assert(!std::is_assignable<int, void>::value, "Error"); +static_assert(!std::is_assignable<int, const void>::value, "Error"); +static_assert(!std::is_assignable<const int, void>::value, "Error"); +static_assert(!std::is_assignable<const int, const void>::value, "Error"); +static_assert(!std::is_assignable<int&, void>::value, "Error"); +static_assert(!std::is_assignable<int&, const void>::value, "Error"); +static_assert(!std::is_assignable<const int&, void>::value, "Error"); +static_assert(!std::is_assignable<const int&, const void>::value, "Error"); +static_assert(!std::is_assignable<void, void>::value, "Error"); +static_assert(!std::is_assignable<const void, void>::value, "Error"); +static_assert(!std::is_assignable<const void, const void>::value, "Error"); + +static_assert(!std::is_assignable<int[1], int[1]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[1], int[1]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[1], int(&)[1]>::value, "Error"); +static_assert(!std::is_assignable<int[2], int[1]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[2], int[1]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[2], int(&)[1]>::value, "Error"); +static_assert(!std::is_assignable<int[1], void>::value, "Error"); +static_assert(!std::is_assignable<int(&)[1], void>::value, "Error"); +static_assert(!std::is_assignable<void, int[1]>::value, "Error"); +static_assert(!std::is_assignable<void, int(&)[1]>::value, "Error"); + +static_assert(!std::is_assignable<int[], int[]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[], int[]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[], int(&)[]>::value, "Error"); +static_assert(!std::is_assignable<int[1], int[]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[1], int[]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[1], int(&)[]>::value, "Error"); +static_assert(!std::is_assignable<int[], int[1]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[], int[1]>::value, "Error"); +static_assert(!std::is_assignable<int(&)[], int(&)[1]>::value, "Error"); +static_assert(!std::is_assignable<int[], void>::value, "Error"); +static_assert(!std::is_assignable<int(&)[], void>::value, "Error"); +static_assert(!std::is_assignable<void, int[]>::value, "Error"); +static_assert(!std::is_assignable<void, int(&)[]>::value, "Error"); + +static_assert(std::is_assignable<DelCopyAssign&, +DelCopyAssign>::value, "Error"); +static_assert(!std::is_assignable<DelCopyAssign&, const +DelCopyAssign>::value, "Error"); +static_assert(!std::is_assignable<DelCopyAssign&, +DelCopyAssign&>::value, "Error"); +static_assert(!std::is_assignable<DelCopyAssign&, const +DelCopyAssign&>::value, "Error"); +static_assert(!std::is_assignable<DelCopyAssign&, void>::value, "Error"); +static_assert(!std::is_assignable<DelCopyAssign&, void()>::value, "Error"); +static_assert(!std::is_assignable<DelCopyAssign&, void(&)()>::value, "Error"); +static_assert(!std::is_assignable<DelCopyAssign&, int>::value, "Error"); + +static_assert(std::is_assignable<DelAnyAssign&, +DelAnyAssign&&>::value, "Error"); +static_assert(std::is_assignable<DelAnyAssign&, const +DelAnyAssign&>::value, "Error"); +static_assert(std::is_assignable<DelAnyAssign, +DelAnyAssign&&>::value, "Error"); +static_assert(std::is_assignable<DelAnyAssign, const +DelAnyAssign&>::value, "Error"); + +static_assert(!std::is_assignable<const DelAnyAssign&, +DelAnyAssign&&>::value, "Error"); +static_assert(!std::is_assignable<const DelAnyAssign&, const +DelAnyAssign&>::value, "Error"); +static_assert(!std::is_assignable<const DelAnyAssign, +DelAnyAssign&&>::value, "Error"); +static_assert(!std::is_assignable<const DelAnyAssign, const +DelAnyAssign&>::value, "Error"); + +static_assert(!std::is_assignable<DelAnyAssign&, int>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, const int&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, void>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, void()>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, + void() const>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, void(&)()>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, void(&&)()>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, +std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, +std::nullptr_t&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, +std::initializer_list<int>>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, +std::initializer_list<int>&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, bool>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, bool&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, E>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, E&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, SE>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, SE&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, Empty>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, Empty&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, B>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, B&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, U>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, U&>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, void*>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int*>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, B*>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, D*>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int B::*>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int D::*>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int[]>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int[1]>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int(&)[]>::value, "Error"); +static_assert(!std::is_assignable<DelAnyAssign&, int(&)[1]>::value, "Error"); + +static_assert(!std::is_assignable<void(), void>::value, "Error"); +static_assert(!std::is_assignable<void, void()>::value, "Error"); +static_assert(!std::is_assignable<void(), void()>::value, "Error"); + +static_assert(!std::is_assignable<void(&)(), void>::value, "Error"); +static_assert(!std::is_assignable<void, void(&)()>::value, "Error"); +static_assert(!std::is_assignable<void(&)(), void(&)()>::value, "Error"); +static_assert(!std::is_assignable<void(&)(), void()>::value, "Error"); +static_assert(!std::is_assignable<void(), void(&)()>::value, "Error"); + +static_assert(std::is_assignable<int&, ImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<int&, ExplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<int, ImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<int, ExplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int, ImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int, ExplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int&, +ImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int&, +ExplicitTo<int>>::value, "Error"); + +static_assert(std::is_assignable<DelImplicitTo<int>&, +DelImplicitTo<int>>::value, "Error"); +static_assert(std::is_assignable<DelImplicitTo<int>, +DelImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<int&, DelImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<int, DelImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int&, +DelImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int, +DelImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<int&, DelExplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<int, DelExplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int&, +DelExplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<const int, +DelExplicitTo<int>>::value, "Error"); + +static_assert(std::is_assignable<B&, B>::value, "Error"); +static_assert(std::is_assignable<B&, D>::value, "Error"); +static_assert(std::is_assignable<B&, B&>::value, "Error"); +static_assert(std::is_assignable<B&, D&>::value, "Error"); +static_assert(!std::is_assignable<const B&, B&>::value, "Error"); +static_assert(!std::is_assignable<const B&, D&>::value, "Error"); +static_assert(!std::is_assignable<D&, B>::value, "Error"); +static_assert(!std::is_assignable<D&, B&>::value, "Error"); + +static_assert(std::is_assignable<B*&, B*>::value, "Error"); +static_assert(std::is_assignable<B*&, D*>::value, "Error"); +static_assert(std::is_assignable<const B*&, D*>::value, "Error"); +static_assert(std::is_assignable<const B*&, const D*>::value, "Error"); +static_assert(std::is_assignable<B*&, B*&>::value, "Error"); +static_assert(std::is_assignable<B*&, D*&>::value, "Error"); +static_assert(std::is_assignable<const B*&, B*&>::value, "Error"); +static_assert(std::is_assignable<const B*&, D*&>::value, "Error"); +static_assert(!std::is_assignable<B* const&, B*&>::value, "Error"); +static_assert(!std::is_assignable<B* const&, D*&>::value, "Error"); +static_assert(!std::is_assignable<D*&, B*>::value, "Error"); +static_assert(!std::is_assignable<D*&, B*&>::value, "Error"); + +static_assert(std::is_assignable<MO&, MO>::value, "Error"); +static_assert(std::is_assignable<MO&, MO&&>::value, "Error"); +static_assert(std::is_assignable<MO, MO>::value, "Error"); +static_assert(std::is_assignable<MO, MO&&>::value, "Error"); + +static_assert(!std::is_assignable<const MO&, MO>::value, "Error"); +static_assert(!std::is_assignable<const MO&, MO&&>::value, "Error"); +static_assert(!std::is_assignable<MO&, const MO&&>::value, "Error"); +static_assert(!std::is_assignable<MO&, MO&>::value, "Error"); +static_assert(!std::is_assignable<MO&, const MO&>::value, "Error"); +static_assert(!std::is_assignable<const MO, MO>::value, "Error"); +static_assert(!std::is_assignable<const MO, MO&&>::value, "Error"); +static_assert(!std::is_assignable<MO, const MO&&>::value, "Error"); +static_assert(!std::is_assignable<MO, MO&>::value, "Error"); +static_assert(!std::is_assignable<MO, const MO&>::value, "Error"); + +static_assert(!std::is_assignable<NontrivialUnion&, +NontrivialUnion>::value, "Error"); +static_assert(!std::is_assignable<NontrivialUnion&, +NontrivialUnion&&>::value, "Error"); +static_assert(!std::is_assignable<NontrivialUnion&, +NontrivialUnion&>::value, "Error"); +static_assert(!std::is_assignable<NontrivialUnion&, const +NontrivialUnion&>::value, "Error"); +static_assert(!std::is_assignable<NontrivialUnion&, const +NontrivialUnion&&>::value, "Error"); + +static_assert(std::is_assignable<Abstract&, Abstract>::value, "Error"); +static_assert(std::is_assignable<Abstract&, Abstract&&>::value, "Error"); +static_assert(std::is_assignable<Abstract&, Abstract&>::value, "Error"); +static_assert(std::is_assignable<Abstract&, const Abstract&>::value, "Error"); +static_assert(std::is_assignable<Abstract&, const Abstract&&>::value, "Error"); +static_assert(std::is_assignable<Abstract&&, Abstract>::value, "Error"); +static_assert(std::is_assignable<Abstract&&, Abstract&&>::value, "Error"); +static_assert(std::is_assignable<Abstract&&, Abstract&>::value, "Error"); +static_assert(std::is_assignable<Abstract&&, const Abstract&>::value, "Error"); +static_assert(std::is_assignable<Abstract&&, const +Abstract&&>::value, "Error"); + +static_assert(std::is_assignable<AbstractDelDtor&, +AbstractDelDtor>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&, +AbstractDelDtor&&>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&, +AbstractDelDtor&>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&, const +AbstractDelDtor&>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&, const +AbstractDelDtor&&>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&&, +AbstractDelDtor>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&&, +AbstractDelDtor&&>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&&, +AbstractDelDtor&>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&&, const +AbstractDelDtor&>::value, "Error"); +static_assert(std::is_assignable<AbstractDelDtor&&, const +AbstractDelDtor&&>::value, "Error"); + +static_assert(std::is_assignable<DelDef&, DelDef>::value, "Error"); +static_assert(std::is_assignable<DelDef&, DelDef&&>::value, "Error"); +static_assert(std::is_assignable<DelDef&, DelDef&>::value, "Error"); +static_assert(std::is_assignable<DelDef&, const DelDef&>::value, "Error"); +static_assert(std::is_assignable<DelDef&, const DelDef&&>::value, "Error"); +static_assert(std::is_assignable<DelDef&&, DelDef>::value, "Error"); +static_assert(std::is_assignable<DelDef&&, DelDef&&>::value, "Error"); +static_assert(std::is_assignable<DelDef&&, DelDef&>::value, "Error"); +static_assert(std::is_assignable<DelDef&&, const DelDef&>::value, "Error"); +static_assert(std::is_assignable<DelDef&&, const DelDef&&>::value, "Error"); + +static_assert(std::is_assignable<Ellipsis&, Ellipsis>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const Ellipsis>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, Ellipsis&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const Ellipsis&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis, Ellipsis>::value, "Error"); +static_assert(std::is_assignable<Ellipsis, const Ellipsis>::value, "Error"); +static_assert(std::is_assignable<Ellipsis, Ellipsis&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis, const Ellipsis&>::value, "Error"); + +static_assert(!std::is_assignable<Ellipsis&, void>::value, "Error"); + +static_assert(std::is_assignable<Ellipsis&, int>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const int>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, int&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const int&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, Empty>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const Empty>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, Empty&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const Empty&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, E>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const E>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, E&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const E&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, SE>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const SE>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, SE&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const SE&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, bool>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const bool>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, bool&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const bool&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const +std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, std::nullptr_t&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const +std::nullptr_t&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, void*>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const void*>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, void*&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, const void*&>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, void()>::value, "Error"); +static_assert(std::is_assignable<Ellipsis&, void(&)()>::value, "Error"); + +static_assert(std::is_assignable<DelEllipsis&, DelEllipsis>::value, "Error"); +static_assert(std::is_assignable<DelEllipsis&, const +DelEllipsis>::value, "Error"); +static_assert(std::is_assignable<DelEllipsis&, DelEllipsis&>::value, "Error"); +static_assert(std::is_assignable<DelEllipsis&, const +DelEllipsis&>::value, "Error"); +static_assert(std::is_assignable<DelEllipsis, DelEllipsis>::value, "Error"); +static_assert(std::is_assignable<DelEllipsis, const +DelEllipsis>::value, "Error"); +static_assert(std::is_assignable<DelEllipsis, DelEllipsis&>::value, "Error"); +static_assert(std::is_assignable<DelEllipsis, const +DelEllipsis&>::value, "Error"); + +static_assert(!std::is_assignable<DelEllipsis&, void>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, int>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const int>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, int&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const int&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, Empty>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const Empty>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, Empty&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const Empty&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, E>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const E>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, E&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const E&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, SE>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const SE>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, SE&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const SE&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, bool>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const bool>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, bool&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const bool&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, +std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const +std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, +std::nullptr_t&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const +std::nullptr_t&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, void*>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const void*>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, void*&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, const void*&>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, void()>::value, "Error"); +static_assert(!std::is_assignable<DelEllipsis&, void(&)()>::value, "Error"); + +static_assert(std::is_assignable<FromArgs<int>&, int>::value, "Error"); +static_assert(std::is_assignable<FromArgs<int>&, const int>::value, "Error"); +static_assert(!std::is_assignable<FromArgs<int>&, +ImplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<FromArgs<int>&, ImplicitTo<const +int>>::value, "Error"); +static_assert(!std::is_assignable<FromArgs<int>&, +ExplicitTo<int>>::value, "Error"); +static_assert(!std::is_assignable<FromArgs<int>&, ExplicitTo<const +int>>::value, "Error"); + +static_assert(!std::is_assignable<DelFromArgs<int>&, int>::value, "Error"); +static_assert(!std::is_assignable<DelFromArgs<int>&, const +int>::value, "Error"); + +static_assert(std::is_assignable<void(*&)(), +ImplicitTo<void(*)()>>::value, "Error"); +static_assert(!std::is_assignable<void(*&)(), +ExplicitTo<void(*)()>>::value, "Error"); + +static_assert(std::is_assignable<UAssignAll&, UAssignAll>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, const +UAssignAll>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, UAssignAll&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, const +UAssignAll&>::value, "Error"); + +static_assert(std::is_assignable<UAssignAll, UAssignAll>::value, "Error"); +static_assert(std::is_assignable<UAssignAll, const +UAssignAll>::value, "Error"); +static_assert(std::is_assignable<UAssignAll, UAssignAll&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll, const +UAssignAll&>::value, "Error"); + +static_assert(!std::is_assignable<UAssignAll&, void>::value, "Error"); +static_assert(!std::is_assignable<const UAssignAll&, void>::value, "Error"); +static_assert(!std::is_assignable<const UAssignAll&, +UAssignAll>::value, "Error"); +static_assert(!std::is_assignable<const UAssignAll&, const +UAssignAll>::value, "Error"); +static_assert(!std::is_assignable<const UAssignAll&, +UAssignAll&>::value, "Error"); +static_assert(!std::is_assignable<const UAssignAll&, const +UAssignAll&>::value, "Error"); +static_assert(!std::is_assignable<UAssignAll&, void() const>::value, "Error"); +static_assert(!std::is_assignable<UAssignAll&, void() &>::value, "Error"); +static_assert(!std::is_assignable<UAssignAll&, void() const volatile &&>::value, "Error"); + +static_assert(std::is_assignable<UAssignAll&, int>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, int&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, E>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, E&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, SE>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, SE&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, double>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, double&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, Empty>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, Empty&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, B>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, B&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, U>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, U&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, std::nullptr_t>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, +std::nullptr_t&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, void()>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, void(&)()>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, void(*)()>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, void(*&)()>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, int*>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, int*&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, void*>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, void*&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, const int*>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, const int*&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, const void*>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, const void*&>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, int[1]>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, int(&)[1]>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, int[]>::value, "Error"); +static_assert(std::is_assignable<UAssignAll&, int(&)[]>::value, "Error"); + +static_assert(!std::is_assignable<UDelAssignAll&, int>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, int&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, E>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, E&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, SE>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, SE&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, double>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, double&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, Empty>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, Empty&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, B>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, B&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, U>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, U&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, +std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, +std::nullptr_t&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, void()>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, void(&)()>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, void() + const>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, void(*)()>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, void(*&)()>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, int*>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, int*&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, void*>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, void*&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, const int*>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, const +int*&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, const +void*>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, const +void*&>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, int[1]>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, int(&)[1]>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, int[]>::value, "Error"); +static_assert(!std::is_assignable<UDelAssignAll&, int(&)[]>::value, "Error"); + +static_assert(!std::is_assignable<void(&)(), std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t, void(&)()>::value, "Error"); +static_assert(!std::is_assignable<void(&)(), int[]>::value, "Error"); +static_assert(!std::is_assignable<int[], void(&)()>::value, "Error"); +static_assert(!std::is_assignable<int[], std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t, int[]>::value, "Error"); +static_assert(!std::is_assignable<int[1], std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t, int[1]>::value, "Error"); +static_assert(!std::is_assignable<void, std::nullptr_t>::value, "Error"); +static_assert(!std::is_assignable<std::nullptr_t, void>::value, "Error"); +static_assert(!std::is_assignable<const D&, B&>::value, "Error"); +static_assert(!std::is_assignable<const B&, B&>::value, "Error"); + +static_assert(std::is_assignable<B&, const D&>::value, "Error"); +static_assert(std::is_assignable<B&, const B&>::value, "Error"); +static_assert(std::is_assignable<int&, const int&>::value, "Error"); +static_assert(std::is_assignable<int&, const double&>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..dd74cfb51 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_base_of<test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/requirements/typedefs.cc new file mode 100644 index 000000000..699282faf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_base_of<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/value.cc new file mode 100644 index 000000000..b380cfeff --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_base_of/value.cc @@ -0,0 +1,91 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +class HiddenCons +{ + HiddenCons(); + HiddenCons(const HiddenCons&); +}; + +class DerivedHiddenCons +: private HiddenCons +{ + DerivedHiddenCons(); + DerivedHiddenCons(const DerivedHiddenCons&); +}; + +class MultiDerivedHiddenCons +: private HiddenCons, private __gnu_test::ClassType +{ + MultiDerivedHiddenCons(); + MultiDerivedHiddenCons(const MultiDerivedHiddenCons&); +}; + +void test01() +{ + using std::is_base_of; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_relationship<is_base_of, volatile ClassType, + ClassType>(true), ""); + static_assert(test_relationship<is_base_of, AbstractClass, + AbstractClass>(true), ""); + static_assert(test_relationship<is_base_of, ClassType, + DerivedType>(true), ""); + static_assert(test_relationship<is_base_of, ClassType, + const DerivedType>(true), ""); + static_assert(test_relationship<is_base_of, volatile ClassType, + volatile DerivedType>(true), ""); + static_assert(test_relationship<is_base_of, PolymorphicClass, + DerivedPolymorphic>(true), ""); + static_assert(test_relationship<is_base_of, HiddenCons, + DerivedHiddenCons>(true), ""); + static_assert(test_relationship<is_base_of, HiddenCons, + MultiDerivedHiddenCons>(true), ""); + static_assert(test_relationship<is_base_of, ClassType, + MultiDerivedHiddenCons>(true), ""); + + // Negative tests. + static_assert(test_relationship<is_base_of, int, int>(false), ""); + static_assert(test_relationship<is_base_of, EnumType, EnumType>(false), ""); + static_assert(test_relationship<is_base_of, UnionType, UnionType>(false), ""); + static_assert(test_relationship<is_base_of, int, const int>(false), ""); + static_assert(test_relationship<is_base_of, volatile UnionType, + UnionType>(false), ""); + static_assert(test_relationship<is_base_of, int&, ClassType>(false), ""); + static_assert(test_relationship<is_base_of, AbstractClass, + ClassType>(false), ""); + static_assert(test_relationship<is_base_of, ClassType, + AbstractClass>(false), ""); + static_assert(test_relationship<is_base_of, DerivedType, + ClassType>(false), ""); + static_assert(test_relationship<is_base_of, DerivedPolymorphic, + PolymorphicClass>(false), ""); + static_assert(test_relationship<is_base_of, DerivedHiddenCons, + HiddenCons>(false), ""); + static_assert(test_relationship<is_base_of, MultiDerivedHiddenCons, + HiddenCons>(false), ""); + static_assert(test_relationship<is_base_of, MultiDerivedHiddenCons, + ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..fce4b3745 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_class<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/requirements/typedefs.cc new file mode 100644 index 000000000..f96b93c44 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_class<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/value.cc new file mode 100644 index 000000000..7d926dc64 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_class/value.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_class; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_class, ClassType>(true), ""); + static_assert(test_category<is_class, DerivedType>(true), ""); + static_assert(test_category<is_class, ConvType>(true), ""); + static_assert(test_category<is_class, AbstractClass>(true), ""); + static_assert(test_category<is_class, PolymorphicClass>(true), ""); + static_assert(test_category<is_class, DerivedPolymorphic>(true), ""); + + // Negative tests. + static_assert(test_category<is_class, UnionType>(false), ""); + static_assert(test_category<is_class, void>(false), ""); + static_assert(test_category<is_class, int>(false), ""); + static_assert(test_category<is_class, float>(false), ""); + static_assert(test_category<is_class, int[2]>(false), ""); + static_assert(test_category<is_class, int*>(false), ""); + static_assert(test_category<is_class, int(*)(int)>(false), ""); + static_assert(test_category<is_class, float&>(false), ""); + static_assert(test_category<is_class, float(&)(float)>(false), ""); + static_assert(test_category<is_class, int (ClassType::*)>(false), ""); + static_assert(test_category<is_class, int (ClassType::*) (int)>(false), ""); + static_assert(test_category<is_class, int (int)>(false), ""); + static_assert(test_category<is_class, EnumType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..3adcd84d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_compound<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/requirements/typedefs.cc new file mode 100644 index 000000000..a06230906 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_compound<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/value.cc new file mode 100644 index 000000000..67375e3ac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_compound/value.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_compound; + using namespace __gnu_test; + + static_assert(test_category<is_compound, void>(false), ""); + static_assert(test_category<is_compound, char>(false), ""); + static_assert(test_category<is_compound, signed char>(false), ""); + static_assert(test_category<is_compound, unsigned char>(false), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_compound, wchar_t>(false), ""); +#endif + static_assert(test_category<is_compound, short>(false), ""); + static_assert(test_category<is_compound, unsigned short>(false), ""); + static_assert(test_category<is_compound, int>(false), ""); + static_assert(test_category<is_compound, unsigned int>(false), ""); + static_assert(test_category<is_compound, long>(false), ""); + static_assert(test_category<is_compound, unsigned long>(false), ""); + static_assert(test_category<is_compound, long long>(false), ""); + static_assert(test_category<is_compound, unsigned long long>(false), ""); + static_assert(test_category<is_compound, float>(false), ""); + static_assert(test_category<is_compound, double>(false), ""); + static_assert(test_category<is_compound, long double>(false), ""); + + // libstdc++/56609 + static_assert(test_category<is_compound, std::nullptr_t>(false), ""); + + // Sanity check. + static_assert(test_category<is_compound, ClassType>(true), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6e9dea10a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_const<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/requirements/typedefs.cc new file mode 100644 index 000000000..1a4df1d57 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_const<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/value.cc new file mode 100644 index 000000000..b37527dac --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_const/value.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_const; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_const, const int>(true), ""); + static_assert(test_property<is_const, const volatile int>(true), ""); + static_assert(test_property<is_const, cClassType>(true), ""); + static_assert(test_property<is_const, cvClassType>(true), ""); + + // Negative tests. + static_assert(test_property<is_const, int>(false), ""); + static_assert(test_property<is_const, volatile int>(false), ""); + static_assert(test_property<is_const, ClassType>(false), ""); + static_assert(test_property<is_const, vClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/51185.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/51185.cc new file mode 100644 index 000000000..904521768 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/51185.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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> + +struct A { }; +struct B : A { }; + +// libstdc++/51185 +void f() +{ + static_assert(!std::is_constructible<B &&, A>(), ""); + static_assert(!std::is_constructible<B const &&, A>(), ""); + static_assert(!std::is_constructible<B const &&, A const>(), ""); + static_assert(!std::is_constructible<B volatile &&, A>(), ""); + static_assert(!std::is_constructible<B volatile &&, A volatile>(), ""); + static_assert(!std::is_constructible<B const volatile &&, A>(), ""); + static_assert(!std::is_constructible<B const volatile &&, A const>(), ""); + static_assert(!std::is_constructible<B const volatile &&, A volatile>(), ""); + static_assert(!std::is_constructible<B const volatile &&, + A const volatile>(), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7eb578e58 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-12-30 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2009-2014 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_constructible<test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..74411fa6d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-12-30 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009-2014 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_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc new file mode 100644 index 000000000..7c3744427 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc @@ -0,0 +1,821 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <initializer_list> +#include <testsuite_tr1.h> + +using namespace __gnu_test::construct; + +static_assert(std::is_constructible<int, int>::value, "Error"); +static_assert(std::is_constructible<std::nullptr_t, std::nullptr_t>::value, + "Error"); +static_assert(std::is_constructible<E, E>::value, "Error"); +static_assert(std::is_constructible<SE, SE>::value, "Error"); +static_assert(std::is_constructible<OpE, OpE>::value, "Error"); +static_assert(std::is_constructible<OpSE, OpSE>::value, "Error"); +static_assert(std::is_constructible<Empty, Empty>::value, "Error"); +static_assert(std::is_constructible<B, B>::value, "Error"); +static_assert(std::is_constructible<U, U>::value, "Error"); +static_assert(std::is_constructible<int B::*, int B::*>::value, "Error"); +static_assert(std::is_constructible<Ellipsis, Ellipsis>::value, "Error"); +static_assert(std::is_constructible<int*, int*>::value, "Error"); +static_assert(std::is_constructible<void*, void*>::value, "Error"); +static_assert(std::is_constructible<Any, Any>::value, "Error"); +static_assert(std::is_constructible<nAny, nAny>::value, "Error"); +static_assert(std::is_constructible<std::initializer_list<int>, + std::initializer_list<int>>::value, "Error"); +static_assert(std::is_constructible<DelDef, DelDef>::value, "Error"); + +static_assert(!std::is_constructible<void, void>::value, "Error"); +static_assert(!std::is_constructible<Abstract, Abstract>::value, "Error"); +static_assert(!std::is_constructible<int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<int[1], int[1]>::value, "Error"); +static_assert(!std::is_constructible<DelCopy, const DelCopy&>::value, "Error"); +static_assert(!std::is_constructible<DelCopy, DelCopy&&>::value, "Error"); +static_assert(!std::is_constructible<DelCopy, DelCopy>::value, "Error"); +static_assert(!std::is_constructible<DelDtor, void>::value, "Error"); +static_assert(!std::is_constructible<DelDtor, int>::value, "Error"); +static_assert(!std::is_constructible<DelDtor, DelDtor>::value, "Error"); +static_assert(!std::is_constructible<DelDtor, DelDtor&&>::value, "Error"); +static_assert(!std::is_constructible<DelDtor, const DelDtor&>::value, "Error"); + +static_assert(std::is_constructible<DelEllipsis, const DelEllipsis&>::value, + "Error"); +static_assert(std::is_constructible<DelEllipsis, DelEllipsis&&>::value, + "Error"); +static_assert(std::is_constructible<DelEllipsis, DelEllipsis>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, void>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, std::nullptr_t>::value, + "Error"); +static_assert(!std::is_constructible<DelEllipsis, B>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, Empty>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, E>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, SE>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, OpE>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, OpSE>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, void()>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, void() const>::value, + "Error"); +static_assert(!std::is_constructible<DelEllipsis, int[1]>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, int[]>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, int*>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, void*>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, int B::*>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, int D::*>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, Abstract>::value, "Error"); +static_assert(!std::is_constructible<int, DelImplicitTo<int>>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, + DelImplicitTo<std::nullptr_t>>::value, "Error"); +static_assert(!std::is_constructible<int&, + DelImplicitTo<const int&>>::value, "Error"); + +static_assert(!std::is_constructible<int, void>::value, "Error"); +static_assert(!std::is_constructible<void, int>::value, "Error"); +static_assert(std::is_constructible<void*, int*>::value, "Error"); +static_assert(!std::is_constructible<int*, void*>::value, "Error"); +static_assert(std::is_constructible<int*, std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, int*>::value, "Error"); +static_assert(!std::is_constructible<Empty, E>::value, "Error"); +static_assert(!std::is_constructible<Empty, SE>::value, "Error"); +static_assert(!std::is_constructible<Empty, OpE>::value, "Error"); +static_assert(!std::is_constructible<Empty, OpSE>::value, "Error"); +static_assert(!std::is_constructible<Empty, void>::value, "Error"); +static_assert(!std::is_constructible<Empty, void*>::value, "Error"); +static_assert(!std::is_constructible<Empty, std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<Empty, int[]>::value, "Error"); +static_assert(!std::is_constructible<Empty, int[3]>::value, "Error"); +static_assert(!std::is_constructible<Empty, int>::value, "Error"); +static_assert(!std::is_constructible<Abstract, int>::value, "Error"); +static_assert(!std::is_constructible<Abstract, std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, Abstract>::value, "Error"); +static_assert(!std::is_constructible<Abstract, int[]>::value, "Error"); +static_assert(std::is_constructible<B, D>::value, "Error"); +static_assert(!std::is_constructible<D, B>::value, "Error"); +static_assert(!std::is_constructible<int[], int[1]>::value, "Error"); +static_assert(!std::is_constructible<int[1], int[]>::value, "Error"); +static_assert(!std::is_constructible<int[], Empty>::value, "Error"); +static_assert(!std::is_constructible<int[], std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<int[1], Abstract>::value, "Error"); + +static_assert(std::is_constructible<const int*, int*>::value, "Error"); +static_assert(std::is_constructible<const void*, void*>::value, "Error"); +static_assert(std::is_constructible<const void*, int*>::value, "Error"); +static_assert(!std::is_constructible<int*, const void*>::value, "Error"); + +static_assert(std::is_constructible<int, E>::value, "Error"); +static_assert(!std::is_constructible<E, int>::value, "Error"); +static_assert(!std::is_constructible<E, E2>::value, "Error"); +static_assert(std::is_constructible<E, E>::value, "Error"); +static_assert(std::is_constructible<bool, E>::value, "Error"); +static_assert(!std::is_constructible<E, bool>::value, "Error"); +static_assert(std::is_constructible<double, E>::value, "Error"); +static_assert(!std::is_constructible<E, double>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, E>::value, "Error"); +static_assert(!std::is_constructible<E, std::nullptr_t>::value, "Error"); + +static_assert(std::is_constructible<int, OpE>::value, "Error"); +static_assert(!std::is_constructible<OpE, int>::value, "Error"); +static_assert(!std::is_constructible<OpE, E2>::value, "Error"); +static_assert(std::is_constructible<OpE, OpE>::value, "Error"); +static_assert(std::is_constructible<bool, OpE>::value, "Error"); +static_assert(!std::is_constructible<OpE, bool>::value, "Error"); +static_assert(std::is_constructible<double, OpE>::value, "Error"); +static_assert(!std::is_constructible<OpE, double>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, OpE>::value, "Error"); +static_assert(!std::is_constructible<OpE, std::nullptr_t>::value, "Error"); + +static_assert(!std::is_constructible<int, SE>::value, "Error"); +static_assert(!std::is_constructible<SE, int>::value, "Error"); +static_assert(!std::is_constructible<E, SE>::value, "Error"); +static_assert(!std::is_constructible<SE, SE2>::value, "Error"); +static_assert(std::is_constructible<SE, SE>::value, "Error"); +static_assert(!std::is_constructible<bool, SE>::value, "Error"); +static_assert(!std::is_constructible<SE, bool>::value, "Error"); +static_assert(!std::is_constructible<double, SE>::value, "Error"); +static_assert(!std::is_constructible<SE, double>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, SE>::value, "Error"); +static_assert(!std::is_constructible<SE, std::nullptr_t>::value, "Error"); + +static_assert(!std::is_constructible<int, OpSE>::value, "Error"); +static_assert(!std::is_constructible<OpSE, int>::value, "Error"); +static_assert(!std::is_constructible<OpE, OpSE>::value, "Error"); +static_assert(!std::is_constructible<OpSE, SE2>::value, "Error"); +static_assert(std::is_constructible<OpSE, OpSE>::value, "Error"); +static_assert(!std::is_constructible<bool, OpSE>::value, "Error"); +static_assert(!std::is_constructible<OpSE, bool>::value, "Error"); +static_assert(!std::is_constructible<double, OpSE>::value, "Error"); +static_assert(!std::is_constructible<OpSE, double>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, OpSE>::value, "Error"); +static_assert(!std::is_constructible<OpSE, std::nullptr_t>::value, "Error"); + +static_assert(!std::is_constructible<D*, B*>::value, "Error"); +static_assert(!std::is_constructible<const volatile D*, B*>::value, "Error"); +static_assert(!std::is_constructible<D*, const volatile B*>::value, "Error"); + +static_assert(!std::is_constructible<D*, B* const>::value, "Error"); +static_assert(!std::is_constructible<const volatile D*, B* const>::value, + "Error"); +static_assert(!std::is_constructible<D*, const volatile B* const>::value, + "Error"); + +static_assert(!std::is_constructible<D*, B*&>::value, "Error"); +static_assert(!std::is_constructible<const volatile D*, B*&>::value, "Error"); +static_assert(!std::is_constructible<D*, const volatile B*&>::value, "Error"); + +static_assert(!std::is_constructible<int B::*, int D::*>::value, "Error"); +static_assert(!std::is_constructible<const volatile int B::*, int D::*>::value, + "Error"); +static_assert(!std::is_constructible<int B::*, const volatile int D::*>::value, + "Error"); + +static_assert(!std::is_constructible<int B::*, int D::* const>::value, "Error"); +static_assert(!std::is_constructible<const volatile int B::*, + int D::* const>::value, "Error"); +static_assert(!std::is_constructible<int B::*, + const volatile int D::* const>::value, "Error"); + +static_assert(!std::is_constructible<int B::*, int D::*&>::value, "Error"); +static_assert(!std::is_constructible<const volatile int B::*, + int D::*&>::value, "Error"); +static_assert(!std::is_constructible<int B::*, + const volatile int D::*&>::value, "Error"); + +static_assert(!std::is_constructible<int B::*, int D::* const &>::value, + "Error"); +static_assert(!std::is_constructible<const volatile int B::*, + int D::* const &>::value, "Error"); +static_assert(!std::is_constructible<int B::*, + const volatile int D::* const &>::value, "Error"); + +static_assert(!std::is_constructible<int&&, int&>::value, "Error"); +static_assert(!std::is_constructible<const int&&, int&>::value, "Error"); + +static_assert(std::is_constructible<B&, D&>::value, "Error"); +static_assert(std::is_constructible<B&&, D&&>::value, "Error"); +static_assert(std::is_constructible<const B&, D&>::value, "Error"); +static_assert(std::is_constructible<const B&&, D&&>::value, "Error"); +static_assert(!std::is_constructible<B&, const D&>::value, "Error"); +static_assert(!std::is_constructible<B&&, const D&&>::value, "Error"); + +static_assert(!std::is_constructible<D&, B&>::value, "Error"); +static_assert(!std::is_constructible<D&&, B&&>::value, "Error"); +static_assert(!std::is_constructible<D&, const B&>::value, "Error"); +static_assert(!std::is_constructible<D&&, const B&&>::value, "Error"); +static_assert(!std::is_constructible<const D&, B&>::value, "Error"); +static_assert(!std::is_constructible<const D&&, B&&>::value, "Error"); + +static_assert(!std::is_constructible<B&&, B&>::value, "Error"); +static_assert(!std::is_constructible<B&&, D&>::value, "Error"); +static_assert(std::is_constructible<B&&, ImplicitTo<D&&>>::value, "Error"); +static_assert(std::is_constructible<B&&, ImplicitTo<D&&>&>::value, "Error"); +static_assert(std::is_constructible<int&&, double&>::value, "Error"); +static_assert(std::is_constructible<const int&, + ImplicitTo<int&>&>::value, "Error"); +static_assert(std::is_constructible<const int&, + ImplicitTo<int&>>::value, "Error"); +static_assert(std::is_constructible<const int&, + ExplicitTo<int&>&>::value, "Error"); +static_assert(std::is_constructible<const int&, + ExplicitTo<int&>>::value, "Error"); + +static_assert(!std::is_constructible<B&&, ExplicitTo<D&&>>::value, "Error"); +static_assert(!std::is_constructible<B&&, ExplicitTo<D&&>&>::value, "Error"); + +static_assert(!std::is_constructible<B&, B&&>::value, "Error"); +static_assert(!std::is_constructible<D&, B&&>::value, "Error"); +static_assert(!std::is_constructible<B&, D&&>::value, "Error"); + +static_assert(std::is_constructible<void(&)(), void(&)()>::value, "Error"); +static_assert(std::is_constructible<void(&&)(), void(&&)()>::value, "Error"); +static_assert(std::is_constructible<void(&&)(), void()>::value, "Error"); + +static_assert(!std::is_constructible<void>::value, "Error" ); +static_assert(!std::is_constructible<void, int>::value, "Error" ); +static_assert(!std::is_constructible<void, int, double>::value, "Error" ); + +static_assert(!std::is_constructible<int&>::value, "Error" ); +static_assert(!std::is_constructible<const int&>::value, "Error" ); +static_assert(!std::is_constructible<int&, int, int>::value, "Error" ); +static_assert(!std::is_constructible<const int&, int, int>::value, "Error" ); + +static_assert(std::is_constructible<void(&)(), void()>::value, "Error"); +static_assert(std::is_constructible<void(&)(), void(&&)()>::value, "Error"); + +static_assert(std::is_constructible<int&, int&>::value, "Error"); +static_assert(!std::is_constructible<int&, const int&>::value, "Error"); +static_assert(!std::is_constructible<int&, int>::value, "Error"); +static_assert(!std::is_constructible<int&, int&&>::value, "Error"); +static_assert(!std::is_constructible<int&, const int&&>::value, "Error"); +static_assert(std::is_constructible<const int&, int&>::value, "Error"); +static_assert(std::is_constructible<const int&, int>::value, "Error"); +static_assert(std::is_constructible<const int&, const int>::value, "Error"); +static_assert(std::is_constructible<const int&, int&&>::value, "Error"); +static_assert(std::is_constructible<const int&, const int&&>::value, "Error"); +static_assert(std::is_constructible<volatile int&, int&>::value, "Error"); +static_assert(!std::is_constructible<volatile int&, const int&>::value, + "Error"); +static_assert(!std::is_constructible<volatile int&, int>::value, "Error"); +static_assert(!std::is_constructible<volatile int&, int&&>::value, "Error"); +static_assert(!std::is_constructible<volatile int&, const int&&>::value, + "Error"); +static_assert(std::is_constructible<const volatile int&, int&>::value, "Error"); +static_assert(!std::is_constructible<const volatile int&, int>::value, "Error"); +static_assert(!std::is_constructible<const volatile int&, const int>::value, + "Error"); +static_assert(!std::is_constructible<const volatile int&, int&&>::value, + "Error"); +static_assert(!std::is_constructible<const volatile int&, const int&&>::value, + "Error"); + +static_assert(std::is_constructible<int&&, int>::value, "Error"); +static_assert(std::is_constructible<int&&, int&&>::value, "Error"); +static_assert(!std::is_constructible<int&&, const int&&>::value, "Error"); +static_assert(!std::is_constructible<int&&, int&>::value, "Error"); +static_assert(!std::is_constructible<int&&, const int&>::value, "Error"); +static_assert(std::is_constructible<int&&, double&>::value, "Error"); +static_assert(std::is_constructible<const int&&, int>::value, "Error"); +static_assert(std::is_constructible<const int&&, int&&>::value, "Error"); +static_assert(std::is_constructible<const int&&, const int>::value, "Error"); +static_assert(std::is_constructible<const int&&, const int&&>::value, "Error"); +static_assert(!std::is_constructible<int&&, const int&>::value, "Error"); +static_assert(!std::is_constructible<const int&&, int&>::value, "Error"); +static_assert(!std::is_constructible<const int&&, const int&>::value, "Error"); +static_assert(std::is_constructible<volatile int&&, int>::value, "Error"); +static_assert(std::is_constructible<volatile int&&, int&&>::value, "Error"); +static_assert(!std::is_constructible<volatile int&&, const int&&>::value, + "Error"); +static_assert(!std::is_constructible<volatile int&&, int&>::value, "Error"); +static_assert(!std::is_constructible<volatile int&&, const int&>::value, + "Error"); +static_assert(std::is_constructible<volatile int&&, double&>::value, "Error"); +static_assert(std::is_constructible<volatile const int&&, int>::value, "Error"); +static_assert(std::is_constructible<const volatile int&&, int&&>::value, + "Error"); +static_assert(std::is_constructible<const volatile int&&, const int>::value, + "Error"); +static_assert(std::is_constructible<const volatile int&&, const int&&>::value, + "Error"); +static_assert(!std::is_constructible<volatile int&&, const int&>::value, + "Error"); +static_assert(!std::is_constructible<const volatile int&&, int&>::value, + "Error"); +static_assert(!std::is_constructible<const volatile int&&, + const int&>::value, "Error"); + +static_assert(std::is_constructible<Empty&, Empty&>::value, "Error"); +static_assert(!std::is_constructible<Empty&, const Empty&>::value, "Error"); +static_assert(!std::is_constructible<Empty&, Empty>::value, "Error"); +static_assert(!std::is_constructible<Empty&, Empty&&>::value, "Error"); +static_assert(!std::is_constructible<Empty&, const Empty&&>::value, "Error"); +static_assert(std::is_constructible<const Empty&, Empty&>::value, "Error"); +static_assert(std::is_constructible<const Empty&, Empty>::value, "Error"); +static_assert(std::is_constructible<const Empty&, const Empty>::value, "Error"); +static_assert(std::is_constructible<const Empty&, Empty&&>::value, "Error"); +static_assert(std::is_constructible<const Empty&, const Empty&&>::value, + "Error"); +static_assert(std::is_constructible<volatile Empty&, Empty&>::value, "Error"); +static_assert(!std::is_constructible<volatile Empty&, const Empty&>::value, + "Error"); +static_assert(!std::is_constructible<volatile Empty&, Empty>::value, "Error"); +static_assert(!std::is_constructible<volatile Empty&, Empty&&>::value, "Error"); +static_assert(!std::is_constructible<volatile Empty&, const Empty&&>::value, + "Error"); +static_assert(std::is_constructible<const volatile Empty&, Empty&>::value, + "Error"); +static_assert(!std::is_constructible<const volatile Empty&, Empty>::value, + "Error"); +static_assert(!std::is_constructible<const volatile Empty&, + const Empty>::value, "Error"); +static_assert(!std::is_constructible<const volatile Empty&, + Empty&&>::value, "Error"); +static_assert(!std::is_constructible<const volatile Empty&, + const Empty&&>::value, "Error"); + +static_assert(std::is_constructible<Empty&&, Empty>::value, "Error"); +static_assert(std::is_constructible<Empty&&, Empty&&>::value, "Error"); +static_assert(!std::is_constructible<Empty&&, const Empty&&>::value, "Error"); +static_assert(!std::is_constructible<Empty&&, Empty&>::value, "Error"); +static_assert(!std::is_constructible<Empty&&, const Empty&>::value, "Error"); +static_assert(!std::is_constructible<Empty&&, double&>::value, "Error"); +static_assert(!std::is_constructible<Empty&&, const double&>::value, "Error"); +static_assert(std::is_constructible<const Empty&&, Empty>::value, "Error"); +static_assert(std::is_constructible<const Empty&&, Empty&&>::value, "Error"); +static_assert(std::is_constructible<const Empty&&, const Empty>::value, + "Error"); +static_assert(std::is_constructible<const Empty&&, const Empty&&>::value, + "Error"); +static_assert(!std::is_constructible<Empty&&, const Empty&>::value, "Error"); +static_assert(!std::is_constructible<const Empty&&, Empty&>::value, "Error"); +static_assert(!std::is_constructible<const Empty&&, const Empty&>::value, + "Error"); +static_assert(std::is_constructible<volatile Empty&&, Empty>::value, "Error"); +static_assert(std::is_constructible<volatile Empty&&, Empty&&>::value, "Error"); +static_assert(!std::is_constructible<volatile Empty&&, const Empty&&>::value, + "Error"); +static_assert(!std::is_constructible<volatile Empty&&, Empty&>::value, "Error"); +static_assert(!std::is_constructible<volatile Empty&&, const Empty&>::value, + "Error"); +static_assert(!std::is_constructible<volatile Empty&&, double&>::value, + "Error"); +static_assert(!std::is_constructible<volatile Empty&&, const double&>::value, + "Error"); +static_assert(std::is_constructible<const volatile Empty&&, Empty>::value, + "Error"); +static_assert(std::is_constructible<const volatile Empty&&, Empty&&>::value, + "Error"); +static_assert(std::is_constructible<const volatile Empty&&, + const Empty>::value, "Error"); +static_assert(std::is_constructible<const volatile Empty&&, + const Empty&&>::value, "Error"); +static_assert(!std::is_constructible<volatile Empty&&, + const Empty&>::value, "Error"); +static_assert(!std::is_constructible<const volatile Empty&&, + Empty&>::value, "Error"); +static_assert(!std::is_constructible<const volatile Empty&&, + const Empty&>::value, "Error"); + +static_assert(std::is_constructible<Ellipsis, int>::value, "Error"); +static_assert(std::is_constructible<Ellipsis, Empty>::value, "Error"); +static_assert(std::is_constructible<Ellipsis, std::nullptr_t>::value, "Error"); +static_assert(std::is_constructible<Ellipsis, int[]>::value, "Error"); +static_assert(std::is_constructible<Ellipsis, int[1]>::value, "Error"); +static_assert(!std::is_constructible<Ellipsis, void>::value, "Error"); + +static_assert(std::is_constructible<int(&)[1], int(&)[1]>::value, "Error"); +static_assert(std::is_constructible<const int(&)[1], + int(&)[1]>::value, "Error"); +static_assert(std::is_constructible<volatile int(&)[1], + int(&)[1]>::value, "Error"); +static_assert(std::is_constructible<const volatile int(&)[1], + int(&)[1]>::value, "Error"); +static_assert(!std::is_constructible<int(&)[1], + const int(&)[1]>::value, "Error"); +static_assert(!std::is_constructible<const int(&)[1], + volatile int(&)[1]>::value, "Error"); + +static_assert(std::is_constructible<int(&)[], int(&)[]>::value, "Error"); + +static_assert(!std::is_constructible<int(&)[1], int(&)[2]>::value, "Error"); +static_assert(!std::is_constructible<int(&)[1], int&>::value, "Error"); +static_assert(!std::is_constructible<int&, int(&)[1]>::value, "Error"); + +static_assert(!std::is_constructible<U, int>::value, "Error"); +static_assert(!std::is_constructible<U, Empty>::value, "Error"); + +static_assert(!std::is_constructible<void(), void()>::value, "Error"); +static_assert(!std::is_constructible<void(), int>::value, "Error"); +static_assert(!std::is_constructible<void(), Abstract>::value, "Error"); +static_assert(!std::is_constructible<void(), std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<void(), Empty>::value, "Error"); +static_assert(!std::is_constructible<void(), U>::value, "Error"); +static_assert(!std::is_constructible<void(), E>::value, "Error"); +static_assert(!std::is_constructible<void(), SE>::value, "Error"); +static_assert(!std::is_constructible<void(), OpE>::value, "Error"); +static_assert(!std::is_constructible<void(), OpSE>::value, "Error"); +static_assert(!std::is_constructible<void(), int[]>::value, "Error"); +static_assert(!std::is_constructible<void(), int[1]>::value, "Error"); + +static_assert(!std::is_constructible<void() const, + void() volatile>::value, "Error"); +static_assert(!std::is_constructible<void() const, int>::value, "Error"); +static_assert(!std::is_constructible<void() const, Abstract>::value, "Error"); +static_assert(!std::is_constructible<void() const, std::nullptr_t>::value, + "Error"); +static_assert(!std::is_constructible<void() const, Empty>::value, "Error"); +static_assert(!std::is_constructible<void() const, U>::value, "Error"); +static_assert(!std::is_constructible<void() const, E>::value, "Error"); +static_assert(!std::is_constructible<void() const, SE>::value, "Error"); +static_assert(!std::is_constructible<void() const, OpE>::value, "Error"); +static_assert(!std::is_constructible<void() const, OpSE>::value, "Error"); +static_assert(!std::is_constructible<void() const, int[]>::value, "Error"); +static_assert(!std::is_constructible<void() const, int[1]>::value, "Error"); + +static_assert(!std::is_constructible<void(int), void()>::value, "Error"); +static_assert(!std::is_constructible<int, void()>::value, "Error"); +static_assert(!std::is_constructible<Abstract, void()>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, void()>::value, "Error"); +static_assert(!std::is_constructible<Empty, void()>::value, "Error"); +static_assert(!std::is_constructible<U, void()>::value, "Error"); +static_assert(!std::is_constructible<E, void()>::value, "Error"); +static_assert(!std::is_constructible<SE, void()>::value, "Error"); +static_assert(!std::is_constructible<OpE, void()>::value, "Error"); +static_assert(!std::is_constructible<OpSE, void()>::value, "Error"); +static_assert(!std::is_constructible<int[], void()>::value, "Error"); +static_assert(!std::is_constructible<int[1], void()>::value, "Error"); + +static_assert(!std::is_constructible<void(int) const, + void() const>::value, "Error"); +static_assert(!std::is_constructible<int, void() const>::value, "Error"); +static_assert(!std::is_constructible<Abstract, void() const>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, void() const>::value, + "Error"); +static_assert(!std::is_constructible<Empty, void() const>::value, "Error"); +static_assert(!std::is_constructible<U, void() const>::value, "Error"); +static_assert(!std::is_constructible<E, void() const>::value, "Error"); +static_assert(!std::is_constructible<SE, void() const>::value, "Error"); +static_assert(!std::is_constructible<OpE, void() const>::value, "Error"); +static_assert(!std::is_constructible<OpSE, void() const>::value, "Error"); +static_assert(!std::is_constructible<int[], void() const>::value, "Error"); +static_assert(!std::is_constructible<int[1], void() const>::value, "Error"); + +static_assert(!std::is_constructible<void, int, int>::value, "Error"); +static_assert(!std::is_constructible<void, Empty, B>::value, "Error"); +static_assert(!std::is_constructible<void, Empty, Empty>::value, "Error"); +static_assert(!std::is_constructible<void, U, Empty>::value, "Error"); +static_assert(!std::is_constructible<void, U, U>::value, "Error"); +static_assert(!std::is_constructible<void, std::nullptr_t, + std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<void, int[1], int[1]>::value, "Error"); +static_assert(!std::is_constructible<void, int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<void, void, int>::value, "Error"); +static_assert(!std::is_constructible<void, void, void>::value, "Error"); +static_assert(!std::is_constructible<void, void(), void()>::value, "Error"); +static_assert(!std::is_constructible<void, void() const, + void() volatile>::value, "Error"); + +static_assert(!std::is_constructible<int, int, int>::value, "Error"); +static_assert(!std::is_constructible<const int, int, int>::value, "Error"); +static_assert(!std::is_constructible<int, void, int>::value, "Error"); +static_assert(!std::is_constructible<const int, void, int>::value, "Error"); +static_assert(!std::is_constructible<int, void, void>::value, "Error"); +static_assert(!std::is_constructible<const int, void, void>::value, "Error"); +static_assert(!std::is_constructible<bool, int, int>::value, "Error"); +static_assert(!std::is_constructible<const bool, int, int>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t, int, int>::value, "Error"); +static_assert(!std::is_constructible<const std::nullptr_t, int, int>::value, + "Error"); +static_assert(!std::is_constructible<std::nullptr_t, void, int>::value, + "Error"); +static_assert(!std::is_constructible<const std::nullptr_t, void, int>::value, + "Error"); +static_assert(!std::is_constructible<std::nullptr_t, void, void>::value, + "Error"); +static_assert(!std::is_constructible<const std::nullptr_t, void, void>::value, + "Error"); +static_assert(!std::is_constructible<E, int, int>::value, "Error"); +static_assert(!std::is_constructible<const E, int, int>::value, "Error"); +static_assert(!std::is_constructible<E, void, int>::value, "Error"); +static_assert(!std::is_constructible<const E, void, int>::value, "Error"); +static_assert(!std::is_constructible<E, void, void>::value, "Error"); +static_assert(!std::is_constructible<const E, void, void>::value, "Error"); +static_assert(!std::is_constructible<SE, int, int>::value, "Error"); +static_assert(!std::is_constructible<const SE, int, int>::value, "Error"); +static_assert(!std::is_constructible<SE, void, int>::value, "Error"); +static_assert(!std::is_constructible<const SE, void, int>::value, "Error"); +static_assert(!std::is_constructible<SE, void, void>::value, "Error"); +static_assert(!std::is_constructible<const SE, void, void>::value, "Error"); +static_assert(!std::is_constructible<OpE, int, int>::value, "Error"); +static_assert(!std::is_constructible<const OpE, int, int>::value, "Error"); +static_assert(!std::is_constructible<OpE, void, int>::value, "Error"); +static_assert(!std::is_constructible<const OpE, void, int>::value, "Error"); +static_assert(!std::is_constructible<OpE, void, void>::value, "Error"); +static_assert(!std::is_constructible<const OpE, void, void>::value, "Error"); +static_assert(!std::is_constructible<OpSE, int, int>::value, "Error"); +static_assert(!std::is_constructible<const OpSE, int, int>::value, "Error"); +static_assert(!std::is_constructible<OpSE, void, int>::value, "Error"); +static_assert(!std::is_constructible<const OpSE, void, int>::value, "Error"); +static_assert(!std::is_constructible<OpSE, void, void>::value, "Error"); +static_assert(!std::is_constructible<const OpSE, void, void>::value, "Error"); +static_assert(!std::is_constructible<Empty, int, int>::value, "Error"); +static_assert(!std::is_constructible<const Empty, int, int>::value, "Error"); +static_assert(!std::is_constructible<Empty, void, int>::value, "Error"); +static_assert(!std::is_constructible<const Empty, void, int>::value, "Error"); +static_assert(!std::is_constructible<Empty, void, void>::value, "Error"); +static_assert(!std::is_constructible<const Empty, void, void>::value, "Error"); +static_assert(!std::is_constructible<U, int, int>::value, "Error"); +static_assert(!std::is_constructible<const U, int, int>::value, "Error"); +static_assert(!std::is_constructible<U, void, int>::value, "Error"); +static_assert(!std::is_constructible<const U, void, int>::value, "Error"); +static_assert(!std::is_constructible<U, void, void>::value, "Error"); +static_assert(!std::is_constructible<const U, void, void>::value, "Error"); +static_assert(!std::is_constructible<B, int, int>::value, "Error"); +static_assert(!std::is_constructible<const B, int, int>::value, "Error"); +static_assert(!std::is_constructible<B, void, int>::value, "Error"); +static_assert(!std::is_constructible<const B, void, int>::value, "Error"); +static_assert(!std::is_constructible<B, void, void>::value, "Error"); +static_assert(!std::is_constructible<const B, void, void>::value, "Error"); +static_assert(!std::is_constructible<Any, int, int>::value, "Error"); +static_assert(!std::is_constructible<const Any, int, int>::value, "Error"); +static_assert(!std::is_constructible<Any, void, int>::value, "Error"); +static_assert(!std::is_constructible<const Any, void, int>::value, "Error"); +static_assert(!std::is_constructible<Any, void, void>::value, "Error"); +static_assert(!std::is_constructible<const Any, void, void>::value, "Error"); +static_assert(!std::is_constructible<nAny, void, int>::value, "Error"); +static_assert(!std::is_constructible<const nAny, void, int>::value, "Error"); +static_assert(!std::is_constructible<nAny, void, void>::value, "Error"); +static_assert(!std::is_constructible<const nAny, void, void>::value, "Error"); +static_assert(!std::is_constructible<FromArgs<>, int, int>::value, "Error"); +static_assert(!std::is_constructible<const FromArgs<>, int, int>::value, + "Error"); +static_assert(!std::is_constructible<FromArgs<>, void, int>::value, "Error"); +static_assert(!std::is_constructible<const FromArgs<>, void, int>::value, + "Error"); +static_assert(!std::is_constructible<FromArgs<>, void, void>::value, "Error"); +static_assert(!std::is_constructible<const FromArgs<>, void, void>::value, + "Error"); +static_assert(!std::is_constructible<Abstract, int, int>::value, "Error"); +static_assert(!std::is_constructible<const Abstract, int, int>::value, "Error"); +static_assert(!std::is_constructible<Abstract, void, int>::value, "Error"); +static_assert(!std::is_constructible<const Abstract, void, int>::value, + "Error"); +static_assert(!std::is_constructible<Abstract, void, void>::value, "Error"); +static_assert(!std::is_constructible<const Abstract, void, void>::value, + "Error"); +static_assert(!std::is_constructible<AbstractDelDtor, int, int>::value, + "Error"); +static_assert(!std::is_constructible<const AbstractDelDtor, int, int>::value, + "Error"); +static_assert(!std::is_constructible<AbstractDelDtor, void, int>::value, + "Error"); +static_assert(!std::is_constructible<const AbstractDelDtor, void, int>::value, + "Error"); +static_assert(!std::is_constructible<AbstractDelDtor, void, void>::value, + "Error"); +static_assert(!std::is_constructible<const AbstractDelDtor, void, void>::value, + "Error"); +static_assert(!std::is_constructible<int[1], int, int>::value, "Error"); +static_assert(!std::is_constructible<const int[1], int, int>::value, "Error"); +static_assert(!std::is_constructible<int[1], void, int>::value, "Error"); +static_assert(!std::is_constructible<const int[1], void, int>::value, "Error"); +static_assert(!std::is_constructible<int[1], void, void>::value, "Error"); +static_assert(!std::is_constructible<const int[1], void, void>::value, "Error"); +static_assert(!std::is_constructible<int&, int, int>::value, "Error"); +static_assert(!std::is_constructible<int&, void, int>::value, "Error"); +static_assert(!std::is_constructible<int&, void, void>::value, "Error"); +static_assert(!std::is_constructible<int&, int&, int&>::value, "Error"); +static_assert(!std::is_constructible<int&, void, int&>::value, "Error"); +static_assert(!std::is_constructible<int&, void, void>::value, "Error"); +static_assert(!std::is_constructible<std::nullptr_t&, int, int>::value, + "Error"); +static_assert(!std::is_constructible<std::nullptr_t&, void, int>::value, + "Error"); +static_assert(!std::is_constructible<std::nullptr_t&, void, void>::value, + "Error"); +static_assert(!std::is_constructible<E&, int, int>::value, "Error"); +static_assert(!std::is_constructible<E&, void, int>::value, "Error"); +static_assert(!std::is_constructible<E&, void, void>::value, "Error"); +static_assert(!std::is_constructible<SE&, int, int>::value, "Error"); +static_assert(!std::is_constructible<SE&, void, int>::value, "Error"); +static_assert(!std::is_constructible<SE&, void, void>::value, "Error"); +static_assert(!std::is_constructible<OpE&, int, int>::value, "Error"); +static_assert(!std::is_constructible<OpE&, void, int>::value, "Error"); +static_assert(!std::is_constructible<OpE&, void, void>::value, "Error"); +static_assert(!std::is_constructible<OpSE&, int, int>::value, "Error"); +static_assert(!std::is_constructible<OpSE&, void, int>::value, "Error"); +static_assert(!std::is_constructible<OpSE&, void, void>::value, "Error"); +static_assert(!std::is_constructible<Empty&, int, int>::value, "Error"); +static_assert(!std::is_constructible<Empty&, void, int>::value, "Error"); +static_assert(!std::is_constructible<Empty&, void, void>::value, "Error"); +static_assert(!std::is_constructible<U&, int, int>::value, "Error"); +static_assert(!std::is_constructible<U&, void, int>::value, "Error"); +static_assert(!std::is_constructible<U&, void, void>::value, "Error"); +static_assert(!std::is_constructible<B&, int, int>::value, "Error"); +static_assert(!std::is_constructible<B&, void, int>::value, "Error"); +static_assert(!std::is_constructible<B&, void, void>::value, "Error"); +static_assert(!std::is_constructible<Any&, int, int>::value, "Error"); +static_assert(!std::is_constructible<Any&, void, int>::value, "Error"); +static_assert(!std::is_constructible<Any&, void, void>::value, "Error"); +static_assert(!std::is_constructible<nAny&, void, int>::value, "Error"); +static_assert(!std::is_constructible<nAny&, void, void>::value, "Error"); +static_assert(!std::is_constructible<FromArgs<>&, int, int>::value, "Error"); +static_assert(!std::is_constructible<FromArgs<>&, void, int>::value, "Error"); +static_assert(!std::is_constructible<FromArgs<>&, void, void>::value, "Error"); +static_assert(!std::is_constructible<Abstract&, int, int>::value, "Error"); +static_assert(!std::is_constructible<Abstract&, void, int>::value, "Error"); +static_assert(!std::is_constructible<Abstract&, void, void>::value, "Error"); +static_assert(!std::is_constructible<int(&)[1], int, int>::value, "Error"); +static_assert(!std::is_constructible<int(&)[1], void, int>::value, "Error"); +static_assert(!std::is_constructible<int(&)[1], void, void>::value, "Error"); + +static_assert(!std::is_constructible<void(), int, int>::value, "Error"); +static_assert(!std::is_constructible<void(), void, int>::value, "Error"); +static_assert(!std::is_constructible<void(), void, void>::value, "Error"); +static_assert(!std::is_constructible<void(), void(), int>::value, "Error"); +static_assert(!std::is_constructible<void(), void(), void()>::value, "Error"); + +static_assert(!std::is_constructible<void() const, int, int>::value, "Error"); +static_assert(!std::is_constructible<void() const, void, int>::value, "Error"); +static_assert(!std::is_constructible<void() const, void, void>::value, "Error"); +static_assert(!std::is_constructible<void() const, void() volatile, + int>::value, "Error"); +static_assert(!std::is_constructible<void() const, void() volatile const, + void() const>::value, "Error"); + +static_assert(!std::is_constructible<FromArgs<int>, int, int>::value, "Error"); +static_assert(!std::is_constructible<const FromArgs<int>, int, int>::value, + "Error"); +static_assert(!std::is_constructible<FromArgs<int>, void, int>::value, "Error"); +static_assert(!std::is_constructible<const FromArgs<int>, void, int>::value, + "Error"); +static_assert(!std::is_constructible<FromArgs<int, int>, void, int>::value, + "Error"); +static_assert(!std::is_constructible<const FromArgs<int, int>, void, + int>::value, "Error"); + +static_assert(!std::is_constructible<DelDtor, int, B, U>::value, "Error"); +static_assert(!std::is_constructible<const DelDtor, int, B, U>::value, "Error"); +static_assert(!std::is_constructible<DelDtor, int>::value, "Error"); +static_assert(!std::is_constructible<const DelDtor, int>::value, "Error"); +static_assert(!std::is_constructible<DelDtor>::value, "Error"); +static_assert(!std::is_constructible<const DelDtor>::value, "Error"); +static_assert(!std::is_constructible<DelDtor, void*, void(&)()>::value, + "Error"); +static_assert(!std::is_constructible<const DelDtor, void*, void(&)()>::value, + "Error"); + +static_assert(!std::is_constructible<AbstractDelDtor>::value, "Error"); +static_assert(!std::is_constructible<const AbstractDelDtor>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis>::value, "Error"); +static_assert(!std::is_constructible<const DelEllipsis>::value, "Error"); +static_assert(!std::is_constructible<DelEllipsis, double>::value, "Error"); +static_assert(!std::is_constructible<const DelEllipsis, double>::value, + "Error"); +static_assert(!std::is_constructible<DelEllipsis, double, int&>::value, + "Error"); +static_assert(!std::is_constructible<const DelEllipsis, double, int&>::value, + "Error"); +static_assert(!std::is_constructible<DelnAny>::value, "Error"); +static_assert(!std::is_constructible<const DelnAny>::value, "Error"); +static_assert(!std::is_constructible<DelnAny, int>::value, "Error"); +static_assert(!std::is_constructible<const DelnAny, int>::value, "Error"); +static_assert(!std::is_constructible<DelnAny, int, void*>::value, "Error"); +static_assert(!std::is_constructible<const DelnAny, int, void*>::value, + "Error"); +static_assert(!std::is_constructible<DelnAny, Empty, B, D>::value, "Error"); +static_assert(!std::is_constructible<const DelnAny, Empty, B, D>::value, + "Error"); + +// Deleted members in unions with non-trivial members: +static_assert(!std::is_constructible<NontrivialUnion>::value, "Error"); +static_assert(!std::is_constructible<NontrivialUnion, + const NontrivialUnion&>::value, "Error"); + +// Unusual copy: +static_assert(!std::is_constructible<UnusualCopy>::value, "Error"); +static_assert(!std::is_constructible<UnusualCopy, UnusualCopy>::value, "Error"); +static_assert(!std::is_constructible<UnusualCopy, + UnusualCopy&&>::value, "Error"); +static_assert(!std::is_constructible<UnusualCopy, + const UnusualCopy&>::value, "Error"); +static_assert(std::is_constructible<UnusualCopy, UnusualCopy&>::value, "Error"); + +static_assert(std::is_constructible<FromArgs<int, char>, + int, char>::value, "Error"); +static_assert(std::is_constructible<const FromArgs<int, char>, + int, char>::value, "Error"); +static_assert(std::is_constructible<FromArgs<int, char>, + int, int>::value, "Error"); +static_assert(std::is_constructible<const FromArgs<int, char>, + int, int>::value, "Error"); +static_assert(std::is_constructible<nAny, int, int>::value, "Error"); +static_assert(std::is_constructible<const nAny, int, int>::value, "Error"); +static_assert(std::is_constructible<FromArgs<int, char>, + ImplicitTo<int>, ImplicitTo<char>>::value, "Error"); +static_assert(std::is_constructible<const FromArgs<int, char>, + ImplicitTo<int>, ImplicitTo<char>>::value, "Error"); +static_assert(std::is_constructible<Ellipsis, int, char>::value, "Error"); +static_assert(std::is_constructible<const Ellipsis, int, char>::value, "Error"); +static_assert(std::is_constructible<Ellipsis, B, U, int&>::value, "Error"); +static_assert(std::is_constructible<const Ellipsis, + B, U, int&>::value, "Error"); +static_assert(std::is_constructible<nAny, B, U, int&>::value, "Error"); +static_assert(std::is_constructible<const nAny, B, U, int&>::value, "Error"); +static_assert(std::is_constructible<FromArgs<std::initializer_list<int>, + std::initializer_list<B>>, std::initializer_list<int>, + std::initializer_list<B>>::value, "Error"); +static_assert(std::is_constructible<const FromArgs<std::initializer_list<int>, + std::initializer_list<B>>, std::initializer_list<int>, + std::initializer_list<B>>::value, "Error"); +static_assert(std::is_constructible<FromArgs<std::initializer_list<int>, + std::initializer_list<B>>, std::initializer_list<int>&, + std::initializer_list<B>&>::value, "Error"); +static_assert(!std::is_constructible<FromArgs<std::initializer_list<int>&, + std::initializer_list<B>&>, std::initializer_list<int>, + std::initializer_list<B>>::value, "Error"); + +static_assert(!std::is_constructible<FromArgs<std::initializer_list<int>>, + int, int>::value, "Error"); +static_assert(!std::is_constructible<const + FromArgs<std::initializer_list<int>>, int, int>::value, "Error"); +static_assert(!std::is_constructible<B[2], B, B>::value, "Error"); +static_assert(!std::is_constructible<const B[2], B, B>::value, "Error"); +static_assert(!std::is_constructible<U[2], U, U>::value, "Error"); +static_assert(!std::is_constructible<const U[2], U, U>::value, "Error"); + +static_assert(!std::is_constructible<E, E, E>::value, "Error"); +static_assert(!std::is_constructible<const E, E, E>::value, "Error"); +static_assert(!std::is_constructible<SE, SE, SE>::value, "Error"); +static_assert(!std::is_constructible<const SE, SE, SE>::value, "Error"); +static_assert(!std::is_constructible<E, B, std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<const E, B, std::nullptr_t>::value, + "Error"); +static_assert(!std::is_constructible<SE, B, std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<const SE, B, std::nullptr_t>::value, + "Error"); +static_assert(!std::is_constructible<E, int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<const E, int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<SE, int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<const SE, int[], int[]>::value, "Error"); + +static_assert(!std::is_constructible<OpE, OpE, OpE>::value, "Error"); +static_assert(!std::is_constructible<const OpE, OpE, OpE>::value, "Error"); +static_assert(!std::is_constructible<OpSE, OpSE, OpSE>::value, "Error"); +static_assert(!std::is_constructible<const OpSE, OpSE, OpSE>::value, "Error"); +static_assert(!std::is_constructible<OpE, B, std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<const OpE, B, std::nullptr_t>::value, + "Error"); +static_assert(!std::is_constructible<OpSE, B, std::nullptr_t>::value, "Error"); +static_assert(!std::is_constructible<const OpSE, B, std::nullptr_t>::value, + "Error"); +static_assert(!std::is_constructible<OpE, int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<const OpE, int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<OpSE, int[], int[]>::value, "Error"); +static_assert(!std::is_constructible<const OpSE, int[], int[]>::value, "Error"); + +static_assert(!std::is_constructible<int[], int, int>::value, "Error"); +static_assert(!std::is_constructible<const int[], int, int>::value, "Error"); + +static_assert(std::is_constructible<int&, ImplicitTo<int&>>::value, "Error"); +static_assert(std::is_constructible<const int&, ImplicitTo<int&&>>::value, + "Error"); +static_assert(std::is_constructible<int&&, ImplicitTo<int&&>>::value, "Error"); +static_assert(std::is_constructible<const int&, ImplicitTo<int>>::value, + "Error"); + +static_assert(!std::is_constructible<const int&, ExplicitTo<int>>::value, + "Error"); +static_assert(!std::is_constructible<int&&, ExplicitTo<int>>::value, "Error"); + +// Binding through reference-compatible type is required to perform +// direct-initialization as described in [over.match.ref] p. 1 b. 1: +static_assert(std::is_constructible<int&, ExplicitTo<int&>>::value, "Error"); +static_assert(std::is_constructible<const int&, ExplicitTo<int&&>>::value, + "Error"); +static_assert(std::is_constructible<int&&, ExplicitTo<int&&>>::value, "Error"); + +// Binding through temporary behaves like copy-initialization, +// see [dcl.init.ref] p. 5, very last sub-bullet: +static_assert(!std::is_constructible<const int&, ExplicitTo<double&&>>::value, + "Error"); +static_assert(!std::is_constructible<int&&, ExplicitTo<double&&>>::value, + "Error"); + +static_assert(std::is_constructible<void(&&)(), void(&)()>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/value.cc new file mode 100644 index 000000000..3a71f1700 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_constructible/value.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// Copyright (C) 2009-2014 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_tr1.h> + +void test01() +{ + using std::is_constructible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_constructible, + ExplicitClass, double&>(true), ""); + static_assert(test_property<is_constructible, ExplicitClass, int&>(true), ""); + + // Negative tests. + static_assert(test_property<is_constructible, + ExplicitClass, void*>(false), ""); + static_assert(test_property<is_constructible, ExplicitClass>(false), ""); + static_assert(test_property<is_constructible, ExplicitClass, + int, double>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..b668b39b4 --- /dev/null +++ b/gcc-4.9/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-2014 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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc new file mode 100644 index 000000000..2e52b5932 --- /dev/null +++ b/gcc-4.9/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-2014 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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_convertible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_convertible/value.cc new file mode 100644 index 000000000..cea9ea4b8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_convertible/value.cc @@ -0,0 +1,118 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009-2014 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_tr1.h> + +void test01() +{ + using std::is_convertible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_relationship<is_convertible, int, int>(true), ""); + static_assert(test_relationship<is_convertible, int, const int>(true), ""); + static_assert(test_relationship<is_convertible, + volatile int, const int>(true), ""); + static_assert(test_relationship<is_convertible, int, float>(true), ""); + static_assert(test_relationship<is_convertible, double, float>(true), ""); + static_assert(test_relationship<is_convertible, float, int>(true), ""); + static_assert(test_relationship<is_convertible, int*, const int*>(true), ""); + static_assert(test_relationship<is_convertible, int*, void*>(true), ""); + static_assert(test_relationship<is_convertible, int[4], int*>(true), ""); + static_assert(test_relationship<is_convertible, float&, int>(true), ""); + static_assert(test_relationship<is_convertible, int, const int&>(true), ""); + static_assert(test_relationship<is_convertible, const int&, int>(true), ""); + static_assert(test_relationship<is_convertible, float, const int&>(true), ""); + static_assert(test_relationship<is_convertible, int(int), + int(*)(int)>(true), ""); + static_assert(test_relationship<is_convertible, + int(&)(int), int(*)(int)>(true), ""); + static_assert(test_relationship<is_convertible, EnumType, int>(true), ""); + static_assert(test_relationship<is_convertible, ClassType, + ClassType>(true), ""); + static_assert(test_relationship<is_convertible, DerivedType, + ClassType>(true), ""); + static_assert(test_relationship<is_convertible, DerivedType*, + ClassType*>(true), ""); + static_assert(test_relationship<is_convertible, DerivedType&, + ClassType&>(true), ""); + + static_assert(test_relationship<is_convertible, const int, + const int&>(true), ""); + + static_assert(test_relationship<is_convertible, void, void>(true), ""); + static_assert(test_relationship<is_convertible, const void, void>(true), ""); + static_assert(test_relationship<is_convertible, void, + volatile void>(true), ""); + static_assert(test_relationship<is_convertible, double&, + ExplicitClass>(true), ""); + + static_assert(test_relationship<is_convertible, int(int), + int(&)(int)>(true), ""); + + // Negative tests. + static_assert(test_relationship<is_convertible, const int*, int*>(false), ""); + static_assert(test_relationship<is_convertible, int*, float*>(false), ""); + static_assert(test_relationship<is_convertible, const int[4], + int*>(false), ""); + static_assert(test_relationship<is_convertible, int[4], int[4]>(false), ""); + static_assert(test_relationship<is_convertible, const int&, int&>(false), ""); + static_assert(test_relationship<is_convertible, float&, int&>(false), ""); + static_assert(test_relationship<is_convertible, float, + volatile int&>(false), ""); + static_assert(test_relationship<is_convertible, int(int), + int(int)>(false), ""); + static_assert(test_relationship<is_convertible, int(int), + int(*)(void)>(false), ""); + static_assert(test_relationship<is_convertible, int(*)(int), + int(&)(int)>(false), ""); + static_assert(test_relationship<is_convertible, int, EnumType>(false), ""); + static_assert(test_relationship<is_convertible, int, ClassType>(false), ""); + static_assert(test_relationship<is_convertible, ClassType, + DerivedType>(false), ""); + static_assert(test_relationship<is_convertible, ClassType*, + DerivedType*>(false), ""); + static_assert(test_relationship<is_convertible, ClassType&, + DerivedType&>(false), ""); + + static_assert(test_relationship<is_convertible, void, int>(false), ""); + static_assert(test_relationship<is_convertible, void, float>(false), ""); + static_assert(test_relationship<is_convertible, void, + int(*)(int)>(false), ""); + + // C++0x + static_assert(test_relationship<is_convertible, int, void>(false), ""); + static_assert(test_relationship<is_convertible, int[4], void>(false), ""); + + static_assert(test_relationship<is_convertible, int, int&>(false), ""); + static_assert(test_relationship<is_convertible, float, + volatile float&>(false), ""); + static_assert(test_relationship<is_convertible, const volatile int, + const volatile int&>(false), ""); + static_assert(test_relationship<is_convertible, volatile int, + volatile int&>(false), ""); + static_assert(test_relationship<is_convertible, int&, + ExplicitClass>(false), ""); + static_assert(test_relationship<is_convertible, void*, + ExplicitClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..cff033966 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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_copy_assignable<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/requirements/typedefs.cc new file mode 100644 index 000000000..5e2a88607 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_copy_assignable<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/value.cc new file mode 100644 index 000000000..eb23e5857 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_assignable/value.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_copy_assignable; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_copy_assignable, int>(true), ""); + static_assert(test_property<is_copy_assignable, float>(true), ""); + static_assert(test_property<is_copy_assignable, EnumType>(true), ""); + static_assert(test_property<is_copy_assignable, int*>(true), ""); + static_assert(test_property<is_copy_assignable, int(*)(int)>(true), ""); + static_assert(test_property<is_copy_assignable, + int (ClassType::*)>(true), ""); + static_assert(test_property<is_copy_assignable, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_copy_assignable, + NoexceptCopyAssignClass>(true), ""); + static_assert(test_property<is_copy_assignable, + ExceptCopyAssignClass>(true), ""); + + // Negative tests. + static_assert(test_property<is_copy_assignable, void>(false), ""); + static_assert(test_property<is_copy_assignable, int[2]>(false), ""); + static_assert(test_property<is_copy_assignable, float[][3]>(false), ""); + static_assert(test_property<is_copy_assignable, + EnumType[2][3][4]>(false), ""); + static_assert(test_property<is_copy_assignable, int*[3]>(false), ""); + static_assert(test_property<is_copy_assignable, + int(*[][2])(int)>(false), ""); + static_assert(test_property<is_copy_assignable, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_property<is_copy_assignable, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_property<is_copy_assignable, + ClassType(unsigned) const &>(false), ""); + static_assert(test_property<is_copy_assignable, + bool(ClassType) const>(false), ""); + static_assert(test_property<is_copy_assignable, + bool(...) &&>(false), ""); + static_assert(test_property<is_copy_assignable, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_copy_assignable, + NoexceptMoveAssignClass>(false), ""); + static_assert(test_property<is_copy_assignable, + ExceptMoveAssignClass>(false), ""); + static_assert(test_property<is_copy_assignable, + DeletedCopyAssignClass>(false), ""); + static_assert(test_property<is_copy_assignable, + DeletedMoveAssignClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..35975f7ab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_copy_constructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..72f8cc4f4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_copy_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/value.cc new file mode 100644 index 000000000..9cd9b5446 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_copy_constructible/value.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_copy_constructible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_copy_constructible, int>(true), ""); + static_assert(test_category<is_copy_constructible, float>(true), ""); + static_assert(test_category<is_copy_constructible, EnumType>(true), ""); + static_assert(test_category<is_copy_constructible, int*>(true), ""); + static_assert(test_category<is_copy_constructible, int(*)(int)>(true), ""); + static_assert(test_category<is_copy_constructible, + int (ClassType::*)>(true), ""); + static_assert(test_category<is_copy_constructible, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_copy_constructible, + NoexceptCopyConsClass>(true), ""); + static_assert(test_property<is_copy_constructible, + const NoexceptCopyConsClass>(true), ""); + static_assert(test_property<is_copy_constructible, + ThrowCopyConsClass>(true), ""); + static_assert(test_property<is_copy_constructible, + ExceptCopyConsClass>(true), ""); + + // Negative tests. + static_assert(test_category<is_copy_constructible, void>(false), ""); + static_assert(test_category<is_copy_constructible, int[2]>(false), ""); + static_assert(test_category<is_copy_constructible, int[]>(false), ""); + static_assert(test_category<is_copy_constructible, float[][3]>(false), ""); + static_assert(test_category<is_copy_constructible, + EnumType[2][3][4]>(false), ""); + static_assert(test_category<is_copy_constructible, int*[3]>(false), ""); + static_assert(test_category<is_copy_constructible, + int(*[][2])(int)>(false), ""); + static_assert(test_category<is_copy_constructible, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_category<is_copy_constructible, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_category<is_copy_constructible, + ClassType(unsigned) const &>(false), ""); + static_assert(test_category<is_copy_constructible, + bool(ClassType) const>(false), ""); + static_assert(test_category<is_copy_constructible, + bool(...) &&>(false), ""); + static_assert(test_category<is_copy_constructible, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_copy_constructible, + volatile NoexceptCopyConsClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..0d1e1db90 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_default_constructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..61c4d08b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_default_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc new file mode 100644 index 000000000..826e81a64 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc @@ -0,0 +1,141 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <initializer_list> +#include <testsuite_tr1.h> + +using namespace __gnu_test::construct; + +static_assert(std::is_default_constructible<int>::value, "Error"); +static_assert(std::is_default_constructible<int const>::value, "Error"); +static_assert(std::is_default_constructible<int const volatile>::value, + "Error"); +static_assert(std::is_default_constructible<int*>::value, "Error"); +static_assert(std::is_default_constructible<void*>::value, "Error"); +static_assert(std::is_default_constructible<void* const>::value, "Error"); +static_assert(std::is_default_constructible<int B::*>::value, "Error"); +static_assert(std::is_default_constructible<void(*)()>::value, "Error"); +static_assert(std::is_default_constructible<std::nullptr_t>::value, "Error"); +static_assert(std::is_default_constructible<std::nullptr_t const>::value, + "Error"); +static_assert(std::is_default_constructible<Empty>::value, "Error"); +static_assert(std::is_default_constructible<Empty const>::value, "Error"); +static_assert(std::is_default_constructible<FromArgs<>>::value, "Error"); +static_assert(std::is_default_constructible<FromArgs<> const>::value, "Error"); +static_assert(std::is_default_constructible<nAny>::value, "Error"); +static_assert(std::is_default_constructible<nAny const>::value, "Error"); +static_assert(std::is_default_constructible<Ellipsis>::value, "Error"); +static_assert(std::is_default_constructible<Ellipsis const>::value, "Error"); +static_assert(std::is_default_constructible<U>::value, "Error"); +static_assert(std::is_default_constructible<U const>::value, "Error"); +static_assert(std::is_default_constructible<E>::value, "Error"); +static_assert(std::is_default_constructible<E const>::value, "Error"); +static_assert(std::is_default_constructible<SE>::value, "Error"); +static_assert(std::is_default_constructible<SE const>::value, "Error"); +static_assert(std::is_default_constructible<OpE>::value, "Error"); +static_assert(std::is_default_constructible<OpE const>::value, "Error"); +static_assert(std::is_default_constructible<OpSE>::value, "Error"); +static_assert(std::is_default_constructible<OpSE const>::value, "Error"); +static_assert(std::is_default_constructible<int[1]>::value, "Error"); +static_assert(std::is_default_constructible<const int[1]>::value, "Error"); +static_assert(std::is_default_constructible<int[1][2]>::value, "Error"); +static_assert(std::is_default_constructible<const int[1][2]>::value, "Error"); +static_assert(std::is_default_constructible<FromArgs<>[1]>::value, "Error"); +static_assert(std::is_default_constructible<const FromArgs<>[1]>::value, + "Error"); +static_assert(std::is_default_constructible<U[1]>::value, "Error"); +static_assert(std::is_default_constructible<const U[1]>::value, "Error"); +static_assert(std::is_default_constructible<Empty[1]>::value, "Error"); +static_assert(std::is_default_constructible<const Empty[1]>::value, "Error"); +static_assert(std::is_default_constructible<Ellipsis[1]>::value, "Error"); +static_assert(std::is_default_constructible<const Ellipsis[1]>::value, "Error"); +static_assert(std::is_default_constructible<std::nullptr_t[1]>::value, "Error"); +static_assert(std::is_default_constructible<const std::nullptr_t[1]>::value, + "Error"); +static_assert(std::is_default_constructible<nAny[1]>::value, "Error"); +static_assert(std::is_default_constructible<const nAny[1]>::value, "Error"); +static_assert(std::is_default_constructible<E[1]>::value, "Error"); +static_assert(std::is_default_constructible<const E[1]>::value, "Error"); +static_assert(std::is_default_constructible<SE[1]>::value, "Error"); +static_assert(std::is_default_constructible<const SE[1]>::value, "Error"); +static_assert(std::is_default_constructible<OpE[1]>::value, "Error"); +static_assert(std::is_default_constructible<const OpE[1]>::value, "Error"); +static_assert(std::is_default_constructible<OpSE[1]>::value, "Error"); +static_assert(std::is_default_constructible<const OpSE[1]>::value, "Error"); +static_assert(std::is_default_constructible<int*[1]>::value, "Error"); +static_assert(std::is_default_constructible<int* const[1]>::value, "Error"); +static_assert(std::is_default_constructible<int B::*[1]>::value, "Error"); +static_assert(std::is_default_constructible<int B::* const[1]>::value, "Error"); +static_assert(std::is_default_constructible<std::initializer_list<int>>::value, + "Error"); +static_assert(std::is_default_constructible<const + std::initializer_list<int>>::value, "Error"); +static_assert(std::is_default_constructible< + std::initializer_list<int>[1]>::value, "Error"); +static_assert(std::is_default_constructible<const + std::initializer_list<int>[1]>::value, "Error"); + +static_assert(std::is_default_constructible + <__gnu_test::NoexceptDefaultClass>::value, "Error"); +static_assert(std::is_default_constructible + <__gnu_test::ThrowDefaultClass>::value, "Error"); +static_assert(std::is_default_constructible + <__gnu_test::ExceptDefaultClass>::value, "Error"); + +static_assert(!std::is_default_constructible<void>::value, "Error"); +static_assert(!std::is_default_constructible<const void>::value, "Error"); +static_assert(!std::is_default_constructible<Abstract>::value, "Error"); +static_assert(!std::is_default_constructible<const Abstract>::value, "Error"); +static_assert(!std::is_default_constructible<Any>::value, "Error"); +static_assert(!std::is_default_constructible<const Any>::value, "Error"); +static_assert(!std::is_default_constructible<FromArgs<int>>::value, "Error"); +static_assert(!std::is_default_constructible<const FromArgs<int>>::value, + "Error"); +static_assert(!std::is_default_constructible<int&>::value, "Error"); +static_assert(!std::is_default_constructible<int&&>::value, "Error"); +static_assert(!std::is_default_constructible<void()>::value, "Error"); +static_assert(!std::is_default_constructible<void() const volatile>::value, + "Error"); +static_assert(!std::is_default_constructible<void(&)()>::value, "Error"); +static_assert(!std::is_default_constructible<int(&)[1]>::value, "Error"); +static_assert(!std::is_default_constructible<int(&)[]>::value, "Error"); +static_assert(!std::is_default_constructible<int[]>::value, "Error"); +static_assert(!std::is_default_constructible<const int[]>::value, "Error"); +static_assert(!std::is_default_constructible<int[][1][2]>::value, "Error"); +static_assert(!std::is_default_constructible<const int[][1][2]>::value, + "Error"); +static_assert(!std::is_default_constructible<Any[1]>::value, "Error"); +static_assert(!std::is_default_constructible<const Any[1]>::value, "Error"); +static_assert(!std::is_default_constructible<FromArgs<int>[1]>::value, "Error"); +static_assert(!std::is_default_constructible<const FromArgs<int>[1]>::value, + "Error"); +static_assert(!std::is_default_constructible< + FromArgs<std::initializer_list<int>>>::value, "Error"); +static_assert(!std::is_default_constructible<const + FromArgs<std::initializer_list<int>>>::value, "Error"); +static_assert(!std::is_default_constructible<const + FromArgs<const std::initializer_list<int>>>::value, "Error"); +static_assert(!std::is_default_constructible<DelDef>::value, "Error"); +static_assert(!std::is_default_constructible<const DelDef>::value, "Error"); +static_assert(!std::is_default_constructible<DelCopy>::value, "Error"); +static_assert(!std::is_default_constructible<const DelCopy>::value, "Error"); +static_assert(!std::is_default_constructible<DelDtor>::value, "Error"); +static_assert(!std::is_default_constructible<const DelDtor>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..c0f5e8587 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_destructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/requirements/typedefs.cc new file mode 100644 index 000000000..7dd7a2c01 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_destructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/value.cc new file mode 100644 index 000000000..766c1fdc3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_destructible/value.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <initializer_list> +#include <testsuite_tr1.h> + +using namespace __gnu_test::destruct; + +static_assert(std::is_destructible<int>::value, "Error"); +static_assert(std::is_destructible<const int>::value, "Error"); +static_assert(std::is_destructible<bool>::value, "Error"); +static_assert(std::is_destructible<const bool>::value, "Error"); +static_assert(std::is_destructible<int*>::value, "Error"); +static_assert(std::is_destructible<void*>::value, "Error"); +static_assert(std::is_destructible<int Der::*>::value, "Error"); +static_assert(std::is_destructible<const int Der::*>::value, "Error"); +static_assert(std::is_destructible<void (Der::*)() const>::value, "Error"); +static_assert(std::is_destructible<void(*)()>::value, "Error"); +static_assert(std::is_destructible<En>::value, "Error"); +static_assert(std::is_destructible<const En>::value, "Error"); +static_assert(std::is_destructible<En2>::value, "Error"); +static_assert(std::is_destructible<const En2>::value, "Error"); +static_assert(std::is_destructible<OpE>::value, "Error"); +static_assert(std::is_destructible<const OpE>::value, "Error"); +static_assert(std::is_destructible<OpSE>::value, "Error"); +static_assert(std::is_destructible<const OpSE>::value, "Error"); +static_assert(std::is_destructible<std::nullptr_t>::value, "Error"); +static_assert(std::is_destructible<const std::nullptr_t>::value, "Error"); +static_assert(std::is_destructible<Der>::value, "Error"); +static_assert(std::is_destructible<const Der>::value, "Error"); +static_assert(std::is_destructible<Aggr>::value, "Error"); +static_assert(std::is_destructible<const Aggr>::value, "Error"); +static_assert(std::is_destructible<E>::value, "Error"); +static_assert(std::is_destructible<const E>::value, "Error"); +static_assert(std::is_destructible<U1>::value, "Error"); +static_assert(std::is_destructible<const U1>::value, "Error"); +static_assert(std::is_destructible<Abstract1>::value, "Error"); +static_assert(std::is_destructible<const Abstract1>::value, "Error"); +static_assert(std::is_destructible<int[1]>::value, "Error"); +static_assert(std::is_destructible<const int[1]>::value, "Error"); +static_assert(std::is_destructible<int[1][2]>::value, "Error"); +static_assert(std::is_destructible<const int[1][2]>::value, "Error"); +static_assert(std::is_destructible<int&>::value, "Error"); +static_assert(std::is_destructible<int&&>::value, "Error"); +static_assert(std::is_destructible<int(&)[1]>::value, "Error"); +static_assert(std::is_destructible<const int(&)[1]>::value, "Error"); +static_assert(std::is_destructible<void(&)()>::value, "Error"); +static_assert(std::is_destructible<Ellipsis>::value, "Error"); +static_assert(std::is_destructible<const Ellipsis>::value, "Error"); +static_assert(std::is_destructible<Abstract2>::value, "Error"); +static_assert(std::is_destructible<const Abstract2>::value, "Error"); +static_assert(std::is_destructible<Aggr2>::value, "Error"); +static_assert(std::is_destructible<const Aggr2>::value, "Error"); +static_assert(std::is_destructible<DelDef>::value, "Error"); +static_assert(std::is_destructible<const DelDef>::value, "Error"); +static_assert(std::is_destructible<DelCopy>::value, "Error"); +static_assert(std::is_destructible<const DelCopy>::value, "Error"); +static_assert(std::is_destructible<DelEllipsis>::value, "Error"); +static_assert(std::is_destructible<const DelEllipsis>::value, "Error"); +static_assert(std::is_destructible<std::initializer_list<int>>::value, + "Error"); +static_assert(std::is_destructible<const std::initializer_list<int>>::value, + "Error"); +static_assert(std::is_destructible<std::initializer_list<Del>>::value, + "Error"); + +static_assert(!std::is_destructible<void>::value, "Error"); +static_assert(!std::is_destructible<const void>::value, "Error"); +static_assert(!std::is_destructible<void()>::value, "Error"); +static_assert(!std::is_destructible<void() const>::value, "Error"); +static_assert(!std::is_destructible<int[]>::value, "Error"); +static_assert(!std::is_destructible<const int[]>::value, "Error"); +static_assert(!std::is_destructible<Del>::value, "Error"); +static_assert(!std::is_destructible<const Del>::value, "Error"); +static_assert(!std::is_destructible<AbstractDelDtor>::value, "Error"); +static_assert(!std::is_destructible<const AbstractDelDtor>::value, "Error"); +static_assert(!std::is_destructible<int[][1]>::value, "Error"); +static_assert(!std::is_destructible<const int[][1]>::value, "Error"); +static_assert(!std::is_destructible<Del[1]>::value, "Error"); +static_assert(!std::is_destructible<const Del[1]>::value, "Error"); +static_assert(!std::is_destructible<Del[]>::value, "Error"); +static_assert(!std::is_destructible<const Del[]>::value, "Error"); + +// Deleted members in unions with non-trivial members: +static_assert(!std::is_destructible<NontrivialUnion>::value, "Error"); + +// Unusual copy: +static_assert(std::is_destructible<UnusualCopy>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..3f6988979 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_empty<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/requirements/typedefs.cc new file mode 100644 index 000000000..d35e3cb13 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_empty<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/value.cc new file mode 100644 index 000000000..00ea444d4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_empty/value.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +class EmptyClassOne +{ typedef int type; }; + +class EmptyClassTwo +{ static int data; }; + +class EmptyClassThree +{ int f(); }; + +class NonEmptyClassOne +{ int data; }; + +class NonEmptyClassTwo +{ + virtual int f(); + virtual ~NonEmptyClassTwo(); +}; + +void test01() +{ + using std::is_empty; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_empty, ClassType>(true), ""); + static_assert(test_category<is_empty, EmptyClassOne>(true), ""); + static_assert(test_category<is_empty, EmptyClassTwo>(true), ""); + static_assert(test_category<is_empty, EmptyClassThree>(true), ""); + + // Negative tests. + static_assert(test_category<is_empty, void>(false), ""); + static_assert(test_category<is_empty, float>(false), ""); + static_assert(test_category<is_empty, int[4]>(false), ""); + static_assert(test_category<is_empty, int*>(false), ""); + static_assert(test_category<is_empty, int&>(false), ""); + static_assert(test_category<is_empty, int (ClassType::*)>(false), ""); + static_assert(test_category<is_empty, EnumType>(false), ""); + static_assert(test_category<is_empty, int (int)>(false), ""); + + static_assert(test_category<is_empty, AbstractClass>(false), ""); + static_assert(test_category<is_empty, NonEmptyClassOne>(false), ""); + static_assert(test_category<is_empty, NonEmptyClassTwo>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6c7eb7d24 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_enum<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/requirements/typedefs.cc new file mode 100644 index 000000000..93f3ecb31 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_enum<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/value.cc new file mode 100644 index 000000000..ccd187a7c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_enum/value.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_enum; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_enum, EnumType>(true), ""); + + // Negative tests. + static_assert(test_category<is_enum, void>(false), ""); + static_assert(test_category<is_enum, int>(false), ""); + static_assert(test_category<is_enum, float>(false), ""); + static_assert(test_category<is_enum, int[2]>(false), ""); + static_assert(test_category<is_enum, int*>(false), ""); + static_assert(test_category<is_enum, int(*)(int)>(false), ""); + static_assert(test_category<is_enum, float&>(false), ""); + static_assert(test_category<is_enum, float(&)(float)>(false), ""); + static_assert(test_category<is_enum, int (ClassType::*)>(false), ""); + static_assert(test_category<is_enum, int (ClassType::*) (int)>(false), ""); + static_assert(test_category<is_enum, int (int)>(false), ""); + + static_assert(test_category<is_enum, ConvType>(false), ""); + + // Sanity check. + static_assert(test_category<is_enum, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..533f48306 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_floating_point<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/requirements/typedefs.cc new file mode 100644 index 000000000..b8330467b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/requirements/typedefs.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_floating_point<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/value.cc new file mode 100644 index 000000000..770780ec2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_floating_point/value.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_floating_point; + using namespace __gnu_test; + + static_assert(test_category<is_floating_point, void>(false), ""); + static_assert(test_category<is_floating_point, char>(false), ""); + static_assert(test_category<is_floating_point, signed char>(false), ""); + static_assert(test_category<is_floating_point, unsigned char>(false), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_floating_point, wchar_t>(false), ""); +#endif + static_assert(test_category<is_floating_point, short>(false), ""); + static_assert(test_category<is_floating_point, unsigned short>(false), ""); + static_assert(test_category<is_floating_point, int>(false), ""); + static_assert(test_category<is_floating_point, unsigned int>(false), ""); + static_assert(test_category<is_floating_point, long>(false), ""); + static_assert(test_category<is_floating_point, unsigned long>(false), ""); + static_assert(test_category<is_floating_point, long long>(false), ""); + static_assert(test_category<is_floating_point, + unsigned long long>(false), ""); + + static_assert(test_category<is_floating_point, float>(true), ""); + static_assert(test_category<is_floating_point, double>(true), ""); + static_assert(test_category<is_floating_point, long double>(true), ""); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_FLOAT128 + static_assert(test_category<is_floating_point, __float128>(true), ""); +#endif + +#ifdef _GLIBCXX_USE_INT128 + static_assert(test_category<is_floating_point, __int128>(false), ""); + static_assert(test_category<is_floating_point, + unsigned __int128>(false), ""); +#endif + + // Sanity check. + static_assert(test_category<is_floating_point, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/24808.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/24808.cc new file mode 100644 index 000000000..3a061a333 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/24808.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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> + +// libstdc++/24808 +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_function; + using namespace __gnu_test; + + VERIFY( (test_category<is_function, IncompleteClass>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/35637.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/35637.cc new file mode 100644 index 000000000..b9958899a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/35637.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x -pedantic-errors" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <functional> + +struct S +{ + void F() const {} +}; + +// libstdc++/35637 +void test01() +{ + std::function<void (S *)> a(&S::F); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..60965cda8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_function<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/requirements/typedefs.cc new file mode 100644 index 000000000..045e8da5f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 tr1/type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::is_function<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/value.cc new file mode 100644 index 000000000..86c21c561 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_function/value.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_function; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_function, int (int)>(true), ""); + static_assert(test_category<is_function, ClassType (ClassType)>(true), ""); + static_assert(test_category<is_function, + float (int, float, int[], int&)>(true), ""); + static_assert(test_category<is_function, int (int, ...)>(true), ""); + static_assert(test_category<is_function, bool (ClassType) const>(true), ""); + static_assert(test_category<is_function, ClassType () &>(true), ""); + static_assert(test_category<is_function, + char (int, ClassType) const volatile &&>(true), ""); + + // Negative tests. + static_assert(test_category<is_function, int&>(false), ""); + static_assert(test_category<is_function, void>(false), ""); + static_assert(test_category<is_function, const void>(false), ""); + + static_assert(test_category<is_function, AbstractClass>(false), ""); + static_assert(test_category<is_function, int(&)(int)>(false), ""); + + // Sanity check. + static_assert(test_category<is_function, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..5fcf9bd2d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_fundamental<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/typedefs.cc new file mode 100644 index 000000000..b9c13c9d2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 tr1/type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::is_fundamental<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/value.cc new file mode 100644 index 000000000..a7fc3ff4c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_fundamental/value.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_fundamental; + using namespace __gnu_test; + + static_assert(test_category<is_fundamental, void>(true), ""); + static_assert(test_category<is_fundamental, char>(true), ""); + static_assert(test_category<is_fundamental, signed char>(true), ""); + static_assert(test_category<is_fundamental, unsigned char>(true), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_fundamental, wchar_t>(true), ""); +#endif + static_assert(test_category<is_fundamental, short>(true), ""); + static_assert(test_category<is_fundamental, unsigned short>(true), ""); + static_assert(test_category<is_fundamental, int>(true), ""); + static_assert(test_category<is_fundamental, unsigned int>(true), ""); + static_assert(test_category<is_fundamental, long>(true), ""); + static_assert(test_category<is_fundamental, unsigned long>(true), ""); + static_assert(test_category<is_fundamental, long long>(true), ""); + static_assert(test_category<is_fundamental, unsigned long long>(true), ""); + static_assert(test_category<is_fundamental, float>(true), ""); + static_assert(test_category<is_fundamental, double>(true), ""); + static_assert(test_category<is_fundamental, long double>(true), ""); + + // libstdc++/56609 + static_assert(test_category<is_fundamental, std::nullptr_t>(true), ""); + + // Sanity check. + static_assert(test_category<is_fundamental, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..17c2c0812 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2008-05-20 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008-2014 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_integral<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc new file mode 100644 index 000000000..26b4b70eb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_integral<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/value.cc new file mode 100644 index 000000000..46ec37b39 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_integral/value.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2008-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2008-2014 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_tr1.h> + +void test01() +{ + using std::is_integral; + using namespace __gnu_test; + + static_assert(test_category<is_integral, void>(false), ""); + + static_assert(test_category<is_integral, char>(true), ""); + static_assert(test_category<is_integral, signed char>(true), ""); + static_assert(test_category<is_integral, unsigned char>(true), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_integral, wchar_t>(true), ""); +#endif + static_assert(test_category<is_integral, char16_t>(true), ""); + static_assert(test_category<is_integral, char32_t>(true), ""); + static_assert(test_category<is_integral, short>(true), ""); + static_assert(test_category<is_integral, unsigned short>(true), ""); + static_assert(test_category<is_integral, int>(true), ""); + static_assert(test_category<is_integral, unsigned int>(true), ""); + static_assert(test_category<is_integral, long>(true), ""); + static_assert(test_category<is_integral, unsigned long>(true), ""); + static_assert(test_category<is_integral, long long>(true), ""); + static_assert(test_category<is_integral, unsigned long long>(true), ""); + + static_assert(test_category<is_integral, float>(false), ""); + static_assert(test_category<is_integral, double>(false), ""); + static_assert(test_category<is_integral, long double>(false), ""); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_INT128 + static_assert(test_category<is_integral, __int128>(true), ""); + static_assert(test_category<is_integral, unsigned __int128>(true), ""); +#endif + +#ifdef _GLIBCXX_USE_FLOAT128 + static_assert(test_category<is_integral, __float128>(false), ""); +#endif + + // Sanity check. + static_assert(test_category<is_integral, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..95d8623aa --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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_literal_type<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc new file mode 100644 index 000000000..31441c262 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_literal_type<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc new file mode 100644 index 000000000..8ff1b4f37 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_literal_type/value.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::is_literal_type; + using namespace __gnu_test; + + static_assert(test_category<is_literal_type, int>(true), ""); + static_assert(test_category<is_literal_type, unsigned char>(true), ""); + + static_assert(test_category<is_literal_type, TType>(true), ""); + static_assert(test_category<is_literal_type, PODType>(true), ""); + + static_assert(test_category<is_literal_type, NType>(false), ""); + static_assert(test_category<is_literal_type, SLType>(false), ""); + + static_assert(test_category<is_literal_type, LType>(true), ""); + static_assert(test_category<is_literal_type, LType[5]>(true), ""); + + static_assert(test_category<is_literal_type, NLType>(false), ""); + static_assert(test_category<is_literal_type, NLType[5]>(false), ""); + + static_assert(test_category<is_literal_type, LTypeDerived>(true), ""); + static_assert(test_category<is_literal_type, LTypeDerived[5]>(true), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..24dd66571 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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_lvalue_reference<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..7430d3241 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_lvalue_reference<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc new file mode 100644 index 000000000..b7b8c0dc0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_lvalue_reference/value.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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_tr1.h> + +void test01() +{ + using std::is_lvalue_reference; + using namespace __gnu_test; + + static_assert(test_category<is_lvalue_reference, int&>(true), ""); + static_assert(test_category<is_lvalue_reference, ClassType&>(true), ""); + static_assert(test_category<is_lvalue_reference, int(&)(int)>(true), ""); + + // Sanity check. + static_assert(test_category<is_lvalue_reference, int&&>(false), ""); + static_assert(test_category<is_lvalue_reference, ClassType>(false), ""); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7b6b6b0b8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_member_function_pointer<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/typedefs.cc new file mode 100644 index 000000000..4e6da23f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 tr1/type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::is_member_function_pointer<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/value.cc new file mode 100644 index 000000000..ea7645b24 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_function_pointer/value.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_member_function_pointer; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_member_function_pointer, + int (ClassType::*) (int)>(true), ""); + static_assert(test_category<is_member_function_pointer, + int (ClassType::*) (int) const>(true), ""); + static_assert(test_category<is_member_function_pointer, + int (ClassType::*) (float, ...)>(true), ""); + static_assert(test_category<is_member_function_pointer, + ClassType (ClassType::*) (ClassType)>(true), ""); + static_assert(test_category<is_member_function_pointer, + float (ClassType::*) (int, float, int[], int&)>(true), ""); + + // Negative tests. + static_assert(test_category<is_member_function_pointer, + int (ClassType::*)>(false), ""); + static_assert(test_category<is_member_function_pointer, + const int (ClassType::*)>(false), ""); + static_assert(test_category<is_member_function_pointer, + ClassType (ClassType::*)>(false), ""); + + // Sanity check. + static_assert(test_category<is_member_function_pointer, + ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..ffdbf6214 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_member_object_pointer<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/typedefs.cc new file mode 100644 index 000000000..278ba4293 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 tr1/type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::is_member_object_pointer<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/value.cc new file mode 100644 index 000000000..2b94f30d5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_object_pointer/value.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_member_object_pointer; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_member_object_pointer, + int (ClassType::*)>(true), ""); + static_assert(test_category<is_member_object_pointer, + const int (ClassType::*)>(true), ""); + static_assert(test_category<is_member_object_pointer, + ClassType (ClassType::*)>(true), ""); + + // Negative tests. + static_assert(test_category<is_member_object_pointer, + int (ClassType::*) (int)>(false), ""); + static_assert(test_category<is_member_object_pointer, + int (ClassType::*) (int) const>(false), ""); + static_assert(test_category<is_member_object_pointer, + int (ClassType::*) (float, ...)>(false), ""); + static_assert(test_category<is_member_object_pointer, + ClassType (ClassType::*) (ClassType)>(false), ""); + static_assert(test_category<is_member_object_pointer, + float (ClassType::*) (int, float, int[], int&)>(false), ""); + + // Sanity check. + static_assert(test_category<is_member_object_pointer, ClassType>(false), ""); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6baaec573 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_member_pointer<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/typedefs.cc new file mode 100644 index 000000000..a7e05152d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 tr1/type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::is_member_pointer<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/value.cc new file mode 100644 index 000000000..f648dbe3e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_member_pointer/value.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_member_pointer; + using namespace __gnu_test; + + static_assert(test_category<is_member_pointer, int (ClassType::*)>(true), ""); + static_assert(test_category<is_member_pointer, + const int (ClassType::*)>(true), ""); + static_assert(test_category<is_member_pointer, + ClassType (ClassType::*)>(true), ""); + + static_assert(test_category<is_member_pointer, + int (ClassType::*) (int)>(true), ""); + static_assert(test_category<is_member_pointer, + int (ClassType::*) (int) const>(true), ""); + static_assert(test_category<is_member_pointer, + int (ClassType::*) (float, ...)>(true), ""); + static_assert(test_category<is_member_pointer, + ClassType (ClassType::*) (ClassType)>(true), ""); + static_assert(test_category<is_member_pointer, + float (ClassType::*) (int, float, int[], int&)>(true), ""); + + // Sanity check. + static_assert(test_category<is_member_pointer, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..c8f28ce3a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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_move_assignable<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/requirements/typedefs.cc new file mode 100644 index 000000000..07f894ca4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_move_assignable<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/value.cc new file mode 100644 index 000000000..08da4a35e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_assignable/value.cc @@ -0,0 +1,76 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_move_assignable; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_move_assignable, int>(true), ""); + static_assert(test_property<is_move_assignable, float>(true), ""); + static_assert(test_property<is_move_assignable, EnumType>(true), ""); + static_assert(test_property<is_move_assignable, int*>(true), ""); + static_assert(test_property<is_move_assignable, int(*)(int)>(true), ""); + static_assert(test_property<is_move_assignable, + int (ClassType::*)>(true), ""); + static_assert(test_property<is_move_assignable, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_move_assignable, + NoexceptMoveAssignClass>(true), ""); + static_assert(test_property<is_move_assignable, + ExceptMoveAssignClass>(true), ""); + static_assert(test_property<is_move_assignable, + NoexceptCopyAssignClass>(true), ""); + static_assert(test_property<is_move_assignable, + ExceptCopyAssignClass>(true), ""); + + // Negative tests. + static_assert(test_property<is_move_assignable, void>(false), ""); + static_assert(test_property<is_move_assignable, int[2]>(false), ""); + static_assert(test_property<is_move_assignable, float[][3]>(false), ""); + static_assert(test_property<is_move_assignable, + EnumType[2][3][4]>(false), ""); + static_assert(test_property<is_move_assignable, int*[3]>(false), ""); + static_assert(test_property<is_move_assignable, int(*[][2])(int)>(false), ""); + static_assert(test_property<is_move_assignable, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_property<is_move_assignable, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_property<is_move_assignable, + ClassType(unsigned) const &>(false), ""); + static_assert(test_property<is_move_assignable, + bool(ClassType) const>(false), ""); + static_assert(test_property<is_move_assignable, + bool(...) &&>(false), ""); + static_assert(test_property<is_move_assignable, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_move_assignable, + DeletedCopyAssignClass>(false), ""); + static_assert(test_property<is_move_assignable, + DeletedMoveAssignClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..58c7d3708 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_move_constructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..720166908 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_move_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/value.cc new file mode 100644 index 000000000..d5262d485 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_move_constructible/value.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_move_constructible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_move_constructible, int>(true), ""); + static_assert(test_category<is_move_constructible, float>(true), ""); + static_assert(test_category<is_move_constructible, EnumType>(true), ""); + static_assert(test_category<is_move_constructible, int*>(true), ""); + static_assert(test_category<is_move_constructible, int(*)(int)>(true), ""); + static_assert(test_category<is_move_constructible, + int (ClassType::*)>(true), ""); + static_assert(test_category<is_move_constructible, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_move_constructible, + NoexceptMoveConsClass>(true), ""); + static_assert(test_property<is_move_constructible, + ThrowMoveConsClass>(true), ""); + static_assert(test_property<is_move_constructible, + ExceptMoveConsClass>(true), ""); + + // Negative tests. + static_assert(test_category<is_move_constructible, void>(false), ""); + static_assert(test_category<is_move_constructible, int[2]>(false), ""); + static_assert(test_category<is_move_constructible, int[]>(false), ""); + static_assert(test_category<is_move_constructible, float[][3]>(false), ""); + static_assert(test_category<is_move_constructible, + EnumType[2][3][4]>(false), ""); + static_assert(test_category<is_move_constructible, int*[3]>(false), ""); + static_assert(test_category<is_move_constructible, + int(*[][2])(int)>(false), ""); + static_assert(test_category<is_move_constructible, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_category<is_move_constructible, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_category<is_move_constructible, + ClassType(unsigned) const &>(false), ""); + static_assert(test_category<is_move_constructible, + bool(ClassType) const>(false), ""); + static_assert(test_category<is_move_constructible, + bool(...) &&>(false), ""); + static_assert(test_category<is_move_constructible, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_move_constructible, + const NoexceptMoveConsClass>(false), ""); + static_assert(test_property<is_move_constructible, + volatile NoexceptMoveConsClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..f3ca22a82 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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_nothrow_assignable<test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/requirements/typedefs.cc new file mode 100644 index 000000000..d64f53243 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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_nothrow_assignable<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/value.cc new file mode 100644 index 000000000..f2dbf20b4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_assignable/value.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_nothrow_assignable; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_relationship<is_nothrow_assignable, int&, int>(true), ""); + static_assert(test_relationship<is_nothrow_assignable, int&, + const int>(true), ""); + + static_assert(test_relationship<is_nothrow_assignable, + NoexceptCopyAssignClass&, + const NoexceptCopyAssignClass&>(true), ""); + static_assert(test_relationship<is_nothrow_assignable, + NoexceptMoveAssignClass&, NoexceptMoveAssignClass&&>(true), ""); + static_assert(test_relationship<is_nothrow_assignable, + NoexceptCopyAssignClass&, NoexceptCopyAssignClass&&>(true), ""); + + // Negative tests. + static_assert(test_relationship<is_nothrow_assignable, int, int>(false), ""); + static_assert(test_relationship<is_nothrow_assignable, int, + const int>(false), ""); + + static_assert(test_relationship<is_nothrow_assignable, + ExceptCopyAssignClass&, + const ExceptCopyAssignClass&>(false), ""); + static_assert(test_relationship<is_nothrow_assignable, + ExceptMoveAssignClass&, ExceptMoveAssignClass&&>(false), ""); + static_assert(test_relationship<is_nothrow_assignable, + NoexceptMoveAssignClass&, + const NoexceptMoveAssignClass&>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d38ba8430 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-06-09 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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_nothrow_constructible<test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..43f3d3f1b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-06-09 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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_nothrow_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value.cc new file mode 100644 index 000000000..c8e77b90d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-06-09 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::is_nothrow_constructible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_nothrow_constructible, NoexceptExplicitClass, + double&>(true), ""); + static_assert(test_property<is_nothrow_constructible, NoexceptExplicitClass, + int&>(true), ""); + static_assert(test_property<is_nothrow_constructible, NoexceptExplicitClass, + double&, int&, double&>(true), ""); + static_assert(test_property<is_nothrow_constructible, NothrowExplicitClass, + double&>(true), ""); + static_assert(test_property<is_nothrow_constructible, NothrowExplicitClass, + int&>(true), ""); + static_assert(test_property<is_nothrow_constructible, NothrowExplicitClass, + double&, int&, double&>(true), ""); + + static_assert(test_property<is_nothrow_constructible, int[1]>(true), ""); + + // Negative tests. + static_assert(test_property<is_nothrow_constructible, NoexceptExplicitClass, + void*>(false), ""); + static_assert(test_property<is_nothrow_constructible, NoexceptExplicitClass> + (false), ""); + static_assert(test_property<is_nothrow_constructible, NoexceptExplicitClass, + int, double>(false), ""); + static_assert(test_property<is_nothrow_constructible, NothrowExplicitClass, + void*>(false), ""); + static_assert(test_property<is_nothrow_constructible, NothrowExplicitClass> + (false), ""); + static_assert(test_property<is_nothrow_constructible, NothrowExplicitClass, + int, double>(false), ""); + + static_assert(test_property<is_nothrow_constructible, ExceptExplicitClass, + double&>(false), ""); + static_assert(test_property<is_nothrow_constructible, ExceptExplicitClass, + int&>(false), ""); + static_assert(test_property<is_nothrow_constructible, ExceptExplicitClass, + double&, int&, double&>(false), ""); + static_assert(test_property<is_nothrow_constructible, ThrowExplicitClass, + double&>(false), ""); + static_assert(test_property<is_nothrow_constructible, ThrowExplicitClass, + int&>(false), ""); + static_assert(test_property<is_nothrow_constructible, ThrowExplicitClass, + double&, int&, double&>(false), ""); + + static_assert(test_property<is_nothrow_constructible, int[]>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..c8940d671 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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_nothrow_copy_assignable<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/requirements/typedefs.cc new file mode 100644 index 000000000..a49f86ec0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_nothrow_copy_assignable<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/value.cc new file mode 100644 index 000000000..8d987085e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_assignable/value.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-06-08 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::is_nothrow_copy_assignable; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_nothrow_copy_assignable, int>(true), ""); + static_assert(test_property<is_nothrow_copy_assignable, float>(true), ""); + static_assert(test_property<is_nothrow_copy_assignable, EnumType>(true), ""); + static_assert(test_property<is_nothrow_copy_assignable, int*>(true), ""); + static_assert(test_property<is_nothrow_copy_assignable, + int(*)(int)>(true), ""); + static_assert(test_property<is_nothrow_copy_assignable, + int (ClassType::*)>(true), ""); + static_assert(test_property<is_nothrow_copy_assignable, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_nothrow_copy_assignable, + NoexceptCopyAssignClass>(true), ""); + + // Negative tests. + static_assert(test_property<is_nothrow_copy_assignable, void>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, int[2]>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + float[][3]>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + EnumType[2][3][4]>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, int*[3]>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + int(*[][2])(int)>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + ClassType(unsigned) const &>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + bool(ClassType) const>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + bool(...) &&>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_nothrow_copy_assignable, + ExceptCopyAssignClass>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + NoexceptMoveAssignClass>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + ExceptMoveAssignClass>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + DeletedCopyAssignClass>(false), ""); + static_assert(test_property<is_nothrow_copy_assignable, + DeletedMoveAssignClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..50bbd66f9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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_nothrow_copy_constructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..5e08f917e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_nothrow_copy_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/value.cc new file mode 100644 index 000000000..a8be7c9cb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_copy_constructible/value.cc @@ -0,0 +1,81 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2004-12-30 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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_tr1.h> + +void test01() +{ + using std::is_nothrow_copy_constructible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_nothrow_copy_constructible, int>(true), ""); + static_assert(test_category<is_nothrow_copy_constructible, float>(true), ""); + static_assert(test_category<is_nothrow_copy_constructible, + EnumType>(true), ""); + static_assert(test_category<is_nothrow_copy_constructible, int*>(true), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int(*)(int)>(true), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int (ClassType::*)>(true), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_nothrow_copy_constructible, + NoexceptCopyConsClass>(true), ""); + static_assert(test_property<is_nothrow_copy_constructible, + const NoexceptCopyConsClass>(true), ""); + + // Negative tests. + static_assert(test_category<is_nothrow_copy_constructible, void>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int[2]>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, int[]>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + float[][3]>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + EnumType[2][3][4]>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int*[3]>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int(*[][2])(int)>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + ClassType(unsigned) const &>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + bool(ClassType) const>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + bool(...) &&>(false), ""); + static_assert(test_category<is_nothrow_copy_constructible, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_nothrow_copy_constructible, + volatile NoexceptCopyConsClass>(false), ""); + static_assert(test_property<is_nothrow_copy_constructible, + ThrowCopyConsClass>(false), ""); + static_assert(test_property<is_nothrow_copy_constructible, + ExceptCopyConsClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..681c50445 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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_nothrow_default_constructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..d20a88229 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_nothrow_default_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/value.cc new file mode 100644 index 000000000..6ea52d37c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_default_constructible/value.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2004-12-29 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2004-2014 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_tr1.h> + +void test01() +{ + using std::is_nothrow_default_constructible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_nothrow_default_constructible, int>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + float>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + EnumType>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + int*>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + int(*)(int)>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + int (ClassType::*)>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + int (ClassType::*) (int)>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + int[2]>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + EnumType[2][3][4]>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + int*[3]>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + int (ClassType::*[2][3])>(true), ""); + static_assert(test_category<is_nothrow_default_constructible, + ClassType>(true), ""); + + static_assert(test_category<is_nothrow_default_constructible, + NoexceptDefaultClass>(true), ""); + + // Negative tests. + static_assert(test_category<is_nothrow_default_constructible, + void>(false), ""); + static_assert(test_category<is_nothrow_default_constructible, + int[]>(false), ""); + static_assert(test_category<is_nothrow_default_constructible, + float[][3]>(false), ""); + static_assert(test_category<is_nothrow_default_constructible, + int(*[][2])(int)>(false), ""); + static_assert(test_category<is_nothrow_default_constructible, + int (ClassType::*[][2][3]) (int)>(false), ""); + + static_assert(test_category<is_nothrow_default_constructible, + ThrowDefaultClass>(false), ""); + static_assert(test_category<is_nothrow_default_constructible, + ExceptDefaultClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..08f3ec14c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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_nothrow_destructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/requirements/typedefs.cc new file mode 100644 index 000000000..b4bb997c1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_nothrow_destructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/value.cc new file mode 100644 index 000000000..fd4b1b753 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_destructible/value.cc @@ -0,0 +1,112 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <initializer_list> +#include <testsuite_tr1.h> + +using namespace __gnu_test::destruct; + +// is_nothrow_destructible: +static_assert(std::is_nothrow_destructible<int>::value, "Error"); +static_assert(std::is_nothrow_destructible<const int>::value, "Error"); +static_assert(std::is_nothrow_destructible<const volatile int>::value, "Error"); +static_assert(std::is_nothrow_destructible<int[12]>::value, "Error"); +static_assert(std::is_nothrow_destructible<const int[12]>::value, "Error"); +static_assert(std::is_nothrow_destructible<const volatile int[12]>::value, "Error"); +static_assert(std::is_nothrow_destructible<decltype(nullptr)>::value, "Error"); +static_assert(std::is_nothrow_destructible<std::initializer_list<int>>::value, "Error"); +static_assert(std::is_nothrow_destructible<std::initializer_list<decltype(nullptr)>>::value, "Error"); +static_assert(std::is_nothrow_destructible<std::initializer_list<TD1>>::value, "Error"); +static_assert(std::is_nothrow_destructible<std::initializer_list<TD2>>::value, "Error"); +static_assert(std::is_nothrow_destructible<E>::value, "Error"); +static_assert(std::is_nothrow_destructible<const E>::value, "Error"); +static_assert(std::is_nothrow_destructible<const volatile E>::value, "Error"); +static_assert(std::is_nothrow_destructible<NTD1>::value, "Error"); +static_assert(std::is_nothrow_destructible<NTD2>::value, "Error"); +static_assert(std::is_nothrow_destructible<NTD3>::value, "Error"); +static_assert(std::is_nothrow_destructible<Aggr>::value, "Error"); +static_assert(std::is_nothrow_destructible<U1>::value, "Error"); +static_assert(std::is_nothrow_destructible<void(*)()>::value, "Error"); +static_assert(std::is_nothrow_destructible<void*>::value, "Error"); +static_assert(std::is_nothrow_destructible<int&>::value, "Error"); +static_assert(std::is_nothrow_destructible<TD1&>::value, "Error"); +static_assert(std::is_nothrow_destructible<TD2&>::value, "Error"); +static_assert(std::is_nothrow_destructible<TD1*>::value, "Error"); +static_assert(std::is_nothrow_destructible<TD2*>::value, "Error"); +static_assert(std::is_nothrow_destructible<void(&)()>::value, "Error"); +static_assert(std::is_nothrow_destructible<void(&&)()>::value, "Error"); +static_assert(std::is_nothrow_destructible<En>::value, "Error"); +static_assert(std::is_nothrow_destructible<En*>::value, "Error"); +static_assert(std::is_nothrow_destructible<En&>::value, "Error"); +static_assert(std::is_nothrow_destructible<En2>::value, "Error"); +static_assert(std::is_nothrow_destructible<En2*>::value, "Error"); +static_assert(std::is_nothrow_destructible<En2&>::value, "Error"); +static_assert(std::is_nothrow_destructible<TD1(&)(Aggr2, TD2)>::value, "Error"); +static_assert(std::is_nothrow_destructible<TD1(*)(Aggr2, TD2)>::value, "Error"); +static_assert(std::is_nothrow_destructible<Abstract1>::value, "Error"); +static_assert(std::is_nothrow_destructible<Der>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del2&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del3&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del(&)[1]>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del2(&)[2]>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del3(&)[3]>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del&&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del2&&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del3&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del(&&)[1]>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del2(&&)[2]>::value, "Error"); +static_assert(std::is_nothrow_destructible<Del3(&&)[3]>::value, "Error"); +static_assert(std::is_nothrow_destructible<Ut&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Ut&&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Ut*>::value, "Error"); +static_assert(std::is_nothrow_destructible<Abstract2&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Abstract3&>::value, "Error"); +static_assert(std::is_nothrow_destructible<Abstract2*>::value, "Error"); +static_assert(std::is_nothrow_destructible<Abstract3*>::value, "Error"); + +static_assert(!std::is_nothrow_destructible<void>::value, "Error"); +static_assert(!std::is_nothrow_destructible<const void>::value, "Error"); +static_assert(!std::is_nothrow_destructible<void()>::value, "Error"); +static_assert(!std::is_nothrow_destructible<void() const>::value, "Error"); +static_assert(!std::is_nothrow_destructible<TD1(Aggr2, TD2)>::value, "Error"); +static_assert(!std::is_nothrow_destructible<int[]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<const int[]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<const volatile int[]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<int[][123]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<TD1>::value, "Error"); +static_assert(!std::is_nothrow_destructible<TD2>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Aggr2>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Aggr2[1]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<TD1[1][2]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Ut>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Ut[3]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<AbstractDelDtor>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Abstract2>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Abstract3>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Der2>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Del>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Del2>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Del3>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Del[1]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Del2[2]>::value, "Error"); +static_assert(!std::is_nothrow_destructible<Del3[3]>::value, "Error"); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..bf77d0abf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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_nothrow_move_assignable<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/requirements/typedefs.cc new file mode 100644 index 000000000..1bdc3b789 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_nothrow_move_assignable<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/value.cc new file mode 100644 index 000000000..2f4fc55f6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_assignable/value.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_nothrow_move_assignable; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_nothrow_move_assignable, int>(true), ""); + static_assert(test_property<is_nothrow_move_assignable, float>(true), ""); + static_assert(test_property<is_nothrow_move_assignable, EnumType>(true), ""); + static_assert(test_property<is_nothrow_move_assignable, int*>(true), ""); + static_assert(test_property<is_nothrow_move_assignable, + int(*)(int)>(true), ""); + static_assert(test_property<is_nothrow_move_assignable, + int (ClassType::*)>(true), ""); + static_assert(test_property<is_nothrow_move_assignable, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_nothrow_move_assignable, + NoexceptMoveAssignClass>(true), ""); + static_assert(test_property<is_nothrow_move_assignable, + NoexceptCopyAssignClass>(true), ""); + + // Negative tests. + static_assert(test_property<is_nothrow_move_assignable, void>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, int[2]>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + float[][3]>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + EnumType[2][3][4]>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, int*[3]>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + int(*[][2])(int)>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + ClassType(unsigned) const &>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + bool(ClassType) const>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + bool(...) &&>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_nothrow_move_assignable, + ExceptMoveAssignClass>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + ExceptCopyAssignClass>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + DeletedMoveAssignClass>(false), ""); + static_assert(test_property<is_nothrow_move_assignable, + DeletedCopyAssignClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..2b1c9a270 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_nothrow_move_constructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/requirements/typedefs.cc new file mode 100644 index 000000000..11e5fbcc2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_nothrow_move_constructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/value.cc new file mode 100644 index 000000000..1cb756a22 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_nothrow_move_constructible/value.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_nothrow_move_constructible; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_nothrow_move_constructible, int>(true), ""); + static_assert(test_category<is_nothrow_move_constructible, float>(true), ""); + static_assert(test_category<is_nothrow_move_constructible, + EnumType>(true), ""); + static_assert(test_category<is_nothrow_move_constructible, int*>(true), ""); + static_assert(test_category<is_nothrow_move_constructible, + int(*)(int)>(true), ""); + static_assert(test_category<is_nothrow_move_constructible, + int (ClassType::*)>(true), ""); + static_assert(test_category<is_nothrow_move_constructible, + int (ClassType::*) (int)>(true), ""); + + static_assert(test_property<is_nothrow_move_constructible, + NoexceptMoveConsClass>(true), ""); + + // Negative tests. + static_assert(test_category<is_nothrow_move_constructible, void>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + int[2]>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + int[]>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + float[][3]>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + EnumType[2][3][4]>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + int*[3]>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + int(*[][2])(int)>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + ClassType(unsigned) const &>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + bool(ClassType) const>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + bool(...) &&>(false), ""); + static_assert(test_category<is_nothrow_move_constructible, + EnumType(int, ...)>(false), ""); + + static_assert(test_property<is_nothrow_move_constructible, + const NoexceptMoveConsClass>(false), ""); + static_assert(test_property<is_nothrow_move_constructible, + volatile NoexceptMoveConsClass>(false), ""); + static_assert(test_property<is_nothrow_move_constructible, + ThrowMoveConsClass>(false), ""); + static_assert(test_property<is_nothrow_move_constructible, + ExceptMoveConsClass>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..0333d8266 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// 2013-05-02 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2013-2014 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_null_pointer<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc new file mode 100644 index 000000000..850239cf9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } +// 2013-05-02 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2013-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_null_pointer<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc new file mode 100644 index 000000000..1efe153bc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_null_pointer/value.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2013-05-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_null_pointer; + using namespace __gnu_test; + + static_assert(test_category<is_null_pointer, std::nullptr_t>(true), ""); + + static_assert(test_category<is_null_pointer, int>(false), ""); + static_assert(test_category<is_null_pointer, float>(false), ""); + static_assert(test_category<is_null_pointer, EnumType>(false), ""); + static_assert(test_category<is_null_pointer, int*>(false), ""); + static_assert(test_category<is_null_pointer, int(*)(int)>(false), ""); + static_assert(test_category<is_null_pointer, int (ClassType::*)>(false), ""); + static_assert(test_category<is_null_pointer, + int (ClassType::*) (int)>(false), ""); + static_assert(test_category<is_null_pointer, int[2]>(false), ""); + static_assert(test_category<is_null_pointer, float[][3]>(false), ""); + static_assert(test_category<is_null_pointer, EnumType[2][3][4]>(false), ""); + static_assert(test_category<is_null_pointer, int*[3]>(false), ""); + static_assert(test_category<is_null_pointer, int(*[][2])(int)>(false), ""); + static_assert(test_category<is_null_pointer, + int (ClassType::*[2][3])>(false), ""); + static_assert(test_category<is_null_pointer, + int (ClassType::*[][2][3]) (int)>(false), ""); + static_assert(test_category<is_null_pointer, ClassType>(false), ""); + static_assert(test_category<is_null_pointer, PODType>(false), ""); + static_assert(test_category<is_null_pointer, void>(false), ""); + static_assert(test_category<is_null_pointer, NType>(false), ""); + static_assert(test_category<is_null_pointer, TType>(false), ""); + static_assert(test_category<is_null_pointer, SLType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/24808.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/24808.cc new file mode 100644 index 000000000..5bdce87be --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/24808.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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> + +// libstdc++/24808 +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_object; + using namespace __gnu_test; + + VERIFY( (test_category<is_object, IncompleteClass>(true)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..1887f4525 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_object<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/requirements/typedefs.cc new file mode 100644 index 000000000..331471093 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_object<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/value.cc new file mode 100644 index 000000000..2b2c86206 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_object/value.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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_tr1.h> + +void test01() +{ + using std::is_object; + using namespace __gnu_test; + + static_assert(test_category<is_object, int (int)>(false), ""); + static_assert(test_category<is_object, ClassType (ClassType)>(false), ""); + static_assert(test_category<is_object, + float (int, float, int[], int&)>(false), ""); + static_assert(test_category<is_object, int&>(false), ""); + static_assert(test_category<is_object, ClassType&>(false), ""); + static_assert(test_category<is_object, int(&)(int)>(false), ""); + static_assert(test_category<is_object, void>(false), ""); + static_assert(test_category<is_object, const void>(false), ""); + + // Sanity check. + static_assert(test_category<is_object, ClassType>(true), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..99db7c483 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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_pod<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc new file mode 100644 index 000000000..7d6c13f2b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_pod<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/value.cc new file mode 100644 index 000000000..86ab24ea2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pod/value.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-02-21 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::is_pod; + using namespace __gnu_test; + + static_assert(test_category<is_pod, int>(true), ""); + static_assert(test_category<is_pod, float>(true), ""); + static_assert(test_category<is_pod, EnumType>(true), ""); + static_assert(test_category<is_pod, int*>(true), ""); + static_assert(test_category<is_pod, int(*)(int)>(true), ""); + static_assert(test_category<is_pod, int (ClassType::*)>(true), ""); + static_assert(test_category<is_pod, int (ClassType::*) (int)>(true), ""); + static_assert(test_category<is_pod, int[2]>(true), ""); + static_assert(test_category<is_pod, float[][3]>(true), ""); + static_assert(test_category<is_pod, EnumType[2][3][4]>(true), ""); + static_assert(test_category<is_pod, int*[3]>(true), ""); + static_assert(test_category<is_pod, int(*[][2])(int)>(true), ""); + static_assert(test_category<is_pod, int (ClassType::*[2][3])>(true), ""); + static_assert(test_category<is_pod, + int (ClassType::*[][2][3]) (int)>(true), ""); + static_assert(test_category<is_pod, ClassType>(true), ""); + static_assert(test_category<is_pod, PODType>(true), ""); + + static_assert(test_category<is_pod, void>(false), ""); + static_assert(test_category<is_pod, NType>(false), ""); + static_assert(test_category<is_pod, TType>(false), ""); + static_assert(test_category<is_pod, SLType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pointer/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..58ca78ad2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_pointer<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pointer/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pointer/value.cc new file mode 100644 index 000000000..e1b851ca3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_pointer/value.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_pointer; + using namespace __gnu_test; + + static_assert(test_category<is_pointer, int*>(true), ""); + static_assert(test_category<is_pointer, ClassType*>(true), ""); + static_assert(test_category<is_pointer, int(*)(int)>(true), ""); + + // Sanity check. + static_assert(test_category<is_pointer, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6e2fb5317 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_polymorphic<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/requirements/typedefs.cc new file mode 100644 index 000000000..43790db9d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_polymorphic<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/value.cc new file mode 100644 index 000000000..04176e6fe --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_polymorphic/value.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 <iostream> +#include <testsuite_tr1.h> + +void test01() +{ + using std::is_polymorphic; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_polymorphic, PolymorphicClass>(true), ""); + static_assert(test_category<is_polymorphic, DerivedPolymorphic>(true), ""); + static_assert(test_category<is_polymorphic, AbstractClass>(true), ""); + static_assert(test_category<is_polymorphic, + VirtualDestructorClass>(true), ""); + static_assert(test_category<is_polymorphic, std::iostream>(true), ""); + static_assert(test_category<is_polymorphic, std::streambuf>(true), ""); + + // Negative tests. + static_assert(test_category<is_polymorphic, void>(false), ""); + static_assert(test_category<is_polymorphic, int (int)>(false), ""); + static_assert(test_category<is_polymorphic, int&>(false), ""); + static_assert(test_category<is_polymorphic, EnumType>(false), ""); + static_assert(test_category<is_polymorphic, ClassType>(false), ""); + static_assert(test_category<is_polymorphic, DerivedType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..699d7dc78 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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_reference<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc new file mode 100644 index 000000000..db59694ab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_reference<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/value.cc new file mode 100644 index 000000000..83250ce6d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_reference/value.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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_tr1.h> + +void test01() +{ + using std::is_reference; + using namespace __gnu_test; + + static_assert(test_category<is_reference, int&>(true), ""); + static_assert(test_category<is_reference, ClassType&>(true), ""); + static_assert(test_category<is_reference, int(&)(int)>(true), ""); + static_assert(test_category<is_reference, int&&>(true), ""); + static_assert(test_category<is_reference, ClassType&&>(true), ""); + static_assert(test_category<is_reference, int(&&)(int)>(true), ""); + + // Sanity check. + static_assert(test_category<is_reference, ClassType>(false), ""); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..e111039c8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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_rvalue_reference<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000..3305a08db --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_rvalue_reference<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc new file mode 100644 index 000000000..35cc67d91 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_rvalue_reference/value.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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_tr1.h> + +void test01() +{ + using std::is_rvalue_reference; + using namespace __gnu_test; + + static_assert(test_category<is_rvalue_reference, int&&>(true), ""); + static_assert(test_category<is_rvalue_reference, ClassType&&>(true), ""); + static_assert(test_category<is_rvalue_reference, int(&&)(int)>(true), ""); + + // Sanity check. + static_assert(test_category<is_rvalue_reference, int&>(false), ""); + static_assert(test_category<is_rvalue_reference, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..36714039f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_same<test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/requirements/typedefs.cc new file mode 100644 index 000000000..13754842f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_same<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/value.cc new file mode 100644 index 000000000..5101d481a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_same/value.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_same; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_relationship<is_same, int, int>(true), ""); + static_assert(test_relationship<is_same, const int, const int>(true), ""); + static_assert(test_relationship<is_same, int&, int&>(true), ""); + static_assert(test_relationship<is_same, ClassType, ClassType>(true), ""); + + // Negative tests. + static_assert(test_relationship<is_same, void, int>(false), ""); + static_assert(test_relationship<is_same, int, const int>(false), ""); + static_assert(test_relationship<is_same, int, int&>(false), ""); + static_assert(test_relationship<is_same, int, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..61b68bcd5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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_scalar<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc new file mode 100644 index 000000000..c919c7142 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// 2010-11-30 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 tr1/type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +void test01() +{ + // Check for required typedefs + typedef std::is_scalar<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/value.cc new file mode 100644 index 000000000..40a7bfd71 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_scalar/value.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-11-30 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::is_scalar; + using namespace __gnu_test; + + static_assert(test_category<is_scalar, int>(true), ""); + static_assert(test_category<is_scalar, float>(true), ""); + static_assert(test_category<is_scalar, EnumType>(true), ""); + static_assert(test_category<is_scalar, int*>(true), ""); + static_assert(test_category<is_scalar, int(*)(int)>(true), ""); + static_assert(test_category<is_scalar, int (ClassType::*)>(true), ""); + static_assert(test_category<is_scalar, int (ClassType::*) (int)>(true), ""); + static_assert(test_category<is_scalar, std::nullptr_t>(true), ""); + + // Sanity check. + static_assert(test_category<is_scalar, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..df10c0c88 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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_signed<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc new file mode 100644 index 000000000..daf1308cf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_signed<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/value.cc new file mode 100644 index 000000000..6e4096152 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_signed/value.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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_tr1.h> + +void test01() +{ + using std::is_signed; + using namespace __gnu_test; + + static_assert(test_category<is_signed, void>(false), ""); + + static_assert(test_category<is_signed, char>(char(-1) < char(0)), ""); + static_assert(test_category<is_signed, signed char>(true), ""); + static_assert(test_category<is_signed, unsigned char>(false), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_signed, wchar_t> + (wchar_t(-1) < wchar_t(0)), ""); +#endif + static_assert(test_category<is_signed, short>(true), ""); + static_assert(test_category<is_signed, unsigned short>(false), ""); + static_assert(test_category<is_signed, int>(true), ""); + static_assert(test_category<is_signed, unsigned int>(false), ""); + static_assert(test_category<is_signed, long>(true), ""); + static_assert(test_category<is_signed, unsigned long>(false), ""); + static_assert(test_category<is_signed, long long>(true), ""); + static_assert(test_category<is_signed, unsigned long long>(false), ""); + + static_assert(test_category<is_signed, float>(true), ""); + static_assert(test_category<is_signed, double>(true), ""); + static_assert(test_category<is_signed, long double>(true), ""); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_INT128 + static_assert(test_category<is_signed, __int128>(true), ""); + static_assert(test_category<is_signed, unsigned __int128>(false), ""); +#endif + +#ifdef _GLIBCXX_USE_FLOAT128 + static_assert(test_category<is_signed, __float128>(true), ""); +#endif + + // Sanity check. + static_assert(test_category<is_signed, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc new file mode 100644 index 000000000..4b13f87a1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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_standard_layout<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc new file mode 100644 index 000000000..ba84205f5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_standard_layout<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc new file mode 100644 index 000000000..82d14d403 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_standard_layout/value.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::is_standard_layout; + using namespace __gnu_test; + + static_assert(test_category<is_standard_layout, SLType>(true), ""); + static_assert(test_category<is_standard_layout, PODType>(true), ""); + + static_assert(test_category<is_standard_layout, NType>(false), ""); + static_assert(test_category<is_standard_layout, TType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..e94602f51 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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_trivial<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/requirements/typedefs.cc new file mode 100644 index 000000000..16cc44b61 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_trivial<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/value.cc new file mode 100644 index 000000000..f6d9e296a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivial/value.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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_tr1.h> + +void test01() +{ + using std::is_trivial; + using namespace __gnu_test; + + static_assert(test_category<is_trivial, TType>(true), ""); + static_assert(test_category<is_trivial, PODType>(true), ""); + + static_assert(test_category<is_trivial, NType>(false), ""); + static_assert(test_category<is_trivial, SLType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..27c24b6f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// 2012-04-15 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2012-2014 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_trivially_destructible<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/requirements/typedefs.cc new file mode 100644 index 000000000..eaefc2d99 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// +// 2012-04-15 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2012-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_trivially_destructible<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/value.cc new file mode 100644 index 000000000..039c90295 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_trivially_destructible/value.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } +// +// 2012-04-15 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2012-2014 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_tr1.h> + +void test01() +{ + using std::is_trivially_destructible; + using namespace __gnu_test; + + static_assert(test_category<is_trivially_destructible, int>(true), ""); + static_assert(test_category<is_trivially_destructible, TType>(true), ""); + static_assert(test_category<is_trivially_destructible, PODType>(true), ""); + + static_assert(test_category<is_trivially_destructible, NType>(false), ""); + static_assert(test_category<is_trivially_destructible, SLType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..3ae51e5fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_union<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/requirements/typedefs.cc new file mode 100644 index 000000000..f12acab81 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_union<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/value.cc new file mode 100644 index 000000000..2c6d8c002 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_union/value.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_union; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_category<is_union, UnionType>(true), ""); + + // Negative tests. + static_assert(test_category<is_union, ClassType>(false), ""); + static_assert(test_category<is_union, DerivedType>(false), ""); + static_assert(test_category<is_union, ConvType>(false), ""); + static_assert(test_category<is_union, AbstractClass>(false), ""); + static_assert(test_category<is_union, PolymorphicClass>(false), ""); + static_assert(test_category<is_union, DerivedPolymorphic>(false), ""); + static_assert(test_category<is_union, void>(false), ""); + static_assert(test_category<is_union, int>(false), ""); + static_assert(test_category<is_union, float>(false), ""); + static_assert(test_category<is_union, int[2]>(false), ""); + static_assert(test_category<is_union, int*>(false), ""); + static_assert(test_category<is_union, int(*)(int)>(false), ""); + static_assert(test_category<is_union, float&>(false), ""); + static_assert(test_category<is_union, float(&)(float)>(false), ""); + static_assert(test_category<is_union, int (ClassType::*)>(false), ""); + static_assert(test_category<is_union, int (ClassType::*) (int)>(false), ""); + static_assert(test_category<is_union, int (int)>(false), ""); + static_assert(test_category<is_union, EnumType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..e3243f6ff --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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_unsigned<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc new file mode 100644 index 000000000..777a3ba13 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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> + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_unsigned<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc new file mode 100644 index 000000000..7075f0416 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_unsigned/value.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2005-01-24 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2005-2014 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_tr1.h> + +void test01() +{ + using std::is_unsigned; + using namespace __gnu_test; + + static_assert(test_category<is_unsigned, void>(false), ""); + + static_assert(test_category<is_unsigned, char>(char(-1) > char(0)), ""); + static_assert(test_category<is_unsigned, signed char>(false), ""); + static_assert(test_category<is_unsigned, unsigned char>(true), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_unsigned, wchar_t> + (wchar_t(-1) > wchar_t(0)), ""); +#endif + static_assert(test_category<is_unsigned, short>(false), ""); + static_assert(test_category<is_unsigned, unsigned short>(true), ""); + static_assert(test_category<is_unsigned, int>(false), ""); + static_assert(test_category<is_unsigned, unsigned int>(true), ""); + static_assert(test_category<is_unsigned, long>(false), ""); + static_assert(test_category<is_unsigned, unsigned long>(true), ""); + static_assert(test_category<is_unsigned, long long>(false), ""); + static_assert(test_category<is_unsigned, unsigned long long>(true), ""); + + static_assert(test_category<is_unsigned, float>(false), ""); + static_assert(test_category<is_unsigned, double>(false), ""); + static_assert(test_category<is_unsigned, long double>(false), ""); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_INT128 + static_assert(test_category<is_unsigned, unsigned __int128>(true), ""); + static_assert(test_category<is_unsigned, __int128>(false), ""); +#endif + +#ifdef _GLIBCXX_USE_FLOAT128 + static_assert(test_category<is_unsigned, __float128>(false), ""); +#endif + + // Sanity check. + static_assert(test_category<is_unsigned, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..da63810b8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_void<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/requirements/typedefs.cc new file mode 100644 index 000000000..d8f4accda --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_void<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/value.cc new file mode 100644 index 000000000..11b11c707 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_void/value.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_void; + using namespace __gnu_test; + + static_assert(test_category<is_void, void>(true), ""); + + static_assert(test_category<is_void, char>(false), ""); + static_assert(test_category<is_void, signed char>(false), ""); + static_assert(test_category<is_void, unsigned char>(false), ""); +#ifdef _GLIBCXX_USE_WCHAR_T + static_assert(test_category<is_void, wchar_t>(false), ""); +#endif + static_assert(test_category<is_void, short>(false), ""); + static_assert(test_category<is_void, unsigned short>(false), ""); + static_assert(test_category<is_void, int>(false), ""); + static_assert(test_category<is_void, unsigned int>(false), ""); + static_assert(test_category<is_void, long>(false), ""); + static_assert(test_category<is_void, unsigned long>(false), ""); + static_assert(test_category<is_void, long long>(false), ""); + static_assert(test_category<is_void, unsigned long long>(false), ""); + static_assert(test_category<is_void, float>(false), ""); + static_assert(test_category<is_void, double>(false), ""); + static_assert(test_category<is_void, long double>(false), ""); + + // Sanity check. + static_assert(test_category<is_void, ClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..7743dab6f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_volatile<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/requirements/typedefs.cc new file mode 100644 index 000000000..d906bf909 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_volatile<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/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/value.cc new file mode 100644 index 000000000..2683dc6b6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/is_volatile/value.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::is_volatile; + using namespace __gnu_test; + + // Positive tests. + static_assert(test_property<is_volatile, volatile int>(true), ""); + static_assert(test_property<is_volatile, const volatile int>(true), ""); + static_assert(test_property<is_volatile, vClassType>(true), ""); + static_assert(test_property<is_volatile, cvClassType>(true), ""); + + // Negative tests. + static_assert(test_property<is_volatile, int>(false), ""); + static_assert(test_property<is_volatile, const int>(false), ""); + static_assert(test_property<is_volatile, ClassType>(false), ""); + static_assert(test_property<is_volatile, cClassType>(false), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..e128e4b46 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 make_signed<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc new file mode 100644 index 000000000..e3b84d649 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_signed; + using std::is_same; + using std::is_signed; + + // Positive tests. + typedef make_signed<const int>::type test2_type; + static_assert( is_same<test2_type, const int>::value, + "make_signed<const int>" ); + + typedef make_signed<const unsigned int>::type test21c_type; + static_assert( is_same<test21c_type, const signed int>::value, + "make_signed<const unsigned int>" ); + + typedef make_signed<volatile unsigned int>::type test21v_type; + static_assert( is_same<test21v_type, volatile signed int>::value, + "make_signed<volatile unsigned int>" ); + + typedef make_signed<const volatile unsigned int>::type test21cv_type; + static_assert( is_same<test21cv_type, const volatile signed int>::value, + "make_signed<const volatile unsigned int>" ); + + typedef make_signed<const char>::type test22_type; + static_assert( is_same<test22_type, const signed char>::value, + "make_signed<const char>" ); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_signed<volatile wchar_t>::type test23_type; + static_assert( is_same<test23_type, volatile signed wchar_t>::value, + "make_signed<volatile wchar_t>" ); +#endif + + // Chapter 48, chapter 20. Smallest rank such that new signed type same size. + typedef make_signed<test_enum>::type test24_type; + static_assert( is_signed<test24_type>::value, + "make_signed<test_enum> makes signed type" ); + static_assert( sizeof(test24_type) == sizeof(test_enum), + "make_signed<test_enum> makes type of same size" ); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_INT128 + typedef make_signed<unsigned __int128>::type test25_type; + static_assert( is_same<test25_type, __int128>::value, + "make_signed<unsigned __int128>" ); + + typedef make_signed<__int128>::type test26_type; + static_assert( is_same<test26_type, __int128>::value, + "make_signed<__int128>" ); +#endif +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc new file mode 100644 index 000000000..654b3759c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-2.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums" } +// { dg-options "-std=gnu++0x -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux-* } } +// { dg-do compile } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +// Ensure that this enum has "short" as its underlying type. +enum test_enum { first_selection = ((unsigned char)-1) + 1 }; + +void test01() +{ + using std::make_signed; + using std::is_same; + + // Positive tests. + typedef make_signed<const int>::type test2_type; + static_assert(is_same<test2_type, const int>::value, ""); + + typedef make_signed<const unsigned int>::type test21c_type; + static_assert(is_same<test21c_type, const signed int>::value, ""); + + typedef make_signed<volatile unsigned int>::type test21v_type; + static_assert(is_same<test21v_type, volatile signed int>::value, ""); + + typedef make_signed<const volatile unsigned int>::type test21cv_type; + static_assert(is_same<test21cv_type, + const volatile signed int>::value, ""); + + typedef make_signed<const char>::type test22_type; + static_assert(is_same<test22_type, const signed char>::value, ""); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_signed<volatile wchar_t>::type test23_type; + static_assert(is_same<test23_type, volatile signed wchar_t>::value, ""); +#endif + + typedef make_signed<test_enum>::type test24_type; + static_assert(is_same<test24_type, short>::value, ""); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_INT128 + typedef make_signed<unsigned __int128>::type test25_type; + static_assert(is_same<test25_type, __int128>::value, ""); + + typedef make_signed<__int128>::type test26_type; + static_assert(is_same<test26_type, __int128>::value, ""); +#endif +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-3.cc new file mode 100644 index 000000000..16c7c90c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-3.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +template<typename Trait, typename Result> + using test = is_same<typename Trait::type, Result>; + +static_assert( test<make_signed<const int>, make_signed_t<const int>>(), + "make_signed_t<const int>" ); + +static_assert( test<make_signed<unsigned>, make_signed_t<unsigned>>(), + "make_signed_t<unsigned>" ); + +static_assert( test<make_signed<char>, make_signed_t<char>>(), + "make_signed_t<char>" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc new file mode 100644 index 000000000..9f155ea92 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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_character.h> + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_signed; + + // Negative tests. + typedef make_signed<bool>::type test1_type; + + typedef make_signed<__gnu_test::pod_uint>::type test2_type; + + typedef make_signed<int[4]>::type test3_type; + + typedef void (fn_type) (); + typedef make_signed<fn_type>::type test4_type; + + typedef make_signed<float>::type test5_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } +// { dg-error "required from here" "" { target *-*-* } 35 } +// { dg-error "required from here" "" { target *-*-* } 37 } +// { dg-error "required from here" "" { target *-*-* } 40 } +// { dg-error "required from here" "" { target *-*-* } 42 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1714 } +// { dg-error "declaration of" "" { target *-*-* } 1678 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..ce29b2314 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2007-2014 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 make_unsigned<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc new file mode 100644 index 000000000..f07cf4a62 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-1.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_unsigned; + using std::is_same; + using std::is_unsigned; + + // Positive tests. + typedef make_unsigned<const unsigned int>::type test2_type; + static_assert(is_same<test2_type, const unsigned int>::value, ""); + + typedef make_unsigned<const signed int>::type test21c_type; + static_assert(is_same<test21c_type, const unsigned int>::value, ""); + + typedef make_unsigned<volatile signed int>::type test21v_type; + static_assert(is_same<test21v_type, volatile unsigned int>::value, ""); + + typedef make_unsigned<const volatile signed int>::type test21cv_type; + static_assert(is_same<test21cv_type, + const volatile unsigned int>::value, ""); + + typedef make_unsigned<const char>::type test22_type; + static_assert(is_same<test22_type, const unsigned char>::value, ""); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_unsigned<volatile wchar_t>::type test23_type; + static_assert(is_same<test23_type, volatile wchar_t>::value, ""); +#endif + + // Chapter 48, chapter 20. Smallest rank such that new unsigned type + // same size. + typedef make_unsigned<test_enum>::type test24_type; + static_assert(is_unsigned<test24_type>::value, ""); + static_assert(sizeof(test24_type) == sizeof(test_enum), ""); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_INT128 + typedef make_unsigned<unsigned __int128>::type test25_type; + static_assert(is_same<test25_type, unsigned __int128>::value, ""); + + typedef make_unsigned<__int128>::type test26_type; + static_assert(is_same<test26_type, unsigned __int128>::value, ""); +#endif +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc new file mode 100644 index 000000000..8997fb7d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-2.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++11 -funsigned-char -fshort-enums" } +// { dg-options "-std=gnu++11 -funsigned-char -fshort-enums -Wl,--no-enum-size-warning" { target arm*-*-linux-* } } +// { dg-do compile } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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> + +// Ensure that this enum has "short" as its underlying type. +enum test_enum { first_selection = ((unsigned char)-1) + 1 }; + +void test01() +{ + using std::make_unsigned; + using std::is_same; + + // Positive tests. + typedef make_unsigned<const unsigned int>::type test2_type; + static_assert(is_same<test2_type, const unsigned int>::value, ""); + + typedef make_unsigned<const signed int>::type test21c_type; + static_assert(is_same<test21c_type, const unsigned int>::value, ""); + + typedef make_unsigned<volatile signed int>::type test21v_type; + static_assert(is_same<test21v_type, volatile unsigned int>::value, ""); + + typedef make_unsigned<const volatile signed int>::type test21cv_type; + static_assert(is_same<test21cv_type, + const volatile unsigned int>::value, ""); + + typedef make_unsigned<const char>::type test22_type; + static_assert(is_same<test22_type, const unsigned char>::value, ""); + +#ifdef _GLIBCXX_USE_WCHAR_T + typedef make_unsigned<volatile wchar_t>::type test23_type; + static_assert(is_same<test23_type, volatile wchar_t>::value, ""); +#endif + + typedef make_unsigned<test_enum>::type test24_type; + static_assert(is_same<test24_type, unsigned short>::value, ""); + + // GNU Extensions. +#ifdef _GLIBCXX_USE_INT128 + typedef make_unsigned<unsigned __int128>::type test25_type; + static_assert(is_same<test25_type, unsigned __int128>::value, ""); + + typedef make_unsigned<__int128>::type test26_type; + static_assert(is_same<test26_type, unsigned __int128>::value, ""); +#endif +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-3.cc new file mode 100644 index 000000000..5bdea5dc9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-3.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +template<typename Trait, typename Result> + using test = is_same<typename Trait::type, Result>; + +static_assert( test<make_unsigned<const int>, make_unsigned_t<const int>>(), + "make_unsigned_t<const int>" ); + +static_assert( test<make_unsigned<unsigned>, make_unsigned_t<unsigned>>(), + "make_unsigned_t<unsigned>" ); + +static_assert( test<make_unsigned<char>, make_unsigned_t<char>>(), + "make_unsigned_t<char>" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc new file mode 100644 index 000000000..57a5c6167 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> +// +// Copyright (C) 2007-2014 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_character.h> + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_unsigned; + + // Negative tests. + typedef make_unsigned<bool>::type test1_type; + + typedef make_unsigned<__gnu_test::pod_uint>::type test2_type; + + typedef make_unsigned<int[4]>::type test3_type; + + typedef void (fn_type) (); + typedef make_unsigned<fn_type>::type test4_type; + + typedef make_unsigned<float>::type test5_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } +// { dg-error "required from here" "" { target *-*-* } 35 } +// { dg-error "required from here" "" { target *-*-* } 37 } +// { dg-error "required from here" "" { target *-*-* } 40 } +// { dg-error "required from here" "" { target *-*-* } 42 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1632 } +// { dg-error "declaration of" "" { target *-*-* } 1596 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/move/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/move/1.cc new file mode 100644 index 000000000..dcd5b83f5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/move/1.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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 <memory> +#include <utility> + +template<class T, class A1> + std::shared_ptr<T> + factory(A1&& a1) + { + return std::shared_ptr<T>(new T(std::forward<A1>(a1))); + } + +struct A +{ + A(); + A(const A&); + A(A&&); +}; + +void g() +{ + A a; + std::shared_ptr<A> sp1 = factory<A>(a); + std::shared_ptr<A> sp2 = factory<A>(std::move(a)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..387a4fd31 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/move/requirements/explicit_instantiation.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-07-10 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 utility with NO OTHER INCLUDES. + +#include <utility> + +namespace std +{ + typedef short test_type; + template std::remove_reference<test_type>::type&& move(test_type&&); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/1.cc new file mode 100644 index 000000000..09207ae02 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/1.cc @@ -0,0 +1,119 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-04-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> +#include <testsuite_hooks.h> + +struct noexcept_move_copy +{ + noexcept_move_copy() + : status(true) + { }; + + noexcept_move_copy(noexcept_move_copy&& r) noexcept + { r.status = false; }; + + noexcept_move_copy(const noexcept_move_copy&) = default; + + operator bool() { return status; } + +private: + bool status; +}; + +struct noexcept_move_no_copy +{ + noexcept_move_no_copy() + : status(true) + { }; + + noexcept_move_no_copy(noexcept_move_no_copy&& r) noexcept + { r.status = false; }; + + noexcept_move_no_copy(const noexcept_move_no_copy&) = delete; + + operator bool() { return status; } + +private: + bool status; +}; + +struct except_move_copy +{ + except_move_copy() + : status(true) + { }; + + except_move_copy(except_move_copy&& r) noexcept(false) + { r.status = false; }; + + except_move_copy(const except_move_copy&) = default; + + operator bool() { return status; } + +private: + bool status; +}; + +struct except_move_no_copy +{ + except_move_no_copy() + : status(true) + { }; + + except_move_no_copy(except_move_no_copy&& r) noexcept(false) + { r.status = false; }; + + except_move_no_copy(const except_move_no_copy&) = delete; + + operator bool() { return status; } + +private: + bool status; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + noexcept_move_copy nemc1; + auto nemc2 __attribute__((unused)) = std::move_if_noexcept(nemc1); + VERIFY( nemc1 == false ); + + noexcept_move_no_copy nemnc1; + auto nemnc2 __attribute__((unused)) = std::move_if_noexcept(nemnc1); + VERIFY( nemnc1 == false ); + + except_move_copy emc1; + auto emc2 __attribute__((unused)) = std::move_if_noexcept(emc1); + VERIFY( emc1 == true ); + + except_move_no_copy emnc1; + auto emnc2 __attribute__((unused)) = std::move_if_noexcept(emnc1); + VERIFY( emnc1 == false ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/constexpr.cc new file mode 100644 index 000000000..19f172c63 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/constexpr.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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> +#include <testsuite_hooks.h> + +struct simple +{ + int i; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + constexpr simple s { 5 }; + constexpr auto s2 __attribute__((unused)) = std::move_if_noexcept(s); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..8c0bdde43 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/move_if_noexcept/requirements/explicit_instantiation.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2011-04-27 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 utility with NO OTHER INCLUDES. + +#include <utility> + +namespace std +{ + typedef short test_type; + + template + std::conditional<(!std::is_nothrow_move_constructible<test_type>::value + && std::is_copy_constructible<test_type>::value), + const test_type&, test_type&&>::type + move_if_noexcept(test_type&); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc new file mode 100644 index 000000000..2a7bc451b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc @@ -0,0 +1,135 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.13.4 Template class owner_less [util.smartptr.ownerless] + +#include <memory> +#include <algorithm> +#include <testsuite_hooks.h> + +struct A { }; + +struct B { A a[2]; }; + +// 20.8.13.4 Template class owner_less [util.smartptr.ownerless] + +int +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty shared_ptrs compare equivalent + std::owner_less<std::shared_ptr<A>> less; + std::owner_less<std::weak_ptr<A>> wless; + std::shared_ptr<A> p1; + std::shared_ptr<A> p2; + VERIFY( !less(p1, p2) && !less(p2, p1) ); + std::weak_ptr<A> p3; + VERIFY( !less(p1, p3) && !less(p3, p1) ); + VERIFY( !wless(p1, p3) && !wless(p3, p1) ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::owner_less<std::shared_ptr<A>> less; + std::owner_less<std::weak_ptr<A>> wless; + + std::shared_ptr<A> empty; + + std::shared_ptr<A> a1(new A); + VERIFY( less(empty, a1) || less(a1, empty) ); + + std::shared_ptr<A> a2(new A); + VERIFY( less(a1, a2) || less(a2, a1) ); + + std::weak_ptr<A> w1(a1); + VERIFY( !less(a1, w1) && !less(w1, a1) ); + + std::weak_ptr<A> w2(a2); + VERIFY( wless(w1, w2) || wless(w2, w1) ); + + a1.reset(); + VERIFY( !less(empty, a1) && !less(a1, empty) ); + VERIFY( less(a1, w1) || less(w1, a1) ); + + a2.reset(); + VERIFY( !less(a2, a1) && !less(a1, a2) ); + + return 0; +} + +// aliasing +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::owner_less<std::shared_ptr<A>> less; + std::owner_less<std::weak_ptr<A>> wless; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a0(b, &b->a[0]); + std::shared_ptr<A> a1(b, &b->a[1]); + // values are different but owners are equivalent: + VERIFY( a0 < a1 && !less(a0, a1) && !less(a1, a0) ); + + std::weak_ptr<A> w0(a0); + std::weak_ptr<A> w1(a1); + VERIFY( !wless(w0, w1) && !wless(w1, w0) ); + VERIFY( !less(a0, w1) && !less(w1, a0) ); + VERIFY( !wless(w0, a1) && !wless(a1, w0) ); + + return 0; +} + +// strict weak ordering +int +test04() +{ + bool test __attribute__((unused)) = true; + + std::owner_less<std::shared_ptr<A>> less; + + std::shared_ptr<A> a[3]; + a[0].reset(new A); + a[1].reset(new A); + a[2].reset(new A); + std::sort(a, a+3, less); + VERIFY( !less(a[0], a[0]) ); + VERIFY( less(a[0], a[1]) && !less(a[1], a[0]) ); + VERIFY( less(a[0], a[1]) && less(a[1], a[2]) && less(a[0], a[2]) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/1.cc new file mode 100644 index 000000000..bd1d926e3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/1.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + + +// heterogeneous +void test01() +{ + bool test __attribute__((unused)) = true; + + std::pair<bool, long> p_bl_1(true, 433); + std::pair<bool, long> p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + std::pair<const char*, float> p_sf_1("total enlightenment", 433.00); + std::pair<const char*, float> p_sf_2 = std::make_pair("total enlightenment", + 433.00); + VERIFY( p_sf_1 == p_sf_2 ); + VERIFY( !(p_sf_1 < p_sf_2) ); + + std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5)); + std::pair<const char*, gnu_obj> p_sg_2 = std::make_pair("enlightenment", + gnu_obj(5)); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5)); + std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(gnu_t<long>(false), + gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/2.cc new file mode 100644 index 000000000..bc69df6ee --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/2.cc @@ -0,0 +1,59 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + +// homogeneous +void test02() +{ + bool test __attribute__((unused)) = true; + + std::pair<bool, bool> p_bb_1(true, false); + std::pair<bool, bool> p_bb_2 = std::make_pair(true, false); + VERIFY( p_bb_1 == p_bb_2 ); + VERIFY( !(p_bb_1 < p_bb_2) ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/3.cc new file mode 100644 index 000000000..7e4e30f29 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/3.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + + +// const +void test03() +{ + bool test __attribute__((unused)) = true; + + const std::pair<bool, long> p_bl_1(true, 433); + const std::pair<bool, long> p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + const std::pair<const char*, float> p_sf_1("total enlightenment", 433.00); + const std::pair<const char*, float> p_sf_2 = + std::make_pair("total enlightenment", 433.00); + VERIFY( p_sf_1 == p_sf_2 ); + VERIFY( !(p_sf_1 < p_sf_2) ); + + const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5)); + const std::pair<const char*, gnu_obj> p_sg_2 = + std::make_pair("enlightenment", gnu_obj(5)); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + const std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5)); + const std::pair<gnu_t<long>, gnu_obj> p_st_2 = + std::make_pair(gnu_t<long>(false), gnu_obj(5)); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/4.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/4.cc new file mode 100644 index 000000000..40ec9bd64 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/4.cc @@ -0,0 +1,66 @@ +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.2.2 Pairs + +#include <utility> +#include <testsuite_hooks.h> + +class gnu_obj +{ + int i; +public: + gnu_obj(int arg = 0): i(arg) { } + bool operator==(const gnu_obj& rhs) const { return i == rhs.i; } + bool operator<(const gnu_obj& rhs) const { return i < rhs.i; } +}; + +template<typename T> + struct gnu_t + { + bool b; + public: + gnu_t(bool arg = 0): b(arg) { } + bool operator==(const gnu_t& rhs) const { return b == rhs.b; } + bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); } + }; + +// const& +void test04() +{ + bool test __attribute__((unused)) = true; + const gnu_obj& obj1 = gnu_obj(5); + const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", obj1); + const std::pair<const char*, gnu_obj> p_sg_2 = + std::make_pair("enlightenment", obj1); + VERIFY( p_sg_1 == p_sg_2 ); + VERIFY( !(p_sg_1 < p_sg_2) ); + + const gnu_t<long>& tmpl1 = gnu_t<long>(false); + const std::pair<gnu_t<long>, gnu_obj> p_st_1(tmpl1, obj1); + const std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(tmpl1, obj1); + VERIFY( p_st_1 == p_st_2 ); + VERIFY( !(p_st_1 < p_st_2) ); +} + +int main() +{ + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/40925.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/40925.cc new file mode 100644 index 000000000..599fd3875 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/40925.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/44487.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/44487.cc new file mode 100644 index 000000000..52474d735 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/44487.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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> + +int x, y; + +std::pair<int&, int&> +foo1() +{ + std::pair<int&, int&> blah(x, y); + return blah; +} + +std::pair<int&, int&> +foo2() +{ + const std::pair<int&, int&> blah(x, y); + return blah; +} + +std::pair<int&, int&> +foo3() +{ + std::pair<int&, int&> blah(x, y); + return std::pair<int&, int&>(std::move(blah)); +} + +std::pair<int&, int&> +foo4() +{ + const std::pair<int&, int&> blah(x, y); + return std::pair<int&, int&>(std::move(blah)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/astuple.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/astuple.cc new file mode 100644 index 000000000..6d2f27fb2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/astuple.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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> +#include <type_traits> + +typedef std::pair<int, long> test_type; + +static_assert( std::tuple_size<test_type>::value == 2, "size is 2" ); + +template<std::size_t N, typename T> + using Tuple_elt = typename std::tuple_element<N, T>::type; + +using std::is_same; + +static_assert( is_same<Tuple_elt<0, test_type>, test_type::first_type>::value, + "first type is int" ); + +static_assert( is_same<Tuple_elt<1, test_type>, test_type::second_type>::value, + "second type is long" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/constexpr_get.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/constexpr_get.cc new file mode 100644 index 000000000..4adbf347d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/constexpr_get.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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-like access to pair + +#include <utility> + +std::pair<int, char> p; +const std::pair<int, char> cp; + +constexpr const int& cri = std::get<0>(cp); +constexpr int& ri = std::get<0>(p); +constexpr int&& rri = std::get<0>(std::move(p)); + +constexpr const char& crc = std::get<1>(cp); +constexpr char& rc = std::get<1>(p); +constexpr char&& rrc = std::get<1>(std::move(p)); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/constexpr_get_by_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/constexpr_get_by_type.cc new file mode 100644 index 000000000..a99acdf7c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/constexpr_get_by_type.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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-like access to pair + +#include <utility> + +std::pair<int, char> p; +const std::pair<int, char> cp; + +constexpr const int& cri = std::get<int>(cp); +constexpr int& ri = std::get<int>(p); +constexpr int&& rri = std::get<int>(std::move(p)); + +constexpr const char& crc = std::get<char>(cp); +constexpr char& rc = std::get<char>(p); +constexpr char&& rrc = std::get<char>(std::move(p)); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get.cc new file mode 100644 index 000000000..b7e3dfd42 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-16 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> + +void test01() +{ + std::pair<float, int> p; + + float&& pfirst __attribute__((unused)) = std::get<0>(std::move(p)); + int&& psecond __attribute__((unused)) = std::get<1>(std::move(p)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_by_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_by_type.cc new file mode 100644 index 000000000..fb066348f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_by_type.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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> + +void test01() +{ + std::pair<float, int> p; + + float&& pfirst __attribute__((unused)) = std::get<float>(std::move(p)); + int&& psecond __attribute__((unused)) = std::get<int>(std::move(p)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_by_type_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_by_type_neg.cc new file mode 100644 index 000000000..a2bb0ab29 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_by_type_neg.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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> + +void test01() +{ + std::pair<int, int> p; + + std::get<int>(p); // { dg-error "ambiguous" } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc new file mode 100644 index 000000000..5598090d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/astuple/get_neg.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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> + +void test01() +{ + std::pair<int, int> p; + + std::get<2>(p); // { dg-error "no matching function" } +} + +// { dg-prune-output "tuple_element<2" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc new file mode 100644 index 000000000..0bd75d3de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_comparison_operators test; + test.operator()<std::pair<int, int>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc new file mode 100644 index 000000000..9cffaecce --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_common_types.h> + +int main() +{ + typedef std::pair<int, int> pair_type; + + __gnu_test::constexpr_default_constructible test1; + test1.operator()<pair_type>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<pair_type, pair_type>(); + test2.operator()<pair_type, std::pair<short, short>>(); + + // test 3 + const int i1(129); + const int i2(6); + constexpr pair_type p0(i1, i2); + + // test 4 + constexpr int i(999); + constexpr pair_type p1 { 44, 90 }; + constexpr pair_type p2 { std::move(p1.first), i }; + constexpr pair_type p3 { i, std::move(p1.second) }; + + constexpr pair_type p5 { 444, 904 }; + constexpr pair_type p6 { std::move(p5.first), std::move(p5.second) }; + + constexpr std::pair<char, char> p8 { 'a', 'z' }; + constexpr pair_type p9(std::move(p8)); + + constexpr pair_type p10(std::move(p0)); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..af7781769 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/cons/noexcept_move_construct.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +typedef std::pair<int, int> tt1; +typedef std::pair<int, double> tt2; +typedef std::pair<NoexceptMoveConsClass, + NoexceptMoveConsClass> tt3; +typedef std::pair<ExceptMoveConsClass, ExceptMoveConsClass> tt4; +typedef std::pair<ExceptMoveConsClass, double> tt5; +typedef std::pair<NoexceptMoveConsClass, + ExceptMoveConsClass> tt6; + +static_assert(std::is_nothrow_move_constructible<tt1>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt2>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt3>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt4>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt5>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt6>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/constexpr_get.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/constexpr_get.cc new file mode 100644 index 000000000..216e41059 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/constexpr_get.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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> + +std::pair<int, int> pi; +const std::pair<int, int> cpi; + +constexpr const int& cri = std::get<0>(cpi); +constexpr int& ri = std::get<0>(pi); +constexpr int&& rri = std::get<0>(std::move(pi)); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/make_pair/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/make_pair/constexpr.cc new file mode 100644 index 000000000..def5c65f4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/make_pair/constexpr.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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/>. + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on pair, and also vector. If the implementation +// changes this test may begin to fail. + +#include <memory> +#include <testsuite_hooks.h> + +void +test1() +{ + bool test __attribute__((unused)) = true; + typedef std::pair<int, float> pair_type; + constexpr pair_type p1 __attribute__((unused)) = std::make_pair(22, 22.222); +} + +int +main() +{ + test1(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/moveable.cc new file mode 100644 index 000000000..c35c0f064 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/moveable.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on pair, and also vector. If the implementation +// changes this test may begin to fail. + +#include <vector> +#include <utility> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +void +test1() +{ + std::pair<int,int> a(1,1),b(2,2); + a=std::move(b); + VERIFY(a.first == 2 && a.second == 2 && b.first == 2 && b.second == 2); + std::pair<int,int> c(std::move(a)); + VERIFY(c.first == 2 && c.second == 2 && a.first == 2 && a.second == 2); +} + +void +test2() +{ + std::vector<int> v,w; + v.push_back(1); + w.push_back(2); + w.push_back(2); + std::pair<int, std::vector<int> > p = make_pair(1,v); + std::pair<int, std::vector<int> > q = make_pair(2,w); + p = std::move(q); + VERIFY(p.first == 2 && q.first == 2 && + p.second.size() == 2 && q.second.size() == 0); + std::pair<int, std::vector<int> > r(std::move(p)); + VERIFY(r.first == 2 && p.first == 2 && + r.second.size() == 2 && p.second.size() == 0); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noexcept_move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noexcept_move_assign.cc new file mode 100644 index 000000000..298f7ba22 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noexcept_move_assign.cc @@ -0,0 +1,42 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +typedef std::pair<int, int> tt1; +typedef std::pair<int, double> tt2; +typedef std::pair<NoexceptMoveAssignClass, + NoexceptMoveAssignClass> tt3; +typedef std::pair<ExceptMoveAssignClass, ExceptMoveAssignClass> tt4; +typedef std::pair<ExceptMoveAssignClass, double> tt5; +typedef std::pair<NoexceptMoveAssignClass, + ExceptMoveAssignClass> tt6; + +static_assert(std::is_nothrow_move_assignable<tt1>::value, "Error"); +static_assert(std::is_nothrow_move_assignable<tt2>::value, "Error"); +static_assert(std::is_nothrow_move_assignable<tt3>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt4>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt5>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt6>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noexcept_swap.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noexcept_swap.cc new file mode 100644 index 000000000..71c237bb7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noexcept_swap.cc @@ -0,0 +1,81 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +typedef std::pair<int, int> tt1; +typedef std::pair<int, double> tt2; +typedef std::pair<short, NoexceptMoveAssignClass> tt4; +typedef std::pair<ExceptMoveAssignClass, double> tt6; +typedef std::pair<int, ExceptMoveConsClass> tt9; +typedef std::pair<ExceptMoveAssignClass, short> tt10; +typedef std::pair<short, NoexceptMoveConsClass> tt11; +typedef std::pair<NoexceptMoveConsClass, + NoexceptMoveConsClass> tt12; +typedef std::pair<NoexceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsNoexceptMoveAssignClass> tt13; +typedef std::pair<ExceptMoveConsNoexceptMoveAssignClass, + ExceptMoveConsNoexceptMoveAssignClass> tt14; +typedef std::pair<NoexceptMoveConsExceptMoveAssignClass, + NoexceptMoveConsExceptMoveAssignClass> tt15; +typedef std::pair<ExceptMoveConsExceptMoveAssignClass, + ExceptMoveConsExceptMoveAssignClass> tt16; +typedef std::pair<NoexceptMoveConsNoexceptMoveAssignClass, + double> tt17; +typedef std::pair<NoexceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsNoexceptMoveAssignClass> tt19; +typedef std::pair<NoexceptMoveConsNoexceptMoveAssignClass, + ExceptMoveConsNoexceptMoveAssignClass> tt21; + +static_assert(noexcept(std::declval<tt1&>().swap(std::declval<tt1&>())), + "Error"); +static_assert(noexcept(std::declval<tt2&>().swap(std::declval<tt2&>())), + "Error"); +static_assert(noexcept(std::declval<tt4&>().swap(std::declval<tt4&>())), + "Error"); +static_assert(!noexcept(std::declval<tt6&>().swap(std::declval<tt6&>())), + "Error"); +static_assert(!noexcept(std::declval<tt9&>().swap(std::declval<tt9&>())), + "Error"); +static_assert(!noexcept(std::declval<tt10&>().swap(std::declval<tt10&>())), + "Error"); +static_assert(noexcept(std::declval<tt11&>().swap(std::declval<tt11&>())), + "Error"); +static_assert(noexcept(std::declval<tt12&>().swap(std::declval<tt12&>())), + "Error"); +static_assert(noexcept(std::declval<tt13&>().swap(std::declval<tt13&>())), + "Error"); +static_assert(!noexcept(std::declval<tt14&>().swap(std::declval<tt14&>())), + "Error"); +static_assert(!noexcept(std::declval<tt15&>().swap(std::declval<tt15&>())), + "Error"); +static_assert(!noexcept(std::declval<tt16&>().swap(std::declval<tt16&>())), + "Error"); +static_assert(noexcept(std::declval<tt17&>().swap(std::declval<tt17&>())), + "Error"); +static_assert(noexcept(std::declval<tt19&>().swap(std::declval<tt19&>())), + "Error"); +static_assert(!noexcept(std::declval<tt21&>().swap(std::declval<tt21&>())), + "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noncopyable.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noncopyable.cc new file mode 100644 index 000000000..55b1cc287 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/noncopyable.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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> + +// PR c++/51213 +class Uncopyable +{ + Uncopyable(const Uncopyable&); + public: + Uncopyable() = default; +}; + +struct ContainsUncopyable +{ + std::pair<Uncopyable, int> pv; +}; + +void foo() +{ + ContainsUncopyable c; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/piecewise.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/piecewise.cc new file mode 100644 index 000000000..cd76a6e57 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/piecewise.cc @@ -0,0 +1,98 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-04-30 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 <utility> +#include <tuple> +#include <testsuite_hooks.h> + +struct type_zero +{ + type_zero() : n_(757) { } + + type_zero(const type_zero&) = delete; + type_zero(type_zero&& other) : n_(other.n_) { } + + int get() const { return n_; } + +private: + int n_; +}; + +struct type_one +{ + type_one(int n) : n_(n) { } + + type_one(const type_one&) = delete; + type_one(type_one&& other) : n_(other.n_) { } + + int get() const { return n_; } + +private: + int n_; +}; + +struct type_two +{ + type_two(int n1, int n2) : n1_(n1), n2_(n2) { } + + type_two(const type_two&) = delete; + type_two(type_two&& other) : n1_(other.n1_), n2_(other.n2_) { } + + int get1() const { return n1_; } + int get2() const { return n2_; } + +private: + int n1_, n2_; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::pair<type_one, type_zero> pp0(std::piecewise_construct_t(), + std::forward_as_tuple(-3), + std::forward_as_tuple()); + VERIFY( pp0.first.get() == -3 ); + VERIFY( pp0.second.get() == 757 ); + + std::pair<type_one, type_two> pp1(std::piecewise_construct_t(), + std::forward_as_tuple(6), + std::forward_as_tuple(5, 4)); + VERIFY( pp1.first.get() == 6 ); + VERIFY( pp1.second.get1() == 5 ); + VERIFY( pp1.second.get2() == 4 ); + + std::pair<type_two, type_two> pp2(std::piecewise_construct_t(), + std::forward_as_tuple(2, 1), + std::forward_as_tuple(-1, -3)); + VERIFY( pp2.first.get1() == 2 ); + VERIFY( pp2.first.get2() == 1 ); + VERIFY( pp2.second.get1() == -1 ); + VERIFY( pp2.second.get2() == -3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc new file mode 100644 index 000000000..e6ac913dc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc @@ -0,0 +1,61 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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> +#include <tuple> + +struct NoCon +{ + NoCon() = delete; + NoCon(const NoCon&) = delete; +}; + +struct RefCheck1 +{ + RefCheck1(NoCon&, NoCon&&) { } + RefCheck1() = delete; + RefCheck1(const RefCheck1&) = delete; +}; + +struct RefCheck2 +{ + RefCheck2(const NoCon&, const NoCon&&, NoCon&) { } + RefCheck2() = delete; + RefCheck2(const RefCheck2&) = delete; +}; + +struct Default +{ + Default(); + Default(const Default&) = delete; +}; + +// libstdc++/51183 +void test01(std::tuple<NoCon&, NoCon&&> t1, + std::tuple<NoCon&, NoCon&&, NoCon&> t2) +{ + std::pair<RefCheck1, RefCheck2>(std::piecewise_construct, + std::move(t1), std::move(t2)); +} + +void test02(std::tuple<> t1, std::tuple<int> t2) +{ + std::pair<Default, int> A(std::piecewise_construct, t1, t2); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc new file mode 100644 index 000000000..e90530483 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <memory> +#include <type_traits> + +// DR 801, pair and tuple vs. "passed in registers" +void test_trivial() +{ + // PODType, TType, NType, SLType, LType, NLType, LTypeDerived + typedef std::pair<int, int> pair_type; + // static_assert(std::is_literal_type<pair_type>::value, "! literal"); + static_assert(std::has_trivial_copy_constructor<pair_type>::value, + "! triv copy"); + static_assert(std::is_trivially_destructible<pair_type>::value, + "! triv destructor"); + // static_assert(std::is_standard_layout<pair_type>::value, + // "! standard layout"); + + // Negative + /* + static_assert(std::has_trivial_default_constructor<pair_type>::value, + "! triv default"); + static_assert(std::has_trivial_copy_assign<pair_type>::value, + "! triv assign"); + static_assert(std::is_trivial<pair_type>::value, "! triv"); + static_assert(std::is_pod<pair_type>::value, "! pod"); + */ +} + +int main() +{ + test_trivial(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..78005a106 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <utility> + +template class std::pair<int, long>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/swap.cc new file mode 100644 index 000000000..3998fe9f9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pair/swap.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <testsuite_allocator.h> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef __gnu_test::uneq_allocator<double> ua_type; + ua_type one(1), two(2); + + std::pair<ua_type, int> p1(one, 1), p2(two, 2); + + p1.swap(p2); + VERIFY( p1.first.get_personality() == 2 ); + VERIFY( p1.second == 2 ); + VERIFY( p2.first.get_personality() == 1 ); + VERIFY( p2.second == 1 ); + + swap(p1, p2); + VERIFY( p2.first.get_personality() == 2 ); + VERIFY( p2.second == 2 ); + VERIFY( p1.first.get_personality() == 1 ); + VERIFY( p1.second == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/pointer_to.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/pointer_to.cc new file mode 100644 index 000000000..f80740682 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/pointer_to.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <testsuite_hooks.h> + +struct Ptr +{ + typedef bool element_type; + bool* value; + + static Ptr pointer_to(bool& b) { return Ptr{&b}; } +}; + +bool operator==(const Ptr& l, const Ptr& r) { return l.value == r.value; } + +void test01() +{ + bool test = true; + Ptr p{ &test }; + + VERIFY( std::pointer_traits<Ptr>::pointer_to(test) == p ); +} + +void test02() +{ + bool test = true; + + VERIFY( std::pointer_traits<bool*>::pointer_to(test) == &test ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..35f5c4281 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 memory with NO OTHER INCLUDES. + +#include <memory> + +namespace std +{ + typedef short test_type; + template struct pointer_traits<test_type*>; + template struct pointer_traits<shared_ptr<test_type>>; + template struct pointer_traits<unique_ptr<test_type>>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/typedefs.cc new file mode 100644 index 000000000..c95e4ce2f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/pointer_traits/requirements/typedefs.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 memory with NO OTHER INCLUDES. + +#include <memory> + +// { dg-do compile } + +template<typename Ptr> +void test01() +{ + // Check for required typedefs + typedef std::pointer_traits<Ptr> test_type; + typedef typename test_type::pointer pointer; + typedef typename test_type::element_type element_type; + typedef typename test_type::difference_type difference_type; + typedef typename test_type::template rebind<char> rebind_type; +} + +int main() +{ + test01<int*>(); + test01<void*>(); + test01<std::shared_ptr<int>>(); + test01<std::shared_ptr<void>>(); + test01<std::unique_ptr<int>>(); + test01<std::unique_ptr<void>>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..f1ebbc41a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 rank<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/requirements/typedefs.cc new file mode 100644 index 000000000..1f6f22d32 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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::rank<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/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/value.cc new file mode 100644 index 000000000..7efa472e4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/rank/value.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::rank; + using namespace __gnu_test; + + static_assert(test_property<rank, int>(0), ""); + static_assert(test_property<rank, int[2]>(1), ""); + static_assert(test_property<rank, int[][4]>(2), ""); + static_assert(test_property<rank, int[2][2][4][4][6][6]>(6), ""); + static_assert(test_property<rank, ClassType>(0), ""); + static_assert(test_property<rank, ClassType[2]>(1), ""); + static_assert(test_property<rank, ClassType[][4]>(2), ""); + static_assert(test_property<rank, ClassType[2][2][4][4][6][6]>(6), ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc new file mode 100644 index 000000000..b13d5329f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp1.cc @@ -0,0 +1,86 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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 <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,3>>::value == 1 )); + VERIFY(( std::ratio_equal<std::ratio<2,6>, std::ratio<1,4>>::value == 0 )); + + VERIFY( (std::ratio_not_equal<std::ratio<2,6>, + std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_not_equal<std::ratio<2,6>, + std::ratio<1,4>>::value == 1) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + VERIFY( (std::ratio_less<std::ratio<1,4>, std::ratio<1,3>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<1,3>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<1,4>>::value == 0) ); + VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<-1,3>>::value == 0) ); + + VERIFY( (std::ratio_less<std::ratio<-1,3>, std::ratio<-1,4>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<0,4>, std::ratio<0,3>>::value == 0) ); + VERIFY( (std::ratio_less<std::ratio<1,3>, std::ratio<0,3>>::value == 0) ); + VERIFY( (std::ratio_less<std::ratio<0,3>, std::ratio<-1,4>>::value == 0) ); + + VERIFY( (std::ratio_less_equal<std::ratio<-1,3>, + std::ratio<-1,3>>::value == 1) ); + VERIFY( ( std::ratio_less_equal<std::ratio<1,4>, + std::ratio<1,3>>::value == 1) ); + + VERIFY( (std::ratio_less_equal<std::ratio<1,4>, + std::ratio<-1,3>>::value == 0) ); + VERIFY( (std::ratio_less_equal<std::ratio<1,3>, + std::ratio<-1,3>>::value == 0) ); + + VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<1,4>>::value == 1) ); + VERIFY( (std::ratio_greater<std::ratio<1,3>, std::ratio<-1,3>>::value == 1) ); + + VERIFY( (std::ratio_greater<std::ratio<1,4>, std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_greater<std::ratio<-1,3>, std::ratio<1,3>>::value == 0) ); + + VERIFY( (std::ratio_greater_equal<std::ratio<1,3>, + std::ratio<1,3>>::value == 1) ); + VERIFY( (std::ratio_greater_equal<std::ratio<1,3>, + std::ratio<-1,3>>::value == 1) ); + + VERIFY( (std::ratio_greater_equal<std::ratio<-1,3>, + std::ratio<1,3>>::value == 0) ); + VERIFY( (std::ratio_greater_equal<std::ratio<1,4>, + std::ratio<1,3>>::value == 0) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc new file mode 100644 index 000000000..ca69b9683 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp2.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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 <ratio> +#include <testsuite_hooks.h> + +static const std::intmax_t M = INTMAX_MAX; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + // No overflow with same denominator + VERIFY( (std::ratio_less<std::ratio<M - 2, M>, + std::ratio<M - 1, M>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<M - 1, M>, + std::ratio<M - 2, M>>::value == 0) ); + + // No overflow if signs differ + VERIFY( (std::ratio_less<std::ratio<-M, M - 1>, + std::ratio<M - 1, M - 2>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<M - 1, M - 2>, + std::ratio<-M, M - 1>>::value == 0) ); + + // No overflow + VERIFY( (std::ratio_less<std::ratio<M, M - 1>, + std::ratio<M, M - 2>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<-M, M - 1>, + std::ratio<-M, M - 2>>::value == 0) ); + + VERIFY( (std::ratio_less<std::ratio<M - 2, M - 1>, + std::ratio<M - 1, M>>::value == 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp3.cc new file mode 100644 index 000000000..8fa03bf24 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/comparisons/comp3.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2011-02-28 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2011-2014 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 <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( (std::ratio_less<std::ratio<59, 29131>, + std::ratio<59, 29129>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<4733, 13>, + std::ratio<4751, 13>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<25703, 25717>, + std::ratio<25733, 25741>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<631, 769>, + std::ratio<673, 773>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<8353, 16903>, + std::ratio<17891, 32099>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<2311, 18701>, + std::ratio<18457, 19571>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<60, 29132>, + std::ratio<60, 29130>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<4734, 14>, + std::ratio<4752, 14>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<25704, 25718>, + std::ratio<25732, 25742>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<632, 770>, + std::ratio<674, 774>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<8352, 16904>, + std::ratio<17892, 32100>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<2312, 18702>, + std::ratio<18458, 19572>>::value == 1) ); + + VERIFY( (std::ratio_less<std::ratio<58, 29130>, + std::ratio<58, 29128>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<4732, 12>, + std::ratio<4750, 12>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<25702, 25716>, + std::ratio<25734, 25740>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<630, 768>, + std::ratio<672, 772>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<8354, 16902>, + std::ratio<17890, 32102>>::value == 1) ); + VERIFY( (std::ratio_less<std::ratio<2310, 18700>, + std::ratio<18456, 19570>>::value == 1) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc new file mode 100644 index 000000000..e03b33484 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/cons/cons1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio<1,3> r0; + std::ratio<2,6> r1; + std::ratio<2,-6> r2; + std::ratio<-2,6> r3; + + VERIFY( r0.num == 1 ); + VERIFY( r0.den == 3 ); + + VERIFY( r1.num == r0.num ); + VERIFY( r1.den == r0.den ); + VERIFY( r2.num == -r0.num ); + VERIFY( r2.den == r0.den ); + VERIFY( r3.num == -r0.num ); + VERIFY( r3.den == r0.den ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc new file mode 100644 index 000000000..790aedd82 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc @@ -0,0 +1,55 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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 <ratio> + +void +test01() +{ + std::ratio<INTMAX_MAX, INTMAX_MAX> r1 __attribute__((unused)); + std::ratio<-INTMAX_MAX, INTMAX_MAX> r2 __attribute__((unused)); +} + +void +test02() +{ + std::ratio<INTMAX_MIN, 1> r1 __attribute__((unused)); +} + +void +test03() +{ + std::ratio<1, INTMAX_MIN> r1 __attribute__((unused)); +} + +void +test04() +{ + std::ratio<1,0> r1 __attribute__((unused)); +} + +// { dg-error "required from here" "" { target *-*-* } 34 } +// { dg-error "required from here" "" { target *-*-* } 40 } +// { dg-error "required from here" "" { target *-*-* } 46 } +// { dg-error "denominator cannot be zero" "" { target *-*-* } 265 } +// { dg-error "out of range" "" { target *-*-* } 266 } +// { dg-error "overflow in constant expression" "" { target *-*-* } 61 } +// { dg-prune-output "not a member" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc new file mode 100644 index 000000000..b7841bab2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/45866.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2010-10-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <ratio> +#include <testsuite_hooks.h> + +// libstdc++/45866 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::ratio<1, 4>::type r_type1; + typedef std::ratio<3, 2>::type r_type2; + + typedef std::ratio_add<r_type1, r_type2> ra_type; + + VERIFY( ra_type::num == ra_type::type::num ); + VERIFY( ra_type::den == ra_type::type::den ); + VERIFY( ra_type::num == 7 ); + VERIFY( ra_type::den == 4 ); + + typedef std::ratio_subtract<r_type1, r_type2> rs_type; + + VERIFY( rs_type::num == rs_type::type::num ); + VERIFY( rs_type::den == rs_type::type::den ); + VERIFY( rs_type::num == -5 ); + VERIFY( rs_type::den == 4 ); + + typedef std::ratio_multiply<r_type1, r_type2> rm_type; + + VERIFY( rm_type::num == rm_type::type::num ); + VERIFY( rm_type::den == rm_type::type::den ); + VERIFY( rm_type::num == 3 ); + VERIFY( rm_type::den == 8 ); + + typedef std::ratio_divide<r_type1, r_type2> rd_type; + + VERIFY( rd_type::num == rd_type::type::num ); + VERIFY( rd_type::den == rd_type::type::den ); + VERIFY( rd_type::num == 1 ); + VERIFY( rd_type::den == 6 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/47913.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/47913.cc new file mode 100644 index 000000000..0e3e45605 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/47913.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2011-2014 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 <ratio> +#include <limits> +#include <testsuite_hooks.h> + +// libstdc++/47913 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + const intmax_t m1 = (intmax_t)1 << (4 * sizeof(intmax_t) - 1); + typedef ratio_add<ratio<1, (m1 - 1) * (m1 - 2)>, + ratio<1, (m1 - 3) * (m1 - 2)> > ra_type1; + VERIFY( ra_type1::num == 2 ); + VERIFY( ra_type1::den == (m1 - 1) * (m1 - 3) ); + + const intmax_t m2 = numeric_limits<intmax_t>::max(); + typedef ratio_add<ratio<m2, 2>, + ratio<-m2, 3> > ra_type2; + VERIFY( ra_type2::num == m2 ); + VERIFY( ra_type2::den == 6 ); + + typedef ratio_add<ratio<m2 / 7 * 5 - 1, 5>, + ratio<-m2 + 2, 7> > ra_type3; + ra_type3(); + + const intmax_t m3 = numeric_limits<intmax_t>::max() - 1; + typedef ratio_add<ratio<-m3 / 7 * 5 - 1, 5>, + ratio<m3, 7> > ra_type4; + ra_type4(); + + const intmax_t m4 = numeric_limits<intmax_t>::max() / 2; + typedef ratio_add<ratio<m4 - 5, 15>, + ratio<m4, 35> > ra_type5; + VERIFY( ra_type5::num == (2 * m4 - 7) ); + VERIFY( ra_type5::den == 21 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/53840.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/53840.cc new file mode 100644 index 000000000..9aaca27d6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/53840.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <chrono> + +std::chrono::duration<long, std::ratio_divide<std::kilo, std::milli>> d1; +std::chrono::duration<long, std::ratio_multiply<std::kilo, std::milli>> d2; +std::chrono::duration<long, std::ratio_add<std::kilo, std::milli>> d3; +std::chrono::duration<long, std::ratio_subtract<std::kilo, std::milli>> d4; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc new file mode 100644 index 000000000..ed885b702 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops1.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_add<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == 19 ); + VERIFY( r.den == 24 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + std::ratio_subtract<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == -1 ); + VERIFY( r.den == 24 ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + std::ratio_multiply<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == 5 ); + VERIFY( r.den == 32 ); +} + +void +test04() +{ + bool test __attribute__((unused)) = true; + std::ratio_divide<std::ratio<3,8>, std::ratio<5,12>>::type r; + + VERIFY( r.num == 9 ); + VERIFY( r.den == 10 ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc new file mode 100644 index 000000000..376e471d0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops2.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <ratio> +#include <testsuite_hooks.h> + +typedef std::ratio<1, INTMAX_MAX> one_over_max; +typedef std::ratio<2, INTMAX_MAX> two_over_max; +typedef std::ratio<INTMAX_MAX, 1> max_over_one; +typedef std::ratio<INTMAX_MAX, 2> max_over_two; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_add<one_over_max, one_over_max>::type r1; + + VERIFY( r1.num == two_over_max::num); + VERIFY( r1.den == two_over_max::den); + + std::ratio_add< + std::ratio<INTMAX_MAX / 2, INTMAX_MAX / 2>, + std::ratio<INTMAX_MAX / 2 , INTMAX_MAX / 2 + 1>>::type r2; + + VERIFY( r2.num == INTMAX_MAX ); + VERIFY( r2.den == (INTMAX_MAX / 2) + 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::ratio_subtract<one_over_max, one_over_max>::type r1; + + VERIFY( r1.num == 0); + VERIFY( r1.den == 1); + + std::ratio_subtract< + std::ratio<INTMAX_MAX / 2, INTMAX_MAX / 2>, + std::ratio<INTMAX_MAX / 2 , INTMAX_MAX / 2 + 1>>::type r2; + + VERIFY( r2.num == 1 ); + VERIFY( r2.den == (INTMAX_MAX / 2) + 1 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc new file mode 100644 index 000000000..db6665bcd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops3.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <ratio> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::ratio_multiply< + std::ratio<2, INTMAX_MAX>, + std::ratio<INTMAX_MAX, 2>>::type r1; + + VERIFY( r1.num == 1 ); + VERIFY( r1.den == 1 ); + + std::ratio_multiply< + std::ratio<INTMAX_MAX, 2>, + std::ratio<2 , INTMAX_MAX - 1>>::type r2; + + VERIFY( r2.num == INTMAX_MAX ); + VERIFY( r2.den == INTMAX_MAX - 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::ratio_divide< + std::ratio<INTMAX_MAX, 2>, + std::ratio<INTMAX_MAX, 2>>::type r1; + + VERIFY( r1.num == 1 ); + VERIFY( r1.den == 1 ); + + std::ratio_divide< + std::ratio<INTMAX_MAX-1, 2>, + std::ratio<INTMAX_MAX, 2>>::type r2; + + VERIFY( r2.num == INTMAX_MAX - 1 ); + VERIFY( r2.den == INTMAX_MAX ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc new file mode 100644 index 000000000..686cc57dd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc @@ -0,0 +1,51 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2008-07-03 Chris Fairles <chris.fairles@gmail.com> + +// Copyright (C) 2008-2014 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 <ratio> + +void +test01() +{ + std::ratio_add<std::ratio<INTMAX_MAX, 1>, std::ratio<1>>::type r1 + __attribute__((unused)); +} + +void +test02() +{ + std::ratio_multiply<std::ratio<-INTMAX_MAX, 2>, std::ratio<3, 2>>::type r1 + __attribute__((unused)); + std::ratio_multiply<std::ratio<INTMAX_MAX>, std::ratio<INTMAX_MAX>>::type r2 + __attribute__((unused)); +} + +// { dg-error "required from here" "" { target *-*-* } 29 } +// { dg-error "expected initializer" "" { target *-*-* } 36 } +// { dg-error "expected initializer" "" { target *-*-* } 38 } +// { dg-error "overflow in addition" "" { target *-*-* } 435 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 97 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 99 } +// { dg-error "overflow in multiplication" "" { target *-*-* } 101 } +// { dg-error "overflow in constant expression" "" { target *-*-* } 108 } +// { dg-prune-output "out of range" } +// { dg-prune-output "not usable in a constant expression" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/requirements/constexpr_data.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/requirements/constexpr_data.cc new file mode 100644 index 000000000..352c19044 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/ratio/requirements/constexpr_data.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <ratio> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr intmax_t v1 __attribute__((unused)) + = _Ttesttype::num; + constexpr intmax_t v2 __attribute__((unused)) + = _Ttesttype::den; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + typedef std::ratio<600, 900> R1; + typedef std::ratio<700, 200> R2; + test.operator()<R1>(); + test.operator()<std::ratio_add<R1, R2>>(); + test.operator()<std::ratio_subtract<R1, R2>>(); + test.operator()<std::ratio_multiply<R1, R2>>(); + test.operator()<std::ratio_divide<R1, R2>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc new file mode 100644 index 000000000..4a0041867 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/base_classes.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.4.2 raw storage iterator + +#include <memory> + +void test01() +{ + using namespace std; + + // Check for required base class. + long l; + typedef raw_storage_iterator<long*, long> test_iterator; + typedef iterator<output_iterator_tag, void, void, void, void> base_iterator; + test_iterator rs_it(&l); + base_iterator* base __attribute__((unused)) = &rs_it; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..473e311d4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007-2014 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/>. + + +// This file tests explicit instantiation of library containers. + +#include <memory> + +template class std::raw_storage_iterator<int*, int>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc new file mode 100644 index 000000000..69ac71726 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/raw_storage_iterator/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2001-2014 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/>. + +// 20.4.2 raw storage iterator + +#include <memory> + +void test01() +{ + using namespace std; + + // Check for required typedefs + typedef raw_storage_iterator<long*, long> test_iterator; + typedef test_iterator::value_type value_type; + typedef test_iterator::difference_type difference_type; + typedef test_iterator::pointer pointer; + typedef test_iterator::reference reference; + typedef test_iterator::iterator_category iteratory_category; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc new file mode 100644 index 000000000..e999ff84a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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 <functional> + +struct test_type +{ + int member(); + int cmember()const; + int member2(char); + int cmember2(char)const; +}; + +struct functor1 : public std::unary_function<int, double> +{ + double operator()(int) const; +}; + +struct functor2 : public std::binary_function<int, char, double> +{ + double operator()(int, char) const; +}; + +template <class T> +void verify_return_type(T, T) +{ +} + +void test01() +{ + test_type* null_tt = 0; + const test_type* null_ttc = 0; + int zero; + + std::reference_wrapper<double (int)>* pr1(0); + verify_return_type((*pr1)(0), double()); + std::reference_wrapper<double (*)(int)>* pr2(0); + verify_return_type((*pr2)(0), double()); + std::reference_wrapper<int (test_type::*)()>* pr3(0); + verify_return_type((*pr3)(null_tt), int()); + std::reference_wrapper<int (test_type::*)()const>* pr4(0); + verify_return_type((*pr4)(null_ttc), int()); + std::reference_wrapper<functor1>* pr5(0); + + // libstdc++/24803 + verify_return_type((*pr5)(0), double()); + verify_return_type((*pr5)(zero), double()); + + std::reference_wrapper<double (int, char)>* pr1b(0); + verify_return_type((*pr1b)(0, 0), double()); + std::reference_wrapper<double (*)(int, char)>* pr2b(0); + verify_return_type((*pr2b)(0, 0), double()); + std::reference_wrapper<int (test_type::*)(char)>* pr3b(0); + verify_return_type((*pr3b)(null_tt,zero), int()); + std::reference_wrapper<int (test_type::*)()const>* pr4b(0); + verify_return_type((*pr4b)(null_ttc), int()); + std::reference_wrapper<functor2>* pr5b(0); + + // libstdc++/24803 + verify_return_type((*pr5b)(0, 0), double()); + verify_return_type((*pr5b)(zero, zero), double()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc new file mode 100644 index 000000000..7d24f37e5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <functional> +#include <testsuite_hooks.h> +#include <testsuite_api.h> + +// libstdc++/41792 +void test01() +{ + using namespace __gnu_test; + + OverloadedAddress* ao1 = new OverloadedAddress(); + std::reference_wrapper<OverloadedAddress> rw1(*ao1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc new file mode 100644 index 000000000..4f0cc866c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile} +// Copyright (C) 2011-2014 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/>. + +// 20.6.4 function object return types [func.ret] +#include <functional> + +struct X +{ + int f(int) { return 0; } + int i; +}; + +void test01() +{ + typedef int (X::*mfp)(int); + typedef int X::*mp; + mfp m = &X::f; + mp m2 = &X::i; + X x = { }; + std::ref(m)(x, 1); + std::ref(m)(&x, 1); + int& i1 __attribute__((unused)) = std::ref(m2)(x); + int& i2 __attribute__((unused)) = std::ref(m2)(&x); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-3.cc new file mode 100644 index 000000000..f8d714d44 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-3.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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/>. + +// 20.8.3.4 reference_wrapper invocation [refwrap.invoke] +#include <functional> + +struct ABC +{ + virtual bool operator()() const = 0; +}; + +struct Concrete : ABC +{ + virtual bool operator()() const { return true; } +}; + +Concrete c; +ABC& abc = c; + +auto b = std::cref(abc)(); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc new file mode 100644 index 000000000..369fb4374 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc @@ -0,0 +1,121 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <functional> +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +struct X +{ + typedef int result_type; + + X() : bar(17) {} + + int foo(float x) { return truncate_float(x); } + int foo_c(float x) const { return truncate_float(x); } + int foo_v(float x) volatile { return truncate_float(x); } + int foo_cv(float x) const volatile { return truncate_float(x); } + int foo_varargs(float x, ...) { return truncate_float(x); } + + int operator()(float x) + { + return foo(x) + 1; + } + + int operator()(float x) const + { + return foo_c(x) + 2; + } + + int bar; + + private: + X(const X&); + X& operator=(const X&); +}; + +int seventeen() { return 17; } + +struct get_seventeen +{ + typedef int result_type; + int operator()() const { return 17; } +}; + +void test01() +{ + using std::ref; + using std::cref; + + ::get_seventeen get_sev; + ::X x; + ::X* xp = &x; + int (::X::* p_foo)(float) = &::X::foo; + int (::X::* p_foo_c)(float) const = &::X::foo_c; + int (::X::* p_foo_v)(float) volatile = &::X::foo_v; + int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv; + int (::X::* p_foo_varargs)(float, ...) __attribute__((unused)) + = &::X::foo_varargs; + int ::X::* p_bar = &::X::bar; + + const float pi = 3.14; + + // Functions + VERIFY(ref(truncate_float)(pi) == 3); + VERIFY(ref(seventeen)() == 17); + + // Function pointers + VERIFY(cref(truncate_float)(pi) == 3); + VERIFY(cref(seventeen)() == 17); + + // Member function pointers + VERIFY(ref(p_foo)(x, pi) == 3); + VERIFY(ref(p_foo)(xp, pi) == 3); + VERIFY(ref(p_foo_c)(x, pi) == 3); + VERIFY(ref(p_foo_c)(xp, pi) == 3); + VERIFY(ref(p_foo_v)(x, pi) == 3); + VERIFY(ref(p_foo_v)(xp, pi) == 3); + VERIFY(ref(p_foo_cv)(x, pi) == 3); + VERIFY(ref(p_foo_cv)(xp, pi) == 3); + // VERIFY(ref(p_foo_varargs)(x, pi) == 3); + // VERIFY(ref(p_foo_varargs)(xp, pi, 1, 1) == 3); + // VERIFY(ref(p_foo_varargs)(x, pi, 1, 1) == 3); + // VERIFY(ref(p_foo_varargs)(xp, pi) == 3); + + // Member data pointers + VERIFY(ref(p_bar)(x) == 17); + VERIFY(ref(p_bar)(xp) == 17); + + // Function objects + VERIFY(ref(get_sev)() == 17); + VERIFY(cref(get_sev)() == 17); + VERIFY(ref(x)(pi) == 4); + VERIFY(cref(x)(pi) == 5); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc new file mode 100644 index 000000000..dcd8828cb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2011-2014 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/>. + +// 20.8.3 Class template reference_wrapper + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include <functional> + +struct X { }; +X rval(); +X&& rvalref(); + +void test01() +{ + std::ref(1); // { dg-error "deleted" } + std::cref(1); // { dg-error "deleted" } + std::ref( int() ); // { dg-error "deleted" } + std::cref( int() ); // { dg-error "deleted" } + std::ref(rval()); // { dg-error "deleted" } + std::cref(rvalref()); // { dg-error "deleted" } +} + +int main() +{ + test01(); +} + +// { dg-prune-output "declared here" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc new file mode 100644 index 000000000..b24cc9983 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-10-06 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <functional> + +using namespace std; + +struct T; + +reference_wrapper<int(float, ...)>::result_type i01; +// reference_wrapper<int(float, ...) const>::result_type i02; +// reference_wrapper<int(float, ...) volatile>::result_type i03; +// reference_wrapper<int(float, ...) const volatile>::result_type i04; + +reference_wrapper<int(*)(float, ...)>::result_type i05; +reference_wrapper<int(* const)(float, ...)>::result_type i06; +reference_wrapper<int(* volatile)(float, ...)>::result_type i07; +reference_wrapper<int(* const volatile)(float, ...)>::result_type i08; + +reference_wrapper<int(T::*)(float, ...)>::result_type i09; +reference_wrapper<int(T::*)(float, ...) const>::result_type i10; +reference_wrapper<int(T::*)(float, ...) volatile>::result_type i11; +reference_wrapper<int(T::*)(float, ...) const volatile>::result_type i12; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc new file mode 100644 index 000000000..04aabdaa2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-10-06 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <functional> + +using namespace std; + +reference_wrapper<int(float)>::argument_type i01; +// reference_wrapper<int(float) const>::argument_type i02; +// reference_wrapper<int(float) volatile>::argument_type i03; +// reference_wrapper<int(float) const volatile>::argument_type i04; +reference_wrapper<int(float)>::result_type i05; +// reference_wrapper<int(float) const>::result_type i06; +// reference_wrapper<int(float) volatile>::result_type i07; +// reference_wrapper<int(float) const volatile>::result_type i08; + +reference_wrapper<int(*)(float)>::argument_type i09; +reference_wrapper<int(* const)(float)>::argument_type i10; +reference_wrapper<int(* volatile)(float)>::argument_type i11; +reference_wrapper<int(* const volatile)(float)>::argument_type i12; +reference_wrapper<int(*)(float)>::result_type i13; +reference_wrapper<int(* const)(float)>::result_type i14; +reference_wrapper<int(* volatile)(float)>::result_type i15; +reference_wrapper<int(* const volatile)(float)>::result_type i16; + +reference_wrapper<int(float, char)>::first_argument_type i17; +// reference_wrapper<int(float, char) const>::first_argument_type i18; +// reference_wrapper<int(float, char) volatile>::first_argument_type i19; +// reference_wrapper<int(float, char) const volatile>::first_argument_type i20; +reference_wrapper<int(float, char)>::second_argument_type i21; +// reference_wrapper<int(float, char) const>::second_argument_type i22; +// reference_wrapper<int(float, char) volatile>::second_argument_type i23; +// reference_wrapper<int(float, char) const volatile>::second_argument_type i24; +reference_wrapper<int(float, char)>::result_type i25; +// reference_wrapper<int(float, char) const>::result_type i26; +// reference_wrapper<int(float, char) volatile>::result_type i27; +// reference_wrapper<int(float, char) const volatile>::result_type i28; + +reference_wrapper<int(*)(float, char)>::first_argument_type i29; +reference_wrapper<int(* const)(float, char)>::first_argument_type i30; +reference_wrapper<int(* volatile)(float, char)>::first_argument_type i31; +reference_wrapper<int(* const volatile)(float, char)>::first_argument_type i32; +reference_wrapper<int(*)(float, char)>::second_argument_type i33; +reference_wrapper<int(* const)(float, char)>::second_argument_type i34; +reference_wrapper<int(* volatile)(float, char)>::second_argument_type i35; +reference_wrapper<int(*const volatile)(float, char)>::second_argument_type i36; +reference_wrapper<int(*)(float, char)>::result_type i37; +reference_wrapper<int(* const)(float, char)>::result_type i38; +reference_wrapper<int(* volatile)(float, char)>::result_type i39; +reference_wrapper<int(* const volatile)(float, char)>::result_type i40; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc new file mode 100644 index 000000000..9881dd54d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc @@ -0,0 +1,149 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <functional> +#include <type_traits> + +struct S { }; + +struct S0 +{ + typedef int argument_type; +}; + +struct S1 +{ + typedef float first_argument_type; +}; + +struct S2 +{ + typedef char second_argument_type; +}; + +struct S01 : S0, S1 { }; +struct S02 : S0, S2 { }; +struct S12 : S1, S2 { }; + +struct S012 : S0, S1, S2 { }; + +using std::true_type; +using std::false_type; +using std::integral_constant; +using std::remove_cv; + +_GLIBCXX_HAS_NESTED_TYPE(argument_type) +_GLIBCXX_HAS_NESTED_TYPE(first_argument_type) +_GLIBCXX_HAS_NESTED_TYPE(second_argument_type) + +template<typename T> + struct has_arg_type : __has_argument_type<T> + { }; + +template<typename T> + struct has_1st_arg_type : __has_first_argument_type<T> + { }; + +template<typename T> + struct has_2nd_arg_type : __has_second_argument_type<T> + { }; + +template<typename T, bool = has_arg_type<T>::value> +struct test_arg_type +{ + static_assert( !has_arg_type<std::reference_wrapper<T>>::value, + "reference_wrapper has no nested argument_type"); +}; + +template<typename T> +struct test_arg_type<T, true> +{ + typedef std::reference_wrapper<T> ref; + + static_assert( has_arg_type<ref>::value, + "reference_wrapper has nested argument_type"); + + static_assert( + std::is_same< typename T::argument_type, + typename ref::argument_type >::value, + "reference_wrapper has the correct argument_type"); +}; + +template<typename T, + bool = has_1st_arg_type<T>::value && has_2nd_arg_type<T>::value> +struct test_1st_2nd_arg_types +{ + typedef std::reference_wrapper<T> ref; + + static_assert( !has_1st_arg_type<ref>::value, + "reference_wrapper has no nested first_argument_type"); + + static_assert( !has_2nd_arg_type<ref>::value, + "reference_wrapper has no nested second_argument_type"); +}; + +template<typename T> +struct test_1st_2nd_arg_types<T, true> +{ + typedef std::reference_wrapper<T> ref; + + static_assert( has_1st_arg_type<ref>::value, + "reference_wrapper has nested first_argument_type"); + + static_assert( has_2nd_arg_type<ref>::value, + "reference_wrapper has nested second_argument_type"); + + static_assert( + std::is_same< typename T::first_argument_type, + typename ref::first_argument_type>::value, + "reference_wrapper has correct first_argument_type"); + + static_assert( + std::is_same< typename T::second_argument_type, + typename ref::second_argument_type>::value, + "reference_wrapper has correct second_argument_type"); +}; + + +template<typename T> + void test() + { + test_arg_type<T> t __attribute__((unused)); + test_arg_type<const T> tc __attribute__((unused)); + test_arg_type<volatile T> tv __attribute__((unused)); + test_arg_type<const volatile T> tcv __attribute__((unused)); + test_1st_2nd_arg_types<T> t12 __attribute__((unused)); + test_1st_2nd_arg_types<const T> t12c __attribute__((unused)); + test_1st_2nd_arg_types<volatile T> t12v __attribute__((unused)); + test_1st_2nd_arg_types<const volatile T> t12cv __attribute__((unused)); + } + +int main() +{ + test<S>(); + test<S0>(); + test<S1>(); + test<S2>(); + test<S01>(); + test<S02>(); + test<S12>(); + test<S012>(); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc new file mode 100644 index 000000000..6c3b9f59b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <functional> +#include <type_traits> + +struct X {}; + +struct int_result_type { typedef int result_type; }; + +struct derives_unary : std::unary_function<int, int> {}; + +struct derives_binary : std::binary_function<int, float, int> {}; + +struct derives_unary_binary + : std::unary_function<int, int>, + std::binary_function<int, float, int> +{ + typedef int result_type; +}; + +void test01() +{ + using std::reference_wrapper; + using std::is_same; + + // Check result_type typedef + static_assert( is_same<reference_wrapper<int_result_type>::result_type, int>::value, "has result_type" ); + static_assert( is_same<reference_wrapper<derives_unary>::result_type, int>::value, "has result_type" ); + static_assert( is_same<reference_wrapper<derives_binary>::result_type, int>::value, "has result_type" ); + static_assert( is_same<reference_wrapper<derives_unary_binary>::result_type, int>::value, "has result_type" ); + static_assert( is_same<reference_wrapper<int(void)>::result_type, int>::value, "has result_type" ); + static_assert( is_same<reference_wrapper<int(*)(void)>::result_type, int>::value, "has result_type" ); + static_assert( is_same<reference_wrapper<int (::X::*)()>::result_type, int>::value, "has result_type" ); + static_assert( is_same<reference_wrapper<int (::X::*)(float)>::result_type, int>::value, "has result_type" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/rel_ops.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/rel_ops.cc new file mode 100644 index 000000000..c549b1f14 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/rel_ops.cc @@ -0,0 +1,45 @@ +// 2002-04-13 Paolo Carlini <pcarlini@unitus.it> + +// Copyright (C) 2002-2014 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/>. + +// 20.2.1 Operators + +#include <utility> +#include <vector> + +using namespace std::rel_ops; + +// libstdc++/3628 +void test01() +{ + std::vector<int> v; + std::vector<int>::iterator vi; + v.push_back(1); + vi = v.end(); + vi != v.begin(); + vi > v.begin(); + vi <= v.begin(); + vi >= v.begin(); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_all_extents/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_all_extents/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..006fae365 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_all_extents/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 remove_all_extents<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_all_extents/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_all_extents/value.cc new file mode 100644 index 000000000..2353b0c52 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_all_extents/value.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::remove_all_extents; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<remove_all_extents<int>::type, int>::value, ""); + static_assert(is_same<remove_all_extents<int[2]>::type, int>::value, ""); + static_assert(is_same<remove_all_extents<int[2][3]>::type, int>::value, ""); + static_assert(is_same<remove_all_extents<int[][3]>::type, int>::value, ""); + static_assert(is_same<remove_all_extents<const int[2][3]>::type, + const int>::value, ""); + static_assert(is_same<remove_all_extents<ClassType>::type, + ClassType>::value, ""); + static_assert(is_same<remove_all_extents<ClassType[2]>::type, + ClassType>::value, ""); + static_assert(is_same<remove_all_extents<ClassType[2][3]>::type, + ClassType>::value, ""); + static_assert(is_same<remove_all_extents<ClassType[][3]>::type, + ClassType>::value, ""); + static_assert(is_same<remove_all_extents<const ClassType[2][3]>::type, + const ClassType>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_const/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_const/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d486ea31f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_const/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 remove_const<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_const/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_const/value.cc new file mode 100644 index 000000000..4301c6748 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_const/value.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::remove_const; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<remove_const<const volatile int>::type, + volatile int>::value, ""); + static_assert(is_same<remove_const<const int*>::type, const int*>::value, ""); + static_assert(is_same<remove_const<const volatile ClassType>::type, + volatile ClassType>::value, ""); + static_assert(is_same<remove_const<const ClassType*>::type, + const ClassType*>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_cv/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_cv/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..e18810cec --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_cv/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 remove_cv<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_cv/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_cv/value.cc new file mode 100644 index 000000000..5df037e8a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_cv/value.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::remove_cv; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<remove_cv<const volatile int>::type, int>::value, ""); + static_assert(is_same<remove_cv<const volatile int*>::type, + const volatile int*>::value, ""); + static_assert(is_same<remove_cv<const volatile ClassType>::type, + ClassType>::value, ""); + static_assert(is_same<remove_cv<const volatile ClassType*>::type, + const volatile ClassType*>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_extent/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_extent/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..05a2f0ff5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_extent/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 remove_extent<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_extent/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_extent/value.cc new file mode 100644 index 000000000..02fd34917 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_extent/value.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::remove_extent; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<remove_extent<int>::type, int>::value, ""); + static_assert(is_same<remove_extent<int[2]>::type, int>::value, ""); + static_assert(is_same<remove_extent<int[2][3]>::type, int[3]>::value, ""); + static_assert(is_same<remove_extent<int[][3]>::type, int[3]>::value, ""); + static_assert(is_same<remove_extent<const int[2]>::type, + const int>::value, ""); + static_assert(is_same<remove_extent<ClassType>::type, ClassType>::value, ""); + static_assert(is_same<remove_extent<ClassType[2]>::type, + ClassType>::value, ""); + static_assert(is_same<remove_extent<ClassType[2][3]>::type, + ClassType[3]>::value, ""); + static_assert(is_same<remove_extent<ClassType[][3]>::type, + ClassType[3]>::value, ""); + static_assert(is_same<remove_extent<const ClassType[2]>::type, + const ClassType>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_pointer/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..9fd9af2ab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 remove_pointer<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_pointer/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_pointer/value.cc new file mode 100644 index 000000000..2b1f2f164 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_pointer/value.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::remove_pointer; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<remove_pointer<int*>::type, int>::value, ""); + static_assert(is_same<remove_pointer<int>::type, int>::value, ""); + static_assert(is_same<remove_pointer<const int*>::type, + const int>::value, ""); + static_assert(is_same<remove_pointer<int**>::type, int*>::value, ""); + static_assert(is_same<remove_pointer<ClassType*>::type, + ClassType>::value, ""); + static_assert(is_same<remove_pointer<ClassType>::type, ClassType>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..6fcf973e4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2007-2014 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 remove_reference<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/requirements/typedefs.cc new file mode 100644 index 000000000..9c06e3b00 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +static_assert( is_same<remove_reference<int>::type, remove_reference_t<int>>(), + "remove_reference_t<int>" ); +static_assert( is_same<remove_reference<int&>::type, remove_reference_t<int&>>(), + "remove_reference_t<int&>" ); +static_assert( is_same<remove_reference<int&&>::type, remove_reference_t<int&&>>(), + "remove_reference_t<int&&>" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/value.cc new file mode 100644 index 000000000..cf687e4ce --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_reference/value.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// 2007-06-02 Paolo Carlini <pcarlini@suse.de> +// +// Copyright (C) 2007-2014 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_tr1.h> + +void test01() +{ + using std::remove_reference; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<remove_reference<int&>::type, int>::value, ""); + static_assert(is_same<remove_reference<int>::type, int>::value, ""); + static_assert(is_same<remove_reference<const int&>::type, + const int>::value, ""); + static_assert(is_same<remove_reference<int*&>::type, int*>::value, ""); + static_assert(is_same<remove_reference<ClassType&>::type, + ClassType>::value, ""); + static_assert(is_same<remove_reference<ClassType>::type, + ClassType>::value, ""); + static_assert(is_same<remove_reference<int(&)(int)>::type, + int(int)>::value, ""); + static_assert(is_same<remove_reference<int&&>::type, int>::value, ""); + static_assert(is_same<remove_reference<int>::type, int>::value, ""); + static_assert(is_same<remove_reference<const int&&>::type, + const int>::value, ""); + static_assert(is_same<remove_reference<int*&&>::type, int*>::value, ""); + static_assert(is_same<remove_reference<ClassType&&>::type, + ClassType>::value, ""); + static_assert(is_same<remove_reference<ClassType>::type, + ClassType>::value, ""); + static_assert(is_same<remove_reference<int(&&)(int)>::type, + int(int)>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_volatile/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_volatile/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..a0bc2496e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_volatile/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 remove_volatile<test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_volatile/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_volatile/value.cc new file mode 100644 index 000000000..037c3b203 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/remove_volatile/value.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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_tr1.h> + +void test01() +{ + using std::remove_volatile; + using std::is_same; + using namespace __gnu_test; + + static_assert(is_same<remove_volatile<const volatile int>::type, + const int>::value, ""); + static_assert(is_same<remove_volatile<volatile int*>::type, + volatile int*>::value, ""); + static_assert(is_same<remove_volatile<const volatile ClassType>::type, + const ClassType>::value, ""); + static_assert(is_same<remove_volatile<volatile ClassType*>::type, + volatile ClassType*>::value, ""); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/1.cc new file mode 100644 index 000000000..b127a4c6f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/1.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <functional> +#include <type_traits> + +struct X { + int i; + void f1() { } + void f2() volatile { } +}; + +typedef int X::*pm; +typedef void (X::*pmf1)(); +typedef void (X::*pmf2)() volatile; + +typedef std::result_of<pm const&(X&)>::type result; +static_assert(std::is_same<result, int&>::value, + "invoking cv-qualified pointer-to-member-object"); + +typedef std::result_of<pmf1 const&(X&)>::type result1; +static_assert(std::is_void<result1>::value, + "invoking cv-qualified pointer-to-member-function"); + +typedef std::result_of<pmf2 const&(X&)>::type result2; +static_assert(std::is_void<result2>::value, + "invoking cv-qualified pointer-to-member-function"); + +typedef std::result_of<pm(volatile X&)>::type result3; +static_assert(std::is_same<result3, volatile int&>::value, + "invoking pointer-to-member-object on volatile object"); + +typedef std::result_of<pmf2(volatile X&)>::type result4; +static_assert(std::is_void<result4>::value, + "invoking pointer-to-member-function on volatile object"); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/2.cc new file mode 100644 index 000000000..ac0dc6987 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/2.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <memory> + +using std::is_same; +using std::result_of; +using std::unique_ptr; + +// Taken from example in [meta.trans.other] + +typedef bool (&PF1)(); +typedef short (*PF2)(long); +struct S { + operator PF2() const; + double operator()(char, int&); + void fn(long) const; + char data; +}; + +typedef void (S::*PMF)(long) const; +typedef char S::*PMD; + +static_assert( is_same<result_of<S(int)>::type, short>::value, "!"); +static_assert( is_same<result_of<S&(unsigned char, int&)>::type, double>::value, "!"); +static_assert( is_same<result_of<PF1()>::type, bool>::value, "!"); +static_assert( is_same<result_of<PMF(unique_ptr<S>, int)>::type, void>::value, "!"); +static_assert( is_same<result_of<PMD(S)>::type, char&&>::value, "!"); +static_assert( is_same<result_of<PMD(const S*)>::type, const char&>::value, "!"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/requirements/typedefs.cc new file mode 100644 index 000000000..730a66d30 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/requirements/typedefs.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +using namespace std; + +using F1 = char(*)(char); +static_assert( is_same<result_of<F1(int)>::type, result_of_t<F1(int)>>(), + "result_of_t<F1(int)>" ); + +struct X { }; +using F2 = int X::*; +static_assert( is_same<result_of<F2(X)>::type, result_of_t<F2(X)>>(), + "result_of_t<F2(X)>" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc new file mode 100644 index 000000000..3a6598768 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_1.cc @@ -0,0 +1,740 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <memory> +#include <cstddef> +#include <type_traits> + +// TODO: Uncomment the following define once gcc has fixed bug 52748 +// (incomplete types in function call expressions): +//#define HAS_52748_FIXED + +// Helper types: +struct has_type_impl +{ + template<typename T, typename = typename T::type> + static std::true_type test(int); + + template<typename> + static std::false_type test(...); +}; + +template<typename T> +struct has_type : public decltype(has_type_impl::test<T>(0)) +{}; + +template<typename T, typename Res> +struct is_expected_type : public std::is_same<typename T::type, Res> +{}; + +template<typename P1, typename P2> +struct and_ : public std::conditional<P1::value, P2, std::false_type>::type +{}; + +template<typename T, typename Res> +struct is_type : public and_<has_type<T>, is_expected_type<T, Res>> +{}; + +// Types under inspection: + +typedef bool (&PF1)(); +typedef short (*PF2)(long); + +struct S { + operator PF2() const; + double operator()(char, int&); + void calc(long) const; +}; + +typedef void (S::*PMS)(long) const; +typedef void (S::*PMSnonconst)(long); + +typedef int S::* PMI; + +struct B { + int i; + void f1() const; + bool f2(int) const volatile; +}; + +struct D : B {}; + +typedef void (B::*base_func_void)() const; +typedef bool (B::*base_func_bool_int)(int) const volatile; + +struct ident_functor { + template<typename T> + T operator()(T&& x); +}; + +template<typename Ret = void> +struct variable_functor { + template<typename... T> + Ret operator()(T&&...); +}; + +struct ident_functor_noref { + template<typename T> + typename std::remove_reference<T>::type operator()(T&& x); +}; + +enum class ScEn; + +enum UnScEn : int; + +union U { + int i; + double d; +}; + +union U2 { + int i; + bool b; + void operator()() const; + int operator()(double) const; + bool operator()(double); + U operator()(int, int); +}; + +struct Ukn; + +typedef Ukn (S::*PMSIncomplete)(long) const; +typedef Ukn (S::*PMSIncompletenonconst)(long); +typedef Ukn (*FuncIncomplete)(long); + +struct Abstract { + virtual ~Abstract() = 0; +}; + +struct Private { +private: + void operator()(); + int operator()(int); +public: + bool operator()(std::nullptr_t); +}; + +union PrivateUnion { + double d; +private: + void operator()(); + int operator()(int); +public: + bool operator()(std::nullptr_t); +}; + +template<typename T> +struct ImplicitTo { + operator T(); +}; + +template<typename> +struct never { static const bool value = false; }; + +template<typename T> +struct BrokenTrait { + static_assert(never<T>::value, "Error!"); + typedef T type; +}; + +template<typename T> +struct BadSmartPtr : T { + T& operator*() const noexcept(typename BrokenTrait<T>::type()); +}; + +template<typename Ret> +using FuncEllipses = Ret(...); + +static_assert(is_type<std::result_of<S(int)>, short>::value, "Error!"); +static_assert(is_type<std::result_of<S&(unsigned char, int&)>, + double>::value, "Error!"); +static_assert(is_type<std::result_of<PF1()>, bool>::value, "Error!"); +static_assert(is_type<std::result_of<PF1&()>, bool>::value, "Error!"); +static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>, + void>::value, "Error!"); +static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>&, unsigned&)>, + void>::value, "Error!"); +static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>, int)>, + void>::value, "Error!"); +static_assert(is_type<std::result_of<PMS&(std::unique_ptr<S>&, unsigned&)>, + void>::value, "Error!"); + +static_assert(is_type<std::result_of<ident_functor(int)>, + int>::value, "Error!"); +static_assert(is_type<std::result_of<ident_functor(const int)>, + int>::value, "Error!"); +static_assert(is_type<std::result_of<ident_functor(const int&&)>, + int>::value, "Error!"); +static_assert(is_type<std::result_of<ident_functor(int&&)>, + int>::value, "Error!"); +static_assert(is_type<std::result_of<ident_functor(int&)>, + int&>::value, "Error!"); + +static_assert(is_type<std::result_of<ident_functor(const B)>, + B>::value, "Error!"); +static_assert(is_type<std::result_of<ident_functor(const B&&)>, + const B>::value, "Error!"); +static_assert(is_type<std::result_of<ident_functor(B&&)>, B>::value, "Error!"); +static_assert(is_type<std::result_of<ident_functor(B&)>, B&>::value, "Error!"); + +static_assert(is_type<std::result_of<int B::*(B&)>, int&>::value, "Error!"); + +// This is expected as of CWG 616 P/R: +static_assert(is_type<std::result_of<int B::*(B)>, int&&>::value, "Error!"); + +static_assert(is_type<std::result_of<volatile int B::*(const B&&)>, + const volatile int&&>::value, "Error!"); +static_assert(is_type<std::result_of<const int B::*(volatile B&&)>, + const volatile int&&>::value, "Error!"); + +static_assert(is_type<std::result_of<int B::*(const B&)>, + const int&>::value, "Error!"); +static_assert(is_type<std::result_of<volatile int B::*(const B&)>, + const volatile int&>::value, "Error!"); +static_assert(is_type<std::result_of<const int B::*(volatile B&)>, + const volatile int&>::value, "Error!"); + +static_assert(is_type<std::result_of<int B::*(B*)>, int&>::value, "Error!"); +static_assert(is_type<std::result_of<int B::*(B*&)>, int&>(), "Error!"); +static_assert(is_type<std::result_of<int B::*(const B*)>, + const int&>::value, "Error!"); +static_assert(is_type<std::result_of<int B::*(const B*&)>, + const int&>::value, "Error!"); +static_assert(is_type<std::result_of<volatile int B::*(const B*)>, + const volatile int&>::value, "Error!"); +static_assert(is_type<std::result_of<const int B::*(volatile B*)>, + const volatile int&>::value, "Error!"); + +static_assert(is_type<std::result_of<base_func_void(const B&)>, + void>::value, "Error!"); +static_assert(is_type<std::result_of<base_func_void(const B*)>, + void>::value, "Error!"); +static_assert(is_type<std::result_of<base_func_void(B&)>, + void>::value, "Error!"); +static_assert(is_type<std::result_of<base_func_void(B*)>, + void>::value, "Error!"); + +static_assert(!has_type<std::result_of<base_func_void(volatile B&)>>::value, + "Error!"); +static_assert(!has_type<std::result_of<base_func_void(volatile B*)>>::value, + "Error!"); + +static_assert(is_type<std::result_of<base_func_bool_int(B&, long)>, + bool>::value, "Error!"); +static_assert(is_type<std::result_of<base_func_bool_int(B*, long)>, + bool>::value, "Error!"); +static_assert(is_type<std::result_of<base_func_bool_int(volatile B&, long)>, + bool>::value, "Error!"); +static_assert(is_type<std::result_of<base_func_bool_int(volatile B*, long)>, + bool>::value, "Error!"); + +static_assert(!has_type<std::result_of<int()>>(), "Error!"); +static_assert(!has_type<std::result_of<void()>>(), "Error!"); +static_assert(!has_type<std::result_of<int(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<void(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PF1(int)>>(), "Error!"); +static_assert(is_type<std::result_of<PF2(long)>, short>(), "Error!"); +static_assert(!has_type<std::result_of<PF2()>>(), "Error!"); +static_assert(!has_type<std::result_of<PF2(B)>>(), "Error!"); +static_assert(!has_type<std::result_of<PF2(ScEn)>>(), "Error!"); +static_assert(is_type<std::result_of<PF2(UnScEn)>, short>(), "Error!"); +static_assert(!has_type<std::result_of<PF2(long, int)>>(), "Error!"); +static_assert(is_type<std::result_of<PMS(std::unique_ptr<S>, int)>, void>(), + "Error!"); +static_assert(!has_type<std::result_of<PMS(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMS(int, std::unique_ptr<S>)>>(), "Error!"); + +// Argument number mismatch: +static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, int, bool)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, int, bool)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PMS(S)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMS(S&)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMS(S, int, bool)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMS(S&, int, bool)>>(), "Error!"); + +// Non-convertible arguments: +static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>, S)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PMS(std::unique_ptr<S>&, S)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PMS(S, S)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMS(S&, S)>>(), "Error!"); + +// cv-violations: +static_assert(!has_type<std::result_of<PMSnonconst(const S&, long)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PMSnonconst(const S&&, long)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PMSnonconst(const S*, long)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PMSnonconst(const S*&, long)>>(), + "Error!"); + +static_assert(is_type<std::result_of<PMI(S*)>, int&>(), "Error!"); +static_assert(is_type<std::result_of<PMI(S&)>, int&>(), "Error!"); +static_assert(is_type<std::result_of<PMI(S&&)>, int&&>(), "Error!"); +static_assert(is_type<std::result_of<PMI(S)>, int&&>(), "Error!"); + +static_assert(!has_type<std::result_of<PMI()>>(), "Error!"); + +static_assert(!has_type<std::result_of<PMI(S*, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMI(S&, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMI(S*, int, S, bool)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMI(S&, int, S, bool)>>(), "Error!"); + +static_assert(!has_type<std::result_of<PMI(B*)>>(), "Error!"); +static_assert(!has_type<std::result_of<PMI(B&)>>(), "Error!"); + +static_assert(is_type<std::result_of<int U::*(U)>, int&&>(), "Error!"); +static_assert(is_type<std::result_of<int U::*(U&)>, int&>(), "Error!"); +static_assert(is_type<std::result_of<int U::*(const U&)>, const int&>(), + "Error!"); +static_assert(is_type<std::result_of + <volatile int U::*(const U&)>, const volatile int&>(), "Error!"); +static_assert(is_type<std::result_of + <const int U::*(volatile U&)>, const volatile int&>(), "Error!"); + +static_assert(is_type<std::result_of<int Ukn::*(Ukn*)>, int&>(), "Error!"); +static_assert(is_type<std::result_of<int Ukn::*(Ukn&)>, int&>(), "Error!"); +static_assert(is_type<std::result_of<int Ukn::*(Ukn&&)>, int&&>(), "Error!"); +static_assert(is_type<std::result_of<int Ukn::*(const Ukn*)>, const int&>(), + "Error!"); +static_assert(is_type<std::result_of<int Ukn::*(const Ukn&)>, const int&>(), + "Error!"); +static_assert(is_type<std::result_of<int Ukn::*(const Ukn&&)>, const int&&>(), + "Error!"); + +typedef void (Ukn::* PUfnMF)(); +typedef void (Ukn::* PUfnConstMF)() const; + +static_assert(is_type<std::result_of<PUfnMF(Ukn*)>, void>(), "Error!"); +static_assert(is_type<std::result_of<PUfnMF(Ukn&)>, void>(), "Error!"); +static_assert(is_type<std::result_of<PUfnMF(Ukn&&)>, void>(), "Error!"); +static_assert(is_type<std::result_of<PUfnConstMF(Ukn*)>, void>(), "Error!"); +static_assert(is_type<std::result_of<PUfnConstMF(Ukn&)>, void>(), "Error!"); +static_assert(is_type<std::result_of<PUfnConstMF(Ukn&&)>, void>(), "Error!"); +static_assert(is_type<std::result_of<PUfnConstMF(const Ukn*)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<PUfnConstMF(const Ukn&&)>, void>(), + "Error!"); + +static_assert(!has_type<std::result_of<S()>>(), "Error!"); +static_assert(!has_type<std::result_of<S(int, S)>>(), "Error!"); +static_assert(!has_type<std::result_of<S(S)>>(), "Error!"); +static_assert(!has_type<std::result_of + <S(double, bool, std::nullptr_t, Ukn&)>>(), "Error!"); + +static_assert(is_type<std::result_of<U2()>, void>(), "Error!"); +static_assert(is_type<std::result_of<const U2&()>, void>(), "Error!"); +static_assert(is_type<std::result_of<U2&()>, void>(), "Error!"); +static_assert(is_type<std::result_of<U2(double)>, bool>(), "Error!"); +static_assert(is_type<std::result_of<const U2&(double)>, int>(), "Error!"); +static_assert(is_type<std::result_of<U2&(double)>, bool>(), "Error!"); +static_assert(is_type<std::result_of<U2(int)>, bool>(), "Error!"); +static_assert(is_type<std::result_of<U2&(int)>, bool>(), "Error!"); +static_assert(is_type<std::result_of<const U2&(int)>, int>(), "Error!"); +static_assert(is_type<std::result_of<U2(int, int)>, U>(), "Error!"); +static_assert(is_type<std::result_of<U2&(int, int)>, U>(), "Error!"); + +static_assert(!has_type<std::result_of<const U2&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<U2(int, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<U2&(int, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const U2&(int, int, int)>>(), "Error!"); + +static_assert(is_type<std::result_of<ident_functor(int)>, int>(), "Error!"); +static_assert(is_type<std::result_of<ident_functor(const volatile int)>, + int>(), "Error!"); +static_assert(is_type<std::result_of<ident_functor(int&)>, int&>(), "Error!"); +static_assert(is_type<std::result_of<ident_functor(const volatile int&)>, + const volatile int&>(), "Error!"); +static_assert(is_type<std::result_of<ident_functor(int&&)>, int>(), "Error!"); +static_assert(is_type<std::result_of<ident_functor(const volatile int&&)>, + int>(), "Error!"); +static_assert(is_type<std::result_of<ident_functor(Abstract&)>, Abstract&>(), + "Error!"); +static_assert(is_type<std::result_of<ident_functor(const volatile Abstract&)>, + const volatile Abstract&>(), "Error!"); + +static_assert(!has_type<std::result_of<ident_functor(int(&&)[1])>>(), "Error!"); +static_assert(!has_type<std::result_of<ident_functor(Abstract&&)>>(), "Error!"); +static_assert(!has_type<std::result_of<ident_functor(const int(&&)[1])>>(), + "Error!"); +static_assert(!has_type<std::result_of<ident_functor(const Abstract&&)>>(), + "Error!"); +static_assert(!has_type<std::result_of<ident_functor_noref(int(&)[1])>>(), + "Error!"); +static_assert(!has_type<std::result_of<ident_functor_noref + (const int(&)[1])>>(), "Error!"); +static_assert(!has_type<std::result_of<ident_functor_noref(Abstract&)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <ident_functor_noref(const Abstract&)>>(), "Error!"); +static_assert(!has_type<std::result_of<ident_functor_noref(void(&)())>>(), + "Error!"); +static_assert(!has_type<std::result_of<ident_functor_noref(void(&&)())>>(), + "Error!"); + +static_assert(!has_type<std::result_of<ident_functor()>>(), "Error!"); +static_assert(!has_type<std::result_of<ident_functor(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const ident_functor&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const ident_functor&&(int)>>(), + "Error!"); + +// Border-line case: +static_assert(!has_type<std::result_of<int S::*(Ukn*)>>(), "Error!"); +static_assert(!has_type<std::result_of<void (S::*(Ukn*))()>>(), "Error!"); + +// We want to allow this, it seems to be required by the order described +// in [func.require] p1: +static_assert(is_type<std::result_of<int S::*(BadSmartPtr<S>&)>, int&>(), + "Error!"); + +static_assert(is_type<std::result_of<Private(std::nullptr_t)>, bool>(), + "Error!"); +static_assert(is_type<std::result_of<Private&(std::nullptr_t)>, bool>(), + "Error!"); +static_assert(is_type<std::result_of<Private&&(std::nullptr_t)>, bool>(), + "Error!"); +static_assert(is_type<std::result_of<Private(ImplicitTo<std::nullptr_t>)>, + bool>(), "Error!"); +static_assert(is_type<std::result_of<Private&(ImplicitTo<std::nullptr_t>)>, + bool>(), "Error!"); +static_assert(is_type<std::result_of<Private&&(ImplicitTo<std::nullptr_t>)>, + bool>(), "Error!"); + +static_assert(!has_type<std::result_of<const Private&(std::nullptr_t)>>(), + "Error!"); +static_assert(!has_type<std::result_of<const Private&&(std::nullptr_t)>>(), + "Error!"); +static_assert(!has_type<std::result_of<Private()>>(), "Error!"); +static_assert(!has_type<std::result_of<Private(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private&()>>(), "Error!"); +static_assert(!has_type<std::result_of<Private&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&()>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private&&()>>(), "Error!"); +static_assert(!has_type<std::result_of<Private&&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private&&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&&()>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&&(int, int)>>(), "Error!"); + +static_assert(!has_type<std::result_of<Private(ScEn)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private(UnScEn)>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&(ScEn)>>(), "Error!"); +static_assert(!has_type<std::result_of<const Private&(UnScEn)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private(ImplicitTo<ScEn>)>>(), "Error!"); +static_assert(!has_type<std::result_of<Private(ImplicitTo<UnScEn>)>>(), + "Error!"); +static_assert(!has_type<std::result_of<const Private&(ImplicitTo<ScEn>)>>(), + "Error!"); +static_assert(!has_type<std::result_of<const Private&(ImplicitTo<UnScEn>)>>(), + "Error!"); + +static_assert(is_type<std::result_of<PrivateUnion(std::nullptr_t)>, bool>(), + "Error!"); +static_assert(is_type<std::result_of<PrivateUnion&(std::nullptr_t)>, bool>(), + "Error!"); +static_assert(is_type<std::result_of<PrivateUnion&&(std::nullptr_t)>, bool>(), + "Error!"); +static_assert(is_type<std::result_of<PrivateUnion(ImplicitTo<std::nullptr_t>)>, + bool>(), "Error!"); +static_assert(is_type<std::result_of + <PrivateUnion&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!"); +static_assert(is_type<std::result_of + <PrivateUnion&&(ImplicitTo<std::nullptr_t>)>, bool>(), "Error!"); + +static_assert(!has_type<std::result_of<const PrivateUnion&(std::nullptr_t)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <const PrivateUnion&&(std::nullptr_t)>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion()>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion&()>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&()>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&(int, int)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion&&()>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion&&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion&&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&&()>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&&(int)>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&&(int, int)>>(), + "Error!"); + +static_assert(!has_type<std::result_of<PrivateUnion(ScEn)>>(), "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion(UnScEn)>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&(ScEn)>>(), "Error!"); +static_assert(!has_type<std::result_of<const PrivateUnion&(UnScEn)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<ScEn>)>>(), + "Error!"); +static_assert(!has_type<std::result_of<PrivateUnion(ImplicitTo<UnScEn>)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <const PrivateUnion&(ImplicitTo<ScEn>)>>(), "Error!"); +static_assert(!has_type<std::result_of + <const PrivateUnion&(ImplicitTo<UnScEn>)>>(), "Error!"); + +static_assert(is_type<std::result_of<void(*(bool))(int)>, void>(), "Error!"); +static_assert(is_type<std::result_of<void(*(UnScEn))(int)>, void>(), "Error!"); +static_assert(is_type<std::result_of<void(*(ImplicitTo<int>))(int)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&))(int)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<void(*(ImplicitTo<int>&&))(int)>, void>(), + "Error!"); + +static_assert(!has_type<std::result_of<void(*(ScEn))(int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <void(*(const ImplicitTo<int>&))(int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <void(*(const ImplicitTo<int>&&))(int)>>(), "Error!"); + +static_assert(is_type<std::result_of<ImplicitTo<void(*)()>()>, void>(), + "Error!"); +static_assert(is_type<std::result_of<ImplicitTo<void(&)()>()>, void>(), + "Error!"); + +static_assert(!has_type<std::result_of<ImplicitTo<void(*)()>(int)>>(), + "Error!"); +static_assert(!has_type<std::result_of<ImplicitTo<void(*)(int)>()>>(), + "Error!"); +static_assert(!has_type<std::result_of<ImplicitTo<void(&)()>(int)>>(), + "Error!"); +static_assert(!has_type<std::result_of<ImplicitTo<void(&)(int)>()>>(), + "Error!"); + +// Conversion operators of types are not considered in call expressions +// (except for conversion to function pointer/reference): +static_assert(!has_type<std::result_of<ImplicitTo<S>(char, int&)>>(), "Error!"); +static_assert(!has_type<std::result_of<ImplicitTo<ident_functor>(int)>>(), + "Error!"); + +static_assert(is_type<std::result_of<variable_functor<>()>, void>(), "Error!"); +static_assert(is_type<std::result_of<variable_functor<>(int)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<>(int, int)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<>(int, int, int)>, + void>(), "Error!"); + +static_assert(is_type<std::result_of<variable_functor<>&()>, void>(), "Error!"); +static_assert(is_type<std::result_of<variable_functor<>&(int)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<>&(int, int)>, void>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<>&(int, int, int)>, + void>(), "Error!"); + +static_assert(!has_type<std::result_of<const variable_functor<>()>>(), + "Error!"); +static_assert(!has_type<std::result_of<const variable_functor<>(int)>>(), + "Error!"); +static_assert(!has_type<std::result_of<const variable_functor<>(int, int)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<>(int, int, int)>>(), "Error!"); + +static_assert(!has_type<std::result_of<const variable_functor<>&()>>(), + "Error!"); +static_assert(!has_type<std::result_of<const variable_functor<>&(int)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<>&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<>&(int, int, int)>>(), "Error!"); + +static_assert(is_type<std::result_of<variable_functor<S>()>, S>(), "Error!"); +static_assert(is_type<std::result_of<variable_functor<S>(int)>, S>(), "Error!"); +static_assert(is_type<std::result_of<variable_functor<S>(int, int)>, S>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<S>(int, int, int)>, S>(), + "Error!"); + +static_assert(is_type<std::result_of<variable_functor<S>&()>, S>(), "Error!"); +static_assert(is_type<std::result_of<variable_functor<S>&(int)>, S>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<S>&(int, int)>, S>(), + "Error!"); +static_assert(is_type<std::result_of + <variable_functor<S>&(int, int, int)>, S>(), "Error!"); + +static_assert(!has_type<std::result_of + <const variable_functor<S>()>>(), "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<S>(int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<S>(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<S>(int, int, int)>>(), "Error!"); + +static_assert(!has_type<std::result_of<const variable_functor<S>&()>>(), + "Error!"); +static_assert(!has_type<std::result_of<const variable_functor<S>&(int)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<S>&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<S>&(int, int, int)>>(), "Error!"); + +#if defined(HAS_52748_FIXED) +static_assert(has_type<std::result_of<variable_functor<Ukn>()>>(), "Error!"); +static_assert(is_type<std::result_of<variable_functor<Ukn>()>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<Ukn>(int)>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<Ukn>(int, int)>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of + <variable_functor<Ukn>(int, int, int)>, Ukn>(), "Error!"); + +static_assert(is_type<std::result_of<variable_functor<Ukn>&()>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of<variable_functor<Ukn>&(int)>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of + <variable_functor<Ukn>&(int, int)>, Ukn>(), "Error!"); +static_assert(is_type<std::result_of + <variable_functor<Ukn>&(int, int, int)>, Ukn>(), "Error!"); + +static_assert(is_type<std::result_of<PMSIncomplete(int)>, Ukn>(), "Error!"); +static_assert(is_type<std::result_of<PMSIncomplete&(int)>, Ukn>(), "Error!"); +static_assert(is_type<std::result_of<PMSIncomplete&&(int)>, Ukn>(), "Error!"); + +static_assert(is_type<std::result_of<FuncIncomplete(int)>, Ukn>(), "Error!"); +static_assert(is_type<std::result_of<FuncIncomplete&(int)>, Ukn>(), "Error!"); +static_assert(is_type<std::result_of<FuncIncomplete&&(int)>, Ukn>(), "Error!"); + +static_assert(is_type<std::result_of<FuncEllipses<Ukn>*()>, Ukn>(), "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<Ukn>&()>, Ukn>(), "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&()>, Ukn>(), "Error!"); + +static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool)>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool)>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<Ukn>&&(bool)>, Ukn>(), + "Error!"); + +static_assert(is_type<std::result_of<FuncEllipses<Ukn>*(bool, int, S)>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<Ukn>&(bool, int, S)>, Ukn>(), + "Error!"); +static_assert(is_type<std::result_of + <FuncEllipses<Ukn>&&(bool, int, S)>, Ukn>(), "Error!"); + +static_assert(!has_type<std::result_of<PMSIncompletenonconst(const S*)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S*, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S*, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S*, int, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S*&)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S*&, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S*&, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S*&, int, int, int)>>(), "Error!"); + +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&, int, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&&)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&&, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&&, int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <PMSIncompletenonconst(const S&&, int, int, int)>>(), "Error!"); +#endif + +static_assert(!has_type<std::result_of<const variable_functor<Ukn>()>>(), + "Error!"); +static_assert(!has_type<std::result_of<const variable_functor<Ukn>(int)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<Ukn>(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<Ukn>(int, int, int)>>(), "Error!"); + +static_assert(!has_type<std::result_of<const variable_functor<Ukn>&()>>(), + "Error!"); +static_assert(!has_type<std::result_of<const variable_functor<Ukn>&(int)>>(), + "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<Ukn>&(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of + <const variable_functor<Ukn>&(int, int, int)>>(), "Error!"); + +static_assert(!has_type<std::result_of<FuncIncomplete()>>(), "Error!"); +static_assert(!has_type<std::result_of<FuncIncomplete(S)>>(), "Error!"); +static_assert(!has_type<std::result_of<FuncIncomplete(int, int)>>(), "Error!"); +static_assert(!has_type<std::result_of<FuncIncomplete(int, int, int)>>(), + "Error!"); + +static_assert(!has_type<std::result_of<FuncIncomplete&&()>>(), "Error!"); +static_assert(!has_type<std::result_of<FuncIncomplete&&(S)>>(), "Error!"); +static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int)>>(), + "Error!"); +static_assert(!has_type<std::result_of<FuncIncomplete&&(int, int, int)>>(), + "Error!"); + +static_assert(is_type<std::result_of<FuncEllipses<int>*()>, int>(), "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<int>&()>, int>(), "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<int>&&()>, int>(), "Error!"); + +static_assert(is_type<std::result_of<FuncEllipses<int>*(bool)>, int>(), + "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<int>&(bool)>, int>(), + "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<int>&&(bool)>, int>(), + "Error!"); + +static_assert(is_type<std::result_of<FuncEllipses<int>*(bool, int, S)>, int>(), + "Error!"); +static_assert(is_type<std::result_of<FuncEllipses<int>&(bool, int, S)>, int>(), + "Error!"); +static_assert(is_type<std::result_of + <FuncEllipses<int>&&(bool, int, S)>, int>(), "Error!"); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_2.cc new file mode 100644 index 000000000..c08243d4c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/result_of/sfinae_friendly_2.cc @@ -0,0 +1,76 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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/>. + +// Taken from N3436: + +#include <type_traits> +#include <string> + +struct eat { template<typename T> eat(T const &) {} }; +struct not_incrementable {}; + +struct inc { + template<typename T> + auto operator()(T t) const -> decltype(t++) + { return t++; } +}; + +template<typename A> +typename std::result_of<inc(A)>::type // sfinae here +try_inc(A a) { + return inc()(a); +} + +not_incrementable +try_inc(eat) { + return not_incrementable(); +} + +template<typename> +struct never { static const bool value = false; }; + +template<typename T> +struct Fail +{ + static_assert(never<T>::value, "duh"); + typedef int type; +}; + +struct Fun +{ + template<typename T> + typename Fail<T>::type operator()(T) + { return 0; } +}; + +template<typename T> +typename std::result_of<Fun(T)>::type foo(T) +{ return 0; } + +template<typename> +int foo(...) +{ return 0; } + +void result_of_sfinae() { + int x = try_inc(1); // OK + not_incrementable y = try_inc(std::string("foo")); // OK, not_incrementable + (void) x; + (void) y; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc new file mode 100644 index 000000000..f77989043 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/1.cc @@ -0,0 +1,103 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <scoped_allocator> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::uneq_allocator; + +struct Element +{ + typedef uneq_allocator<Element> allocator_type; + + allocator_type alloc; + + Element(const allocator_type& a = allocator_type()) : alloc(a) { } + + Element(std::allocator_arg_t, const allocator_type& a, int = 0) + : alloc(a) { } + + Element(std::allocator_arg_t, const allocator_type& a, const Element&) + : alloc(a) { } + + const allocator_type& get_allocator() const { return alloc; } +}; + +void test01() +{ + bool test __attribute((unused)) = false; + + typedef std::scoped_allocator_adaptor<Element::allocator_type> alloc1_type; + + typedef std::vector<Element, alloc1_type> EltVec; + + alloc1_type a1(1); + Element e; + EltVec ev1(1, e, a1); + VERIFY( ev1.get_allocator().get_personality() == 1 ); + VERIFY( ev1[0].get_allocator().get_personality() == 1 ); +} + +void test02() +{ + bool test __attribute((unused)) = false; + + typedef std::scoped_allocator_adaptor<Element::allocator_type> inner_alloc_type; + + typedef std::vector<Element, inner_alloc_type> EltVec; + + typedef std::scoped_allocator_adaptor<Element::allocator_type, + Element::allocator_type> alloc_type; + + typedef std::vector<EltVec, alloc_type> EltVecVec; + + alloc_type a(1, Element::allocator_type(2)); // outer=1, inner=2 + Element e; + EltVec ev(1, e); + EltVecVec evv(1, ev, a); + + VERIFY( evv.get_allocator().get_personality() == 1 ); + VERIFY( evv[0].get_allocator().get_personality() == 2 ); + VERIFY( evv[0][0].get_allocator().get_personality() == 2 ); + + alloc_type a2(3, Element::allocator_type(4)); // outer=3, inner=4 + + EltVecVec evv2(evv, a2); // copy with a different allocator + + VERIFY( evv2.get_allocator().get_personality() == 3 ); + VERIFY( evv2[0].get_allocator().get_personality() == 4 ); + VERIFY( evv2[0][0].get_allocator().get_personality() == 4 ); + + EltVecVec evv3(std::move(evv), a2); // move with a different allocator + + VERIFY( evv3.get_allocator().get_personality() == 3 ); + VERIFY( evv3[0].get_allocator().get_personality() == 4 ); + VERIFY( evv3[0][0].get_allocator().get_personality() == 4 ); + +} + + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/2.cc new file mode 100644 index 000000000..6b807abf8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/2.cc @@ -0,0 +1,308 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 <memory> +#include <scoped_allocator> +#include <vector> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// 20.12.4 Scoped allocator adaptor members [allocator.adaptor.members] +// +// Test piecewise construction of std::pair by scoped_allocator_adaptor + +using __gnu_test::uneq_allocator; +using std::scoped_allocator_adaptor; + +// a DefaultConstructible and CopyConstructible type +struct def +{ + def() : id(999) { } + + int id; +}; + +// a CopyConstructible and non-DefaultConstructible type +struct copyable +{ + copyable(int id) : id(id) { } + + // not constructed with an allocator so nothing to test + bool verify() const { return true; } + + int id; +}; + +// a MoveConstructible and non-DefaultConstructible type +struct move_only +{ + move_only(int id) : id(id) { } + move_only(move_only&&) = default; + + // not constructed with an allocator so nothing to test + bool verify() const { return true; } + + int id; +}; + +// a type for which std::uses_allocator is true +struct uses_alloc_post +{ + typedef uneq_allocator<uses_alloc_post> allocator_type; + + uses_alloc_post(const allocator_type& alloc) + : allocator_personality(alloc.get_personality()), id(999) + { } + + uses_alloc_post(copyable arg, const allocator_type& alloc) + : allocator_personality(alloc.get_personality()), id(arg.id) + { } + + uses_alloc_post(move_only arg, const allocator_type& alloc) + : allocator_personality(alloc.get_personality()), id(arg.id) + { } + + // allocator-extended copy ctor + uses_alloc_post(const uses_alloc_post& other, const allocator_type& alloc) + : allocator_personality(alloc.get_personality()), id(other.id) + { } + + // verify we were constructed with right allocator + bool verify() const { return allocator_personality == id; } + + int allocator_personality; + int id; +}; + +// a type for which std::uses_allocator is true +struct uses_alloc_pre : uses_alloc_post +{ + typedef uneq_allocator<uses_alloc_pre> allocator_type; + + uses_alloc_pre(std::allocator_arg_t, const allocator_type& alloc) + : uses_alloc_post(alloc) + { } + + uses_alloc_pre(std::allocator_arg_t, const allocator_type& alloc, + copyable arg) + : uses_alloc_post(arg, alloc) + { } + + // allocator-extended copy ctor + uses_alloc_pre(std::allocator_arg_t, const allocator_type& alloc, + const uses_alloc_pre& other) + : uses_alloc_post(other, alloc) + { } + + uses_alloc_pre(std::allocator_arg_t, const allocator_type& alloc, + move_only arg) + : uses_alloc_post(std::move(arg), alloc) + { } +}; + +template<typename A, typename B> + void + test_def() + { + bool test __attribute((unused)) = false; + + typedef std::pair<A, B> test_type; + typedef uneq_allocator<test_type> alloc_type; + typedef scoped_allocator_adaptor<alloc_type, alloc_type> alloc_adaptor; + + int inner_id = 2; + alloc_adaptor a(-1, alloc_type(inner_id)); // outer=-1, inner=2 + + // all pair members that can be constructed with an allocator + // should be constructed with the inner allocator, with personality==2 + + auto p = a.allocate(1); + + // construct(pair<T1, T2>* p, piecewise_construct_t, tuple<...>, tuple<...>) + std::tuple<> t; + a.construct(p, std::piecewise_construct, t, t); + VERIFY( p->first.id == 999 ); + VERIFY( p->second.id == 999 ); + a.destroy(p); + + // construct(pair<T1, T2>* __p) + a.construct(p); + VERIFY( p->first.id == 999 ); + VERIFY( p->second.id == 999 ); + auto pp = *p; + a.destroy(p); + + // construct(pair<T1, T2>* p, const pair<U, V>& x) + a.construct(p, pp); + VERIFY( p->first.id == 999 ); + VERIFY( p->second.id == 999 ); + a.destroy(p); + + // construct(pair<T1, T2>* p, pair<U, V>&& x) + a.construct(p, std::move(pp)); + VERIFY( p->first.id == 999 ); + VERIFY( p->second.id == 999 ); + a.destroy(p); + + a.deallocate(p, 1); + } + +template<typename A, typename B> + void + test_copying() + { + bool test __attribute((unused)) = false; + + typedef std::pair<A, B> test_type; + typedef uneq_allocator<test_type> alloc_type; + typedef scoped_allocator_adaptor<alloc_type, alloc_type> alloc_adaptor; + + int inner_id = 2; + alloc_adaptor a(-1, alloc_type(inner_id)); // outer=-1, inner=2 + + // all pair members that can be constructed with an allocator + // should be constructed with the inner allocator, with personality==2 + + auto p = a.allocate(1); + + // construct(pair<T1, T2>* p, piecewise_construct_t, tuple<...>, tuple<...>) + auto t = std::make_tuple(copyable(inner_id)); + a.construct(p, std::piecewise_construct, t, t); + VERIFY( p->first.verify() ); + VERIFY( p->second.verify() ); + a.destroy(p); + + // construct(pair<T1, T2>* __p) + // cannot test this overload using non-DefaultConstructible types + + // construct(pair<T1, T2>* p, U&& x, V&& y) + copyable c(inner_id); + a.construct(p, c, c); + VERIFY( p->first.verify() ); + VERIFY( p->second.verify() ); + auto pp = *p; + a.destroy(p); + + // construct(pair<T1, T2>* p, const pair<U, V>& x) + a.construct(p, pp); + VERIFY( p->first.verify() ); + VERIFY( p->second.verify() ); + a.destroy(p); + + // construct(pair<T1, T2>* p, pair<U, V>&& x) + a.construct(p, std::move(pp)); + VERIFY( p->first.verify() ); + VERIFY( p->second.verify() ); + a.destroy(p); + + a.deallocate(p, 1); + } + +template<typename A, typename B> + void + test_moving() + { + bool test __attribute((unused)) = false; + + typedef std::pair<A, B> test_type; + typedef uneq_allocator<test_type> alloc_type; + typedef scoped_allocator_adaptor<alloc_type, alloc_type> alloc_adaptor; + + int inner_id = 2; + alloc_adaptor a(-1, alloc_type(inner_id)); // outer=-1, inner=2 + + // all pair members that can be constructed with an allocator + // should be constructed with the inner allocator, with personality==2 + + auto p = a.allocate(1); + + // construct(pair<T1, T2>* p, piecewise_construct_t, tuple<...>, tuple<...>) + a.construct(p, std::piecewise_construct, + std::make_tuple(move_only(inner_id)), + std::make_tuple(move_only(inner_id))); + VERIFY( p->first.verify() ); + VERIFY( p->second.verify() ); + a.destroy(p); + + // construct(pair<T1, T2>* __p) + // cannot test this overload using non-DefaultConstructible types + + // construct(pair<T1, T2>* p, U&& x, V&& y) + a.construct(p, move_only(inner_id), move_only(inner_id)); + VERIFY( p->first.verify() ); + VERIFY( p->second.verify() ); + a.destroy(p); + + // construct(pair<T1, T2>* p, const pair<U, V>& x) + // cannot test this overload using move-only types + + // construct(pair<T1, T2>* p, pair<U, V>&& x) + a.construct(p, std::make_pair(move_only(inner_id), move_only(inner_id))); + VERIFY( p->first.verify() ); + VERIFY( p->second.verify() ); + a.destroy(p); + + a.deallocate(p, 1); + } + +void test01() +{ + test_def<def, def>(); + test_def<def, uses_alloc_pre>(); + test_def<def, uses_alloc_post>(); + test_def<uses_alloc_pre, def>(); + test_def<uses_alloc_pre, uses_alloc_pre>(); + test_def<uses_alloc_pre, uses_alloc_post>(); + test_def<uses_alloc_post, def>(); + test_def<uses_alloc_post, uses_alloc_pre>(); + test_def<uses_alloc_post, uses_alloc_post>(); +} + +void test02() +{ + test_copying<copyable, copyable>(); + test_copying<copyable, uses_alloc_pre>(); + test_copying<copyable, uses_alloc_post>(); + test_copying<uses_alloc_pre, copyable>(); + test_copying<uses_alloc_pre, uses_alloc_pre>(); + test_copying<uses_alloc_pre, uses_alloc_post>(); + test_copying<uses_alloc_post, copyable>(); + test_copying<uses_alloc_post, uses_alloc_pre>(); + test_copying<uses_alloc_post, uses_alloc_post>(); +} + +void test03() +{ + test_moving<move_only, move_only>(); + test_moving<move_only, uses_alloc_pre>(); + test_moving<move_only, uses_alloc_post>(); + test_moving<uses_alloc_pre, move_only>(); + test_moving<uses_alloc_pre, uses_alloc_pre>(); + test_moving<uses_alloc_pre, uses_alloc_post>(); + test_moving<uses_alloc_post, move_only>(); + test_moving<uses_alloc_post, uses_alloc_pre>(); + test_moving<uses_alloc_post, uses_alloc_post>(); +} + +int main() +{ + test01(); + test02(); + test03(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/propagation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/propagation.cc new file mode 100644 index 000000000..fc8729885 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/propagation.cc @@ -0,0 +1,105 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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/>. + +// test that propagate_on_container_xxx is true iff it is true for +// any of the outer or inner allocators + +#include <scoped_allocator> + +using std::scoped_allocator_adaptor; + +typedef short test_type; + +template<typename T> + struct minimal_allocator + { + typedef T value_type; + minimal_allocator(); + template <typename U> + minimal_allocator(const minimal_allocator<U>&); + T* allocate(std::size_t); + void deallocate(T*, std::size_t); + }; + +template<typename T, bool copy, bool move, bool swap> + struct test_allocator : minimal_allocator<T> + { + struct propagate_on_container_copy_assignment + { static const bool value = copy; }; + + struct propagate_on_container_move_assignment + { static const bool value = move; }; + + struct propagate_on_container_swap + { static const bool value = swap; }; + }; + +template<typename A> + constexpr bool prop_on_copy() + { + typedef typename A::propagate_on_container_copy_assignment type; + return type::value; + } + +template<typename A> + constexpr bool prop_on_move() + { + typedef typename A::propagate_on_container_move_assignment type; + return type::value; + } + +template<typename A> + constexpr bool prop_on_swap() + { + typedef typename A::propagate_on_container_swap type; + return type::value; + } + +template<typename A, bool C, bool M, bool S> + constexpr bool test1() + { + static_assert( prop_on_copy<A>() == C, "copy" ); + static_assert( prop_on_move<A>() == M, "move" ); + static_assert( prop_on_swap<A>() == S, "swap" ); + return true; + } + +template<bool C, bool M, bool S> + constexpr bool test2() + { + typedef minimal_allocator<test_type> base_alloc; + typedef test_allocator<test_type, C, M, S> test_alloc; + typedef scoped_allocator_adaptor<base_alloc, test_alloc> scoped1; + typedef scoped_allocator_adaptor<test_alloc, base_alloc> scoped2; + typedef scoped_allocator_adaptor<test_alloc, test_alloc> scoped3; + return test1<scoped1, C, M, S>() + && test1<scoped2, C, M, S>() + && test1<scoped3, C, M, S>(); + } + +static_assert( test2<false, false, false>(), "never propagate" ); +static_assert( test2<true, false, false>(), "propagate on copy" ); +static_assert( test2<false, true, false>(), "propagate on move" ); +static_assert( test2<false, false, true>(), "propagate on swap" ); +static_assert( test2<true, true, false>(), "propagate on copy & move" ); +static_assert( test2<true, false, true>(), "propagate on copy & swap" ); +static_assert( test2<false, true, true>(), "propagate on move & swap" ); +static_assert( test2<true, true, true>(), "always propagate" ); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..c0f17505a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/explicit_instantiation.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 memory with NO OTHER INCLUDES. + +#include <scoped_allocator> +#include <memory> + +typedef short test_type; + +template<typename T> + struct minimal_allocator + { + typedef T value_type; + minimal_allocator(); + template <typename U> + minimal_allocator(const minimal_allocator<U>&); + T* allocate(unsigned long); + void deallocate(T*, unsigned long); + }; + +namespace std +{ + template struct scoped_allocator_adaptor<std::allocator<test_type>>; + + template struct scoped_allocator_adaptor<minimal_allocator<test_type>>; + + template struct scoped_allocator_adaptor<std::allocator<test_type>, + minimal_allocator<test_type>>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/typedefs.cc new file mode 100644 index 000000000..a65b6a1c5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/scoped_allocator/requirements/typedefs.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2011-2014 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 scoped_allocator with NO OTHER INCLUDES. + +#include <scoped_allocator> + +// { dg-do compile } + +template<typename T> + struct minimal_allocator + { + typedef T value_type; + minimal_allocator(); + template <typename U> + minimal_allocator(const minimal_allocator<U>&); + T* allocate(unsigned long); + void deallocate(T*, unsigned long); + }; + +struct S +{ + typedef minimal_allocator<short> allocator_type; + S(const allocator_type&); +}; + +void test01() +{ + typedef minimal_allocator<S> outer_type; + typedef minimal_allocator<S::allocator_type> inner_type; + typedef std::scoped_allocator_adaptor<outer_type, inner_type> test_type; + + // Check for required typedefs + typedef typename test_type::outer_allocator_type outer_allocator_type; + typedef typename test_type::inner_allocator_type inner_allocator_type; + typedef typename test_type::value_type value_type; + typedef typename test_type::size_type size_type; + typedef typename test_type::difference_type difference_type; + typedef typename test_type::pointer pointer; + typedef typename test_type::const_pointer const_pointer; + typedef typename test_type::void_pointer void_pointer; + typedef typename test_type::const_void_pointer const_void_pointer; + typedef typename test_type::propagate_on_container_copy_assignment + propagate_on_container_copy_assignment; + typedef typename test_type::propagate_on_container_move_assignment + propagate_on_container_move_assignment; + typedef typename test_type::propagate_on_container_swap + propagate_on_container_swap; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc new file mode 100644 index 000000000..b9816b896 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/assign.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from shared_ptr<Y> +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + + a = std::shared_ptr<A>(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a = std::shared_ptr<A>(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc new file mode 100644 index 000000000..e81a96a39 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from auto_ptr<Y> +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a(new A); + std::auto_ptr<B> b(new B); + a = std::move(b); + VERIFY( a.get() != 0 ); + VERIFY( b.get() == 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc new file mode 100644 index 000000000..74788418c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible auto_ptr<Y> +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::auto_ptr<B> b; + a = std::move(b); // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} + +// { dg-prune-output "cannot convert" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc new file mode 100644 index 000000000..b3c61d928 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x -Wno-deprecated" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +std::auto_ptr<A> source() { return std::auto_ptr<A>(); } + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from rvalue auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + a = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::auto_ptr<A> au; + a = std::move(au); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc new file mode 100644 index 000000000..7f98ac27b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/dr541.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +// DR 541. shared_ptr template assignment and void +void test01() +{ + std::shared_ptr<void> p; + p.operator=<void>(p); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc new file mode 100644 index 000000000..c30e52097 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/move.cc @@ -0,0 +1,118 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <utility> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Rvalue assignment from shared_ptr +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1; + std::shared_ptr<A> a2(new A); + + a1 = std::move(a2); + VERIFY( a1.get() != 0 ); + VERIFY( a2.get() == 0 ); + VERIFY( a1.use_count() == 1 ); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + a1 = std::move(std::shared_ptr<A>()); + VERIFY( a1.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); +} + +// Rvalue assignment from shared_ptr<Y> +void +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::shared_ptr<B> b(new B); + + a = std::move(b); + VERIFY( a.get() != 0 ); + VERIFY( b.get() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( b.use_count() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + a = std::move(std::shared_ptr<A>()); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 1 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc new file mode 100644 index 000000000..b6fdefa1a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr.cc @@ -0,0 +1,96 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from shared_ptr<Y> +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + + a = std::shared_ptr<A>(); + VERIFY( a.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + a = std::shared_ptr<A>(new A); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + a = std::shared_ptr<B>(new B); + VERIFY( a.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc new file mode 100644 index 000000000..e7835e85e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/shared_ptr_neg.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from incompatible shared_ptr<Y> +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::shared_ptr<B> b; + a = b; // { dg-error "here" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-error "In instantiation" "" { target *-*-* } 0 } +// { dg-error "cannot convert" "" { target *-*-* } 0 } +// { dg-error "required from" "" { target *-*-* } 0 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc new file mode 100644 index 000000000..48f1c00fd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_lvalue_neg.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from lvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::unique_ptr<A> u; + a = u; // { dg-error "cannot bind" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-prune-output "initializing argument" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc new file mode 100644 index 000000000..8290b4273 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/assign/unique_ptr_rvalue.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +std::unique_ptr<A> source() { return std::unique_ptr<A>(); } + +// 20.7.12.2.3 shared_ptr assignment [util.smartptr.shared.assign] + +// Assignment from rvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + a = source(); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::unique_ptr<A> u; + a = std::move(u); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc new file mode 100644 index 000000000..2ffe62903 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/casts/1.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2006-2014 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/>. + +// 20.6.6.2.10 shared_ptr casts [util.smartptr.shared.cast] + +#include <memory> +#include <testsuite_tr1.h> + +// { dg-do compile } + +struct MyP { virtual ~MyP() { }; }; +struct MyDP : MyP { }; + +int main() +{ + using __gnu_test::check_ret_type; + using std::shared_ptr; + using std::static_pointer_cast; + using std::const_pointer_cast; + using std::dynamic_pointer_cast; + + shared_ptr<double> spd; + shared_ptr<const int> spci; + shared_ptr<MyP> spa; + + check_ret_type<shared_ptr<void> >(static_pointer_cast<void>(spd)); + check_ret_type<shared_ptr<int> >(const_pointer_cast<int>(spci)); + check_ret_type<shared_ptr<MyDP> >(static_pointer_cast<MyDP>(spa)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc new file mode 100644 index 000000000..4be554ae0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/42925.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.11.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> + +// libstdc++/42925 (also see GB 99) +void test01() +{ + std::shared_ptr<int> ptr; + if (ptr == 0) + { } + if (0 == ptr) + { } + if (ptr != 0) + { } + if (0 != ptr) + { } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc new file mode 100644 index 000000000..1fd7aca66 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc @@ -0,0 +1,88 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.6.2.6 shared_ptr comparison [util.smartptr.shared.cmp] + +int +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty shared_ptrs compare equivalent + std::shared_ptr<A> p1; + std::shared_ptr<B> p2; + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p2 < p1) ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> A_default; + + std::shared_ptr<A> A_from_A(new A); + VERIFY( A_default != A_from_A ); + VERIFY( !(A_default == A_from_A) ); + VERIFY( (A_default < A_from_A) || (A_from_A < A_default) ); + + std::shared_ptr<B> B_from_B(new B); + VERIFY( B_from_B != A_from_A ); + VERIFY( !(B_from_B == A_from_A) ); + VERIFY( (B_from_B < A_from_A) || (A_from_A < B_from_B) ); + + A_from_A.reset(); + VERIFY( A_default == A_from_A ); + VERIFY( !(A_default != A_from_A) ); + VERIFY( !(A_default < A_from_A) && !(A_from_A < A_default) ); + + B_from_B.reset(); + VERIFY( B_from_B == A_from_A ); + VERIFY( !(B_from_B != A_from_A) ); + VERIFY( !(B_from_B < A_from_A) && !(A_from_A < B_from_B) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/dr1401.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/dr1401.cc new file mode 100644 index 000000000..3691cdc7a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/dr1401.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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/>. + +// 20.7.2.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> + +// DR 1401 +void test01() +{ + std::shared_ptr<int> ptr1, ptr2; + if (ptr1 == ptr2) + { } + if (ptr1 == nullptr) + { } + if (nullptr == ptr1) + { } + if (ptr1 != ptr2) + { } + if (ptr1 != nullptr) + { } + if (nullptr != ptr1) + { } + if (ptr1 < ptr2) + { } + if (ptr1 < nullptr) + { } + if (nullptr < ptr1) + { } + if (ptr1 <= ptr2) + { } + if (ptr1 <= nullptr) + { } + if (nullptr <= ptr1) + { } + if (ptr1 > ptr2) + { } + if (ptr1 > nullptr) + { } + if (nullptr > ptr1) + { } + if (ptr1 >= ptr2) + { } + if (ptr1 >= nullptr) + { } + if (nullptr >= ptr1) + { } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc new file mode 100644 index 000000000..7f8d263db --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc @@ -0,0 +1,102 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.13.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +namespace std +{ + template<> + struct less<A*> : binary_function<A*,A*,bool> + { + static int count; + bool operator()(A* l, A* r) { ++count; return l < r; } + }; + int less<A*>::count = 0; +} + +// 20.8.13.2.7 shared_ptr comparison [util.smartptr.shared.cmp] + + +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::less<std::shared_ptr<A>> less; + // test empty shared_ptrs compare equivalent + std::shared_ptr<A> p1; + std::shared_ptr<A> p2; + VERIFY( !less(p1, p2) && !less(p2, p1) ); + VERIFY( std::less<A*>::count == 2 ); + return 0; +} + + +// Construction from pointer +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::less<std::shared_ptr<A>> less; + + std::shared_ptr<A> empty; + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(new A); + + VERIFY( less(p1, p2) || less(p2, p1) ); + VERIFY( !(less(p1, p2) && less(p2, p1)) ); + + p1.reset(); + VERIFY( !less(p1, empty) && !less(empty, p1) ); + + p2.reset(); + VERIFY( !less(p1, p2) && !less(p2, p1) ); + + return 0; +} + +// Aliasing +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::less<std::shared_ptr<A>> less; + + A a; + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1, &a); + VERIFY( less(p1, p2) || less(p2, p1) ); + + return 0; +} +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc new file mode 100644 index 000000000..6c6e76c79 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/39405.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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 <memory> + +// libstdc++/39405 +template<typename T> + struct foo + { + std::shared_ptr<foo<T> > m_foo; + }; + +std::shared_ptr<foo<int> > t; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc new file mode 100644 index 000000000..fbd8ccde6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/43820_neg.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.11.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +// incomplete type +struct X; + +// get an auto_ptr rvalue +std::auto_ptr<X>&& ap(); + +void test01() +{ + X* px = 0; + std::shared_ptr<X> p1(px); // { dg-error "here" } + // { dg-error "incomplete" "" { target *-*-* } 875 } + + std::shared_ptr<X> p9(ap()); // { dg-error "here" } + // { dg-error "incomplete" "" { target *-*-* } 307 } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc new file mode 100644 index 000000000..01a3bad47 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/46910.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +// 20.9.10.2.1 shared_ptr constructors [util.smartptr.shared.const] + +struct deleter; + +class A +{ + ~A() = default; + friend struct deleter; +}; + +struct deleter +{ + void operator()(A* a) const; +}; + +void +test01() +{ + std::shared_ptr<A> p(new A, deleter()); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/51365.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/51365.cc new file mode 100644 index 000000000..eb823ed30 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/51365.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <memory> + +// libstdc++/51365 +// Test with 'final' deleter and allocator. + +struct A { }; + +struct D final +{ + void operator()(A*) { } +}; + +template<typename T> +struct Alloc final : std::allocator<T> +{ + Alloc() = default; + template<typename U> Alloc(const Alloc<U>&) { } + + template<typename U> + struct rebind + { typedef Alloc<U> other; }; +}; + +A a; +D d; + +Alloc<A> al; + +auto sd = std::shared_ptr<A>(&a, d); +auto sa = std::shared_ptr<A>(&a, d, al); +auto as = std::allocate_shared<A>(al); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/52924.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/52924.cc new file mode 100644 index 000000000..446f557b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/52924.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <memory> + +// libstdc++/52924 + +struct A { }; + +struct D { + ~D() noexcept(false) { } + void operator()(A*) { } +}; + +template<typename T> +struct Alloc : std::allocator<T> +{ + Alloc() = default; + ~Alloc() noexcept(false) { } + template<typename U> Alloc(const Alloc<U>&) { } + + template<typename U> + struct rebind + { typedef Alloc<U> other; }; +}; + +A a; +D d; +Alloc<A> al; + +auto sd = std::shared_ptr<A>(&a, d); +auto sa = std::shared_ptr<A>(&a, d, al); +auto as = std::allocate_shared<A>(al); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/55123.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/55123.cc new file mode 100644 index 000000000..83b9c6135 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/55123.cc @@ -0,0 +1,28 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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 <memory> + +// libstdc++/55123 + +void f() { + std::unique_ptr<const int> y; + std::shared_ptr<const int> x = std::move(y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58659.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58659.cc new file mode 100644 index 000000000..6df3289fb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58659.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2013-2014 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 <memory> +#include <testsuite_hooks.h> + +struct X { }; + +using spcd = std::_Sp_counted_deleter<X*, std::default_delete<X>, +std::allocator<void>, std::__default_lock_policy>; + +namespace std +{ + template<> + struct allocator<spcd> + { + using value_type = spcd; + + allocator() = default; + + template<typename U> + allocator(const allocator<U>&) { } + + value_type* allocate(size_t n) + { + if (n != 1) + throw bad_alloc(); + allocated = true; + return static_cast<value_type*>((void*)(storage)); + } + + void deallocate(value_type* p, size_t n) + { + VERIFY(n == 1 && p == (void*)storage && allocated); + allocated = false; + } + + static char storage[sizeof(spcd)]; + static bool allocated; + }; + + char allocator<spcd>::storage[]; + bool allocator<spcd>::allocated = false; +} + +int main() +{ + std::shared_ptr<X> s( std::unique_ptr<X>(new X) ); + VERIFY( std::allocator<spcd>::allocated ); + s.reset(); + VERIFY( !std::allocator<spcd>::allocated ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc new file mode 100644 index 000000000..535e798e9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 <memory> + +// libstdc++/58839 + +struct D { + void operator()(void*) const noexcept { } +}; + +void test01() +{ + std::unique_ptr<void, D> y; + std::shared_ptr<void> x = std::move(y); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc new file mode 100644 index 000000000..fcc31a3de --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alias.cc @@ -0,0 +1,107 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() : i() { } + virtual ~A() { } + int i; +}; + +struct B : A +{ + B() : A(), a() { } + virtual ~B() { } + A a; +}; + +void deletefunc(A* p) { delete p; } + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Aliasing constructors + +int test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + std::shared_ptr<bool> b1(a, &test); + VERIFY( b1.use_count() == 0 ); + VERIFY( a.get() == 0 ); + VERIFY( b1.get() == &test ); + + std::shared_ptr<bool> b2(b1); + VERIFY( b2.use_count() == 0 ); + VERIFY( b1.get() == b2.get() ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a(new A); + std::shared_ptr<int> i1(a, &a->i); + VERIFY( i1.use_count() == 2 ); + + std::shared_ptr<int> i2(i1); + VERIFY( i2.use_count() == 3 ); + VERIFY( i2.get() == &a->i ); + + return 0; +} + +int +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a1(b, b.get()); + std::shared_ptr<A> a2(b, &b->a); + VERIFY( a2.use_count() == 3 ); + VERIFY( a1 == b ); + VERIFY( a2 != b ); + VERIFY( a1.get() != a2.get() ); + + std::shared_ptr<A> a3(a1); + VERIFY( a3 == b ); + + a3 = a2; + VERIFY( a3.get() == &b->a ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc new file mode 100644 index 000000000..72a288281 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc.cc @@ -0,0 +1,103 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A { }; +void deletefunc(A* p) { delete p; } +struct D +{ + void operator()(A* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction with allocator +int +test01() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + std::shared_ptr<A> p1(new A, deletefunc, tracker_allocator<A>()); + std::size_t const sz = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz > 0 ); + { + std::shared_ptr<A> p2(p1); + VERIFY( p2.use_count() == 2 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + } + VERIFY( p1.use_count() == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + p1.reset(); + VERIFY( p1.use_count() == 0 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz ); + + return 0; +} + +// Construction with allocator +int +test02() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + std::shared_ptr<A> p1(new A, deletefunc, tracker_allocator<A>()); + std::size_t const sz1 = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz1 > 0 ); + std::shared_ptr<A> p2(new A, D(), tracker_allocator<A>()); + std::size_t const sz2 = tracker_allocator_counter::get_allocation_count(); + VERIFY( sz2 > sz1 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == 0 ); + p1 = p2; + VERIFY( p2.use_count() == 2 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 ); + p1.reset(); + VERIFY( p2.use_count() == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz1 ); + p2.reset(); + VERIFY( tracker_allocator_counter::get_allocation_count() == sz2 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() == sz2 ); + VERIFY( D::delete_count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc_min.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc_min.cc new file mode 100644 index 000000000..2ade28df1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/alloc_min.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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/>. + +// 20.7.2.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_allocator.h> + +struct X { }; + +// 20.7.2.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// test shared_ptr with minimal allocator + +__gnu_test::SimpleAllocator<X> alloc; +auto deleter = [](X* p) { delete p; }; +std::shared_ptr<X> p(new X, deleter, alloc); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc new file mode 100644 index 000000000..397cb3297 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from auto_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> a(new A); + std::shared_ptr<A> a2(std::move(a)); + VERIFY( a.get() == 0 ); + VERIFY( a2.get() != 0 ); + VERIFY( a2.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc new file mode 100644 index 000000000..a3d429ff0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +struct A { }; + +// 20.6.6.2.3 shared_ptr assignment [util.smartptr.shared.const] + +// Construction from const auto_ptr +void +test01() +{ + const std::auto_ptr<A> a; + std::shared_ptr<A> p(std::move(a)); // { dg-error "no match" } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc new file mode 100644 index 000000000..46f9ed3ef --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/constexpr.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt10shared_ptrIiEC2Ev" } } +// { dg-final { scan-assembler-not "_ZNSt10shared_ptrIiEC2EDn" } } + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test1; //not literal + test1.operator()<std::shared_ptr<int>>(); + + __gnu_test::constexpr_single_value_constructible test2; //not literal + test2.operator()<std::shared_ptr<int>, std::nullptr_t>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc new file mode 100644 index 000000000..2d2a14b47 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/copy.cc @@ -0,0 +1,136 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +void deleter(A* p) { delete p; } + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Copy construction +int test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1; + std::shared_ptr<A> a2(a1); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1(new A); + std::shared_ptr<A> a2(a1); + VERIFY( a2.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a(b); + VERIFY( a.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B, &deleter); + std::shared_ptr<A> a(b); + VERIFY( a.use_count() == 2 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc new file mode 100644 index 000000000..78b76fa1d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/default.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Default construction +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + VERIFY( a.get() == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc new file mode 100644 index 000000000..37b967835 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/move.cc @@ -0,0 +1,164 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +// TR1 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <utility> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct D +{ + void operator()(B* p) const { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + D::delete_count = 0; + } +}; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Rvalue construction +int test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1; + std::shared_ptr<A> a2(std::move(a1)); + VERIFY( a1.use_count() == 0 ); + VERIFY( a2.use_count() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a1(new A); + std::shared_ptr<A> a2(std::move(a1)); + VERIFY( a1.use_count() == 0 ); + VERIFY( a2.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + return 0; +} + +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B); + std::shared_ptr<A> a(std::move(b)); + VERIFY( b.use_count() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + return 0; +} + +int +test04() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> b(new B, D()); + std::shared_ptr<A> a(std::move(b)); + VERIFY( b.use_count() == 0 ); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + + a = std::move(std::shared_ptr<A>()); + VERIFY( D::delete_count == 1 ); + VERIFY( B::dtor_count == 1 ); + + return 0; +} + +int +test05() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a(std::move(std::shared_ptr<A>(new A))); + VERIFY( a.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..b03da371c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-14 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 <memory> + +typedef std::shared_ptr<int> sptype; + +static_assert(std::is_nothrow_move_constructible<sptype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/nullptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/nullptr.cc new file mode 100644 index 000000000..dc54f3e58 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/nullptr.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.11.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> +#include <cstddef> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +// 20.9.11.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from nullptr + +struct deleter +{ + int count; + deleter() : count(0) { } + void operator()(std::nullptr_t) { ++count; } + void operator()(int*) const { throw "wrong type passed to deleter"; } +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<int> p = nullptr; + VERIFY( p.get() == nullptr ); + VERIFY( p.use_count() == 0 ); + +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + deleter d; + std::shared_ptr<int> p(nullptr, std::ref(d)); + VERIFY( p.get() == nullptr ); + VERIFY( p.use_count() == 1 ); + + p = nullptr; + VERIFY( p.use_count() == 0 ); + VERIFY( d.count == 1 ); +} + + +void +test03() +{ + bool test __attribute__((unused)) = true; + + deleter d; + __gnu_test::tracker_allocator<int> a; + std::shared_ptr<int> p(nullptr, std::ref(d), a); + VERIFY( p.get() == nullptr ); + VERIFY( p.use_count() == 1 ); + + p = nullptr; + VERIFY( p.use_count() == 0 ); + VERIFY( d.count == 1 ); + + typedef __gnu_test::tracker_allocator_counter c; + VERIFY( c::get_destruct_count() == c::get_construct_count() ); + VERIFY( c::get_deallocation_count() == c::get_allocation_count() ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc new file mode 100644 index 000000000..ba2adb725 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/pointer.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B : A { }; + + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from pointer + +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = 0; + std::shared_ptr<A> p(a); + VERIFY( p.get() == 0 ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr<A> p(a); + VERIFY( p.get() == a ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + + +int +test03() +{ + bool test __attribute__((unused)) = true; + + B * const b = new B; + std::shared_ptr<A> p(b); + VERIFY( p.get() == b ); + VERIFY( p.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc new file mode 100644 index 000000000..8f6505692 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.2.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.7.2.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> up(new A); + std::shared_ptr<A> sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc new file mode 100644 index 000000000..41e56d6c4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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/>. + +// 20.7.2.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +int destroyed = 0; + +struct A : std::enable_shared_from_this<A> +{ + ~A() { ++destroyed; } +}; + +// 20.7.2.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr<A[]> +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> up(new A[2]); + std::shared_ptr<A> sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + + VERIFY( sp->shared_from_this() != nullptr ); + + sp.reset(); + VERIFY( destroyed == 2 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc new file mode 100644 index 000000000..915443575 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +struct D { + void operator()(A* p) const { delete p; ++count; } + static int count; +}; + +int D::count = 0; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A, D> up(new A, D()); + { + std::shared_ptr<A> sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + } + VERIFY( D::count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc new file mode 100644 index 000000000..05dd41405 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_1.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +struct D { + typedef void result_type; + void operator()(A* p) { delete p; ++count; } + int count; +}; + + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + D d = D(); + std::unique_ptr<A, D&> up(new A, d); + { + std::shared_ptr<A> sp(std::move(up)); + VERIFY( up.get() == 0 ); + VERIFY( sp.get() != 0 ); + VERIFY( sp.use_count() == 1 ); + } + VERIFY( d.count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc new file mode 100644 index 000000000..4a0a33b7e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_deleter_ref_2.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <functional> +#include <testsuite_hooks.h> + +struct A { }; + +struct D { + typedef void result_type; + void operator()(A* p) { delete p; ++count; } + int count; +}; + + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from unique_ptr +// See: http://gcc.gnu.org/ml/libstdc++/2008-09/msg00070.html. +int +test01() +{ + bool test __attribute__((unused)) = true; + + D d; + std::unique_ptr<A, D&> p1(new A, d); + + std::shared_ptr<A> p2(std::move(p1)); + + typedef std::reference_wrapper<D> D2; + D2* p3 = std::get_deleter<D2>(p2); + + VERIFY( p3 != 0 ); + VERIFY( &p3->get() == &d ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc new file mode 100644 index 000000000..563d2f83e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/unique_ptr_neg.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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/>. + +// 20.7.12.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.7.12.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from lvalue unique_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> a; + std::shared_ptr<A> p(a); // { dg-error "cannot bind" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} +// { dg-prune-output "initializing argument" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc new file mode 100644 index 000000000..3f93a5e52 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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/>. + +// 20.8.2.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +void test01() +{ + std::shared_ptr<void> p((void*)nullptr); // { dg-error "here" } + // { dg-error "incomplete" "" { target *-*-* } 874 } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc new file mode 100644 index 000000000..5a95095d8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from weak_ptr +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr<A> a1(a); + std::weak_ptr<A> wa(a1); + std::shared_ptr<A> a2(wa); + VERIFY( a2.get() == a ); + VERIFY( a2.use_count() == wa.use_count() ); + + return 0; +} + + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc new file mode 100644 index 000000000..7cc7c4c90 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/cons/weak_ptr_expired.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.1 shared_ptr constructors [util.smartptr.shared.const] + +// Construction from expired weak_ptr +int +test01() +{ + bool test = false; + + std::shared_ptr<A> a1(new A); + std::weak_ptr<A> wa(a1); + a1.reset(); + VERIFY( wa.expired() ); + try + { + std::shared_ptr<A> a2(wa); + } + catch (const std::bad_weak_ptr& e) + { + // Expected. + if (e.what() == std::string("bad_weak_ptr")) + test = true; + } + VERIFY( test ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc new file mode 100644 index 000000000..cf6b33500 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/36949.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <memory> + +struct A : std::enable_shared_from_this<A> { }; + +// libstdc++/36949 +void test01() +{ + std::make_shared<A>()->shared_from_this(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594.cc new file mode 100644 index 000000000..9501ab3b5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/58594.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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 <memory> + +// libstdc++/58594 +void test01() +{ + std::make_shared<const int>(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc new file mode 100644 index 000000000..cd2712a9d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc.cc @@ -0,0 +1,110 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A +{ + A(int i, double d, char c = '\0') : i(i), d(d), c(c) { ++ctor_count; } + explicit A(int i) : i(i), d(), c() { ++ctor_count; } + A() : i(), d(), c() { ++ctor_count; } + ~A() { ++dtor_count; } + int i; + double d; + char c; + static int ctor_count; + static int dtor_count; +}; +int A::ctor_count = 0; +int A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + tracker_allocator_counter::reset(); + } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + { + std::shared_ptr<A> p1 = std::allocate_shared<A>(tracker_allocator<A>()); + VERIFY( p1.get() != 0 ); + VERIFY( p1.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + } + VERIFY( A::ctor_count == A::dtor_count ); + VERIFY( tracker_allocator_counter::get_allocation_count() + == tracker_allocator_counter::get_deallocation_count() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + std::shared_ptr<A> p1; + + p1 = std::allocate_shared<A>(tracker_allocator<A>(), 1); + VERIFY( A::ctor_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + + p1 = std::allocate_shared<A>(tracker_allocator<A>(), 1, 2.0); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + VERIFY( tracker_allocator_counter::get_deallocation_count() > 0 ); + + p1 = std::allocate_shared<A>(tracker_allocator<A>(), 1, 2.0, '3'); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( p1->i == 1 ); + VERIFY( p1->d == 2.0 ); + VERIFY( p1->c == '3' ); + + p1 = std::shared_ptr<A>(); + VERIFY( A::ctor_count == A::dtor_count ); + VERIFY( tracker_allocator_counter::get_allocation_count() + == tracker_allocator_counter::get_deallocation_count() ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc_min.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc_min.cc new file mode 100644 index 000000000..cfdaa58a6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/alloc_min.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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/>. + +// 20.7.2.2 Class template shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_allocator.h> + +struct X { }; + +// 20.7.2.2.6 shared_ptr creation [util.smartptr.shared.create] + +// test shared_ptr with minimal allocator + +__gnu_test::SimpleAllocator<X> alloc; +auto p = std::allocate_shared<X>(alloc); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc new file mode 100644 index 000000000..ec351ce3a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr402.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <new> +#include <testsuite_hooks.h> + +struct A +{ + void* operator new(size_t n) { return new char[sizeof(A)]; } + void operator delete(void* p, size_t) { delete (char*)p; } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p = std::make_shared<A>(); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc new file mode 100644 index 000000000..351977c23 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/dr925.cc @@ -0,0 +1,90 @@ +// { dg-options "-std=gnu++0x -Wno-deprecated" } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.11.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ +}; + +std::unique_ptr<A> +create_unique_ptr() +{ + return std::unique_ptr<A>(new A()); +} + +std::auto_ptr<A> +create_auto_ptr() +{ + return std::auto_ptr<A>(new A()); +} + +void +process(std::shared_ptr<A> a) +{ + bool test __attribute__((unused)) = true; + + VERIFY( a.get() != 0 ); + VERIFY( a.use_count() == 1 ); +} + +// 20.9.11.2.1 shared_ptr creation [util.smartptr.shared.const] + +// Implicit conversion of auto_ptr to shared_ptr is allowed + +void +test01() +{ + process(create_auto_ptr()); +} + +void +test02() +{ + std::auto_ptr<A> a = create_auto_ptr(); + process(std::move(a)); +} + +// Implicit conversion of unique_ptr to shared_ptr is allowed + +void +test03() +{ + process(create_unique_ptr()); +} + +void +test04() +{ + std::unique_ptr<A> a = create_unique_ptr(); + process(std::move(a)); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc new file mode 100644 index 000000000..9b5a611c7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/make.cc @@ -0,0 +1,97 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A(int i, double d, char c = '\0') : i(i), d(d), c(c) { ++ctor_count; } + explicit A(int i) : i(i), d(), c() { ++ctor_count; } + A() : i(), d(), c() { ++ctor_count; } + ~A() { ++dtor_count; } + int i; + double d; + char c; + static int ctor_count; + static int dtor_count; +}; +int A::ctor_count = 0; +int A::dtor_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + } +}; + +// 20.6.6.2.6 shared_ptr creation [util.smartptr.shared.create] + +void +test01() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + { + std::shared_ptr<A> p1 = std::make_shared<A>(); + VERIFY( p1.get() != 0 ); + VERIFY( p1.use_count() == 1 ); + VERIFY( A::ctor_count == 1 ); + } + VERIFY( A::ctor_count == A::dtor_count ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + reset_count_struct __attribute__((unused)) reset; + + std::shared_ptr<A> p1; + + p1 = std::make_shared<A>(1); + VERIFY( A::ctor_count == 1 ); + + p1 = std::make_shared<A>(1, 2.0); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 1 ); + + p1 = std::make_shared<A>(1, 2.0, '3'); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( p1->i == 1 ); + VERIFY( p1->d == 2.0 ); + VERIFY( p1->c == '3' ); + + p1 = std::shared_ptr<A>(); + VERIFY( A::ctor_count == A::dtor_count ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/private.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/private.cc new file mode 100644 index 000000000..e7b845ef5 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/creation/private.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <new> + +// The behaviour tested here relies on the resolution of LWG issue 2070 + +template<typename T> struct MyAlloc; + +class Private +{ + Private() = default; + Private(const Private&) = default; + ~Private() = default; + + friend class MyAlloc<Private>; + +public: + int get() const { return 0; } +}; + +template<typename T> +struct MyAlloc : std::allocator<Private> +{ + void construct(T* p) { ::new((void*)p) T(); } + void destroy(T* p) { p->~T(); } +}; + +int main() +{ + MyAlloc<Private> a; + auto p = std::allocate_shared<Private>(a); + return p->get(); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc new file mode 100644 index 000000000..b5e0e2cd1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/dest/dest.cc @@ -0,0 +1,134 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + +struct D +{ + void operator()(const B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + D::delete_count = 0; + } +}; + + +// 20.6.6.2.2 shared_ptr destructor [util.smartptr.shared.dest] + +// empty shared_ptr +int +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + { + std::shared_ptr<A> a; + } + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + VERIFY( D::delete_count == 0 ); + + return 0; +} + +// shared ownership +int +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a; + { + a = std::shared_ptr<A>(new B, D()); + } + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); + VERIFY( D::delete_count == 0 ); + + return 0; +} + +// exclusive ownership +int +test03() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + { + std::shared_ptr<A> a1(new B); + std::shared_ptr<A> a2(new B, D()); + } + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 2 ); + VERIFY( B::ctor_count == 2 ); + VERIFY( B::dtor_count == 2 ); + VERIFY( D::delete_count == 1 ); + + return 0; +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/hash/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/hash/1.cc new file mode 100644 index 000000000..0aa808943 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/hash/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + struct T { }; + + std::shared_ptr<T> s0(new T); + std::hash<std::shared_ptr<T>> hs0; + std::hash<T*> hp0; + + VERIFY( hs0(s0) == hp0(s0.get()) ); + + std::__shared_ptr<T> s1(new T); + std::hash<std::__shared_ptr<T>> hs1; + std::hash<T*> hp1; + + VERIFY( hs1(s1) == hp1(s1.get()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc new file mode 100644 index 000000000..afa7d6f9d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/24595.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +using std::get_deleter; + +// libstdc++/24595 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<int> sp; + VERIFY( !get_deleter<void(*)(int*)>(sp) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc new file mode 100644 index 000000000..6745ae04b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/42019.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x -fno-rtti" } +// Copyright (C) 2009-2014 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/>. + +// 20.8.15.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +// libstdc++/42019 + +class A {}; + +struct B { + explicit B(int i) : i(i) { } + int i; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> spA = std::make_shared<A>(); + + VERIFY( spA.get() != 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<B> spB = std::make_shared<B>(99); + + VERIFY( spB->i == 99 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc new file mode 100644 index 000000000..e793b207d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/io.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <sstream> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.8 shared_ptr I/O [util.smartptr.shared.io] + +// operator<< +int +test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p(new A); + std::ostringstream buf; + buf << p; + const std::string s = buf.str(); + buf.str(""); + buf << p.get(); + VERIFY( s == buf.str() ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc new file mode 100644 index 000000000..8505d6dc6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/misc/swap.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.9 shared_ptr specialized algorithms [util.smartptr.shared.spec] + +// std::swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a1 = new A; + A * const a2 = new A; + std::shared_ptr<A> p1(a1); + std::shared_ptr<A> p2(a2); + std::swap(p1, p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc new file mode 100644 index 000000000..e404941b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/24805.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap + +// libstdc++/24805 +using std::swap; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc new file mode 100644 index 000000000..4cfe978af --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset.cc @@ -0,0 +1,89 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B : A { }; +struct D +{ + void operator()(B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// reset +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + std::shared_ptr<A> p1(a); + std::shared_ptr<A> p2(p1); + p1.reset(); + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == a ); + + return 0; +} + +int +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + B * const b = new B; + std::shared_ptr<A> p1(a); + std::shared_ptr<A> p2(p1); + p1.reset(b); + VERIFY( p1.get() == b ); + VERIFY( p2.get() == a ); + + return 0; +} + +int +test03() +{ + bool test __attribute__((unused)) = true; + + { + std::shared_ptr<A> p1; + p1.reset(new B, D()); + } + VERIFY( D::delete_count == 1 ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc new file mode 100644 index 000000000..8036bc1e1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_alloc.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> +#include <testsuite_allocator.h> + +using __gnu_test::tracker_allocator_counter; +using __gnu_test::tracker_allocator; + +struct A { }; +struct B : A { }; +struct D +{ + void operator()(B* p) { delete p; ++delete_count; } + static long delete_count; +}; +long D::delete_count = 0; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// Reset with allocator +int +test01() +{ + bool test __attribute__((unused)) = true; + tracker_allocator_counter::reset(); + + { + std::shared_ptr<A> p1; + p1.reset(new B, D(), tracker_allocator<B>()); + VERIFY( tracker_allocator_counter::get_allocation_count() > 0 ); + } + VERIFY( D::delete_count == 1 ); + VERIFY( tracker_allocator_counter::get_allocation_count() == tracker_allocator_counter::get_deallocation_count() ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc new file mode 100644 index 000000000..45fa86af1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/reset_neg.cc @@ -0,0 +1,47 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// reset +int +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1(new A); + p1.reset(); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc new file mode 100644 index 000000000..dfff23a91 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a1 = new A; + A * const a2 = new A; + std::shared_ptr<A> p1(a1); + std::shared_ptr<A> p2(a2); + p1.swap(p2); + VERIFY( p1.get() == a2 ); + VERIFY( p2.get() == a1 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc new file mode 100644 index 000000000..11e0d32f7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/modifiers/swap_neg.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.4 shared_ptr modifiers [util.smartptr.shared.mod] + +// swap +int +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(new A); + p1.swap(p2); // { dg-error "discards qualifiers" } + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc new file mode 100644 index 000000000..4589d2eda --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/bool_conv.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// conversion to bool +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1; + VERIFY( static_cast<bool>(p1) == false ); + const std::shared_ptr<A> p2(p1); + VERIFY( static_cast<bool>(p2) == false ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + VERIFY( static_cast<bool>(p1) ); + std::shared_ptr<A> p2(p1); + VERIFY( static_cast<bool>(p2) ); + p1.reset(); + VERIFY( !static_cast<bool>(p1) ); + VERIFY( static_cast<bool>(p2) ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p2.reset(new A); + VERIFY( static_cast<bool>(p1) ); + VERIFY( static_cast<bool>(p2) ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc new file mode 100644 index 000000000..e38907254 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/get.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() : i() {} + int i; +}; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// get +void +test01() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr<A> p(a); + VERIFY( p.get() == a ); +} + +// operator* +void +test02() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr<A> p(a); + VERIFY( &*p == a ); +} + +// operator-> +void +test03() +{ + bool test __attribute__((unused)) = true; + + A * const a = new A; + const std::shared_ptr<A> p(a); + VERIFY( &p->i == &a->i ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc new file mode 100644 index 000000000..648b52499 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/owner_before.cc @@ -0,0 +1,94 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.13.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + int i; + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty shared_ptrs compare equivalent + std::shared_ptr<A> p1; + std::shared_ptr<B> p2; + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); +} + + +// Construction from pointer +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a0; + + std::shared_ptr<A> a1(new A); + VERIFY( a1.owner_before(a0) || a0.owner_before(a1) ); + VERIFY( !(a1.owner_before(a0) && a0.owner_before(a1)) ); + + std::shared_ptr<B> b1(new B); + VERIFY( a1.owner_before(b1) || b1.owner_before(a1) ); + VERIFY( !(a1.owner_before(b1) && b1.owner_before(a1)) ); + + std::shared_ptr<A> a2(a1); + VERIFY( !a1.owner_before(a2) && !a2.owner_before(a1) ); + a2 = b1; + VERIFY( !b1.owner_before(a2) && !a2.owner_before(b1) ); + + std::weak_ptr<A> w1(a1); + VERIFY( !a1.owner_before(w1) && !w1.owner_before(a1) ); + std::weak_ptr<A> w2(a2); + VERIFY( !b1.owner_before(w2) && !w2.owner_before(b1) ); +} + +// Aliasing +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A()); + std::shared_ptr<int> p2(p1, &p1->i); + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc new file mode 100644 index 000000000..0c71fdcd4 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/unique.cc @@ -0,0 +1,75 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// unique +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1; + VERIFY( !p1.unique() ); + const std::shared_ptr<A> p2(p1); + VERIFY( !p1.unique() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + VERIFY( p1.unique() ); + std::shared_ptr<A> p2(p1); + VERIFY( !p1.unique() ); + p1.reset(); + VERIFY( !p1.unique() ); + VERIFY( p2.unique() ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p2.reset(new A); + VERIFY( p1.unique() ); + VERIFY( p2.unique() ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc new file mode 100644 index 000000000..2b44d79e8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/observers/use_count.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B : A { }; + +// 20.6.6.2.5 shared_ptr observers [util.smartptr.shared.obs] + +// use_count +void +test01() +{ + bool test __attribute__((unused)) = true; + + const std::shared_ptr<A> p1; + VERIFY( p1.use_count() == 0 ); + const std::shared_ptr<A> p2(p1); + VERIFY( p1.use_count() == 0 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p1.reset(); + VERIFY( p1.use_count() == 0 ); + VERIFY( p2.use_count() == 1 ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> p1(new A); + std::shared_ptr<A> p2(p1); + p2.reset(new B); + VERIFY( p1.use_count() == 1 ); + VERIFY( p2.use_count() == 1 ); +} + + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..40ebec096 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::shared_ptr; +template class shared_ptr<int>; +template class shared_ptr<void>; +template class shared_ptr<ClassType>; +template class shared_ptr<IncompleteClass>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..148375a4a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +// Check the _S_single lock policy can be instantiated. For a thread-enabled +// library this checks the templates can be instantiated for non-default +// lock policy, for a single-threaded lib this is redundant but harmless. +using namespace __gnu_test; +using std::__shared_ptr; +using std::_S_single; +template class __shared_ptr<int, _S_single>; +template class __shared_ptr<ClassType, _S_single>; +template class __shared_ptr<IncompleteClass, _S_single>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc new file mode 100644 index 000000000..1255b7407 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc @@ -0,0 +1,197 @@ +// Copyright (C) 2006-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* } } +// { dg-options "-pthread -std=gnu++0x" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* } } +// { dg-options "-pthreads -std=gnu++0x" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } + +#include <memory> +#include <random> +#include <vector> +#include <testsuite_hooks.h> +#include <iostream> +#include <cstdlib> + +#include <pthread.h> + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +/* This (brute-force) tests the atomicity and thus thread safety of the + * shared_ptr <- weak_ptr + * assignment operation by allocating a test object, retrieving a weak + * reference to it, and letting a number of threads repeatedly create strong + * references from the weak reference. + * Specifically, this tests the function _Sp_counted_base<true>::add_ref_lock() + */ + + +const unsigned int HAMMER_MAX_THREADS = 10; +const unsigned int POOL_SIZE = 1000; +const unsigned long HAMMER_REPEAT = 100000; +const unsigned long KILL_ONE_IN = 1000; + +struct A + { + static _Atomic_word counter; + A() + { + __gnu_cxx::__atomic_add(&counter, 1); + } + ~A() + { + __gnu_cxx::__atomic_add(&counter, -1); + } + }; + +_Atomic_word A::counter = 0; + +typedef std::shared_ptr<A> sp_A_t; +typedef std::weak_ptr<A> wp_A_t; + +typedef std::vector<sp_A_t> sp_vector_t; +typedef std::vector<wp_A_t> wp_vector_t; + +struct shared_and_weak_pools +{ + sp_vector_t& shared_pool; + wp_vector_t& weak_pool; + + shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool) + : shared_pool(_shared_pool), weak_pool(_weak_pool) + { } +}; + +void* thread_hammer_and_kill(void* opaque_pools) +{ + shared_and_weak_pools& pools = *static_cast<shared_and_weak_pools*>(opaque_pools); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + sp_vector_t::iterator cur_shared = pools.shared_pool.begin(); + wp_vector_t::iterator cur_weak = pools.weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == pools.weak_pool.end()) + break; + } + + if (rng() % KILL_ONE_IN == 0) + { + cur_shared->reset(); + ++cur_shared; + } + } + return 0; +} + +void* thread_hammer(void* opaque_weak) +{ + wp_vector_t& weak_pool = *static_cast<wp_vector_t*>(opaque_weak); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + wp_vector_t::iterator cur_weak = weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == weak_pool.end()) + break; + } + } + return 0; +} + +int +test01() +{ + bool test __attribute__((unused)) = true; + sp_vector_t obj_pool(POOL_SIZE); + + for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur) + { + cur->reset(new A); + } + // Obtain weak references. + std::vector<wp_vector_t> weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end())); + + // Launch threads with pointer to weak reference. + pthread_t threads[HAMMER_MAX_THREADS]; +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (HAMMER_MAX_THREADS); +#endif + + pthread_attr_t tattr; + pthread_attr_init(&tattr); + + shared_and_weak_pools pools(obj_pool, weak_pool[0]); + pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast<void*>(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, static_cast<void*>(&weak_pool[worker]))) + std::abort(); + } + // Wait for threads to complete, then check integrity of reference. + void* status; + for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_join(threads[worker], &status)) + std::abort(); + } + obj_pool.clear(); + + VERIFY( A::counter == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc new file mode 100644 index 000000000..d8182fadf --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc @@ -0,0 +1,199 @@ +// Copyright (C) 2006-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* } } +// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* } } +// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } } +// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } } + +#include <memory> +#include <random> +#include <vector> +#include <testsuite_hooks.h> +#include <iostream> +#include <cstdlib> + +#include <pthread.h> + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include <unistd.h> // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +/* This (brute-force) tests the atomicity and thus thread safety of the + * shared_ptr <- weak_ptr + * assignment operation by allocating a test object, retrieving a weak + * reference to it, and letting a number of threads repeatedly create strong + * references from the weak reference. + * Specifically, this tests the function _Sp_counted_base<true>::add_ref_lock() + */ + + +const unsigned int HAMMER_MAX_THREADS = 10; +const unsigned int POOL_SIZE = 1000; +const unsigned long HAMMER_REPEAT = 100000; +const unsigned long KILL_ONE_IN = 1000; + +struct A + { + static _Atomic_word counter; + A() + { + __gnu_cxx::__atomic_add(&counter, 1); + } + ~A() + { + __gnu_cxx::__atomic_add(&counter, -1); + } + }; + +_Atomic_word A::counter = 0; + +using std::_S_mutex; + +typedef std::__shared_ptr<A, _S_mutex> sp_A_t; +typedef std::__weak_ptr<A, _S_mutex> wp_A_t; + +typedef std::vector<sp_A_t> sp_vector_t; +typedef std::vector<wp_A_t> wp_vector_t; + +struct shared_and_weak_pools +{ + sp_vector_t& shared_pool; + wp_vector_t& weak_pool; + + shared_and_weak_pools(sp_vector_t& _shared_pool, wp_vector_t& _weak_pool) + : shared_pool(_shared_pool), weak_pool(_weak_pool) + { } +}; + +void* thread_hammer_and_kill(void* opaque_pools) +{ + shared_and_weak_pools& pools = *static_cast<shared_and_weak_pools*>(opaque_pools); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + sp_vector_t::iterator cur_shared = pools.shared_pool.begin(); + wp_vector_t::iterator cur_weak = pools.weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == pools.weak_pool.end()) + break; + } + + if (rng() % KILL_ONE_IN == 0) + { + cur_shared->reset(); + ++cur_shared; + } + } + return 0; +} + +void* thread_hammer(void* opaque_weak) +{ + wp_vector_t& weak_pool = *static_cast<wp_vector_t*>(opaque_weak); + // Using the same parameters as in the RNG test cases. + std::mersenne_twister_engine< + unsigned long, 32, 624, 397, 31, + 0x9908b0dful, 11, + 0xfffffffful, 7, + 0x9d2c5680ul, 15, + 0xefc60000ul, 18, 1812433253ul> rng; + + wp_vector_t::iterator cur_weak = weak_pool.begin(); + + for (unsigned int i = 0; i < HAMMER_REPEAT; ++i) + { + try + { + sp_A_t strong(*cur_weak); + } + catch (std::bad_weak_ptr& exception) + { + ++cur_weak; + if (cur_weak == weak_pool.end()) + break; + } + } + return 0; +} + +int +test01() +{ + bool test __attribute__((unused)) = true; + sp_vector_t obj_pool(POOL_SIZE); + + for(sp_vector_t::iterator cur = obj_pool.begin(); cur != obj_pool.end(); ++cur) + { + cur->reset(new A); + } + // Obtain weak references. + std::vector<wp_vector_t> weak_pool(HAMMER_MAX_THREADS, wp_vector_t(obj_pool.begin(), obj_pool.end())); + + // Launch threads with pointer to weak reference. + pthread_t threads[HAMMER_MAX_THREADS]; +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (HAMMER_MAX_THREADS); +#endif + + pthread_attr_t tattr; + pthread_attr_init(&tattr); + + shared_and_weak_pools pools(obj_pool, weak_pool[0]); + pthread_create(threads, &tattr, thread_hammer_and_kill, static_cast<void*>(&pools)); + for (unsigned int worker = 1; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_create(&threads[worker], &tattr, + thread_hammer, static_cast<void*>(&weak_pool[worker]))) + std::abort(); + } + // Wait for threads to complete, then check integrity of reference. + void* status; + for (unsigned int worker = 0; worker < HAMMER_MAX_THREADS; worker++) + { + if (pthread_join(threads[worker], &status)) + std::abort(); + } + obj_pool.clear(); + + VERIFY( A::counter == 0 ); + + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/58982.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/58982.cc new file mode 100644 index 000000000..74ecb2aee --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/58982.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2013-2014 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/>. + +// 20.7.12 specialized algorithms + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include <memory> + +// libstdc++/58982 + +// trivial class that is not assignable +struct T +{ + T() = default; + ~T() = default; + + T& operator=(const T&) = delete; +}; + +void +test01(T* result) +{ + T t[1]; + std::uninitialized_copy(t, t+1, result); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc new file mode 100644 index 000000000..201dd7ea0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2012-2014 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 <vector> +#include <stdexcept> + +// 4.4.x only +struct c +{ + void *m; + + c(void* o = 0) : m(o) {} + c(const c &r) : m(r.m) {} + + template<class T> + explicit c(T &o) : m((void*)0xdeadbeef) { } +}; + +int main() +{ + std::vector<c> cbs; + const c cb((void*)0xcafebabe); + + for (int fd = 62; fd < 67; ++fd) + { + cbs.resize(fd + 1); + cbs[fd] = cb; + } + + for (int fd = 62; fd< 67; ++fd) + if (cb.m != cbs[fd].m) + throw std::runtime_error("wrong"); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc new file mode 100644 index 000000000..a2829f73d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/move_iterators/1.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <iterator> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::uninitialized_copy; + +typedef test_container<rvalstruct, input_iterator_wrapper> container_in; +typedef test_container<rvalstruct, forward_iterator_wrapper> container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + uninitialized_copy(std::move_iterator<input_iterator_wrapper<rvalstruct> >(incon.begin()), + std::move_iterator<input_iterator_wrapper<rvalstruct> >(incon.end()), + outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/58982.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/58982.cc new file mode 100644 index 000000000..23034f8b2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/58982.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2013-2014 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/>. + +// 20.7.12 specialized algorithms + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include <memory> + +// libstdc++/58982 + +// trivial class that is not assignable +struct T +{ + T() = default; + ~T() = default; + + T& operator=(const T&) = delete; +}; + +void +test01(T* result) +{ + T t[1]; + std::uninitialized_copy_n(t, 1, result); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc new file mode 100644 index 000000000..3e9b20897 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/move_iterators/1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2008-2014 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/>. + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <iterator> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::uninitialized_copy_n; + +typedef test_container<rvalstruct, input_iterator_wrapper> container_in; +typedef test_container<rvalstruct, forward_iterator_wrapper> container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + uninitialized_copy_n(std::move_iterator<input_iterator_wrapper<rvalstruct> >(incon.begin()), + size, outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc new file mode 100644 index 000000000..72911d890 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/32158.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2014 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/>. + +// 20.4.4 specialized algorithms + +// { dg-do compile } + +#include <memory> +#include <utility> + +// c++/32158 + +typedef std::pair<const int, int> MyPair; + +void +Alpha(MyPair* start, MyPair* end) +{ + MyPair my_pair(1, 2); + std::uninitialized_fill(start, end, my_pair); +}; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/58982.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/58982.cc new file mode 100644 index 000000000..f9b1b775c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/58982.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2013-2014 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/>. + +// 20.7.12 specialized algorithms + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include <memory> + +// libstdc++/58982 + +// trivial class that is not assignable +struct T +{ + T() = default; + ~T() = default; + + T& operator=(const T&) = delete; +}; + +void +test01(T* first, T* last) +{ + T t; + std::uninitialized_fill(first, last, t); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc new file mode 100644 index 000000000..cfe01ca45 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/16505.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004-2014 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/>. + +// 20.4.4 specialized algorithms + +// { dg-do compile } + +#include <memory> + +// libstdc++/16505 + +struct S { }; + +template + void + std::uninitialized_fill_n<S*, int, S>(S*, int, const S&); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/58982.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/58982.cc new file mode 100644 index 000000000..359f8b57a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill_n/58982.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2013-2014 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/>. + +// 20.7.12 specialized algorithms + +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +#include <memory> + +// libstdc++/58982 + +// trivial class that is not assignable +struct T +{ + T() = default; + ~T() = default; + + T& operator=(const T&) = delete; +}; + +void +test01(T* first) +{ + T t; + std::uninitialized_fill_n(first, 1, t); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/steady_clock/constexpr_data.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/steady_clock/constexpr_data.cc new file mode 100644 index 000000000..f729f2742 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/steady_clock/constexpr_data.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::is_steady; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + test.operator()<std::chrono::steady_clock>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/system_clock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/system_clock/1.cc new file mode 100644 index 000000000..b725efe08 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/system_clock/1.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } +// { dg-require-time "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.5 Clocks [time.clock] + +#include <chrono> + +// 20.8.5.1 system_clock [time.clock.system] +int +main() +{ + using namespace std::chrono; + + system_clock::time_point t1 = system_clock::now(); + bool is_steady = system_clock::is_steady; + is_steady = is_steady; // suppress unused warning + std::time_t t2 = system_clock::to_time_t(t1); + system_clock::time_point t3 = system_clock::from_time_t(t2); + t3 = t3; // suppress unused warning + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc new file mode 100644 index 000000000..049f90dea --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/system_clock/constexpr_data.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_data + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::is_steady; + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + __gnu_test::constexpr_member_data test; + test.operator()<std::chrono::system_clock>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/temporary_buffer.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/temporary_buffer.cc new file mode 100644 index 000000000..fd96b8bd9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/temporary_buffer.cc @@ -0,0 +1,50 @@ +// 2002-01-24 Phil Edwards <pme@gcc.gnu.org> + +// Copyright (C) 2002-2014 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/>. + +// 20.4.3 temporary buffers + +#include <memory> +#include <testsuite_hooks.h> + +struct junk { char j[12]; }; + +int main(void) +{ + bool test __attribute__((unused)) = true; + + typedef std::pair<junk*, std::ptrdiff_t> pair_type; + pair_type results = std::get_temporary_buffer<junk>(5); + + if (results.second != 0) + { + // make sure it works: test the returned capacity, and then construct + // some junk in the buffer. + // XXX + VERIFY( results.first != 0 ); + } + else + { + // if it says it didn't work, make sure it didn't work + VERIFY( results.first == 0 ); + } + + std::return_temporary_buffer(results.first); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/1.cc new file mode 100644 index 000000000..e9d5a58d0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.4 Class template time_point [time.point] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.4.1 time_point constructors [time.point.cons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1; + VERIFY(t1.time_since_epoch() == system_clock::duration::zero()); + + time_point<steady_clock> t2; + VERIFY(t2.time_since_epoch() == steady_clock::duration::zero()); + + time_point<high_resolution_clock> t3; + VERIFY(t3.time_since_epoch() == high_resolution_clock::duration::zero()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/2.cc new file mode 100644 index 000000000..e7bcabd80 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/2.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.4 Class template time_point [time.point] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.4.3 time_point arithmetic [time.point.arithmetic] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1, t2; + t1 += seconds(1); + VERIFY(t2.time_since_epoch() + seconds(1) == t1.time_since_epoch()); + + t1 -= std::chrono::seconds(1); + VERIFY(t2.time_since_epoch() == t1.time_since_epoch()); +} + +// 20.8.4.5 time_point non-member arithmetic [time.point.nonmember] +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1; + time_point<system_clock> t2(t1 + seconds(1)); + VERIFY(t2.time_since_epoch() == t1.time_since_epoch() + seconds(1)); + + time_point<system_clock> t3(seconds(1) + t1); + VERIFY(t3.time_since_epoch() == t1.time_since_epoch() + seconds(1)); + + time_point<system_clock> t4(seconds(1)); + time_point<system_clock> t5(seconds(2)); + + time_point<system_clock> t6(t5 - seconds(1)); + VERIFY(t6.time_since_epoch() == t4.time_since_epoch()); + + time_point<system_clock> t7(t5 - t4); + VERIFY(t7.time_since_epoch() == t4.time_since_epoch()); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/3.cc new file mode 100644 index 000000000..a8a28ea21 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/3.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.4 Class template time_point [time.point] + +#include <chrono> +#include <testsuite_hooks.h> + +// 20.8.4.6 time_point comparisons [time.point.comparisons] +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + time_point<system_clock> t1(seconds(1)); + time_point<system_clock> t2(seconds(1)); + time_point<system_clock> t3(seconds(2)); + + VERIFY(t1 == t2); + VERIFY(t1 != t3); + VERIFY(t1 < t3); + VERIFY(t1 <= t3); + VERIFY(t1 <= t2); + VERIFY(t3 > t1); + VERIFY(t3 >= t1); + VERIFY(t2 >= t1); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc new file mode 100644 index 000000000..2b6cc0d55 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/comparison_operators/constexpr.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +int main() +{ + using namespace std::chrono; + __gnu_test::constexpr_comparison_operators test; + test.operator()<time_point<system_clock>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/cons/constexpr.cc new file mode 100644 index 000000000..474abe463 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/cons/constexpr.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +int main() +{ + using namespace std::chrono; + + __gnu_test::constexpr_default_constructible test1; + test1.operator()<time_point<system_clock>>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<time_point<system_clock>, seconds>(); + test2.operator()<time_point<system_clock, seconds>, + time_point<system_clock, minutes>>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/nonmember/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/nonmember/constexpr.cc new file mode 100644 index 000000000..1e2202e77 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/nonmember/constexpr.cc @@ -0,0 +1,45 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <chrono> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + using namespace std::chrono; + + typedef time_point<system_clock> time_type; + + constexpr time_type t1(seconds(1)); + constexpr time_type t2(seconds(30)); + constexpr time_type t3(seconds(60)); + + constexpr duration<int> d0(12); + constexpr duration<int> d1(3); + + constexpr auto r1 __attribute__((unused)) = t1 + d0; + constexpr auto r2 __attribute__((unused)) = d1 + t2; + + constexpr auto r3 __attribute__((unused)) = t1 - d0; + constexpr auto r4 __attribute__((unused)) = t2 - t3; + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/requirements/constexpr_functions.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/requirements/constexpr_functions.cc new file mode 100644 index 000000000..b252db652 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/requirements/constexpr_functions.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +namespace __gnu_test +{ + struct constexpr_member_functions + { + template<typename _Ttesttype> + void + operator()() + { + struct _Concept + { + void __constraint() + { + constexpr auto v1 __attribute__((unused)) + = _Ttesttype::min(); + constexpr auto v2 __attribute__((unused)) + = _Ttesttype::max(); + + constexpr _Ttesttype obj; + constexpr auto v3 __attribute__((unused)) + = obj.time_since_epoch(); + } + }; + + _Concept c; + c.__constraint(); + } + }; +} + +int main() +{ + using namespace std::chrono; + __gnu_test::constexpr_member_functions test; + test.operator()<time_point<system_clock>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..0ceffdfab --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// Copyright (C) 2008-2014 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 <chrono> + +template class std::chrono::time_point<std::chrono::system_clock>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point_cast/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point_cast/constexpr.cc new file mode 100644 index 000000000..816aeb862 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/time_point_cast/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <chrono> +#include <testsuite_common_types.h> + +int main() +{ + using namespace std::chrono; + typedef time_point<system_clock, hours> to_type; + typedef time_point<system_clock, minutes> from_type; + + // constexpr + constexpr minutes m(6000); + constexpr hours h(19); + constexpr to_type tpm(h); // time_point object with minutes + constexpr from_type tph(m); // time_point object with hours + + constexpr auto res(time_point_cast<hours>(tpm)); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/48476.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/48476.cc new file mode 100644 index 000000000..f54f67800 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/48476.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <tuple> +#include <type_traits> +#include <memory> +#include <testsuite_hooks.h> + +template<typename T> + typename std::decay<T>::type copy(T&& x) + { return std::forward<T>(x); } + +// libstdc++/48476 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<int> p(new int()), q, r; + + std::tuple<std::shared_ptr<int>&, int> t0(p, 23), t1(q, 0); + t1 = copy(t0); // shall be equivalent to + // q = p; std::get<1>(t1) = std::get<1>(t0); + VERIFY( q == p ); + + std::tuple<std::shared_ptr<int>&, char> t2(r, 0); + t2 = copy(t1); // shall be equivalent to + // r = q; std::get<1>(t2) = std::get<1>(t1); + VERIFY( r == q ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/51365.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/51365.cc new file mode 100644 index 000000000..206de0267 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/51365.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <tuple> + +// libstdc++/51365 + +struct F final { }; +std::tuple<F> t; + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/53648.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/53648.cc new file mode 100644 index 000000000..7bde67e7e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/53648.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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/>. + +// libstdc++/53648 + +#include <tuple> +#include <type_traits> + +using std::tuple; + +struct A { }; + +template class tuple<tuple<>>; +template class tuple<tuple<tuple<>>>; +template class tuple<A, tuple<A, tuple<A, tuple<A>>>>; +template class tuple<tuple<tuple<A, A>, A>, A>; + +// Verify the following QoI properties are preserved + +static_assert( std::is_empty<tuple<>>::value, "tuple<> is empty" ); + +static_assert( std::is_empty<tuple<tuple<>>>::value, + "tuple<tuple<>> is empty" ); + +static_assert( sizeof(tuple<char, tuple<>>) == sizeof(char), + "tuple<> is eligible for EBO" ); + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc new file mode 100644 index 000000000..a3eddd37a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/35480_neg.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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> + +// libstdc++/35480 +void test01() +{ + std::tuple<int> t1( 1 ); + std::tuple<int, int> t2( 1, 2 ); + if ( t1 < t2 ) {} // { dg-error "here" } + if ( t1 == t2 ) {} // { dg-error "here" } +} +// { dg-prune-output "incomplete type" } +// { dg-excess-errors "body of constexpr function" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc new file mode 100644 index 000000000..2bd7eb5b0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/comparisons.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <testsuite_hooks.h> + +using namespace std; + +bool test __attribute__((unused)) = true; + +#define TEST1(x) VERIFY( x == x && !(x != x) && x <= x && !(x < x) ) + +int +main() +{ + int i=0; + int j=0; + int k=2; + tuple<int, int, int> a(0, 0, 0); + tuple<int, int, int> b(0, 0, 1); + tuple<int& , int& , int&> c(i,j,k); + tuple<const int&, const int&, const int&> d(c); + TEST1(a); + TEST1(b); + TEST1(c); + TEST1(d); + VERIFY(!(a > a) && !(b > b)); + VERIFY(a >= a && b >= b); + VERIFY(a < b && !(b < a) && a <= b && !(b <= a)); + VERIFY(b > a && !(a > b) && b >= a && !(a >= b)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/constexpr.cc new file mode 100644 index 000000000..9b7467ec3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/constexpr.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012-2014 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 <tuple> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_comparison_operators test; + test.operator()<std::tuple<int, int>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc new file mode 100644 index 000000000..625a273c3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009-2014 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/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc new file mode 100644 index 000000000..d269f606a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/44487.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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 <tuple> + +int x, y; + +std::tuple<int&, int&> +foo1() +{ + std::pair<int&, int&> blah(x, y); + return blah; +} + +std::tuple<int&, int&> +foo2() +{ + const std::pair<int&, int&> blah(x, y); + return blah; +} + +std::tuple<int&, int&> +foo3() +{ + std::pair<int&, int&> blah(x, y); + return std::tuple<int&, int&>(std::move(blah)); +} + +std::tuple<int&, int&> +foo4() +{ + const std::pair<int&, int&> blah(x, y); + return std::tuple<int&, int&>(std::move(blah)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc new file mode 100644 index 000000000..87e59098d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/45228.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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 <tuple> + +typedef std::tuple<int> Tuple_1; +typedef std::tuple<int, int> Tuple_2; +typedef std::tuple<int, int, int> Tuple_3; + + Tuple_1 A_1() { return Tuple_1(); } +const Tuple_1 B_1() { return Tuple_1(); } + + Tuple_2 A_2() { return Tuple_2(); } +const Tuple_2 B_2() { return Tuple_2(); } + + Tuple_3 A_3() { return Tuple_3(); } +const Tuple_3 B_3() { return Tuple_3(); } + +Tuple_1 test_A_1(A_1()); +Tuple_1 test_B_1(B_1()); + +Tuple_2 test_A_2(A_2()); +Tuple_2 test_B_2(B_2()); + +Tuple_3 test_A_3(A_3()); +Tuple_3 test_B_3(B_3()); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc new file mode 100644 index 000000000..bdec0c04e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/48476.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <tuple> + +void f() +{ + int i = 0; + std::tuple<int&, int> t __attribute__((unused)) = std::forward_as_tuple(i, 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc new file mode 100644 index 000000000..9b1c6a7f3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc @@ -0,0 +1,169 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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/>. + +// 20.4.2.1 [tuple.cnstr] Allocator-extended constructors + +#include <memory> +#include <tuple> +#include <testsuite_hooks.h> + +struct MyAlloc { }; + +// type that can't be constructed with an allocator +struct CannotUse +{ + CannotUse(int = 0, int = 0) : ok(true) { } + + bool ok; +}; + +// type that can be constructed with an allocator +// but which has uses_allocator == false +struct DoesNotUse +{ + typedef MyAlloc allocator_type; + + DoesNotUse(int = 0) : ok(true) { } + DoesNotUse(std::allocator_arg_t, MyAlloc, int = 0) : ok(false) { } + DoesNotUse(MyAlloc) : ok(false) { } + DoesNotUse(int, MyAlloc) : ok(false) { } + + DoesNotUse(const DoesNotUse&) : ok(true) { } + DoesNotUse(std::allocator_arg_t, MyAlloc, const DoesNotUse&) : ok(false) { } + DoesNotUse(const DoesNotUse&, MyAlloc) : ok(false) { } + + DoesNotUse(DoesNotUse&&) : ok(true) { } + DoesNotUse(std::allocator_arg_t, MyAlloc, DoesNotUse&&) : ok(false) { } + DoesNotUse(DoesNotUse&&, MyAlloc) : ok(false) { } + + bool ok; +}; + +namespace std +{ + template<typename A> + struct uses_allocator<DoesNotUse, A> : false_type { }; +} + +// type that can be constructed with an allocator as second argument +struct UsesWithTag +{ + typedef MyAlloc allocator_type; + + UsesWithTag(int = 0) : ok(false) { } + UsesWithTag(std::allocator_arg_t, MyAlloc, int = 0) : ok(true) { } + UsesWithTag(MyAlloc) : ok(false) { } + UsesWithTag(int, MyAlloc) : ok(false) { } + + UsesWithTag(const UsesWithTag&) : ok(false) { } + UsesWithTag(std::allocator_arg_t, MyAlloc, const UsesWithTag&) : ok(true) { } + UsesWithTag(const UsesWithTag&, MyAlloc) : ok(false) { } + + UsesWithTag(UsesWithTag&&) : ok(false) { } + UsesWithTag(std::allocator_arg_t, MyAlloc, UsesWithTag&&) : ok(true) { } + UsesWithTag(UsesWithTag&&, MyAlloc) : ok(false) { } + + bool ok; +}; + +// type that can be constructed with an allocator as last argument +struct UsesWithoutTag +{ + typedef MyAlloc allocator_type; + + UsesWithoutTag(int = 0) : ok(false) { } + UsesWithoutTag(MyAlloc) : ok(true) { } + UsesWithoutTag(int, MyAlloc) : ok(true) { } + + UsesWithoutTag(const UsesWithoutTag&) : ok(false) { } + UsesWithoutTag(const UsesWithoutTag&, MyAlloc) : ok(true) { } + + UsesWithoutTag(UsesWithoutTag&&) : ok(false) { } + UsesWithoutTag(UsesWithoutTag&&, MyAlloc) : ok(true) { } + + bool ok; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::allocator_arg; + using std::tuple; + using std::make_tuple; + using std::get; + + typedef CannotUse T1; + typedef DoesNotUse T2; + typedef UsesWithTag T3; + typedef UsesWithoutTag T4; + typedef tuple<T1, T2, T3, T4> test_type; + + MyAlloc a; + + // default construction + test_type t1(allocator_arg, a); + VERIFY( get<0>(t1).ok ); + VERIFY( get<1>(t1).ok ); + VERIFY( get<2>(t1).ok ); + VERIFY( get<3>(t1).ok ); + + // copy construction + test_type t2(allocator_arg, a, t1); + VERIFY( get<0>(t2).ok ); + VERIFY( get<1>(t2).ok ); + VERIFY( get<2>(t2).ok ); + VERIFY( get<3>(t2).ok ); + + // move construction + test_type t3(allocator_arg, a, std::move(t1)); + VERIFY( get<0>(t3).ok ); + VERIFY( get<1>(t3).ok ); + VERIFY( get<2>(t3).ok ); + VERIFY( get<3>(t3).ok ); + + // construction from int + test_type t4(allocator_arg, a, 1, 2, 3, 4); + VERIFY( get<0>(t4).ok ); + VERIFY( get<1>(t4).ok ); + VERIFY( get<2>(t4).ok ); + VERIFY( get<3>(t4).ok ); + + auto ints = make_tuple(1, 2, 3, 4); + + // construction from lvalue tuple of ints + test_type t5(allocator_arg, a, ints); + VERIFY( get<0>(t5).ok ); + VERIFY( get<1>(t5).ok ); + VERIFY( get<2>(t5).ok ); + VERIFY( get<3>(t2).ok ); + + // construction from rvalue tuple of ints + test_type t6(allocator_arg, a, std::move(ints)); + VERIFY( get<0>(t6).ok ); + VERIFY( get<1>(t6).ok ); + VERIFY( get<2>(t6).ok ); + VERIFY( get<3>(t6).ok ); + +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc new file mode 100644 index 000000000..62c27075d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/assignment.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + tuple<> ta; + tuple<> tb; + ta = tb; + + tuple<int> tc(1); + tuple<int> td(0); + td = tc; + VERIFY(get<0>(td) == 1); + + int i=0; + tuple<int&> te(i); + te = tc; + VERIFY(i == 1); + + tuple<const int&> tf(tc); + + get<0>(tc) = 2; + VERIFY(get<0>(tf) == 2); + tuple<double> tg; + tg = tc; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc new file mode 100644 index 000000000..40db4a43c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/big_tuples.cc @@ -0,0 +1,105 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <utility> // for pair +#include <testsuite_hooks.h> + +using namespace std; + +// A simple class without conversions to check some things +struct foo +{ }; + +void +test_constructors() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple<int,int> tb; + // Test construction from values + tuple<int,int> tc(x1,x2); + tuple<int,int&> td(x1,x2); + tuple<const int&> te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple<int,int> tf(tc); + tuple<int,int> tg(td); + tuple<const int&> th(te); + // Test different tuple copy constructor + tuple<int,double> ti(tc); + tuple<int,double> tj(td); + // Test constructing from a pair + pair<int,int> pair1(1,1); + const pair<int,int> pair2(pair1); + tuple<int,int> tl(pair1); + tuple<int,const int&> tm(pair1); + tuple<int,int> tn(pair2); + tuple<int,const int&> to(pair2); +} + +int +main(void) +{ + //test construction + typedef tuple<int,int,int,int,int,int,int,int,int,int> type1; + type1 a(0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + type1 b(0, 0, 0, 0, 0, 0, 0, 0, 0, 2); + type1 c(a); + typedef tuple<int,int,int,int,int,int,int,int,int,char> type2; + type2 d(0, 0, 0, 0, 0, 0, 0, 0, 0, 3); + type1 e(d); + typedef tuple<foo,int,int,int,int,int,int,int,int,foo> type3; + // get + VERIFY(get<9>(a)==1 && get<9>(b)==2); + // comparisons + VERIFY(a==a && !(a!=a) && a<=a && a>=a && !(a<a) && !(a>a)); + VERIFY(!(a==b) && a!=b && a<=b && a<b && !(a>=b) && !(a>b)); + //tie + { + int i = 0; + tie(ignore, ignore, ignore, ignore, ignore, ignore, ignore, ignore, + ignore, i) = a; + VERIFY(i == 1); + } + //test_assignment + a=d; + a=b; + //make_tuple + make_tuple(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + //tuple_size + VERIFY(tuple_size<type3>::value == 10); + //tuple_element + { + foo q1; + tuple_element<0,type3>::type q2(q1); + tuple_element<9,type3>::type q3(q1); + } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-2.cc new file mode 100644 index 000000000..8f2e68351 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-2.cc @@ -0,0 +1,63 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_common_types.h> + +#include <iostream> + +// 2 element tuple +int main() +{ + typedef std::tuple<int, int> tuple_type; + + // 01: default ctor + __gnu_test::constexpr_default_constructible test1; + test1.operator()<tuple_type>(); + + // 02: default copy ctor + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<tuple_type, tuple_type>(); + + // 03: element move ctor, single element + const int i1(415); + constexpr tuple_type t2 { 44, std::move(i1) }; + + // 04: element move ctor, two element + const int i2(510); + const int i3(408); + constexpr tuple_type t4 { std::move(i2), std::move(i3) }; + + // 05: value-type conversion constructor + const int i4(650); + const int i5(310); + constexpr tuple_type t8(i4, i5); + + // 06: pair conversion ctor + test2.operator()<tuple_type, std::pair<int, int>>(); + test2.operator()<std::tuple<short, short>, std::pair<int, int>>(); + test2.operator()<tuple_type, std::pair<short, short>>(); + + // 07: different-tuple-type conversion constructor + test2.operator()<tuple_type, std::tuple<short, short>>(); + test2.operator()<std::tuple<short, short>, tuple_type>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-3.cc new file mode 100644 index 000000000..5af48128d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr-3.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <testsuite_common_types.h> + +#include <iostream> + +// 3 element tuple +int main() +{ + typedef std::tuple<int, int, int> tuple_type; + + // 01: default ctor + __gnu_test::constexpr_default_constructible test1; + test1.operator()<tuple_type>(); + + // 02: default copy ctor + __gnu_test::constexpr_single_value_constructible test2; + test2.operator()<tuple_type, tuple_type>(); + + // 03: element move ctor, single element + const int i1(415); + constexpr tuple_type t2 { 44, 55, std::move(i1) }; + + // 04: element move ctor, three element + const int i2(510); + const int i3(408); + const int i4(650); + constexpr tuple_type t4 { std::move(i2), std::move(i3), std::move(i4) }; + + // 05: value-type conversion constructor + const int i5(310); + const int i6(310); + const int i7(310); + constexpr tuple_type t8(i5, i6, i7); + + // 06: different-tuple-type conversion constructor + test2.operator()<tuple_type, std::tuple<short, short, short>>(); + test2.operator()<std::tuple<short, short, short>, tuple_type>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc new file mode 100644 index 000000000..8542423d2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/constructor.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <utility> // for pair +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1=0,x2=0; + const int &z1=x1; + + // Test empty constructor + tuple<> ta __attribute__((unused)); + tuple<int,int> tb; + // Test construction from values + tuple<int,int> tc(x1,x2); + tuple<int,int&> td(x1,x2); + tuple<const int&> te(z1); + x1=1; + x2=1; + VERIFY(get<0>(td) == 0 && get<1>(td) == 1 && get<0>(te) == 1); + + // Test identical tuple copy constructor + tuple<int,int> tf(tc); + tuple<int,int> tg(td); + tuple<const int&> th(te); + // Test different tuple copy constructor + tuple<int,double> ti(tc); + tuple<int,double> tj(td); + //tuple<int&, int&> tk(tc); + tuple<const int&, const int&> tl(tc); + tuple<const int&, const int&> tm(tl); + // Test constructing from a pair + pair<int,int> pair1(1,1); + const pair<int,int> pair2(pair1); + tuple<int,int> tn(pair1); + tuple<int,const int&> to(pair1); + tuple<int,int> tp(pair2); + tuple<int,const int&> tq(pair2); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc new file mode 100644 index 000000000..e298a8167 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/converting.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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 <tuple> + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00047.html +std::tuple<int> ts1; +std::tuple<unsigned> tu1(ts1); + +std::tuple<int, int> ts2; +std::tuple<unsigned, unsigned> tu2(ts2); + +std::tuple<int, int, int> ts3; +std::tuple<unsigned, unsigned, unsigned> tu3(ts3); + +std::tuple<int, unsigned> tm2; +std::tuple<unsigned, int> tm2_(tm2); + +std::tuple<int, unsigned, int> tm3; +std::tuple<unsigned, int, unsigned> tm3_(tm3); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..ad92ea7cd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_move_construct.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-20 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 <tuple> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +typedef std::tuple<int> tt1; +typedef std::tuple<int, double> tt2; +typedef std::tuple<short, double, int> tt3; +typedef std::tuple<short, NoexceptMoveConsClass, double> tt4; +typedef std::tuple<NoexceptMoveConsClass, + NoexceptMoveConsClass, double> tt5; +typedef std::tuple<NoexceptMoveConsClass, + NoexceptMoveConsClass, + NoexceptMoveConsClass> tt6; +typedef std::tuple<ExceptMoveConsClass> tt7; +typedef std::tuple<ExceptMoveConsClass, double> tt8; +typedef std::tuple<short, double, ExceptMoveConsClass> tt9; +typedef std::tuple<ExceptMoveConsClass, double, + ExceptMoveConsClass> tt10; +typedef std::tuple<NoexceptMoveConsClass, + ExceptMoveConsClass> tt11; +typedef std::tuple<int, + NoexceptMoveConsClass, + ExceptMoveConsClass> tt12; + +static_assert(std::is_nothrow_move_constructible<tt1>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt2>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt3>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt4>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt5>::value, "Error"); +static_assert(std::is_nothrow_move_constructible<tt6>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt7>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt8>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt9>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt10>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt11>::value, "Error"); +static_assert(!std::is_nothrow_move_constructible<tt12>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc new file mode 100644 index 000000000..1c34d857b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/23978.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } +// +// Copyright (C) 2007-2014 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> +#include <utility> +#include <testsuite_hooks.h> + +using namespace std; + +// libstdc++/23978 +void test01() +{ + bool test __attribute__((unused)) = true; + + pair<int, int> p(1, 2); + int x = 0; + int y = 0; + tie(x, y) = p; + VERIFY( x == 1 && y == 2 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc new file mode 100644 index 000000000..72a80d161 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/48476.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <tuple> +#include <type_traits> +#include <testsuite_hooks.h> + +template<typename T> + typename std::decay<T>::type copy(T&& x) + { return std::forward<T>(x); } + +template<typename... Args1, typename... Args2> + void + check_tuple_cat(std::tuple<Args1...> t1, std::tuple<Args2...> t2) + { + bool test __attribute__((unused)) = true; + + typedef std::tuple<Args1..., Args2...> concatenated; + + auto cat1 = std::tuple_cat( t1, t2 ); + auto cat2 = std::tuple_cat(copy(t1), t2 ); + auto cat3 = std::tuple_cat( t1, copy(t2)); + auto cat4 = std::tuple_cat(copy(t1), copy(t2)); + + static_assert( std::is_same<decltype(cat1), concatenated>::value, "" ); + static_assert( std::is_same<decltype(cat2), concatenated>::value, "" ); + static_assert( std::is_same<decltype(cat3), concatenated>::value, "" ); + static_assert( std::is_same<decltype(cat4), concatenated>::value, "" ); + + VERIFY( cat1 == cat2 ); + VERIFY( cat1 == cat3 ); + VERIFY( cat1 == cat4 ); + } + +// libstdc++/48476 +void test01() +{ + int i = 0; + std::tuple<> t0; + std::tuple<int&> t1(i); + std::tuple<int&, int> t2(i, 0); + std::tuple<int const&, int, double> t3(i, 0, 0); + + check_tuple_cat(t0, t0); + check_tuple_cat(t0, t1); + check_tuple_cat(t0, t2); + check_tuple_cat(t0, t3); + + check_tuple_cat(t1, t0); + check_tuple_cat(t1, t1); + check_tuple_cat(t1, t2); + check_tuple_cat(t1, t3); + + check_tuple_cat(t2, t0); + check_tuple_cat(t2, t1); + check_tuple_cat(t2, t2); + check_tuple_cat(t2, t3); + + check_tuple_cat(t3, t0); + check_tuple_cat(t3, t1); + check_tuple_cat(t3, t2); + check_tuple_cat(t3, t3); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc new file mode 100644 index 000000000..47f3e3f6f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc @@ -0,0 +1,131 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on pair, and also vector. If the implementation +// changes this test may begin to fail. + +#include <tuple> + +bool test __attribute__((unused)) = true; + + +// make_tuple +void +test_make_tuple() +{ + { + typedef std::tuple<int, float> tuple_type; + constexpr tuple_type p1 __attribute__((unused)) + = std::make_tuple(22, 22.222); + } + + { + typedef std::tuple<int, float, int> tuple_type; + constexpr tuple_type p1 __attribute__((unused)) + = std::make_tuple(22, 22.222, 77799); + } +} + +#if 0 +// forward_as_tuple +void +test_forward_as_tuple() +{ + { + typedef std::tuple<int, float> tuple_type; + constexpr tuple_type p1 __attribute__((unused)) + = std::forward_as_tuple(22, 22.222); + } + + { + typedef std::tuple<int, float, int> tuple_type; + constexpr tuple_type p1 __attribute__((unused)) + = std::forward_as_tuple(22, 22.222, 77799); + } +} +#endif + +#if 0 +// tie +void +test_tie() +{ + { + int i(22); + float f(22.222); + typedef std::tuple<int, float> tuple_type; + constexpr tuple_type p1 __attribute__((unused)) + = std::tie(i, f); + } + + { + int i(22); + float f(22.222); + int ii(77799); + + typedef std::tuple<int, float, int> tuple_type; + constexpr tuple_type p1 __attribute__((unused)) + = std::tie(i, f, ii); + } +} +#endif + +// get +void +test_get() +{ + { + typedef std::tuple<int, float> tuple_type; + constexpr tuple_type t1 { 55, 77.77 }; + constexpr auto var __attribute__((unused)) + = std::get<1>(t1); + } + + { + typedef std::tuple<int, float, int> tuple_type; + constexpr tuple_type t1 { 55, 77.77, 99 }; + constexpr auto var __attribute__((unused)) + = std::get<2>(t1); + } +} + +// tuple_cat +void +test_tuple_cat() +{ + typedef std::tuple<int, float> tuple_type1; + typedef std::tuple<int, int, float> tuple_type2; + + constexpr tuple_type1 t1 { 55, 77.77 }; + constexpr tuple_type2 t2 { 55, 99, 77.77 }; + constexpr auto cat1 __attribute__((unused)) = std::tuple_cat(t1, t2); +} + +int +main() +{ + test_make_tuple(); + test_get(); + test_tuple_cat(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc new file mode 100644 index 000000000..c096f95c0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-04-30 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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> +#include <type_traits> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::forward_as_tuple(); + + VERIFY( std::get<0>(std::forward_as_tuple(-1)) == -1 ); + VERIFY( (std::is_same<decltype(std::forward_as_tuple(-1)), + std::tuple<int&&>>::value) ); + + const int i1 = 1; + const int i2 = 2; + const double d1 = 4.0; + auto t1 = std::forward_as_tuple(i1, i2, d1); + VERIFY( (std::is_same<decltype(t1), std::tuple<const int&, + const int&, const double&>>::value) ); + VERIFY( std::get<0>(t1) == i1 ); + VERIFY( std::get<1>(t1) == i2 ); + VERIFY( std::get<2>(t1) == d1 ); + + typedef const int a_type1[3]; + a_type1 a1 = { -1, 1, 2 }; + auto t2 = std::forward_as_tuple(a1); + VERIFY( (std::is_same<decltype(t2), std::tuple<a_type1&>>::value) ); + VERIFY( std::get<0>(t2)[0] == a1[0] ); + VERIFY( std::get<0>(t2)[1] == a1[1] ); + VERIFY( std::get<0>(t2)[2] == a1[2] ); + + typedef int a_type2[2]; + a_type2 a2 = { 2, -2 }; + volatile int i4 = 1; + auto t3 = std::forward_as_tuple(a2, i4); + VERIFY( (std::is_same<decltype(t3), std::tuple<a_type2&, + volatile int&>>::value) ); + VERIFY( std::get<0>(t3)[0] == a2[0] ); + VERIFY( std::get<0>(t3)[1] == a2[1] ); + VERIFY( std::get<1>(t3) == i4 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc new file mode 100644 index 000000000..17d748e8c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/make_tuple.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <functional> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int i=0; + make_tuple(1,2,4.0); + make_tuple(ref(i)) = tuple<int>(1); + VERIFY(i == 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc new file mode 100644 index 000000000..7263d875d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int x1 = 0; + int x2 = 0; + int y1 = 0; + int y2 = 0; + tuple<int,int> ta(1,1); + tuple<const int&,const int&> tc(x1,x2); + tie(y1,y2)=ta; + VERIFY(y1 == 1 && y2 == 1); + tie(y1,y2)=tc; + VERIFY(y1 == 0 && y2 == 0); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc new file mode 100644 index 000000000..cc1af3a61 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tie2.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <string> +#include <testsuite_hooks.h> + +int +main() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + int i; + string s; + + tie(i, ignore, s) = make_tuple(42, 3.14, "C++"); + VERIFY( i == 42 ); + VERIFY( s == "C++" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tuple_cat.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tuple_cat.cc new file mode 100644 index 000000000..1217fe575 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/creation_functions/tuple_cat.cc @@ -0,0 +1,131 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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> +#include <array> + +static_assert(std::is_same<decltype(std::tuple_cat()), + std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype(std::tuple_cat + (std::declval<std::tuple<>>())), + std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype(std::tuple_cat + (std::declval<std::tuple<>&>())), + std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype(std::tuple_cat + (std::declval<const std::tuple<>>())), + std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype(std::tuple_cat + (std::declval<const std::tuple<>&>())), + std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype(std::tuple_cat + (std::declval<std::pair<int, bool>>())), + std::tuple<int, bool>>::value, "Error"); +static_assert(std::is_same<decltype(std::tuple_cat + (std::declval<std::pair<int, bool>&>())), + std::tuple<int, bool>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat(std::declval<const std::pair<int, bool>>())), + std::tuple<int, bool>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat(std::declval<const std::pair<int, bool>&>())), + std::tuple<int, bool>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat(std::declval<std::array<int, 3>>())), + std::tuple<int, int, int>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat(std::declval<std::array<int, 3>&>())), + std::tuple<int, int, int>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat(std::declval<const std::array<int, 3>>())), + std::tuple<int, int, int>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat(std::declval<const std::array<int, 3>&>())), + std::tuple<int, int, int>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat + (std::declval<std::tuple<>>(), std::declval<std::tuple<>>())), + std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat + (std::declval<std::tuple<>>(), std::declval<std::tuple<>>(), + std::declval<std::tuple<>>())), std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat + (std::declval<std::tuple<>>(), + std::declval<std::array<char, 0>>(), + std::declval<std::array<int, 0>>(), + std::declval<std::tuple<>>())), std::tuple<>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat + (std::declval<std::tuple<int>>(), + std::declval<std::tuple<double>>())), + std::tuple<int, double>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat + (std::declval<std::tuple<int>>(), + std::declval<std::tuple<double>>(), + std::declval<std::tuple<const long&>>())), + std::tuple<int, double, const long&>>::value, "Error"); +static_assert(std::is_same<decltype + (std::tuple_cat + (std::declval<std::array<wchar_t, 3>&>(), + std::declval<std::tuple<double>>(), + std::declval<std::tuple<>>(), + std::declval<std::tuple<unsigned&>>(), + std::declval<std::pair<bool, std::nullptr_t>>())), + std::tuple<wchar_t, wchar_t, wchar_t, + double, unsigned&, bool, std::nullptr_t> + >::value, "Error"); + +int main() +{ + std::tuple_cat(); + std::tuple_cat(std::tuple<>{ }); + std::tuple_cat(std::tuple<>{ }, std::tuple<>{ }); + std::array<int, 3> a3; + std::tuple_cat(a3); + std::pair<double, bool> pdb; + std::tuple<unsigned, float, std::nullptr_t, void*> t; + int i{ }; + double d{ }; + int* pi{ }; + std::tuple<int&, double&, int*&> to{i, d, pi}; + std::tuple_cat(pdb); + std::tuple_cat(to); + std::tuple_cat(to, to); + std::tuple_cat(a3, pdb); + std::tuple_cat(a3, pdb, t); + std::tuple_cat(a3, pdb, t, a3); + std::tuple_cat(a3, pdb, t, a3, pdb, t); + + static_assert(std::is_same<decltype + (std::tuple_cat(a3, pdb, t, a3, pdb, t)), + std::tuple<int, int, int, double, bool, + unsigned, float, std::nullptr_t, void*, + int, int, int, double, bool, unsigned, + float, std::nullptr_t, void*> + >::value, "Error"); + + std::tuple_cat(std::tuple<int, char, void*>{}, to, a3, + std::tuple<>{}, std::pair<float, + std::nullptr_t>{}, pdb, to); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_element.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_element.cc new file mode 100644 index 000000000..eb518556f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_element.cc @@ -0,0 +1,34 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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> + +using namespace std; + +static_assert(is_same<tuple_element<0, const tuple<double, void, int>>::type, + const double>::value, "Error"); +static_assert(is_same<tuple_element<1, volatile tuple<short, void>>::type, + volatile void>::value, "Error"); +static_assert(is_same<tuple_element<2, const volatile tuple<float, + char, int>>::type, const volatile int>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_size.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_size.cc new file mode 100644 index 000000000..993a2623b --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/cv_tuple_size.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + VERIFY( tuple_size<const tuple<> >::value == 0 ); + VERIFY( tuple_size<volatile tuple<int> >::value == 1 ); + VERIFY( tuple_size<const volatile tuple<void> >::value == 1 ); + + typedef tuple<int, const int&, void> test_tuple1; + VERIFY( tuple_size<const test_tuple1>::value == 3 ); + VERIFY( tuple_size<const volatile test_tuple1>::value == 3 ); + VERIFY( tuple_size<volatile tuple<tuple<void> > >::value == 1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/constexpr_get.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/constexpr_get.cc new file mode 100644 index 000000000..70e5ade48 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/constexpr_get.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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> + +std::tuple<int> ti; +const std::tuple<int> cti; + +constexpr const int& cri = std::get<0>(cti); +constexpr int& ri = std::get<0>(ti); +constexpr int&& rri = std::get<0>(std::move(ti)); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/constexpr_get_by_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/constexpr_get_by_type.cc new file mode 100644 index 000000000..436517f5d --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/constexpr_get_by_type.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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> + +std::tuple<long, int, const int, long> ti; +const std::tuple<long, int, const int, long> cti; + +constexpr const int& cri = std::get<int>(cti); +constexpr int& ri = std::get<int>(ti); +constexpr int&& rri = std::get<int>(std::move(ti)); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc new file mode 100644 index 000000000..c4cd6f657 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int j=1; + const int k=2; + tuple<int,int &,const int&> a(0,j,k); + const tuple<int,int &,const int&> b(1,j,k); + VERIFY(get<0>(a)==0 && get<1>(a)==1 && get<2>(a)==2); + get<0>(a)=3; + get<1>(a)=4; + VERIFY(get<0>(a)==3 && get<1>(a)==4); + VERIFY(j==4); + get<1>(b)=5; + VERIFY(get<0>(b)==1 && get<1>(b)==5 && get<2>(b)==2); + VERIFY(j==5); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get2.cc new file mode 100644 index 000000000..e6fac45fb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-17 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 <tuple> + +void test01() +{ + std::tuple<int> t1; + + int&& t1one __attribute__((unused)) = std::get<0>(std::move(t1)); + + std::tuple<float, int> t2; + + float&& t2one __attribute__((unused)) = std::get<0>(std::move(t2)); + int&& t2two __attribute__((unused)) = std::get<1>(std::move(t2)); + + std::tuple<short, int, double> t3; + + short&& t3one __attribute__((unused)) = std::get<0>(std::move(t3)); + int&& t3two __attribute__((unused)) = std::get<1>(std::move(t3)); + double&& t3thr __attribute__((unused)) = std::get<2>(std::move(t3)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get2_by_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get2_by_type.cc new file mode 100644 index 000000000..9387ff98c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get2_by_type.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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 <tuple> + +void test01() +{ + std::tuple<int> t1; + + int&& t1one __attribute__((unused)) = std::get<int>(std::move(t1)); + + std::tuple<float, int> t2; + + float&& t2one __attribute__((unused)) = std::get<0>(std::move(t2)); + int&& t2two __attribute__((unused)) = std::get<int>(std::move(t2)); + + std::tuple<short, int, double> t3; + + short&& t3one __attribute__((unused)) = std::get<short>(std::move(t3)); + int&& t3two __attribute__((unused)) = std::get<int>(std::move(t3)); + double&& t3thr __attribute__((unused)) = std::get<double>(std::move(t3)); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get_by_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get_by_type.cc new file mode 100644 index 000000000..226e9e4a8 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/element_access/get_by_type.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + int j=1; + const int k=2; + tuple<int,int &,const int&> a(0,j,k); + const tuple<int,int &,const int&> b(1,j,k); + VERIFY(get<int>(a)==0 && get<int&>(a)==1 && get<const int&>(a)==2); + get<0>(a)=3; + get<1>(a)=4; + VERIFY(get<int>(a)==3 && get<int&>(a)==4); + VERIFY(j==4); + get<1>(b)=5; + VERIFY(get<int>(b)==1 && get<int&>(b)==5 && get<const int&>(b)==2); + VERIFY(j==5); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/moveable.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/moveable.cc new file mode 100644 index 000000000..ab3886013 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/moveable.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include <tuple> +#include <utility> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int, double> a(1, 2.0), b; + b = std::move(a); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + VERIFY( std::get<0>(a) == 1 && std::get<1>(a) == 2.0 ); + + std::tuple<int, double> c(std::move(b)); + VERIFY( std::get<0>(c) == 1 && std::get<1>(c) == 2.0 ); + VERIFY( std::get<0>(b) == 1 && std::get<1>(b) == 2.0 ); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc new file mode 100644 index 000000000..d2957c3e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/moveable2.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <tuple> +#include <utility> + +struct MoveOnly +{ + MoveOnly () { } + + MoveOnly (MoveOnly&&) { } + + MoveOnly& operator=(MoveOnly&&) + { return *this; } + + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; +}; + +MoveOnly +make_move_only () +{ return MoveOnly(); } + +// http://gcc.gnu.org/ml/libstdc++/2008-02/msg00046.html +void test01() +{ + typedef std::tuple<MoveOnly> move_only_tuple; + + move_only_tuple t1(make_move_only()); + move_only_tuple t2(std::move(t1)); + move_only_tuple t3 = std::move(t2); + t1 = std::move(t3); + + typedef std::tuple<MoveOnly, MoveOnly> move_only_tuple2; + + move_only_tuple2 t4(make_move_only(), make_move_only()); + move_only_tuple2 t5(std::move(t4)); + move_only_tuple2 t6 = std::move(t5); + t4 = std::move(t6); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/noexcept_move_assign.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/noexcept_move_assign.cc new file mode 100644 index 000000000..1e8859a35 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/noexcept_move_assign.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 <tuple> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +typedef std::tuple<int> tt1; +typedef std::tuple<int, double> tt2; +typedef std::tuple<short, double, int> tt3; +typedef std::tuple<short, NoexceptMoveAssignClass, double> tt4; +typedef std::tuple<NoexceptMoveAssignClass, + NoexceptMoveAssignClass, double> tt5; +typedef std::tuple<NoexceptMoveAssignClass, + NoexceptMoveAssignClass, + NoexceptMoveAssignClass> tt6; +typedef std::tuple<ExceptMoveAssignClass> tt7; +typedef std::tuple<ExceptMoveAssignClass, double> tt8; +typedef std::tuple<short, double, ExceptMoveAssignClass> tt9; +typedef std::tuple<ExceptMoveAssignClass, double, + ExceptMoveAssignClass> tt10; +typedef std::tuple<NoexceptMoveAssignClass, + ExceptMoveAssignClass> tt11; +typedef std::tuple<int, + NoexceptMoveAssignClass, + ExceptMoveAssignClass> tt12; + +static_assert(std::is_nothrow_move_assignable<tt1>::value, "Error"); +static_assert(std::is_nothrow_move_assignable<tt2>::value, "Error"); +static_assert(std::is_nothrow_move_assignable<tt3>::value, "Error"); +static_assert(std::is_nothrow_move_assignable<tt4>::value, "Error"); +static_assert(std::is_nothrow_move_assignable<tt5>::value, "Error"); +static_assert(std::is_nothrow_move_assignable<tt6>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt7>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt8>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt9>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt10>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt11>::value, "Error"); +static_assert(!std::is_nothrow_move_assignable<tt12>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/noexcept_swap.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/noexcept_swap.cc new file mode 100644 index 000000000..ec16973d3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/noexcept_swap.cc @@ -0,0 +1,116 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-05-19 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 <tuple> +#include <testsuite_tr1.h> + +using namespace __gnu_test; + +typedef std::tuple<int> tt1; +typedef std::tuple<int, double> tt2; +typedef std::tuple<short, double, int> tt3; +typedef std::tuple<short, NoexceptMoveAssignClass, double> tt4; +typedef std::tuple<ExceptMoveAssignClass> tt5; +typedef std::tuple<ExceptMoveAssignClass, double> tt6; +typedef std::tuple<short, double, ExceptMoveAssignClass> tt7; +typedef std::tuple<ExceptMoveConsClass> tt8; +typedef std::tuple<int, ExceptMoveConsClass> tt9; +typedef std::tuple<ExceptMoveConsClass, short, double> tt10; +typedef std::tuple<short, NoexceptMoveConsClass, double> tt11; +typedef std::tuple<NoexceptMoveConsClass> tt12; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass> tt13; +typedef std::tuple<ExceptMoveConsNoexceptMoveAssignClass> tt14; +typedef std::tuple<NoexceptMoveConsExceptMoveAssignClass> tt15; +typedef std::tuple<ExceptMoveConsExceptMoveAssignClass> tt16; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + double> tt17; +typedef std::tuple<double, + NoexceptMoveConsNoexceptMoveAssignClass, + short> tt18; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsNoexceptMoveAssignClass, + char> tt19; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsNoexceptMoveAssignClass> tt20; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + ExceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsNoexceptMoveAssignClass> tt21; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + ExceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsExceptMoveAssignClass> tt22; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + NoexceptMoveConsNoexceptMoveAssignClass, + ExceptMoveConsExceptMoveAssignClass> tt23; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + short, ExceptMoveConsExceptMoveAssignClass> tt24; +typedef std::tuple<NoexceptMoveConsNoexceptMoveAssignClass, + short, ExceptMoveConsExceptMoveAssignClass> tt25; + +static_assert(noexcept(std::declval<tt1&>().swap(std::declval<tt1&>())), + "Error"); +static_assert(noexcept(std::declval<tt2&>().swap(std::declval<tt2&>())), + "Error"); +static_assert(noexcept(std::declval<tt3&>().swap(std::declval<tt3&>())), + "Error"); +static_assert(noexcept(std::declval<tt4&>().swap(std::declval<tt4&>())), + "Error"); +static_assert(!noexcept(std::declval<tt5&>().swap(std::declval<tt5&>())), + "Error"); +static_assert(!noexcept(std::declval<tt6&>().swap(std::declval<tt6&>())), + "Error"); +static_assert(!noexcept(std::declval<tt7&>().swap(std::declval<tt7&>())), + "Error"); +static_assert(!noexcept(std::declval<tt8&>().swap(std::declval<tt8&>())), + "Error"); +static_assert(!noexcept(std::declval<tt9&>().swap(std::declval<tt9&>())), + "Error"); +static_assert(!noexcept(std::declval<tt10&>().swap(std::declval<tt10&>())), + "Error"); +static_assert(noexcept(std::declval<tt11&>().swap(std::declval<tt11&>())), + "Error"); +static_assert(noexcept(std::declval<tt12&>().swap(std::declval<tt12&>())), + "Error"); +static_assert(noexcept(std::declval<tt13&>().swap(std::declval<tt13&>())), + "Error"); +static_assert(!noexcept(std::declval<tt14&>().swap(std::declval<tt14&>())), + "Error"); +static_assert(!noexcept(std::declval<tt15&>().swap(std::declval<tt15&>())), + "Error"); +static_assert(!noexcept(std::declval<tt16&>().swap(std::declval<tt16&>())), + "Error"); +static_assert(noexcept(std::declval<tt17&>().swap(std::declval<tt17&>())), + "Error"); +static_assert(noexcept(std::declval<tt18&>().swap(std::declval<tt18&>())), + "Error"); +static_assert(noexcept(std::declval<tt19&>().swap(std::declval<tt19&>())), + "Error"); +static_assert(noexcept(std::declval<tt20&>().swap(std::declval<tt20&>())), + "Error"); +static_assert(!noexcept(std::declval<tt21&>().swap(std::declval<tt21&>())), + "Error"); +static_assert(!noexcept(std::declval<tt22&>().swap(std::declval<tt22&>())), + "Error"); +static_assert(!noexcept(std::declval<tt23&>().swap(std::declval<tt23&>())), + "Error"); +static_assert(!noexcept(std::declval<tt24&>().swap(std::declval<tt24&>())), + "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc new file mode 100644 index 000000000..a2e8c7dd7 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/requirements/dr801.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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 <tuple> +#include <type_traits> + +// DR 801, pair and tuple vs. "passed in registers" +void test_trivial() +{ + // PODType, TType, NType, SLType, LType, NLType, LTypeDerived + typedef std::tuple<int, int> tuple_type; + // static_assert(std::is_literal_type<tuple_type>::value, "! literal"); + static_assert(std::has_trivial_copy_constructor<tuple_type>::value, + "! triv copy"); + static_assert(std::is_trivially_destructible<tuple_type>::value, + "! triv destructor"); + // static_assert(std::is_standard_layout<tuple_type>::value, + // "! standard layout"); + + // Negative + /* + static_assert(std::has_trivial_default_constructor<tuple_type>::value, + "! triv default"); + static_assert(std::has_trivial_copy_assign<tuple_type>::value, + "! triv assign"); + static_assert(std::is_trivial<tuple_type>::value, "! triv"); + static_assert(std::is_pod<tuple_type>::value, "! pod"); + */ +} + +int main() +{ + test_trivial(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..4dd32fe09 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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 <tuple> + +template class std::tuple<short, int, double>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/swap.cc new file mode 100644 index 000000000..f2b69a7f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/swap.cc @@ -0,0 +1,111 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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/>. + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on tuple. If the implementation changed +// this test may begin to fail. + +#include <tuple> +#include <utility> +#include <testsuite_hooks.h> + +struct MoveOnly +{ + explicit MoveOnly (int j) : i(j) { } + + MoveOnly (MoveOnly&& m) : i(m.i) { } + + MoveOnly& operator=(MoveOnly&& m) + { i = m.i; return *this; } + + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + + bool operator==(MoveOnly const& m) + { return i == m.i; } + + void swap(MoveOnly& m) + { std::swap(m.i, i); } + + int i; +}; + +void swap(MoveOnly& m1, MoveOnly& m2) +{ m1.swap(m2); } + +MoveOnly +make_move_only (int i) +{ return MoveOnly(i); } + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::tuple<> t1, t2; + std::swap(t1, t2); + + VERIFY( t1 == t2 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int> t1(1), t2(2); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int, float> t1(1, 1.0f), t2(2, 2.0f); + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); +} + +void test04() +{ + bool test __attribute__((unused)) = true; + + std::tuple<int, float, MoveOnly> + t1(1, 1.0f, make_move_only(1)), + t2(2, 2.0f, make_move_only(2)); + + std::swap(t1, t2); + + VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 ); + VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f ); + VERIFY( std::get<2>(t1) == make_move_only(2) + && std::get<2>(t2) == make_move_only(1) ); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc new file mode 100644 index 000000000..0dbdf10fc --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/tuple_element.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> + +using namespace std; + +struct foo +{ }; + +int +main() +{ + // As foo isn't constructible from anything else, this + // lets us check if type is returning foo when it should + foo q1; + tuple_element<0,tuple<foo,void,int> >::type q2(q1); + tuple_element<2,tuple<void,int,foo> >::type q3(q1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc new file mode 100644 index 000000000..c4c459119 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/tuple/tuple_size.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007-2014 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> +#include <testsuite_hooks.h> + +using namespace std; + +int +main() +{ + bool test __attribute__((unused)) = true; + + VERIFY(tuple_size<tuple<> >::value == 0); + VERIFY(tuple_size<tuple<int> >::value == 1); + VERIFY(tuple_size<tuple<void> >::value == 1); + typedef tuple<int,const int&,void> test_tuple1; + VERIFY(tuple_size<test_tuple1>::value == 3); + VERIFY(tuple_size<tuple<tuple<void> > >::value == 1); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/comparison_operators.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/comparison_operators.cc new file mode 100644 index 000000000..fca6622e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/comparison_operators.cc @@ -0,0 +1,88 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 <typeindex> +#include <testsuite_hooks.h> + +#define TEST3(TI1, TI2, TO1, TO2) \ + VERIFY( (TI1 == TI2) == (TO1 == TO2) ); \ + VERIFY( (TI1 != TI2) == (TO1 != TO2) ); \ + VERIFY( (TI1 < TI2) == (TO1.before(TO2)) ); \ + VERIFY( (TI1 <= TI2) == (!TO2.before(TO1)) ); \ + VERIFY( (TI1 > TI2) == (TO2.before(TO1)) ); \ + VERIFY( (TI1 >= TI2) == (!TO1.before(TO2)) ); + +#define TEST2(TI, TO) \ + TEST3(TI, ti1, TO, to1) \ + TEST3(TI, ti2, TO, to2) \ + TEST3(TI, ti3, TO, to3) \ + TEST3(TI, ti4, TO, to4) \ + TEST3(TI, ti5, TO, to5) \ + TEST3(TI, ti6, TO, to6) \ + TEST3(TI, ti7, TO, to7) + +#define TEST \ + TEST2(ti1, to1) \ + TEST2(ti2, to2) \ + TEST2(ti3, to3) \ + TEST2(ti4, to4) \ + TEST2(ti5, to5) \ + TEST2(ti6, to6) \ + TEST2(ti7, to7) + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_info& to1 = typeid(int); + const type_index ti1(to1); + + const type_info& to2 = typeid(double); + const type_index ti2(to2); + + const type_info& to3 = typeid(Abraca); + const type_index ti3(to3); + + const type_info& to4 = typeid(const Abraca); + const type_index ti4(to4); + + const type_info& to5 = typeid(const Abraca&); + const type_index ti5(to5); + + const type_info& to6 = typeid(a1); + const type_index ti6(to6); + + const type_info& to7 = typeid(a2); + const type_index ti7(to7); + + TEST +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/hash.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/hash.cc new file mode 100644 index 000000000..16fd0084f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/hash.cc @@ -0,0 +1,60 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 <typeindex> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_index ti1(typeid(int)); + VERIFY( hash<type_index>()(ti1) == ti1.hash_code() ); + + const type_index ti2(typeid(double)); + VERIFY( hash<type_index>()(ti2) == ti2.hash_code() ); + + const type_index ti3(typeid(Abraca)); + VERIFY( hash<type_index>()(ti3) == ti3.hash_code() ); + + const type_index ti4(typeid(const Abraca)); + VERIFY( hash<type_index>()(ti4) == ti4.hash_code() ); + + const type_index ti5(typeid(const Abraca&)); + VERIFY( hash<type_index>()(ti5) == ti5.hash_code() ); + + const type_index ti6(typeid(a1)); + VERIFY( hash<type_index>()(ti6) == ti6.hash_code() ); + + const type_index ti7(typeid(a2)); + VERIFY( hash<type_index>()(ti7) == ti7.hash_code() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/hash_code.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/hash_code.cc new file mode 100644 index 000000000..6ab619926 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/hash_code.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 <typeindex> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_info& to1 = typeid(int); + const type_index ti1(to1); + VERIFY( ti1.hash_code() == to1.hash_code() ); + + const type_info& to2 = typeid(double); + const type_index ti2(to2); + VERIFY( ti2.hash_code() == to2.hash_code() ); + + const type_info& to3 = typeid(Abraca); + const type_index ti3(to3); + VERIFY( ti3.hash_code() == to3.hash_code() ); + + const type_info& to4 = typeid(const Abraca); + const type_index ti4(to4); + VERIFY( ti4.hash_code() == to4.hash_code() ); + + const type_info& to5 = typeid(const Abraca&); + const type_index ti5(to5); + VERIFY( ti5.hash_code() == to5.hash_code() ); + + const type_info& to6 = typeid(a1); + const type_index ti6(to6); + VERIFY( ti6.hash_code() == to6.hash_code() ); + + const type_info& to7 = typeid(a2); + const type_index ti7(to7); + VERIFY( ti7.hash_code() == to7.hash_code() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/name.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/name.cc new file mode 100644 index 000000000..bcbc3e530 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/typeindex/name.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-22 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 <typeindex> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + class Abraca { }; + Abraca a1, a2_; + const Abraca a2 = a2_; + + const type_info& to1 = typeid(int); + const type_index ti1(to1); + VERIFY( ti1.name() == to1.name() ); + + const type_info& to2 = typeid(double); + const type_index ti2(to2); + VERIFY( ti2.name() == to2.name() ); + + const type_info& to3 = typeid(Abraca); + const type_index ti3(to3); + VERIFY( ti3.name() == to3.name() ); + + const type_info& to4 = typeid(const Abraca); + const type_index ti4(to4); + VERIFY( ti4.name() == to4.name() ); + + const type_info& to5 = typeid(const Abraca&); + const type_index ti5(to5); + VERIFY( ti5.name() == to5.name() ); + + const type_info& to6 = typeid(a1); + const type_index ti6(to6); + VERIFY( ti6.name() == to6.name() ); + + const type_info& to7 = typeid(a2); + const type_index ti7(to7); + VERIFY( ti7.name() == to7.name() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..e14eba937 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 enum E1 : unsigned { } test_type1; + typedef enum E2 : char { } test_type2; + typedef enum class E3 { } test_type3; + typedef enum class E4 : unsigned char { c = 1 } test_type4; + typedef enum class E5 : int { a = -1, b = 1 } test_type5; + typedef enum class E6 : long { c = __LONG_MAX__ } test_type6; + + template struct underlying_type<test_type1>; + template struct underlying_type<test_type2>; + template struct underlying_type<test_type3>; + template struct underlying_type<test_type4>; + template struct underlying_type<test_type5>; + template struct underlying_type<test_type6>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-1.cc new file mode 100644 index 000000000..b5ee1e4f6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-1.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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() +{ + typedef enum E1 : unsigned { } test_type1; + typedef enum E2 : char { } test_type2; + typedef enum class E3 { } test_type3; + typedef enum class E4 : unsigned char { c = 1 } test_type4; + typedef enum class E5 : int { a = -1, b = 1 } test_type5; + typedef enum class E6 : long { c = __LONG_MAX__ } test_type6; + + // Check for required typedef + typedef std::underlying_type<test_type1>::type type1; + typedef std::underlying_type<test_type2>::type type2; + typedef std::underlying_type<test_type3>::type type3; + typedef std::underlying_type<test_type4>::type type4; + typedef std::underlying_type<test_type5>::type type5; + typedef std::underlying_type<test_type6>::type type6; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-2.cc new file mode 100644 index 000000000..dc3723634 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-2.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2011-2014 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() +{ + using namespace std; + + enum E1 : unsigned { }; + enum E2 : char { }; + enum class E3 { }; + enum class E4 : unsigned char { c = 1 }; + enum class E5 : int { a = -1, b = 1 }; + enum class E6 : long { c = __LONG_MAX__ }; + + static_assert(is_same<underlying_type<E1>::type, unsigned>::value, "Error"); + static_assert(is_same<underlying_type<E2>::type, char>::value, "Error"); + static_assert(is_same<underlying_type<E3>::type, int>::value, "Error"); + static_assert(is_same<underlying_type<E4>::type, + unsigned char>::value, "Error"); + static_assert(is_same<underlying_type<E5>::type, int>::value, "Error"); + static_assert(is_same<underlying_type<E6>::type, long>::value, "Error"); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-3.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-3.cc new file mode 100644 index 000000000..78090b7dd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-3.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } +// +// Copyright (C) 2013-2014 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> + +using namespace std; + +enum E : long { }; + +static_assert( is_same<typename underlying_type<E>::type, + underlying_type_t<E>>(), + "underlying_type_t" ); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/54351.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/54351.cc new file mode 100644 index 000000000..b296b245f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/54351.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do run } + +// Copyright (C) 2012-2014 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/>. + +// 20.7.1 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A; + +struct B +{ + std::unique_ptr<A> a; +}; + +struct A +{ + B* b; + ~A() { VERIFY(b->a != nullptr); } +}; + +void test01() +{ + B b; + b.a.reset(new A); + b.a->b = &b; +} + +struct C; + +struct D +{ + std::unique_ptr<C[]> c; +}; + +struct C +{ + D* d; + ~C() { VERIFY(d->c != nullptr); } +}; + +void test02() +{ + D d; + d.c.reset(new C[1]); + d.c[0].d = &d; +} + +int main() +{ + test01(); + test02(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc new file mode 100644 index 000000000..c672d014c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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 <memory> +#include <testsuite_hooks.h> + +struct Deleter +{ + Deleter() = default; + Deleter(const Deleter&) = default; + Deleter(Deleter&&) = default; + + Deleter& + operator=(const Deleter&) + { + bool test __attribute__((unused)) = true; + VERIFY( true ); + return *this; + } + + Deleter& + operator=(Deleter&&) + { + bool test __attribute__((unused)) = true; + VERIFY( false ); + return *this; + } + + template<class T> + void + operator()(T*) const { } +}; + +struct DDeleter : Deleter { }; + +// libstdc++/48635 +void test01() +{ + Deleter d; + + std::unique_ptr<int, Deleter&> p1(nullptr, d), p2(nullptr, d); + p2 = std::move(p1); + + DDeleter dd; + + std::unique_ptr<int, DDeleter&> p1t(nullptr, dd); + std::unique_ptr<int, Deleter&> p2t(nullptr, d); + p2t = std::move(p1t); + + std::unique_ptr<int[], Deleter&> p1a(nullptr, d), p2a(nullptr, d); + p2a = std::move(p1a); + + std::unique_ptr<int[], DDeleter&> p1at(nullptr, dd); + std::unique_ptr<int[], Deleter&> p2at(nullptr, d); + p2at = std::move(p1at); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc new file mode 100644 index 000000000..749177f9f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/48635_neg.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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 <memory> + +struct D; + +struct B +{ + B& operator=(D&) = delete; // { dg-error "declared here" } + + template<class T> + void operator()(T*) const {} +}; + +struct D : B { }; + +// libstdc++/48635 +void f() +{ + B b; + D d; + + std::unique_ptr<int, B&> ub(nullptr, b); + std::unique_ptr<int, D&> ud(nullptr, d); + ub = std::move(ud); +// { dg-error "use of deleted function" "" { target *-*-* } 272 } + + std::unique_ptr<int[], B&> uba(nullptr, b); + std::unique_ptr<int[], D&> uda(nullptr, d); + uba = std::move(uda); +// { dg-error "use of deleted function" "" { target *-*-* } 517 } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc new file mode 100644 index 000000000..76e33def1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <memory> + +struct base { virtual ~base() {} }; +struct derived : base {}; + +void +test01() +{ + std::unique_ptr<derived> p1(new derived); + std::unique_ptr<derived> p2(new derived); +// p2 = p1; // should not compile + p2 = std::move(p1); + std::unique_ptr<base> p3(new base); +// p3 = p2; // should not compile + p3 = std::move(p2); +} + +void +test02() +{ + std::unique_ptr<int[]> p1(new int(420)); + std::unique_ptr<int[]> p2 = p1; // { dg-error "deleted" } +} + +void +test03() +{ + std::unique_ptr<int[2]> p1(new int[3]); // { dg-error "no match" } + // { dg-error "candidate" "candidate-note" { target *-*-* } 48 } + std::unique_ptr<int[2]> p2 = p1; // { dg-error "deleted" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/cv_qual.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/cv_qual.cc new file mode 100644 index 000000000..b4989afbb --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/cv_qual.cc @@ -0,0 +1,89 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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/>. + +// 20.7.1 Class template unique_ptr [unique.ptr] + +#include <memory> + +struct A { virtual ~A() = default; }; + +struct B : A { }; + +// Assignment from objects with different cv-qualification + +void +test01() +{ + std::unique_ptr<A> upA; + + std::unique_ptr<const A> cA; + cA = std::move(upA); + std::unique_ptr<volatile A> vA; + vA = std::move(upA); + std::unique_ptr<const volatile A> cvA; + cvA = std::move(upA); +} + +void +test02() +{ + std::unique_ptr<B> upB; + + std::unique_ptr<const A> cA; + cA = std::move(upB); + std::unique_ptr<volatile A> vA; + vA = std::move(upB); + std::unique_ptr<const volatile A> cvA; + cvA = std::move(upB); +} + +void +test03() +{ + std::unique_ptr<A[]> upA; + + std::unique_ptr<const A[]> cA; + cA = std::move(upA); + std::unique_ptr<volatile A[]> vA; + vA = std::move(upA); + std::unique_ptr<const volatile A[]> cvA; + cvA = std::move(upA); +} + +struct A_pointer { operator A*() const { return nullptr; } }; + +template<typename T> +struct deleter +{ + deleter() = default; + template<typename U> + deleter(const deleter<U>) { } + typedef T pointer; + void operator()(T) const { } +}; + +void +test04() +{ + // Allow conversions from user-defined pointer-like types + std::unique_ptr<B[], deleter<A_pointer>> p; + std::unique_ptr<A[], deleter<A*>> upA; + upA = std::move(p); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc new file mode 100644 index 000000000..0bdccf6f0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D; + std::unique_ptr<D> p1(d); + std::unique_ptr<D> p2(new D); + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); + + std::unique_ptr<B> p3(new B); + p3 = std::move(p2); + + VERIFY( p2.get() == 0 ); + VERIFY( p3.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc new file mode 100644 index 000000000..752ad28e0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/move_array.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct B { virtual ~B() {} }; +struct D : public B {}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + D *d = new D[3]; + std::unique_ptr<D[]> p1(d); + std::unique_ptr<D[]> p2; + p2 = std::move(p1); + + VERIFY( p1.get() == 0 ); + VERIFY( p2.get() == d ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc new file mode 100644 index 000000000..1cf36a9d6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/assign/nullptr.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p(new A); + p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> p(new A[2]); + p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc new file mode 100644 index 000000000..21282ec4c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/42925.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include <memory> + +// libstdc++/42925 (also see GB 99) +void test01() +{ + std::unique_ptr<int> ptr; + if (ptr == 0) + { } + if (0 == ptr) + { } + if (ptr != 0) + { } + if (0 != ptr) + { } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/dr1401.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/dr1401.cc new file mode 100644 index 000000000..c09386a87 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/comparison/dr1401.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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/>. + +// 20.7.1 Class template unique_ptr [unique.ptr] + +#include <memory> + +// DR 1401 +void test01() +{ + std::unique_ptr<int> ptr1, ptr2; + if (ptr1 == ptr2) + { } + if (ptr1 == nullptr) + { } + if (nullptr == ptr1) + { } + if (ptr1 != ptr2) + { } + if (ptr1 != nullptr) + { } + if (nullptr != ptr1) + { } + if (ptr1 < ptr2) + { } + if (ptr1 < nullptr) + { } + if (nullptr < ptr1) + { } + if (ptr1 <= ptr2) + { } + if (ptr1 <= nullptr) + { } + if (nullptr <= ptr1) + { } + if (ptr1 > ptr2) + { } + if (ptr1 > nullptr) + { } + if (nullptr > ptr1) + { } + if (ptr1 >= ptr2) + { } + if (ptr1 >= nullptr) + { } + if (nullptr >= ptr1) + { } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/array_convertible_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/array_convertible_neg.cc new file mode 100644 index 000000000..b422f72ca --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/array_convertible_neg.cc @@ -0,0 +1,58 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 <memory> + +struct A +{ +}; + +struct B : A +{ + virtual ~B() { } +}; + +// 20.7.1.3 unique_ptr for array objects [unique.ptr.runtime] + +struct D +{ + template<typename T> + void operator()(const T* p) const { delete[] p; } +}; + +// Conversion from different type of unique_ptr<T[], D> +void +test01() +{ + std::unique_ptr<B[], D> b(new B[1]); + std::unique_ptr<A[], D> a(std::move(b)); //{ dg-error "no matching function" } + a = std::move(b); //{ dg-error "no match" } +} + +// Conversion from non-array form of unique_ptr +void +test02() +{ + std::unique_ptr<A> nonarray(new A); + std::unique_ptr<A[]> array(std::move(nonarray)); //{ dg-error "no matching function" } + array = std::move(nonarray); //{ dg-error "no match" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc new file mode 100644 index 000000000..80349b029 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +// 20.9.10.2.1 unique_ptr constructors [unique.ptr.single.ctor] + +// Construction from auto_ptr +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::auto_ptr<A> a(new A); + std::unique_ptr<A> a2(std::move(a)); + VERIFY( a.get() == nullptr ); + VERIFY( a2.get() != 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc new file mode 100644 index 000000000..b3e7bd825 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include <memory> + +struct A { }; + +// 20.9.10.2.1 unique_ptr constructors [unique.ptr.single.ctor] + +// Construction from const auto_ptr +void +test01() +{ + const std::auto_ptr<A> a(new A); + std::unique_ptr<A> a2(std::move(a)); // { dg-error "no match" } +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc new file mode 100644 index 000000000..38e052765 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/constexpr.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2Ev" } } +// { dg-final { scan-assembler-not "_ZNSt10unique_ptrIiSt14default_deleteIiEEC2EDn" } } + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test1; //not literal + test1.operator()<std::unique_ptr<int>>(); + + __gnu_test::constexpr_single_value_constructible test2; //not literal + test2.operator()<std::unique_ptr<int>, std::nullptr_t>(); + + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/convertible_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/convertible_neg.cc new file mode 100644 index 000000000..cd3329428 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/convertible_neg.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012-2014 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 <memory> + +struct A +{ +}; + +// 20.7.1.3 unique_ptr for array objects [unique.ptr.runtime] + +// Conversion to non-array form of unique_ptr +void +test01() +{ + std::unique_ptr<A[]> array(new A[1]); + std::unique_ptr<A> nonarray(std::move(array)); //{ dg-error "no matching function" } + nonarray = std::move(array); //{ dg-error "no match" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/cv_qual.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/cv_qual.cc new file mode 100644 index 000000000..d8350ce73 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/cv_qual.cc @@ -0,0 +1,115 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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/>. + +// 20.7.1 Class template unique_ptr [unique.ptr] + +#include <memory> + +struct A { virtual ~A() = default; }; + +struct B : A { }; + +// Construction from objects with different cv-qualification + +void +test01() +{ + std::unique_ptr<const A> cA(new A); + std::unique_ptr<volatile A> vA(new A); + std::unique_ptr<const volatile A> cvA(new A); +} + +void +test02() +{ + std::unique_ptr<const A> cB(new B); + std::unique_ptr<volatile A> vB(new B); + std::unique_ptr<const volatile A> cvB(new B); +} + +void +test03() +{ + std::unique_ptr<A> upA; + + std::unique_ptr<const A> cA(std::move(upA)); + std::unique_ptr<volatile A> vA(std::move(upA)); + std::unique_ptr<const volatile A> cvA(std::move(upA)); +} + +void +test04() +{ + std::unique_ptr<B> upB; + + std::unique_ptr<const A> cA(std::move(upB)); + std::unique_ptr<volatile A> vA(std::move(upB)); + std::unique_ptr<const volatile A> cvA(std::move(upB)); +} + +void +test05() +{ + std::unique_ptr<const A[]> cA(new A[1]); + std::unique_ptr<volatile A[]> vA(new A[1]); + std::unique_ptr<const volatile A[]> cvA(new A[1]); +} + +void +test06() +{ + std::unique_ptr<A[]> upA; + + std::unique_ptr<const A[]> cA(std::move(upA)); + std::unique_ptr<volatile A[]> vA(std::move(upA)); + std::unique_ptr<const volatile A[]> cvA(std::move(upA)); +} + +struct A_pointer { operator A*() const { return nullptr; } }; + +void +test07() +{ + // Allow conversions from user-defined pointer-like types + A_pointer p; + std::unique_ptr<A[]> upA(p); + std::unique_ptr<const A[]> cA(p); + std::unique_ptr<volatile A[]> vA(p); + std::unique_ptr<const volatile A[]> cvA(p); +} + +template<typename T> +struct deleter +{ + deleter() = default; + template<typename U> + deleter(const deleter<U>) { } + typedef T pointer; + void operator()(T) const { } +}; + +void +test08() +{ + // Allow conversions from user-defined pointer-like types + std::unique_ptr<B[], deleter<A_pointer>> p; + std::unique_ptr<A[], deleter<A*>> upA(std::move(p)); +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..4a17acc43 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-14 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 <memory> + +typedef std::unique_ptr<int> uptype; + +static_assert(std::is_nothrow_move_constructible<uptype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc new file mode 100644 index 000000000..1c8bb3d14 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/nullptr.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10 Class template unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> p = nullptr; + + VERIFY( p.get() == nullptr ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc new file mode 100644 index 000000000..cab149d59 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer.cc @@ -0,0 +1,117 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + +// 20.6.11.2.1 unique_ptr constructors [unique.ptr.single.ctor] + +// Construction from pointer +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr<A> A_from_A(new A); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr<A> A_from_B(new B); + VERIFY( A_from_B.get() != 0 ); + VERIFY( A::ctor_count == 2 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 1 ); + VERIFY( B::dtor_count == 0 ); +} + +void +test02() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + A * const A_default = 0; + std::unique_ptr<A> p1(A_default); + VERIFY( p1.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + A * const A_from_A = new A; + std::unique_ptr<A> p2(A_from_A); + VERIFY( p2.get() == A_from_A ); + VERIFY( A::ctor_count == 1 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc new file mode 100644 index 000000000..e89cf9da1 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() { ++ctor_count; } + virtual ~A() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long A::ctor_count = 0; +long A::dtor_count = 0; + +struct B : A +{ + B() { ++ctor_count; } + virtual ~B() { ++dtor_count; } + static long ctor_count; + static long dtor_count; +}; +long B::ctor_count = 0; +long B::dtor_count = 0; + + +struct reset_count_struct +{ + ~reset_count_struct() + { + A::ctor_count = 0; + A::dtor_count = 0; + B::ctor_count = 0; + B::dtor_count = 0; + } +}; + + +// 20.4.5.1 unique_ptr constructors [unique.ptr.cons] + +// Construction from pointer +void +test01() +{ + reset_count_struct __attribute__((unused)) reset; + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> A_default; + VERIFY( A_default.get() == 0 ); + VERIFY( A::ctor_count == 0 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); + + std::unique_ptr<A[]> A_from_A(new A[3]); + VERIFY( A_from_A.get() != 0 ); + VERIFY( A::ctor_count == 3 ); + VERIFY( A::dtor_count == 0 ); + VERIFY( B::ctor_count == 0 ); + VERIFY( B::dtor_count == 0 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc new file mode 100644 index 000000000..57c22239a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/pointer_array_convertible_neg.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2008-2014 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 <memory> + +struct A +{ +}; + +struct B : A +{ + virtual ~B() { } +}; + +// 20.7.1.3.1 unique_ptr constructors [unique.ptr.runtime.ctor] + +// Construction from pointer of derived type +void +test01() +{ + std::unique_ptr<B[]> B_from_A(new A[3]); //{ dg-error "invalid conversion from" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc new file mode 100644 index 000000000..b3031f0b6 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do run } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +static int count; + +void del(int* p) { ++count; delete p; } +void vdel(int* p) { ++count; delete[] p; } + +void +test01() +{ + bool test __attribute__((unused)) = true; + count = 0; + { + std::unique_ptr<int, void(*)(int*)> p(nullptr, del); + } + VERIFY( count == 0 ); + { + std::unique_ptr<int, void(*)(int*)> p(new int, del); + } + VERIFY( count == 1 ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + count = 0; + { + std::unique_ptr<int[], void(*)(int*)> p(nullptr, vdel); + } + VERIFY( count == 0 ); + { + std::unique_ptr<int[], void(*)(int*)> p(new int[1], vdel); + } + VERIFY( count == 1 ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} + diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc new file mode 100644 index 000000000..2aef3ec18 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010-2014 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/>. + +// 20.7.1 Class template unique_ptr [unique.ptr] + +#include <memory> + +using std::unique_ptr; + +// { dg-prune-output "static assertion failed" } + +void +test01() +{ + unique_ptr<long, void(*)(long*)> p1; // { dg-error "here" } + + unique_ptr<short, void(*)(short*)> p2(nullptr); // { dg-error "here" } + + unique_ptr<int, void(*)(int*)> p3(new int); // { dg-error "here" } +} + +void +test02() +{ + unique_ptr<long[], void(*)(long*)> p1; // { dg-error "here" } + + unique_ptr<short[], void(*)(short*)> p2(nullptr); // { dg-error "here" } + + unique_ptr<int[], void(*)(int*)> p3(new int[1]); // { dg-error "here" } +} + + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/array.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/array.cc new file mode 100644 index 000000000..53c621b17 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/array.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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/>. + +// 20.9.1.4 unique_ptr creation [unique.ptr.create] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() : b(true) { } + A(int) : b(false) { } + bool b; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> a = std::make_unique<A[]>(3); + VERIFY( a != nullptr ); + VERIFY( a[0].b && a[1].b && a[2].b ); +} + +int +main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/array_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/array_neg.cc new file mode 100644 index 000000000..719eda1ad --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/array_neg.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013-2014 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/>. + +// 20.9.1.4 unique_ptr creation [unique.ptr.create] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; + +auto p1 = std::make_unique<A[]>(); // { dg-error "no matching function" } +auto p2 = std::make_unique<A[]>(1, 2); // { dg-error "no matching function" } +auto p3 = std::make_unique<A[1]>(); // { dg-error "deleted" } +auto p4 = std::make_unique<A[1]>(1); // { dg-error "deleted" } + +// { dg-prune-output "declared here" } +// { dg-prune-output "no type named" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/single.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/single.cc new file mode 100644 index 000000000..6ba554052 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/creation/single.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013-2014 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/>. + +// 20.9.1.4 unique_ptr creation [unique.ptr.create] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + A() : b(false) { } + A(int, double&, char&&, void*) : b(true) { } + bool b; +}; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int i = 0; + double d = 0; + char c = 0; + std::unique_ptr<A> a = std::make_unique<A>(i, d, std::move(c), nullptr); + VERIFY( a != nullptr ); + VERIFY( a->b ); + + a = std::make_unique<A>(); + VERIFY( a != nullptr ); + VERIFY( !a->b ); +} + +int +main() +{ + test01(); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc new file mode 100644 index 000000000..edbc65361 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-11 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + struct T { }; + + std::unique_ptr<T> u0(new T); + std::hash<std::unique_ptr<T>> hu0; + std::hash<typename std::unique_ptr<T>::pointer> hp0; + + VERIFY( hu0(u0) == hp0(u0.get()) ); + + std::unique_ptr<T[]> u1(new T[10]); + std::hash<std::unique_ptr<T[]>> hu1; + std::hash<typename std::unique_ptr<T[]>::pointer> hp1; + + VERIFY( hu1(u1) == hp1(u1.get()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc new file mode 100644 index 000000000..f20879dd0 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/43183.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010-2014 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/>. + +// 20.9.10.2.5 unique_ptr modifiers [unique.ptr.single.modifiers] + +#include <memory> +#include <testsuite_hooks.h> + +struct D +{ + static int count; + + void operator()(int* p) const + { + ++count; + delete p; + } +}; +int D::count = 0; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<int, D> up; + up.reset(); + VERIFY( D::count == 0 ); + up.reset(new int); + VERIFY( D::count == 0 ); + up.reset(up.get()); + VERIFY( D::count == 1 ); + up.release(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc new file mode 100644 index 000000000..98d430aa3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/48398.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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/>. + +// 20.7.1 Class template unique_ptr [unique.ptr] + +#include <memory> + +// PR libstdc++/48398 + +struct my_deleter +{ + typedef int* pointer; + + void operator()( pointer p ) { delete p; } +}; + +void test01() +{ + std::unique_ptr<void, my_deleter> p( new int() ); + + p.get(); + p.reset(); + +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/cv_qual.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/cv_qual.cc new file mode 100644 index 000000000..23b1b227e --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/cv_qual.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2012-2014 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/>. + +// 20.7.1 Class template unique_ptr [unique.ptr] + +#include <memory> + +struct A { virtual ~A() = default; }; + +struct B : A { }; + +// Construction from objects with different cv-qualification + +void +test01() +{ + std::unique_ptr<const A> cA; + cA.reset(new A); + std::unique_ptr<volatile A> vA; + vA.reset(new A); + std::unique_ptr<const volatile A> cvA; + cvA.reset(new A); +} + +void +test02() +{ + std::unique_ptr<const A> cB; + cB.reset(new B); + std::unique_ptr<volatile A> vB; + vB.reset(new B); + std::unique_ptr<const volatile A> cvB; + cvB.reset(new B); +} + +void +test03() +{ + std::unique_ptr<const A[]> cA; + cA.reset(new A[1]); + std::unique_ptr<volatile A[]> vA; + vA.reset(new A[1]); + std::unique_ptr<const volatile A[]> cvA; + cvA.reset(new A[1]); +} + +struct A_pointer { operator A*() const { return nullptr; } }; + +void +test07() +{ + // Allow conversions from user-defined pointer-like types + A_pointer p; + std::unique_ptr<A[]> upA; + upA.reset(p); + std::unique_ptr<const A[]> cA; + cA.reset(p); + std::unique_ptr<volatile A[]> vA; + vA.reset(p); + std::unique_ptr<const volatile A[]> cvA; + cvA.reset(p); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc new file mode 100644 index 000000000..45e2c5ab9 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/modifiers/reset_neg.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <memory> + +struct A +{ +}; + +struct B : A +{ + virtual ~B() { } +}; + +void test01() +{ + std::unique_ptr<B[]> up; + up.reset(new A[3]); // { dg-error "invalid conversion" } +} + +// { dg-prune-output "include" } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc new file mode 100644 index 000000000..fbc91213c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc @@ -0,0 +1,24 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008-2014 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 <memory> + +template class std::unique_ptr<int>; +template class std::unique_ptr<int[]>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc new file mode 100644 index 000000000..4c4b0ce87 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type.cc @@ -0,0 +1,49 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2010-2014 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/>. + +// 20.7.1.2 unique_ptr for single objects [unique.ptr.single] + +#include <memory> + +struct A +{ + void operator()(void*) const { } +}; + +struct B +{ + typedef char* pointer; + void operator()(pointer) const { } +}; + +int main() +{ + typedef std::unique_ptr<int> up; + typedef std::unique_ptr<int, A> upA; + typedef std::unique_ptr<int, B> upB; + typedef std::unique_ptr<int, A&> upAr; + typedef std::unique_ptr<int, B&> upBr; + + static_assert( std::is_same< up::pointer, int*>::value, "" ); + static_assert( std::is_same< upA::pointer, int*>::value, "" ); + static_assert( std::is_same< upB::pointer, char*>::value, "" ); + static_assert( std::is_same< upAr::pointer, int*>::value, "" ); + static_assert( std::is_same< upBr::pointer, char*>::value, "" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type_array.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type_array.cc new file mode 100644 index 000000000..72a181e2c --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/requirements/pointer_type_array.cc @@ -0,0 +1,49 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2010-2014 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/>. + +// 20.7.1.3 unique_ptr for array objects [unique.ptr.runtime] + +#include <memory> + +struct A +{ + void operator()(void*) const { } +}; + +struct B +{ + typedef char* pointer; + void operator()(pointer) const { } +}; + +int main() +{ + typedef std::unique_ptr<int[]> up; + typedef std::unique_ptr<int[], A> upA; + typedef std::unique_ptr<int[], B> upB; + typedef std::unique_ptr<int[], A&> upAr; + typedef std::unique_ptr<int[], B&> upBr; + + static_assert( std::is_same< up::pointer, int*>::value, "" ); + static_assert( std::is_same< upA::pointer, int*>::value, "" ); + static_assert( std::is_same< upB::pointer, char*>::value, "" ); + static_assert( std::is_same< upAr::pointer, int*>::value, "" ); + static_assert( std::is_same< upBr::pointer, char*>::value, "" ); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc new file mode 100644 index 000000000..c98aa885a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p1; + std::unique_ptr<A> p2; + + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p1 > p2) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p1; + std::unique_ptr<A> p2(new A); + + VERIFY( p1 != p2 ); + VERIFY( !(p1 == p2) ); + VERIFY( (p1 < p2) || (p1 > p2) ); + VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc new file mode 100644 index 000000000..b553d7ecd --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/comparisons_array.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.6.11 Template class unique_ptr [unique.ptr] + +#include <memory> +#include <testsuite_hooks.h> + +struct A +{ + virtual ~A() { } +}; + +struct B : A +{ +}; + +// 20.6.11.5 unqiue_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> p1; + std::unique_ptr<A[]> p2; + + VERIFY( p1 == p2 ); + VERIFY( !(p1 != p2) ); + VERIFY( !(p1 < p2) && !(p1 > p2) ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A[]> p1; + std::unique_ptr<A[]> p2(new A[3]); + + VERIFY( p1 != p2 ); + VERIFY( !(p1 == p2) ); + VERIFY( (p1 < p2) || (p1 > p2) ); + VERIFY( ((p1 <= p2) && (p1 != p2)) || ((p1 >= p2) && (p1 != p2)) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc new file mode 100644 index 000000000..cf9594257 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/unique_ptr/specialized_algorithms/swap.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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 <memory> +#include <testsuite_hooks.h> + +struct A {}; + +//20.6.11.5 unique_ptr specialized algorithms [unique.ptr.special] + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::unique_ptr<A> p1; + std::unique_ptr<A> p2(new A); + std::unique_ptr<A> p3; + + std::swap(p3, p2); + + VERIFY( p1 != p3 ); + VERIFY( p2 != p3 ); + VERIFY( p1 == p2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc new file mode 100644 index 000000000..5ce344c37 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011-2014 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/>. + +// 20.4.2.1 [tuple.cnstr] Allocator-extended constructors + +#include <memory> +#include <tuple> + +struct MyAlloc { }; + +struct Type +{ + typedef MyAlloc allocator_type; // uses_allocator<Type, MyAlloc> is true + + explicit Type(int) { } + + Type(std::allocator_arg_t, MyAlloc) { } + Type(MyAlloc) { } +}; + +void test01() +{ + using std::allocator_arg; + using std::tuple; + + MyAlloc a; + + tuple<Type> t(allocator_arg, a, 1); +} +// { dg-error "no matching function" "" { target *-*-* } 118 } diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/construction.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/construction.cc new file mode 100644 index 000000000..7f6cf7775 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/construction.cc @@ -0,0 +1,108 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011-2014 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/>. + +// 20.6.7.2 uses-allocator construction + +#include <memory> +#include <tuple> +#include <testsuite_hooks.h> + +struct MyAlloc { }; + +// type that can't be constructed with an allocator +struct CannotUse +{ + CannotUse(int) : ok(true) { } + + bool ok; +}; + +// type that can be constructed with an allocator +// but which has uses_allocator == false +struct DoesNotUse +{ + typedef MyAlloc allocator_type; + + DoesNotUse(int) : ok(true) { } + DoesNotUse(std::allocator_arg_t, MyAlloc, int) : ok(false) { } + DoesNotUse(int, MyAlloc) : ok(false) { } + + bool ok; +}; + +namespace std +{ + template<typename A> + struct uses_allocator<DoesNotUse, A> : false_type { }; +} + +// type that can be constructed with an allocator as second argument +struct UsesWithTag +{ + typedef MyAlloc allocator_type; + + UsesWithTag(int) : ok(false) { } + UsesWithTag(std::allocator_arg_t, MyAlloc, int) : ok(true) { } + UsesWithTag(int, MyAlloc) : ok(false) { } + + bool ok; +}; + +// type that can be constructed with an allocator as last argument +struct UsesWithoutTag +{ + typedef MyAlloc allocator_type; + + UsesWithoutTag(int) : ok(false) { } + UsesWithoutTag(int, MyAlloc) : ok(true) { } + + bool ok; +}; + + +template<typename TestType, typename... T> + bool test2(T... args) + { + using std::allocator_arg; + using std::tuple; + using std::get; + + tuple<TestType, T...> t(allocator_arg, MyAlloc(), 1, args...); + + return get<0>(t).ok; + } + +template<typename... T> + void test(T... args) + { + bool test __attribute__((unused)) = true; + + VERIFY( test2<CannotUse>(args...) ); + VERIFY( test2<DoesNotUse>(args...) ); + VERIFY( test2<UsesWithTag>(args...) ); + VERIFY( test2<UsesWithoutTag>(args...) ); + } + +int main() +{ + test(); + test(1); + test(1, 2); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/explicit_instantiation.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..41b26c84f --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-09-27 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <memory> + +namespace std +{ + typedef short test_type; + template struct uses_allocator<test_type, test_type>; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/typedefs.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/typedefs.cc new file mode 100644 index 000000000..8d39f6d6a --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-09-27 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2010-2014 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 <memory> + +void test01() +{ + // Check for required typedefs + typedef std::uses_allocator<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/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/value.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/value.cc new file mode 100644 index 000000000..cb96d7ac2 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/uses_allocator/value.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-09-27 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +struct MyAlloc { }; + +struct MyDerivedAlloc +: public MyAlloc { }; + +struct UA { }; + +struct UB { typedef int allocator_type; }; + +struct UC { typedef MyAlloc allocator_type; }; + +struct UD { typedef MyDerivedAlloc allocator_type; }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::uses_allocator; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_relationship<uses_allocator, UC, MyAlloc>(true)) ); + VERIFY( (test_relationship<uses_allocator, UC, MyDerivedAlloc>(true))); + + // Negative tests. + VERIFY( (test_relationship<uses_allocator, UA, MyAlloc>(false)) ); + VERIFY( (test_relationship<uses_allocator, UB, MyAlloc>(false)) ); + VERIFY( (test_relationship<uses_allocator, UD, MyAlloc>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc new file mode 100644 index 000000000..377bfe060 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x " } +// { dg-do compile } + +// Copyright (C) 2008-2014 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/>. + +// 20.6.6.3 Template class weak_ptr [util.smartptr.weak] + +#include <memory> + +struct A { }; + +// 20.8.13.3.6 weak_ptr comparison [util.smartptr.weak.cmp] (removed) + +int +test01() +{ + std::weak_ptr<A> p1; + p1 < p1; // { dg-error "no match" } + // { dg-error "candidate" "candidate note" { target *-*-* } 33 } + return 0; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc new file mode 100644 index 000000000..32ff8ac26 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/cons/constexpr.cc @@ -0,0 +1,30 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x -fno-inline -save-temps -g0" } +// { dg-final { scan-assembler-not "_ZNSt8weak_ptrIiEC2Ev" } } + +// Copyright (C) 2010-2014 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 <memory> +#include <testsuite_common_types.h> + +int main() +{ + __gnu_test::constexpr_default_constructible test; //not literal + test.operator()<std::weak_ptr<int>>(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/cons/noexcept_move_construct.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/cons/noexcept_move_construct.cc new file mode 100644 index 000000000..774b6ce61 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/cons/noexcept_move_construct.cc @@ -0,0 +1,27 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2011-06-14 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2011-2014 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 <memory> + +typedef std::weak_ptr<int> wptype; + +static_assert(std::is_nothrow_move_constructible<wptype>::value, "Error"); diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc new file mode 100644 index 000000000..fcc2ec7c3 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/lock/1.cc @@ -0,0 +1,36 @@ +// 2006-09-24 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2006-2014 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/>. + +// 20.6.6.3 Template class weak_ptr [util.smartptr.weak] + +#include <memory> +#include <testsuite_tr1.h> + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +int main() +{ + using __gnu_test::check_ret_type; + using std::weak_ptr; + using std::shared_ptr; + + weak_ptr<int> wp; + check_ret_type<shared_ptr<int> >(wp.lock()); +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc new file mode 100644 index 000000000..a8497e680 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008-2014 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/>. + +// 20.8.13.3 Template class weak_ptr [util.smartptr.weak] + +#include <memory> +#include <testsuite_hooks.h> + +struct A { }; +struct B { }; + +// 20.6.6.3.5 weak_ptr observers [util.smartptr.weak.obs] + +int +test01() +{ + bool test __attribute__((unused)) = true; + + // test empty weak_ptrs compare equivalent + std::weak_ptr<A> p1; + std::weak_ptr<B> p2; + VERIFY( !p1.owner_before(p2) && !p2.owner_before(p1) ); + + std::shared_ptr<B> p3; + VERIFY( !p1.owner_before(p3) && !p3.owner_before(p1) ); + + return 0; +} + + +int +test02() +{ + bool test __attribute__((unused)) = true; + + std::shared_ptr<A> a0; + std::weak_ptr<A> w0(a0); + + std::shared_ptr<A> a1(new A); + std::weak_ptr<A> w1(a1); + VERIFY( !a1.owner_before(w1) && !w1.owner_before(a1) ); + + VERIFY( w1.owner_before(w0) || w0.owner_before(w1) ); + VERIFY( !(w1.owner_before(w0) && w0.owner_before(w1)) ); + + VERIFY( w1.owner_before(a0) || a0.owner_before(w1) ); + VERIFY( !(w1.owner_before(a0) && a0.owner_before(w1)) ); + + std::shared_ptr<B> b1(new B); + VERIFY( w1.owner_before(b1) || b1.owner_before(w1) ); + + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..c5a30f272 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2006-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +using namespace __gnu_test; +using std::weak_ptr; +template class weak_ptr<int>; +template class weak_ptr<void>; +template class weak_ptr<ClassType>; +template class weak_ptr<IncompleteClass>; diff --git a/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..5c1e91b79 --- /dev/null +++ b/gcc-4.9/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007-2014 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/>. + +// 20.6.6.2 Template class shared_ptr [util.smartptr.shared] + +#include <memory> +#include <testsuite_tr1.h> + +// Check the _S_single lock policy can be instantiated. For a thread-enabled +// library this checks the templates can be instantiated for non-default +// lock policy, for a single-threaded lib this is redundant but harmless. +using namespace __gnu_test; +using std::__weak_ptr; +using std::_S_single; +template class __weak_ptr<int, _S_single>; +template class __weak_ptr<void, _S_single>; +template class __weak_ptr<ClassType, _S_single>; +template class __weak_ptr<IncompleteClass, _S_single>; |