From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libstdc++-v3/testsuite/20_util/pair/1.cc | 78 +++++++++++++++++ libstdc++-v3/testsuite/20_util/pair/2.cc | 59 +++++++++++++ libstdc++-v3/testsuite/20_util/pair/3.cc | 78 +++++++++++++++++ libstdc++-v3/testsuite/20_util/pair/4.cc | 66 +++++++++++++++ libstdc++-v3/testsuite/20_util/pair/40925.cc | 67 +++++++++++++++ libstdc++-v3/testsuite/20_util/pair/44487.cc | 51 +++++++++++ .../20_util/pair/comparison_operators/constexpr.cc | 29 +++++++ .../testsuite/20_util/pair/cons/constexpr.cc | 39 +++++++++ libstdc++-v3/testsuite/20_util/pair/moveable.cc | 63 ++++++++++++++ libstdc++-v3/testsuite/20_util/pair/piecewise.cc | 98 ++++++++++++++++++++++ .../testsuite/20_util/pair/requirements/dr801.cc | 52 ++++++++++++ .../pair/requirements/explicit_instantiation/1.cc | 25 ++++++ libstdc++-v3/testsuite/20_util/pair/swap.cc | 50 +++++++++++ 13 files changed, 755 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/pair/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/2.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/3.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/4.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/40925.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/44487.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/moveable.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/piecewise.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/20_util/pair/swap.cc (limited to 'libstdc++-v3/testsuite/20_util/pair') diff --git a/libstdc++-v3/testsuite/20_util/pair/1.cc b/libstdc++-v3/testsuite/20_util/pair/1.cc new file mode 100644 index 000000000..f5b15f755 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/1.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +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 + 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 p_bl_1(true, 433); + std::pair p_bl_2 = std::make_pair(true, 433); + VERIFY( p_bl_1 == p_bl_2 ); + VERIFY( !(p_bl_1 < p_bl_2) ); + + std::pair p_sf_1("total enlightenment", 433.00); + std::pair 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 p_sg_1("enlightenment", gnu_obj(5)); + std::pair 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_obj> p_st_1(gnu_t(false), gnu_obj(5)); + std::pair, gnu_obj> p_st_2 = std::make_pair(gnu_t(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/libstdc++-v3/testsuite/20_util/pair/2.cc b/libstdc++-v3/testsuite/20_util/pair/2.cc new file mode 100644 index 000000000..0826cdb2f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/2.cc @@ -0,0 +1,59 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +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 + 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 p_bb_1(true, false); + std::pair 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/libstdc++-v3/testsuite/20_util/pair/3.cc b/libstdc++-v3/testsuite/20_util/pair/3.cc new file mode 100644 index 000000000..fc19a4acd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/3.cc @@ -0,0 +1,78 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +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 + 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 p_bl_1(true, 433); + const std::pair 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 p_sf_1("total enlightenment", 433.00); + const std::pair 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 p_sg_1("enlightenment", gnu_obj(5)); + const std::pair 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_obj> p_st_1(gnu_t(false), gnu_obj(5)); + const std::pair, gnu_obj> p_st_2 = + std::make_pair(gnu_t(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/libstdc++-v3/testsuite/20_util/pair/4.cc b/libstdc++-v3/testsuite/20_util/pair/4.cc new file mode 100644 index 000000000..7431fc1e7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/4.cc @@ -0,0 +1,66 @@ +// 2001-06-18 Benjamin Kosnik + +// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.2.2 Pairs + +#include +#include + +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 + 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 p_sg_1("enlightenment", obj1); + const std::pair 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& tmpl1 = gnu_t(false); + const std::pair, gnu_obj> p_st_1(tmpl1, obj1); + const std::pair, 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/libstdc++-v3/testsuite/20_util/pair/40925.cc b/libstdc++-v3/testsuite/20_util/pair/40925.cc new file mode 100644 index 000000000..6abeb617f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/40925.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +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 p1(0, 0); + std::pair p2(ip, 0); + std::pair p3(0, ip); + std::pair p4(ip, ip); + + std::pair p5(0, 0); + std::pair p6(mp, 0); + std::pair p7(0, mp); + std::pair p8(mp, mp); + + std::pair p9(0, move_only()); + std::pair p10(0, move_only()); + std::pair p11(move_only(), 0); + std::pair p12(move_only(), 0); + + std::pair p13(ip, move_only()); + std::pair p14(mp, move_only()); + std::pair p15(move_only(), ip); + std::pair p16(move_only(), mp); + + std::pair p17(move_only(), move_only()); +} diff --git a/libstdc++-v3/testsuite/20_util/pair/44487.cc b/libstdc++-v3/testsuite/20_util/pair/44487.cc new file mode 100644 index 000000000..833d98645 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/44487.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +int x, y; + +std::pair +foo1() +{ + std::pair blah(x, y); + return blah; +} + +std::pair +foo2() +{ + const std::pair blah(x, y); + return blah; +} + +std::pair +foo3() +{ + std::pair blah(x, y); + return std::pair(std::move(blah)); +} + +std::pair +foo4() +{ + const std::pair blah(x, y); + return std::pair(std::move(blah)); +} diff --git a/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc new file mode 100644 index 000000000..d5dc6e4e1 --- /dev/null +++ b/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 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_comparison_operators test; + test.operator()>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc new file mode 100644 index 000000000..1c854627e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int main() +{ + __gnu_test::constexpr_default_constructible test1; + test1.operator()>(); + + __gnu_test::constexpr_single_value_constructible test2; + test2.operator(), std::pair>(); + test2.operator(), std::pair>(); + + // test 3 + const int i1(129); + const int i2(6); + constexpr std::pair p3(i1, i2); + + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/moveable.cc b/libstdc++-v3/testsuite/20_util/pair/moveable.cc new file mode 100644 index 000000000..9abdd8107 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/moveable.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +// 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 +#include +#include + +bool test __attribute__((unused)) = true; + +void +test1() +{ + std::pair 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 c(std::move(a)); + VERIFY(c.first == 2 && c.second == 2 && a.first == 2 && a.second == 2); +} + +void +test2() +{ + std::vector v,w; + v.push_back(1); + w.push_back(2); + w.push_back(2); + std::pair > p = make_pair(1,v); + std::pair > 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 > 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/libstdc++-v3/testsuite/20_util/pair/piecewise.cc b/libstdc++-v3/testsuite/20_util/pair/piecewise.cc new file mode 100644 index 000000000..ef7147320 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/piecewise.cc @@ -0,0 +1,98 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-04-30 Paolo Carlini +// +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Tuple + +#include +#include +#include + +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 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 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 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/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc b/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc new file mode 100644 index 000000000..36d380dcf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 801, pair and tuple vs. "passed in registers" +void test_trivial() +{ + // PODType, TType, NType, SLType, LType, NLType, LTypeDerived + typedef std::pair pair_type; + // static_assert(std::is_literal_type::value, "! literal"); + static_assert(std::has_trivial_copy_constructor::value, + "! triv copy"); + static_assert(std::has_trivial_destructor::value, + "! triv destructor"); + // static_assert(std::is_standard_layout::value, + // "! standard layout"); + + // Negative + /* + static_assert(std::has_trivial_default_constructor::value, + "! triv default"); + static_assert(std::has_trivial_copy_assign::value, + "! triv assign"); + static_assert(std::is_trivial::value, "! triv"); + static_assert(std::is_pod::value, "! pod"); + */ +} + +int main() +{ + test_trivial(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..262c575cf --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING3. If not see +// . + + +// This file tests explicit instantiation of library containers. + +#include + +template class std::pair; diff --git a/libstdc++-v3/testsuite/20_util/pair/swap.cc b/libstdc++-v3/testsuite/20_util/pair/swap.cc new file mode 100644 index 000000000..a76f5f3cb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/swap.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + typedef __gnu_test::uneq_allocator ua_type; + ua_type one(1), two(2); + + std::pair 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; +} -- cgit v1.2.3