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/26_numerics/valarray/27867.cc | 44 +++++ .../testsuite/26_numerics/valarray/28277.cc | 43 +++++ .../testsuite/26_numerics/valarray/30416.cc | 181 +++++++++++++++++++++ .../testsuite/26_numerics/valarray/33084.cc | 39 +++++ .../testsuite/26_numerics/valarray/40691.cc | 39 +++++ .../testsuite/26_numerics/valarray/algo.cc | 31 ++++ .../26_numerics/valarray/binary_closure.cc | 37 +++++ .../26_numerics/valarray/const_bracket.cc | 39 +++++ .../testsuite/26_numerics/valarray/dr543.cc | 39 +++++ .../testsuite/26_numerics/valarray/dr630-1.cc | 60 +++++++ .../testsuite/26_numerics/valarray/dr630-2.cc | 67 ++++++++ .../testsuite/26_numerics/valarray/init-list.cc | 49 ++++++ .../testsuite/26_numerics/valarray/name_lookup.cc | 133 +++++++++++++++ .../testsuite/26_numerics/valarray/operators.cc | 68 ++++++++ .../testsuite/26_numerics/valarray/range_access.cc | 31 ++++ .../requirements/explicit_instantiation.cc | 25 +++ .../26_numerics/valarray/requirements/typedefs.cc | 30 ++++ .../26_numerics/valarray/subset_assignment.cc | 78 +++++++++ 18 files changed, 1033 insertions(+) create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/27867.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/28277.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/30416.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/33084.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/40691.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/algo.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/const_bracket.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/dr630-1.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/dr630-2.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/name_lookup.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/operators.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/subset_assignment.cc (limited to 'libstdc++-v3/testsuite/26_numerics/valarray') diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/27867.cc b/libstdc++-v3/testsuite/26_numerics/valarray/27867.cc new file mode 100644 index 000000000..4100aa7c4 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/27867.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2006, 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 + +// libstdc++/27867 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::valarray v1(100, 1); + std::valarray v2(100, 1); + std::valarray v3(true, 1); + + std::valarray resl(1); + resl = ((v1 == v2) == v3); + VERIFY( resl[0] == true ); + + std::valarray resr(1); + resr = (v3 == (v1 == v2)); + VERIFY( resr[0] == true ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/28277.cc b/libstdc++-v3/testsuite/26_numerics/valarray/28277.cc new file mode 100644 index 000000000..7e619c020 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/28277.cc @@ -0,0 +1,43 @@ +// 2006-07-15 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// libstdc++/28277 +void test01() +{ + bool test __attribute__((unused)) = true; + + const std::valarray v1(1, 5000000); + + const std::valarray v2 = v1.shift(1); + VERIFY( v2.size() == v1.size() ); + VERIFY( v2[v1.size() - 1] == 0 ); + + const std::valarray v3 = v2.cshift(-1); + VERIFY( v3.size() == v2.size() ); + VERIFY( v3[0] == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/30416.cc b/libstdc++-v3/testsuite/26_numerics/valarray/30416.cc new file mode 100644 index 000000000..4ce8f75ed --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/30416.cc @@ -0,0 +1,181 @@ +// 2007-01-11 Paolo Carlini + +// 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 + +bool +comp_vala(const std::valarray& v1, const std::valarray& v2) +{ + if (v1.size() == v2.size()) + { + for (size_t i = 0; i < v1.size(); ++i) + if (v1[i] != v2[i]) + return false; + return true; + } + return false; +} + +void +init_vala(std::valarray& v, size_t first, size_t last, int val) +{ + for (size_t i = first; i <= last; ++i) + v[i] = val++; +} + +// libstdc++/30416 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + // shift + valarray v1; + valarray v1_ris(v1.shift(0)); + VERIFY( comp_vala(v1, v1_ris) ); + + valarray v2; + valarray v2_ris(v2.shift(10)); + VERIFY( comp_vala(v2, v2_ris) ); + + valarray v3; + valarray v3_ris(v3.shift(-10)); + VERIFY( comp_vala(v3, v3_ris) ); + + valarray v4(10); + valarray v4_ris(v4.shift(0)); + VERIFY( comp_vala(v4, v4_ris) ); + + valarray v5(10); + init_vala(v5, 0, 9, 1); + valarray v5_ref(10); + + valarray v5_ris(v5.shift(16)); + VERIFY( comp_vala(v5_ris, v5_ref) ); + + valarray v6(10); + init_vala(v6, 0, 9, 1); + valarray v6_ref(10); + + valarray v6_ris(v6.shift(-16)); + VERIFY( comp_vala(v6_ris, v6_ref) ); + + valarray v7(10); + init_vala(v7, 0, 9, 1); + valarray v7_ref(10); + + valarray v7_ris(v7.shift(10)); + VERIFY( comp_vala(v7_ris, v7_ref) ); + + valarray v8(10); + init_vala(v8, 0, 9, 1); + valarray v8_ref(10); + + valarray v8_ris(v8.shift(-10)); + VERIFY( comp_vala(v8_ris, v8_ref) ); + + valarray v9(10); + init_vala(v9, 0, 9, 1); + valarray v9_ref(10); + init_vala(v9_ref, 0, 3, 7); + + valarray v9_ris(v9.shift(6)); + VERIFY( comp_vala(v9_ris, v9_ref) ); + + valarray v10(10); + init_vala(v10, 0, 9, 1); + valarray v10_ref(10); + init_vala(v10_ref, 6, 9, 1); + + valarray v10_ris(v10.shift(-6)); + VERIFY( comp_vala(v10_ris, v10_ref) ); + + // cshift + valarray v11; + valarray v11_ris(v11.cshift(0)); + VERIFY( comp_vala(v11, v11_ris) ); + + valarray v12; + valarray v12_ris(v12.cshift(10)); + VERIFY( comp_vala(v12, v12_ris) ); + + valarray v13; + valarray v13_ris(v13.cshift(-10)); + VERIFY( comp_vala(v13, v13_ris) ); + + valarray v14(10); + valarray v14_ris(v14.cshift(0)); + VERIFY( comp_vala(v14, v14_ris) ); + + valarray v15(10); + init_vala(v15, 0, 9, 1); + valarray v15_ref(10); + init_vala(v15_ref, 0, 3, 7); + init_vala(v15_ref, 4, 9, 1); + + valarray v15_ris(v15.cshift(16)); + VERIFY( comp_vala(v15_ris, v15_ref) ); + + valarray v16(10); + init_vala(v16, 0, 9, 1); + valarray v16_ref(10); + init_vala(v16_ref, 0, 5, 5); + init_vala(v16_ref, 6, 9, 1); + + valarray v16_ris(v16.cshift(-16)); + VERIFY( comp_vala(v16_ris, v16_ref) ); + + valarray v17(10); + init_vala(v17, 0, 9, 1); + + valarray v17_ris(v15.cshift(10)); + VERIFY( comp_vala(v17, v17_ris) ); + + valarray v18(10); + init_vala(v18, 0, 9, 1); + + valarray v18_ris(v18.cshift(-10)); + VERIFY( comp_vala(v18, v18_ris) ); + + valarray v19(10); + init_vala(v19, 0, 9, 1); + valarray v19_ref(10); + init_vala(v19_ref, 0, 3, 7); + init_vala(v19_ref, 4, 9, 1); + + valarray v19_ris(v15.cshift(6)); + VERIFY( comp_vala(v19_ris, v19_ref) ); + + valarray v20(10); + init_vala(v20, 0, 9, 1); + valarray v20_ref(10); + init_vala(v20_ref, 0, 5, 5); + init_vala(v20_ref, 6, 9, 1); + + valarray v20_ris(v20.cshift(-6)); + VERIFY( comp_vala(v20_ris, v20_ref) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/33084.cc b/libstdc++-v3/testsuite/26_numerics/valarray/33084.cc new file mode 100644 index 000000000..918414197 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/33084.cc @@ -0,0 +1,39 @@ +// 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 +// . + + +// { dg-do compile } + +#include + +// libstdc++/33084 +void test01() +{ + std::valarray vc(char(0), 10); + std::valarray res(10); + char c(0); + + res = vc == vc; + res = vc == c; + res = c == vc; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/40691.cc b/libstdc++-v3/testsuite/26_numerics/valarray/40691.cc new file mode 100644 index 000000000..5524835a6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/40691.cc @@ -0,0 +1,39 @@ +// 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 +// . + +// { dg-do compile } + +#include + +// PR libstdc++/40691 +void test01() +{ + const std::valarray vi(12); + std::valarray vb1(12); + std::valarray vb2(3); + std::slice s(0,3,4); + + vb1 = !vi; + vb2 = !(std::valarray)vi[s]; + vb2 = !vi[s]; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/algo.cc b/libstdc++-v3/testsuite/26_numerics/valarray/algo.cc new file mode 100644 index 000000000..c12497611 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/algo.cc @@ -0,0 +1,31 @@ +// 19990404 gdr + +// Copyright (C) 1999, 2000, 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 + +int main() +{ + // 02: algo + using std::valarray; + valarray b, c; + double m __attribute__((unused)) = std::abs(b - c).max(); + + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc b/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc new file mode 100644 index 000000000..7dbcfbd52 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/binary_closure.cc @@ -0,0 +1,37 @@ +// 19990805 gdr +// +// XXX: to impove later. +// Origin: Andreas Amann +// CXXFLAGS: -g + +#include +#include + + +int main() +{ + std::valarray a(10), b(10), c(10), d(10); + + a = 1.2; + b = 3.1; + + c = 4.0; + + d = ( 2.0 * b + a ); // works + std::cout << "d[4] = " << d[4] << std::endl; + + d = (a * 2.0 + b ); // works + std::cout << "d[4] = " << d[4] << std::endl; + + d = (a + b * 2.0 ); // segfaults! + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + std::cout << "d[4] = " << d[4] << std::endl; + d = (a + 2.0* b ); + + std::cout << "d[4] = " << d[4] << std::endl; + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/const_bracket.cc b/libstdc++-v3/testsuite/26_numerics/valarray/const_bracket.cc new file mode 100644 index 000000000..abd9cd873 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/const_bracket.cc @@ -0,0 +1,39 @@ +// 20010518 gdr + +// Copyright (C) 2001, 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 + +// dg-do compile + +template + void copy(P, std::size_t) { } + +template + void test(const std::valarray& v) + { + copy(&v[0], v.size()); + } + +int main() +{ + std::valarray v(190); + test(v); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc b/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc new file mode 100644 index 000000000..e474ef998 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/dr543.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2006, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 543. valarray slice default constructor +void test01() +{ + bool test __attribute__((unused)) = true; + + std::valarray v1(10); + std::valarray v2 = v1[std::slice()]; + VERIFY( v2.size() == 0 ); + + std::valarray v3(10); + std::valarray v4 = v3[std::gslice()]; + VERIFY( v4.size() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/dr630-1.cc b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-1.cc new file mode 100644 index 000000000..9e5d14a28 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-1.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 630. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + valarray v1; + const valarray v2(-1, 10000); + + v1 = v2; + VERIFY( v1.size() == v2.size() ); + VERIFY( (v1 == v2).min() == true ); + + valarray v3(0, 10000); + const valarray v4; + + v3 = v4; + VERIFY( v3.size() == v4.size() ); + VERIFY( v3.size() == 0 ); + + valarray v5(0, 100); + const valarray v6(-1, 10000); + + v5 = v6; + VERIFY( v5.size() == v6.size() ); + VERIFY( (v5 == v6).min() == true ); + + valarray v7(0, 10000); + const valarray v8(-1, 100); + + v7 = v8; + VERIFY( v7.size() == v8.size() ); + VERIFY( (v7 == v8).min() == true ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/dr630-2.cc b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-2.cc new file mode 100644 index 000000000..ddb6bcaff --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/dr630-2.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// DR 630. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + valarray v1; + + v1 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + VERIFY( v1.size() == 10 ); + VERIFY( v1.min() == -1 ); + VERIFY( v1.max() == -1 ); + + valarray v2(0, 10); + + v2 = { }; + VERIFY( v2.size() == 0 ); + + valarray v3(0, 10); + + v3 = { -1, -1, -1, -1, -1 }; + VERIFY( v3.size() == 5 ); + VERIFY( v3.min() == -1 ); + VERIFY( v3.max() == -1 ); + + valarray v4(0, 5); + + v4 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + VERIFY( v4.size() == 10 ); + VERIFY( v4.min() == -1 ); + VERIFY( v4.max() == -1 ); + + valarray v5(0, 10); + + v5 = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + VERIFY( v5.size() == 10 ); + VERIFY( v5.min() == -1 ); + VERIFY( v5.max() == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc b/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc new file mode 100644 index 000000000..1c0665901 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more 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 "-std=gnu++0x" } + +#include +#include + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + valarray m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m[0] == 1); + VERIFY(m[1] == 5); + VERIFY(m[2] == 37); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m[0] == 28); + VERIFY(m[1] == 37); + VERIFY(m[2] == 102); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/name_lookup.cc b/libstdc++-v3/testsuite/26_numerics/valarray/name_lookup.cc new file mode 100644 index 000000000..65d679a21 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/name_lookup.cc @@ -0,0 +1,133 @@ +// 2002-08-02 gdr + +// Copyright (C) 2002, 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 +// . + + +// Test name lookup resolutions for standard functions applied to an +// array expression. +// { dg-do compile } + +#include + +namespace My +{ + struct Number + { + operator bool() const; + }; + + Number operator+(Number); + Number operator-(Number); + Number operator~(Number); + + bool operator!(Number); + + Number operator+(Number, Number); + Number operator-(Number, Number); + Number operator*(Number, Number); + Number operator/(Number, Number); + Number operator%(Number, Number); + + Number operator^(Number, Number); + Number operator&(Number, Number); + Number operator|(Number, Number); + + Number operator<<(Number, Number); + Number operator>>(Number, Number); + + bool operator==(Number, Number); + bool operator!=(Number, Number); + bool operator<(Number, Number); + bool operator<=(Number, Number); + bool operator>(Number, Number); + bool operator>=(Number, Number); + + Number abs(Number); + + Number cos(Number); + Number cosh(Number); + Number acos(Number); + + Number sin(Number); + Number sinh(Number); + Number asin(Number); + + Number tan(Number); + Number tanh(Number); + Number atan(Number); + + Number exp(Number); + Number log(Number); + Number log10(Number); + Number sqrt(Number); + + Number atan2(Number, Number); + Number pow(Number, Number); +} + +int main() +{ + typedef std::valarray Array; + Array u(10), v(10); + v = +u; + v = -u; + v = ~u; + std::valarray z = !u; + + v = abs(u); + + v = cos(u); + v = cosh(u); + v = acos(u); + + v = sin(u); + v = sinh(u); + v = asin(u); + + v = tan(u); + v = tanh(u); + v = atan(u); + + v = exp(u); + v = log(u); + v = log10(u); + v = sqrt(u); + + Array w = u + v; + w = u - v; + w = u * v; + w = u / v; + w = u % v; + + w = u ^ v; + w = u & v; + w = u | v; + + w = u << v; + w = u >> v; + + z = u == v; + z = u != v; + z = u < v; + z = u <= v; + z = u > v; + z = u >= v; + + w = atan2(u, v); + w = pow(u, v); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/operators.cc b/libstdc++-v3/testsuite/26_numerics/valarray/operators.cc new file mode 100644 index 000000000..82904334a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/operators.cc @@ -0,0 +1,68 @@ +// { dg-do run } +// 2003-02-03 Volker Reichelt + +// Copyright (C) 2003, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +void test01() // check unary operators +{ + bool test __attribute__((unused)) = true; + std::valarray u(1); + u[0]=1; + + VERIFY( (+u)[0] == +1 ); + VERIFY( (-u)[0] == -1 ); + VERIFY( (!u)[0] == !1 ); + VERIFY( (~u)[0] == ~1 ); +} + +void test02() // check binary operators +{ + bool test __attribute__((unused)) = true; + std::valarray u(1), v(1); + u[0]=1; + v[0]=3; + + VERIFY( (u+ v)[0] == (1+ 3) ); + VERIFY( (u- v)[0] == (1- 3) ); + VERIFY( (u* v)[0] == (1* 3) ); + VERIFY( (u/ v)[0] == (1/ 3) ); + VERIFY( (u% v)[0] == (1% 3) ); + VERIFY( (u^ v)[0] == (1^ 3) ); + VERIFY( (u& v)[0] == (1& 3) ); + VERIFY( (u| v)[0] == (1| 3) ); + VERIFY( (u<>v)[0] == (1>>3) ); + VERIFY( (u&&v)[0] == (1&&3) ); + VERIFY( (u||v)[0] == (1||3) ); + VERIFY( (u==v)[0] == (1==3) ); + VERIFY( (u!=v)[0] == (1!=3) ); + VERIFY( (u< v)[0] == (1< 3) ); + VERIFY( (u> v)[0] == (1> 3) ); + VERIFY( (u<=v)[0] == (1<=3) ); + VERIFY( (u>=v)[0] == (1>=3) ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc new file mode 100644 index 000000000..10f67dac8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/range_access.cc @@ -0,0 +1,31 @@ +// { 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 +// . + +// 26.6.10 valarray range access: [valarray.range] + +#include + +void +test01() +{ + std::valarray va{1.0, 2.0, 3.0}; + std::begin(va); + std::end(va); +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/explicit_instantiation.cc new file mode 100644 index 000000000..d63ea7c75 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/explicit_instantiation.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::valarray; diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/typedefs.cc new file mode 100644 index 000000000..6501d0738 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { 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 +// . + + +// 6.2.2 Class template array + +#include + +void test01() +{ + // Check for required typedefs + typedef std::valarray test_type; + typedef test_type::value_type value_type; +} diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/subset_assignment.cc b/libstdc++-v3/testsuite/26_numerics/valarray/subset_assignment.cc new file mode 100644 index 000000000..00ec70b60 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/subset_assignment.cc @@ -0,0 +1,78 @@ +// 2004-01-03 Jerry Quinn + +// Copyright (C) 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 +// . + + +// PR 3247 + +// This is DR-253. Test for accessible assignment-operators. +#include +#include + +bool check_array(std::valarray& a, double b[]) +{ + for (unsigned int i=0; i < a.size(); i++) + if (a[i] != b[i]) return false; + return true; +} + +int main() +{ + std::valarray val_d(10); // 0 1 2 3 4 5 6 7 8 9 + std::valarray val_d1(10); // 10 9 8 7 6 5 4 3 2 1 + + for (int i=0; i< 10; i++) { val_d[i] = 10; val_d1[i] = i; } + std::valarray val_c(val_d); + std::valarray val_f(val_d); + std::valarray val_g(val_d); + + std::slice slc(1, 3, 3); // 1 4 7 + val_d[slc] = val_d1[slc]; + + double ans1[10] = {10, 1, 10, 10, 4, 10, 10, 7, 10, 10}; + VERIFY(check_array(val_d, ans1)); + + std::valarray val_size(2); + std::valarray val_stride(2); + val_size[0] = 2; val_size[1] = 3; + val_stride[0] = 4; val_stride[1] = 1; + + std::gslice gslc(1, val_size, val_stride); + val_c[gslc] = val_d1[gslc]; + + double ans2[10] = {10, 1, 2, 3, 10, 5, 6, 7, 10, 10}; + VERIFY(check_array(val_c, ans2)); + + std::valarray val_b(false, 10); + val_b[2] = val_b[6] = val_b[9] = true; + val_f[val_b] = val_d1[val_b]; + + double ans3[10] = {10, 10, 2, 10, 10, 10, 6, 10, 10, 9}; + VERIFY(check_array(val_f, ans3)); + + size_t addr[] = {1, 2, 3, 4, 5}; + size_t addr1[] = {2, 7, 1, 9, 4}; + std::valarray val_indirect(addr, 5); + std::valarray val_indirect1(addr1, 5); + val_g[val_indirect] = val_d1[val_indirect1]; + + double ans4[10] = {10, 2, 7, 1, 9, 4, 10, 10, 10, 10}; + VERIFY(check_array(val_g, ans4)); + + return 0; +}; -- cgit v1.2.3