diff options
Diffstat (limited to 'libstdc++-v3/testsuite/26_numerics/headers')
36 files changed, 1630 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc new file mode 100644 index 000000000..29e8dac5f --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <ccomplex> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc new file mode 100644 index 000000000..3a1910692 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <cfenv> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cfenv/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/types_std_c++0x.cc new file mode 100644 index 000000000..dbe066ac0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cfenv/types_std_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cfenv> + +void test01() +{ +#if _GLIBCXX_USE_C99_FENV_TR1 + + typedef std::fenv_t my_fenv_t; + typedef std::fexcept_t my_fexcept_t; + +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/19322.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/19322.cc new file mode 100644 index 000000000..25494c357 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/19322.cc @@ -0,0 +1,35 @@ +// { dg-require-c-std "" } + +// Copyright (C) 2005, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <cmath> +#include <testsuite_hooks.h> + +// libstdc++/19322 +void test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( !std::isnan(3.0) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc new file mode 100644 index 000000000..025db2c2c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/25913.cc @@ -0,0 +1,38 @@ +// 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 +// <http://www.gnu.org/licenses/>. + + +// { dg-do compile } + +#include <cmath> +#include <string> + +struct employee +: private std::string { }; + +struct manager +: public employee { }; + +bool isnormal(const employee&) +{ return false; } + +// libstdc++/25913 +void test01() +{ + manager m; + isnormal(m); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc new file mode 100644 index 000000000..0cec658d8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/37582.cc @@ -0,0 +1,35 @@ +// 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 +// <http://www.gnu.org/licenses/>. + + +// { dg-do compile } + +#include <cmath> + +struct foo +{ + foo (double); +}; + +bool operator &&(int, const foo &); + +// libstdc++/37582 +double +test01(double x) +{ + return std::pow (x, 2.0); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++.cc new file mode 100644 index 000000000..3f4b8ba26 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++.cc @@ -0,0 +1,84 @@ +// 2001-04-06 gdr + +// Copyright (C) 2001, 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 +// <http://www.gnu.org/licenses/>. + + +// { dg-do compile { xfail uclibc } } +// { dg-excess-errors "" { target uclibc } } + +#include <cmath> + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + +#if _GLIBCXX_USE_C99_MATH +template <typename _Tp> + void test_c99_classify() + { + bool test __attribute__((unused)) = true; + + typedef _Tp fp_type; + fp_type f1 = 1.0; + fp_type f2 = 3.0; + int res = 0; + + res = std::fpclassify(f1); + res = std::isfinite(f2); + res = std::isinf(f1); + res = std::isnan(f2); + res = std::isnormal(f1); + res = std::signbit(f2); + res = std::isgreater(f1, f2); + res = std::isgreaterequal(f1, f2); + res = std::isless(f1, f2); + res = std::islessequal(f1,f2); + res = std::islessgreater(f1, f2); + res = std::isunordered(f1, f2); + res = res; // Suppress unused warning. + } +#endif + +int main() +{ +#if _GLIBCXX_USE_C99_MATH + test_c99_classify<float>(); + test_c99_classify<double>(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++0x.cc new file mode 100644 index 000000000..413fe6925 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c++0x.cc @@ -0,0 +1,92 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++0x" } +// { dg-do compile { xfail uclibc } } +// { dg-excess-errors "" { target uclibc } } + +#include <cmath> + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + +#if _GLIBCXX_USE_C99_MATH +template <typename _Tp, typename _Up = _Tp> + void test_c99_classify() + { + bool test __attribute__((unused)) = true; + + typedef _Tp fp_type_one; + typedef _Up fp_type_two; + fp_type_one f1 = 1.0; + fp_type_two f2 = 3.0; + int resi; + bool res; + + resi = std::fpclassify(f1); + res = std::isfinite(f2); + res = std::isinf(f1); + res = std::isnan(f2); + res = std::isnormal(f1); + res = std::signbit(f2); + res = std::isgreater(f1, f2); + res = std::isgreaterequal(f1, f2); + res = std::isless(f1, f2); + res = std::islessequal(f1,f2); + res = std::islessgreater(f1, f2); + res = std::isunordered(f1, f2); + resi = resi; // Suppress unused warning. + res = res; + } +#endif + +int main() +{ +#if _GLIBCXX_USE_C99_MATH + test_c99_classify<float>(); + test_c99_classify<double>(); + test_c99_classify<long double>(); + test_c99_classify<float, double>(); + test_c99_classify<float, long double>(); + test_c99_classify<double, float>(); + test_c99_classify<double, long double>(); + test_c99_classify<long double, float>(); + test_c99_classify<long double, double>(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc new file mode 100644 index 000000000..716dda51b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c99_classification_macros_c.cc @@ -0,0 +1,51 @@ +// 2001-04-06 gdr + +// Copyright (C) 2001, 2005, 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-add-options no_pch } + +// { dg-xfail-if "" { { *-*-linux* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* } || { uclibc || newlib } } { "*" } { "" } } +// { dg-excess-errors "" { target { { *-*-linux* *-*-darwin* *-*-solaris2.1[0-9]* hppa*-*-hpux* } || { uclibc || newlib } } } } + +#include <math.h> + +void fpclassify() { } + +void isfinite() { } + +void isinf() { } + +void isnan() { } + +void isnormal() { } + +void signbit() { } + +void isgreater() { } + +void isgreaterequal() { } + +void isless() { } + +void islessequal() { } + +void islessgreater() { } + +void isunordered() { } + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math.cc new file mode 100644 index 000000000..b8cf6e5e1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math.cc @@ -0,0 +1,70 @@ +// 1999-06-05 +// Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr> + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <cmath> +#include <testsuite_hooks.h> + +// test compilation. +int +test01() +{ + float a = 1.f; + float b; + std::modf(a, &b); + return 0; +} + +// need more extravagant checks than this, of course, but this used to core... +int +test02() +{ + std::sin(static_cast<float>(0)); + return 0; +} + +// as did this. +int +test03() +{ + double powtest __attribute__((unused)) = std::pow(2., 0); + return 0; +} + +// this used to abort. +int +test04() +{ + bool test __attribute__((unused)) = true; + float x[2] = {1, 2}; + float y = 3.4; + std::modf(y, &x[0]); + VERIFY(x[1] == 2); + return 0; +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math_dynamic.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math_dynamic.cc new file mode 100644 index 000000000..de4dbe39c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/c_math_dynamic.cc @@ -0,0 +1,49 @@ +// Inspired by libstdc++/7680 & 26_numerics/c_math.cc, 2003-04-12 ljr + +// 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 +// <http://www.gnu.org/licenses/>. + + +// { dg-do link } +// { dg-options "-D_XOPEN_SOURCE" { target *-*-freebsd* } } + +#include <cmath> + +int +test01() +{ + float a = 1.f; + float b; + std::modf(a, &b); + return 0; +} + +int +test02 () +{ + float a = 0.0f; + float b __attribute__((unused)) = std::acos(a); + return 0; +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc new file mode 100644 index 000000000..c8f7c5cc5 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/dr550.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// 2008-05-26 Paolo Carlini <paolo.carlini@oracle.com> +// +// 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 +// <http://www.gnu.org/licenses/>. + +#include <cmath> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +// DR 550. What should the return type of pow(float,int) be? +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::check_ret_type; + + const int i1 = 1; + const float f1 = 1.0f; + const double d1 = 1.0; + const long double ld1 = 1.0l; + + check_ret_type<double>(std::pow(f1, i1)); + VERIFY( std::pow(f1, i1) == std::pow(double(f1), double(i1)) ); + check_ret_type<double>(std::pow(d1, i1)); + check_ret_type<long double>(std::pow(ld1, i1)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/fabs_inline.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/fabs_inline.cc new file mode 100644 index 000000000..17057773e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/fabs_inline.cc @@ -0,0 +1,36 @@ +// Copyright (C) 1999, 2002, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// Test to see whether the host provides its own (inline) view of fabs. +// Origin: Kurt Garloff <kurt@garloff.de>, 2001-05-24 +// dg-do link + +#include <cmath> +#include <cstdio> + +typedef double (*realfn) (double); + +using std::fabs; + +int main () +{ + double a = fabs (-2.4); + realfn myfn = fabs; + double b = myfn (-2.5); + std::printf ("%f, %f, %p\n", a, b, myfn); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std.cc new file mode 100644 index 000000000..5226ee4eb --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/functions_std.cc @@ -0,0 +1,46 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cmath> + +namespace gnu +{ + using std::acos; + using std::asin; + using std::atan; + using std::atan2; + using std::ceil; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::floor; + using std::fmod; + using std::frexp; + using std::ldexp; + using std::log; + using std::log10; + using std::modf; + using std::pow; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/macros.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/macros.cc new file mode 100644 index 000000000..754f94402 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/macros.cc @@ -0,0 +1,27 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cmath> + +namespace gnu +{ +#ifndef HUGE_VAL + #error "HUGE_VAL_must_be_a_macro" +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc new file mode 100644 index 000000000..5819e1a18 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/overloads.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2003, 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 +// <http://www.gnu.org/licenses/>. + +// PR 3181 +// Origin: pete@toyon.com + +#include <cmath> + +int main() +{ + int i = -1; + int j = 9; + double ans; + ans = std::abs(i); + ans = std::acos(i); + ans = std::asin(i); + ans = std::atan(i); + ans = std::atan2(i, j); + ans = std::cos(i); + ans = std::cosh(i); + ans = std::exp(i); + ans = std::fabs(i); + ans = std::floor(i); + ans = std::log(i); + ans = std::log10(i); + ans = std::sqrt(i); + ans = std::sin(i); + ans = std::sinh(j); + ans = std::tan(i); + ans = std::tanh(i); + ans = ans; // Suppress unused warnings. +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/powi.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/powi.cc new file mode 100644 index 000000000..2af912357 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/powi.cc @@ -0,0 +1,63 @@ +// 2005-02-13 Paolo Carlini <pcarlini@suse.de> + +// Copyright (C) 2005, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 26.5 C Library + +#include <cmath> +#include <testsuite_hooks.h> + +template<typename T> + void test01_do() + { + using namespace std; + bool test __attribute__((unused)) = true; + + VERIFY( pow(T(1.0), 0) == T(1.0) ); + VERIFY( pow(T(2.0), 0) == T(1.0) ); + VERIFY( pow(T(-1.0), 0) == T(1.0) ); + VERIFY( pow(T(-4.0), 0) == T(1.0) ); + + VERIFY( pow(T(1.0), 1) == T(1.0) ); + VERIFY( pow(T(2.0), 1) == T(2.0) ); + VERIFY( pow(T(-1.0), 1) == T(-1.0) ); + VERIFY( pow(T(-4.0), 1) == T(-4.0) ); + + VERIFY( pow(T(1.0), -1) == T(1.0) / T(1.0) ); + VERIFY( pow(T(2.0), -1) == T(1.0) / T(2.0) ); + VERIFY( pow(T(-1.0), -1) == T(1.0) / T(-1.0) ); + VERIFY( pow(T(-4.0), -1) == T(1.0) / T(-4.0) ); + + VERIFY( pow(T(1.0), 2) == T(1.0) * T(1.0) ); + VERIFY( pow(T(2.0), 2) == T(2.0) * T(2.0) ); + VERIFY( pow(T(-1.0), 2) == T(-1.0) * T(-1.0) ); + VERIFY( pow(T(-4.0), 2) == T(-4.0) * T(-4.0) ); + } + +void test01() +{ + test01_do<float>(); + test01_do<double>(); + test01_do<long double>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x.cc new file mode 100644 index 000000000..7e4abe90e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cmath> + +void test01() +{ +#if _GLIBCXX_USE_C99_MATH_TR1 + + typedef std::double_t my_double_t; + typedef std::float_t my_float_t; + +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc new file mode 100644 index 000000000..27fd15cde --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cmath> + +namespace gnu +{ + // C++0x changes from TR1. + using std::assoc_laguerre; + using std::assoc_legendre; + using std::beta; + using std::comp_ellint_1; + using std::comp_ellint_2; + using std::comp_ellint_3; + using std::conf_hyperg; + using std::cyl_bessel_i; + using std::cyl_bessel_j; + using std::cyl_bessel_k; + using std::cyl_neumann; + using std::ellint_1; + using std::ellint_2; + using std::ellint_3; + using std::expint; + using std::hermite; + using std::hyperg; + using std::laguerre; + using std::legendre; + using std::riemann_zeta; + using std::sph_bessel; + using std::sph_legendre; + using std::sph_neumann; +} + +// { 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 } +// { dg-error "has not been declared" "" { target *-*-* } 30 } +// { dg-error "has not been declared" "" { target *-*-* } 31 } +// { dg-error "has not been declared" "" { target *-*-* } 32 } +// { dg-error "has not been declared" "" { target *-*-* } 33 } +// { dg-error "has not been declared" "" { target *-*-* } 34 } +// { dg-error "has not been declared" "" { target *-*-* } 35 } +// { dg-error "has not been declared" "" { target *-*-* } 36 } +// { dg-error "has not been declared" "" { target *-*-* } 37 } +// { dg-error "has not been declared" "" { target *-*-* } 38 } +// { dg-error "has not been declared" "" { target *-*-* } 39 } +// { dg-error "has not been declared" "" { target *-*-* } 40 } +// { dg-error "has not been declared" "" { target *-*-* } 41 } +// { dg-error "has not been declared" "" { target *-*-* } 42 } +// { dg-error "has not been declared" "" { target *-*-* } 43 } +// { dg-error "has not been declared" "" { target *-*-* } 44 } +// { dg-error "has not been declared" "" { target *-*-* } 45 } +// { dg-error "has not been declared" "" { target *-*-* } 46 } +// { dg-error "has not been declared" "" { target *-*-* } 47 } +// { dg-error "has not been declared" "" { target *-*-* } 48 } diff --git a/libstdc++-v3/testsuite/26_numerics/headers/complex/synopsis.cc b/libstdc++-v3/testsuite/26_numerics/headers/complex/synopsis.cc new file mode 100644 index 000000000..4d885930b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/complex/synopsis.cc @@ -0,0 +1,87 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <complex> + +namespace std { + template<class T> class complex; + template<> class complex<float>; + template<> class complex<double>; + template<> class complex<long double>; + + // 26.2.6 operators: + template<class T> + complex<T> operator+(const complex<T>&, const complex<T>&); + template<class T> complex<T> operator+(const complex<T>&, const T&); + template<class T> complex<T> operator+(const T&, const complex<T>&); + template<class T> complex<T> operator- + (const complex<T>&, const complex<T>&); + template<class T> complex<T> operator-(const complex<T>&, const T&); + template<class T> complex<T> operator-(const T&, const complex<T>&); + template<class T> complex<T> operator* + (const complex<T>&, const complex<T>&); + template<class T> complex<T> operator*(const complex<T>&, const T&); + template<class T> complex<T> operator*(const T&, const complex<T>&); + template<class T> complex<T> operator/ + (const complex<T>&, const complex<T>&); + template<class T> complex<T> operator/(const complex<T>&, const T&); + template<class T> complex<T> operator/(const T&, const complex<T>&); + template<class T> complex<T> operator+(const complex<T>&); + template<class T> complex<T> operator-(const complex<T>&); + template<class T> bool operator== + (const complex<T>&, const complex<T>&); + template<class T> bool operator==(const complex<T>&, const T&); + template<class T> bool operator==(const T&, const complex<T>&); + + + template<class T> bool operator!=(const complex<T>&, const complex<T>&); + template<class T> bool operator!=(const complex<T>&, const T&); + template<class T> bool operator!=(const T&, const complex<T>&); + template<class T, class charT, class traits> + basic_istream<charT, traits>& + operator>>(basic_istream<charT, traits>&, complex<T>&); + template<class T, class charT, class traits> + basic_ostream<charT, traits>& + operator<<(basic_ostream<charT, traits>&, const complex<T>&); + + // 26.2.7 values: + template<class T> T real(const complex<T>&); + template<class T> T imag(const complex<T>&); + template<class T> T abs(const complex<T>&); + template<class T> T arg(const complex<T>&); + template<class T> T norm(const complex<T>&); + template<class T> complex<T> conj(const complex<T>&); + template<class T> complex<T> polar(const T& rho, const T& theta = 0); + + // 26.2.8 transcendentals: + template<class T> complex<T> cos(const complex<T>&); + template<class T> complex<T> cosh(const complex<T>&); + template<class T> complex<T> exp(const complex<T>&); + template<class T> complex<T> log(const complex<T>&); + template<class T> complex<T> log10(const complex<T>&); + template<class T> complex<T> pow(const complex<T>&, int); + template<class T> complex<T> pow(const complex<T>&, const T&); + template<class T> complex<T> pow(const complex<T>&, const complex<T>&); + template<class T> complex<T> pow(const T&, const complex<T>&); + template<class T> complex<T> sin (const complex<T>&); + template<class T> complex<T> sinh(const complex<T>&); + template<class T> complex<T> sqrt(const complex<T>&); + template<class T> complex<T> tan(const complex<T>&); + template<class T> complex<T> tanh(const complex<T>&); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc new file mode 100644 index 000000000..ff40cd67c --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc @@ -0,0 +1,43 @@ +// 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 +// <http://www.gnu.org/licenses/>. + + +#include <cstdlib> +#include <testsuite_hooks.h> + +#if _GLIBCXX_USE_C99 +// libstdc++/13943 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + VERIFY( llabs(-3) == 3 ); + + lldiv_t q = lldiv(6, 4); + VERIFY( q.quot == 1 ); + VERIFY( q.rem == 2 ); +} +#endif + +int main() +{ +#if _GLIBCXX_USE_C99 + test01(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/2190.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/2190.cc new file mode 100644 index 000000000..b3a5075ed --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/2190.cc @@ -0,0 +1,36 @@ +// 2000-01-01 bkoz + +// Copyright (C) 2001, 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 +// <http://www.gnu.org/licenses/>. + +// 17.4.1.2 Headers, cstdlib + +#include <cstdlib> + +// libstdc++/2190 +void test01() +{ + long a __attribute__((unused)) = std::abs(1L); + std::div(2L, 1L); + std::ldiv_t b __attribute__((unused)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/functions_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/functions_std.cc new file mode 100644 index 000000000..b37b588aa --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/functions_std.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 +// <http://www.gnu.org/licenses/>. + +#include <cstdlib> + +namespace gnu +{ + using std::abs; + using std::div; + using std::labs; + using std::ldiv; + using std::srand; + using std::rand; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/macros.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/macros.cc new file mode 100644 index 000000000..5aa0889df --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/macros.cc @@ -0,0 +1,27 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cstdlib> + +namespace gnu +{ +#ifndef RAND_MAX + #error "RAND_MAX_must_be_a_macro" +#endif +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std.cc new file mode 100644 index 000000000..503caf1dd --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std.cc @@ -0,0 +1,26 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cstdlib> + +namespace gnu +{ + std::div_t d; + std::ldiv_t ld; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc new file mode 100644 index 000000000..0eb8b651a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <cstdlib> + +#if _GLIBCXX_HOSTED + +void test01() +{ +#if _GLIBCXX_USE_C99 + + typedef std::lldiv_t my_lldiv_t; + +#endif +} + +#endif diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc new file mode 100644 index 000000000..23b266e85 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <ctgmath> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/numeric_parallel_mode.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/numeric_parallel_mode.cc new file mode 100644 index 000000000..3db5fc22a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/numeric_parallel_mode.cc @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-D_GLIBCXX_PARALLEL -fopenmp" { target *-*-* } } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <numeric> diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric.cc new file mode 100644 index 000000000..452f8fe35 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric.cc @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <parallel/numeric> diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed1.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed1.cc new file mode 100644 index 000000000..a1ce8f052 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed1.cc @@ -0,0 +1,48 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <parallel/numeric> +#include <numeric> +#include <vector> +#include <numeric> + +void test() +{ + typedef unsigned short value_type; + typedef std::vector<value_type> vector_type; + + const value_type c(0); + + vector_type v(10); + + std::accumulate(v.begin(), v.end(), value_type(1)); + std::accumulate(v.begin(), v.end(), value_type(1), std::plus<value_type>()); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1)); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1), + std::plus<value_type>()); + + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed2.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed2.cc new file mode 100644 index 000000000..a38d92561 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/parallel_numeric_mixed2.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// 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 +// <http://www.gnu.org/licenses/>. + +// Make sure to test without _GLIBCXX_PARALLEL +#ifdef _GLIBCXX_PARALLEL +# undef _GLIBCXX_PARALLEL +#endif + +#include <parallel/numeric> +#include <numeric> +#include <vector> +#include <numeric> + +void test() +{ + typedef unsigned short value_type; + typedef std::vector<value_type> vector_type; + + const value_type c(0); + + vector_type v(10); + + std::accumulate(v.begin(), v.end(), value_type(1)); + std::accumulate(v.begin(), v.end(), value_type(1), std::plus<value_type>()); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1)); + __gnu_parallel::accumulate(v.begin(), v.end(), value_type(1), + std::plus<value_type>()); + + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + std::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1)); + __gnu_parallel::inner_product(v.begin(), v.end(), v.begin(), value_type(1), + std::multiplies<value_type>(), std::plus<value_type>()); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc b/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc new file mode 100644 index 000000000..21a21c9ff --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/numeric/synopsis.cc @@ -0,0 +1,64 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <numeric> + +namespace std { + template <class InputIterator, class T> + T accumulate(InputIterator first, InputIterator last, T init); + + template <class InputIterator, class T, class BinaryOperation> + T accumulate(InputIterator first, InputIterator last, T init, + BinaryOperation binary_op); + + template <class InputIterator1, class InputIterator2, class T> + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init); + + template <class InputIterator1, class InputIterator2, class T, + class BinaryOperation1, class BinaryOperation2> + T inner_product(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, T init, + BinaryOperation1 binary_op1, + BinaryOperation2 binary_op2); + + template <class InputIterator, class OutputIterator> + OutputIterator partial_sum(InputIterator first, + InputIterator last, + OutputIterator result); + + template <class InputIterator, class OutputIterator, + class BinaryOperation> + OutputIterator partial_sum(InputIterator first, + InputIterator last, + OutputIterator result, + BinaryOperation binary_op); + + template <class InputIterator, class OutputIterator> + OutputIterator adjacent_difference(InputIterator first, + InputIterator last, + OutputIterator result); + + template <class InputIterator, class OutputIterator, + class BinaryOperation> + OutputIterator adjacent_difference(InputIterator first, + InputIterator last, + OutputIterator result, + BinaryOperation binary_op); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc new file mode 100644 index 000000000..1f83cdac6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/random/std_c++0x_neg.cc @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <random> + +// { dg-error "upcoming ISO" "" { target *-*-* } 32 } + + + diff --git a/libstdc++-v3/testsuite/26_numerics/headers/random/types_std_c++0x.cc b/libstdc++-v3/testsuite/26_numerics/headers/random/types_std_c++0x.cc new file mode 100644 index 000000000..9f8ae967e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/random/types_std_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <random> + +namespace gnu +{ + using std::random_device; + using std::bernoulli_distribution; +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/valarray/synopsis.cc b/libstdc++-v3/testsuite/26_numerics/headers/valarray/synopsis.cc new file mode 100644 index 000000000..2f7b08468 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/valarray/synopsis.cc @@ -0,0 +1,127 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <valarray> + +namespace std { + template<class T> class valarray; + + class slice; + template<class T> class slice_array; + + class gslice; + template<class T> class gslice_array; + template<class T> class mask_array; + template<class T> class indirect_array; + template<class T> valarray<T> operator* + (const valarray<T>&, const valarray<T>&); + template<class T> valarray<T> operator* (const valarray<T>&, const T&); + template<class T> valarray<T> operator* (const T&, const valarray<T>&); + +template<class T> valarray<T> operator/ + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator/ (const valarray<T>&, const T&); +template<class T> valarray<T> operator/ (const T&, const valarray<T>&); +template<class T> valarray<T> operator% + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator% (const valarray<T>&, const T&); +template<class T> valarray<T> operator% (const T&, const valarray<T>&); +template<class T> valarray<T> operator+ + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator+ (const valarray<T>&, const T&); +template<class T> valarray<T> operator+ (const T&, const valarray<T>&); +template<class T> valarray<T> operator- + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator- (const valarray<T>&, const T&); +template<class T> valarray<T> operator- (const T&, const valarray<T>&); +template<class T> valarray<T> operator^ + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator^ (const valarray<T>&, const T&); +template<class T> valarray<T> operator^ (const T&, const valarray<T>&); +template<class T> valarray<T> operator& + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator& (const valarray<T>&, const T&); +template<class T> valarray<T> operator& (const T&, const valarray<T>&); +template<class T> valarray<T> operator| + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator| (const valarray<T>&, const T&); +template<class T> valarray<T> operator| (const T&, const valarray<T>&); +template<class T> valarray<T> operator<< + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator<<(const valarray<T>&, const T&); +template<class T> valarray<T> operator<<(const T&, const valarray<T>&); +template<class T> valarray<T> operator>> + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<T> operator>>(const valarray<T>&, const T&); +template<class T> valarray<T> operator>>(const T&, const valarray<T>&); +template<class T> valarray<bool> operator&& + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<bool> operator&&(const valarray<T>&, const T&); +template<class T> valarray<bool> operator&&(const T&, const valarray<T>&); +template<class T> valarray<bool> operator|| + (const valarray<T>&, const valarray<T>&); +template<class T> valarray<bool> operator||(const valarray<T>&, const T&); +template<class T> valarray<bool> operator||(const T&, const valarray<T>&); + + template<class T> + valarray<bool> operator==(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator==(const valarray<T>&, const T&); + template<class T> valarray<bool> operator==(const T&, const valarray<T>&); + template<class T> + valarray<bool> operator!=(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator!=(const valarray<T>&, const T&); + template<class T> valarray<bool> operator!=(const T&, const valarray<T>&); + template<class T> + valarray<bool> operator< (const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator< (const valarray<T>&, const T&); + template<class T> valarray<bool> operator< (const T&, const valarray<T>&); + template<class T> + valarray<bool> operator> (const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator> (const valarray<T>&, const T&); + template<class T> valarray<bool> operator> (const T&, const valarray<T>&); + template<class T> + valarray<bool> operator<=(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator<=(const valarray<T>&, const T&); + template<class T> valarray<bool> operator<=(const T&, const valarray<T>&); + template<class T> + valarray<bool> operator>=(const valarray<T>&, const valarray<T>&); + template<class T> valarray<bool> operator>=(const valarray<T>&, const T&); + template<class T> valarray<bool> operator>=(const T&, const valarray<T>&); + template<class T> valarray<T> abs (const valarray<T>&); + template<class T> valarray<T> acos (const valarray<T>&); + template<class T> valarray<T> asin (const valarray<T>&); + template<class T> valarray<T> atan (const valarray<T>&); + template<class T> valarray<T> atan2 + (const valarray<T>&, const valarray<T>&); + template<class T> valarray<T> atan2(const valarray<T>&, const T&); + template<class T> valarray<T> atan2(const T&, const valarray<T>&); + template<class T> valarray<T> cos (const valarray<T>&); + template<class T> valarray<T> cosh (const valarray<T>&); + template<class T> valarray<T> exp (const valarray<T>&); + template<class T> valarray<T> log (const valarray<T>&); + template<class T> valarray<T> log10(const valarray<T>&); + template<class T> valarray<T> pow(const valarray<T>&, const valarray<T>&); + template<class T> valarray<T> pow(const valarray<T>&, const T&); + template<class T> valarray<T> pow(const T&, const valarray<T>&); + template<class T> valarray<T> sin (const valarray<T>&); + template<class T> valarray<T> sinh (const valarray<T>&); + template<class T> valarray<T> sqrt (const valarray<T>&); + template<class T> valarray<T> tan (const valarray<T>&); + template<class T> valarray<T> tanh (const valarray<T>&); +} diff --git a/libstdc++-v3/testsuite/26_numerics/headers/valarray/types_std.cc b/libstdc++-v3/testsuite/26_numerics/headers/valarray/types_std.cc new file mode 100644 index 000000000..7c47f27f6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/valarray/types_std.cc @@ -0,0 +1,26 @@ +// { 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 +// <http://www.gnu.org/licenses/>. + +#include <valarray> + +namespace gnu +{ + typedef std::slice t1; + typedef std::gslice t2; +} |