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. --- .../testsuite/25_algorithms/search_n/11400.cc | 31 ++++++ .../testsuite/25_algorithms/search_n/check_type.cc | 38 +++++++ .../testsuite/25_algorithms/search_n/iterator.cc | 111 +++++++++++++++++++++ .../requirements/explicit_instantiation/2.cc | 41 ++++++++ .../requirements/explicit_instantiation/pod.cc | 40 ++++++++ 5 files changed, 261 insertions(+) create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc (limited to 'libstdc++-v3/testsuite/25_algorithms/search_n') diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc new file mode 100644 index 000000000..0160b78a5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2003, 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 +// . + +// 25.1.9 [lib.alg.search] + +// { dg-do compile } + +#include +#include + +struct Integral { operator int() const; }; + +namespace std +{ + template int* search_n (int*, int*, Integral, const int&); + template int* search_n (int*, int*, Integral, const int&, greater); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc new file mode 100644 index 000000000..3f15a4f5b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2005, 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 +// . + +// 25.1.9 search_n + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +struct Y { }; + +bool +operator==(const X&, const Y&) +{ return true; } + +forward_iterator_wrapper +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end, int i, Y& value) +{ return std::search_n(begin, end, i , value); } diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc new file mode 100644 index 000000000..d7be297f0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc @@ -0,0 +1,111 @@ +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 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 +// . + +// { dg-options "-DTEST_DEPTH=10" { target simulator } } + +// 25 algorithms, search_n + +#include +#include +#include +#include + +#ifndef TEST_DEPTH +#define TEST_DEPTH 14 +#endif + +int array1[11] = {0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0}; +int array2[TEST_DEPTH]; + +bool +pred(int i, int j) +{ + return i == j; +} + +bool +lexstep(int* start, int length) +{ + int i = 0; + int carry = 1; + while(i < length && carry) + { + if(start[i] == 1) + start[i] = 0; + else + { + start[i] = 1; + carry = 0; + } + i++; + } + return !carry; +} + +int main() +{ + using __gnu_test::test_container; + using __gnu_test::random_access_iterator_wrapper; + using __gnu_test::bidirectional_iterator_wrapper; + using __gnu_test::forward_iterator_wrapper; + + using std::search_n; + + test_container con(array1,array1 + 10); + VERIFY(search_n(con.end(), con.end(), 0, 1) == con.end()); + VERIFY(search_n(con.end(), con.end(), 1, 1) == con.end()); + VERIFY(search_n(con.begin(), con.end(), 1, 1).ptr == array1 + 1); + VERIFY(search_n(con.begin(), con.end(), 2, 1).ptr == array1 + 4); + VERIFY(search_n(con.begin(), con.end(), 3, 1).ptr == array1 + 7); + VERIFY(search_n(con.begin(), con.end(), 3, 0) == con.end()); + + // Now do a brute-force comparison of the different types + for(int i = 0; i < TEST_DEPTH; i++) + { + for(int j = 0; j < i; j++) + array2[i] = 0; + do { + for(int j = 0; j < i; j++) + { + test_container + forwardcon(array2, array2 + i); + test_container + randomcon(array2, array2 + i); + test_container + bidircon(array2, array2 + i); + + int* t1 = search_n(forwardcon.begin(), + forwardcon.end(), j, 1).ptr; + int* t2 = search_n(forwardcon.begin(), + forwardcon.end(), j, 1, pred).ptr; + int* t3 = search_n(bidircon.begin(), + bidircon.end(), j, 1).ptr; + int* t4 = search_n(bidircon.begin(), + bidircon.end(), j, 1, pred).ptr; + int* t5 = search_n(randomcon.begin(), + randomcon.end(), j, 1).ptr; + int* t6 = search_n(randomcon.begin(), + randomcon.end(), j, 1, pred).ptr; + VERIFY((t1 == t2) && (t2 == t3) && (t3 == t4) && + (t4 == t5) && (t5 == t6)); + } + } + while(lexstep(array2, i)); + } + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..9d86804eb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// 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 + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::size_t size_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&); + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..cba6b054c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// 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 + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::size_t size_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&); + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&, predicate_type); +} -- cgit v1.2.3