diff options
Diffstat (limited to 'libstdc++-v3/testsuite')
62 files changed, 3792 insertions, 108 deletions
diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc b/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc index 40d8219093e..56b4e4f413e 100644 --- a/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/duration/cons/1_neg.cc @@ -26,7 +26,7 @@ void test01() { - std::chrono::duration<int> d1(1.0); + std::chrono::duration<int> d1(1.0); // { dg-error "no matching" } } void @@ -35,11 +35,7 @@ test02() using namespace std::chrono; duration<int, std::micro> d2(8); - duration<int, std::milli> d2_copy(d2); + duration<int, std::milli> d2_copy(d2); // { dg-error "no matching" } } -// { dg-error "instantiated from here" "" { target *-*-* } 29 } -// { dg-error "instantiated from here" "" { target *-*-* } 38 } -// { dg-error "not exactly representable" "" { target *-*-* } 227 } -// { dg-error "integral duration with floating point" "" { target *-*-* } 217 } -// { dg-excess-errors "In instantiation of" } +// { dg-excess-errors "candidates are" } diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc b/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc new file mode 100644 index 00000000000..4466d30097a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/duration/cons/dr974.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 20.8.3.1 duration constructors [time.duration.cons] + +#include <chrono> + +// DR 974. +void test01() +{ + using namespace std::chrono; + + duration<double> d(3.5); + duration<int> i = d; // { dg-error "conversion" } +} diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc index e8b6d33a1ea..297b5cb690d 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg1.cc @@ -31,6 +31,6 @@ void test01() test_type d; } -// { dg-error "rep cannot be a duration" "" { target *-*-* } 202 } +// { dg-error "rep cannot be a duration" "" { target *-*-* } 203 } // { dg-error "instantiated from here" "" { target *-*-* } 31 } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc index 91081836779..b83bf494db5 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg2.cc @@ -32,6 +32,6 @@ void test01() test_type d; } -// { dg-error "must be a specialization of ratio" "" { target *-*-* } 203 } +// { dg-error "must be a specialization of ratio" "" { target *-*-* } 204 } // { dg-error "instantiated from here" "" { target *-*-* } 32 } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc index 540d72dde46..b4224401d47 100644 --- a/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc +++ b/libstdc++-v3/testsuite/20_util/duration/requirements/typedefs_neg3.cc @@ -33,6 +33,6 @@ void test01() test_type d; } -// { dg-error "period must be positive" "" { target *-*-* } 205 } +// { dg-error "period must be positive" "" { target *-*-* } 206 } // { dg-error "instantiated from here" "" { target *-*-* } 33 } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..646c4b25b0a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/explicit_instantiation.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef short test_type; + template struct is_convertible<test_type, test_type>; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc new file mode 100644 index 00000000000..1e8deb511c8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + // Check for required typedefs + typedef std::is_convertible<int, int> test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc new file mode 100644 index 00000000000..6ec22d024a9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc @@ -0,0 +1,102 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-10-29 Paolo Carlini <paolo.carlini@oracle.com> +// +// 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 +// <http://www.gnu.org/licenses/>. + +#include <type_traits> +#include <testsuite_hooks.h> +#include <testsuite_tr1.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_convertible; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_relationship<is_convertible, int, int>(true)) ); + VERIFY( (test_relationship<is_convertible, int, const int>(true)) ); + VERIFY( (test_relationship<is_convertible, volatile int, const int>(true)) ); + VERIFY( (test_relationship<is_convertible, int, float>(true)) ); + VERIFY( (test_relationship<is_convertible, double, float>(true)) ); + VERIFY( (test_relationship<is_convertible, float, int>(true)) ); + VERIFY( (test_relationship<is_convertible, int*, const int*>(true)) ); + VERIFY( (test_relationship<is_convertible, int*, void*>(true)) ); + VERIFY( (test_relationship<is_convertible, int[4], int*>(true)) ); + VERIFY( (test_relationship<is_convertible, float&, int>(true)) ); + VERIFY( (test_relationship<is_convertible, int, const int&>(true)) ); + VERIFY( (test_relationship<is_convertible, const int&, int>(true)) ); + VERIFY( (test_relationship<is_convertible, float, const int&>(true)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(*)(int)>(true)) ); + VERIFY( (test_relationship<is_convertible, int(&)(int), int(*)(int)>(true)) ); + VERIFY( (test_relationship<is_convertible, EnumType, int>(true)) ); + VERIFY( (test_relationship<is_convertible, ClassType, ClassType>(true)) ); + VERIFY( (test_relationship<is_convertible, DerivedType, ClassType>(true)) ); + VERIFY( (test_relationship<is_convertible, DerivedType*, ClassType*>(true)) ); + VERIFY( (test_relationship<is_convertible, DerivedType&, ClassType&>(true)) ); + + VERIFY( (test_relationship<is_convertible, const int, const int&>(true)) ); + + VERIFY( (test_relationship<is_convertible, void, void>(true)) ); + VERIFY( (test_relationship<is_convertible, const void, void>(true)) ); + VERIFY( (test_relationship<is_convertible, void, volatile void>(true)) ); + + // Negative tests. + VERIFY( (test_relationship<is_convertible, const int*, int*>(false)) ); + VERIFY( (test_relationship<is_convertible, int*, float*>(false)) ); + VERIFY( (test_relationship<is_convertible, const int[4], int*>(false)) ); + VERIFY( (test_relationship<is_convertible, int[4], int[4]>(false)) ); + VERIFY( (test_relationship<is_convertible, const int&, int&>(false)) ); + VERIFY( (test_relationship<is_convertible, float&, int&>(false)) ); + VERIFY( (test_relationship<is_convertible, float, volatile int&>(false)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(int)>(false)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(*)(void)>(false)) ); + VERIFY( (test_relationship<is_convertible, int(*)(int), + int(&)(int)>(false)) ); + VERIFY( (test_relationship<is_convertible, int, EnumType>(false)) ); + VERIFY( (test_relationship<is_convertible, int, ClassType>(false)) ); + VERIFY( (test_relationship<is_convertible, ClassType, DerivedType>(false)) ); + VERIFY( (test_relationship<is_convertible, ClassType*, + DerivedType*>(false)) ); + VERIFY( (test_relationship<is_convertible, ClassType&, + DerivedType&>(false)) ); + + VERIFY( (test_relationship<is_convertible, void, int>(false)) ); + VERIFY( (test_relationship<is_convertible, void, float>(false)) ); + VERIFY( (test_relationship<is_convertible, void, int(*)(int)>(false)) ); + + // C++0x + VERIFY( (test_relationship<is_convertible, int, void>(false)) ); + VERIFY( (test_relationship<is_convertible, int[4], void>(false)) ); + + VERIFY( (test_relationship<is_convertible, int, int&>(false)) ); + VERIFY( (test_relationship<is_convertible, float, + volatile float&>(false)) ); + VERIFY( (test_relationship<is_convertible, const volatile int, + const volatile int&>(false)) ); + VERIFY( (test_relationship<is_convertible, volatile int, + volatile int&>(false)) ); + VERIFY( (test_relationship<is_convertible, int(int), int(&)(int)>(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 3455462869b..2ae375454e0 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -3,7 +3,7 @@ // 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> // -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 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 @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 570 } -// { dg-error "declaration of" "" { target *-*-* } 532 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 547 } +// { dg-error "declaration of" "" { target *-*-* } 509 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 3d3a10a9ba8..5bf030cabcb 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -3,7 +3,7 @@ // 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> // -// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// Copyright (C) 2007, 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 @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 491 } -// { dg-error "declaration of" "" { target *-*-* } 453 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 468 } +// { dg-error "declaration of" "" { target *-*-* } 430 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/pair/40925.cc b/libstdc++-v3/testsuite/20_util/pair/40925.cc new file mode 100644 index 00000000000..6abeb617fa0 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/40925.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include <utility> + +struct X +{ + explicit X(int, int) { } + +private: + X(const X&) = delete; +}; + +struct move_only +{ + move_only() { } + move_only(move_only&&) { } + +private: + move_only(const move_only&) = delete; +}; + +// libstdc++/40925 +void test01() +{ + int *ip = 0; + int X::*mp = 0; + + std::pair<int*, int*> p1(0, 0); + std::pair<int*, int*> p2(ip, 0); + std::pair<int*, int*> p3(0, ip); + std::pair<int*, int*> p4(ip, ip); + + std::pair<int X::*, int*> p5(0, 0); + std::pair<int X::*, int X::*> p6(mp, 0); + std::pair<int X::*, int X::*> p7(0, mp); + std::pair<int X::*, int X::*> p8(mp, mp); + + std::pair<int*, move_only> p9(0, move_only()); + std::pair<int X::*, move_only> p10(0, move_only()); + std::pair<move_only, int*> p11(move_only(), 0); + std::pair<move_only, int X::*> p12(move_only(), 0); + + std::pair<int*, move_only> p13(ip, move_only()); + std::pair<int X::*, move_only> p14(mp, move_only()); + std::pair<move_only, int*> p15(move_only(), ip); + std::pair<move_only, int X::*> p16(move_only(), mp); + + std::pair<move_only, move_only> p17(move_only(), move_only()); +} diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc new file mode 100644 index 00000000000..6bd405c093b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/41530.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// Tuple + +#include <tuple> + +class A {}; +class B : public A {}; + +// PR libstdc++/41530 +void test01() +{ + std::tuple<B*> b; + std::tuple<A*> a1(b); + std::tuple<A*> a2(std::move(b)); +} diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc index f0236eb2637..bf49aa6b080 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc @@ -49,10 +49,13 @@ test03() std::unique_ptr<int[2]> p2 = p1; } +// { dg-error "deleted function" "" { target *-*-* } 358 } // { dg-error "used here" "" { target *-*-* } 42 } // { dg-error "no matching" "" { target *-*-* } 48 } -// { dg-error "used here" "" { target *-*-* } 49 } -// { dg-error "candidates are" "" { target *-*-* } 213 } +// { dg-warning "candidates are" "" { target *-*-* } 119 } +// { dg-warning "note" "" { target *-*-* } 112 } +// { dg-warning "note" "" { target *-*-* } 107 } +// { dg-warning "note" "" { target *-*-* } 102 } +// { dg-warning "note" "" { target *-*-* } 96 } // { dg-error "deleted function" "" { target *-*-* } 213 } -// { dg-error "deleted function" "" { target *-*-* } 358 } -// { dg-excess-errors "note" } +// { dg-error "used here" "" { target *-*-* } 49 } diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/5.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc index edabe1fcc29..edabe1fcc29 100644 --- a/libstdc++-v3/testsuite/25_algorithms/fill/5.cc +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc new file mode 100644 index 00000000000..4b07a63edee --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, bidirectional_iterator_wrapper> container; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int array[]={0,2,4,1,3,5}; + rvalstruct rv_array[6]; + std::copy(array, array + 6, rv_array); + container con(rv_array, rv_array + 6); + std::inplace_merge(con.begin(), con.it(3), con.end()); + VERIFY( rv_array[0] == 0 && rv_array[1] == 1 && rv_array[2] == 2 + && rv_array[3] == 3 && rv_array[4] == 4 && rv_array[5] == 5 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc new file mode 100644 index 00000000000..32ab3c70c6b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, bidirectional_iterator_wrapper> container; + +bool +are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int array[]={0,2,4,1,3,5}; + rvalstruct rv_array[6]; + std::copy(array, array + 6, rv_array); + container con(rv_array, rv_array + 6); + std::inplace_merge(con.begin(), con.it(3), con.end(), are_ordered); + VERIFY( rv_array[0] == 0 && rv_array[1] == 1 && rv_array[2] == 2 + && rv_array[3] == 3 && rv_array[4] == 4 && rv_array[5] == 5 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc new file mode 100644 index 00000000000..d48d6029a52 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 25.2.10 rotate + +// Tests rotate when an moveable class is used + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, forward_iterator_wrapper> Fcontainer; +typedef test_container<rvalstruct, bidirectional_iterator_wrapper> Bcontainer; +typedef test_container<rvalstruct, random_access_iterator_wrapper> Rcontainer; + +template<typename Con> + void + test_con(int length, int rotate_pos) + { + bool test __attribute__((unused)) = true; + + rvalstruct array[length]; + for(int i = 0; i < length; ++i) + array[i] = i; + Con con(array, array + length); + std::rotate(con.begin(), con.it(rotate_pos), con.end()); + + if(length != 0) + { + for(int i = 0; i < length; ++i) + VERIFY( array[i].valid && array[i].val == (i + rotate_pos) % length ); + } + } + +void +test01() +{ + for(int i = 0; i < 20; ++i) + { + for(int j = 0; j <= i; ++j) + { + test_con<Fcontainer>(i, j); + test_con<Bcontainer>(i, j); + test_con<Rcontainer>(i, j); + } + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc new file mode 100644 index 00000000000..193f1312849 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 25.2.12 [lib.alg.partitions] Partitions. + +#include <algorithm> +#include <functional> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, random_access_iterator_wrapper> Container; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N = sizeof(A) / sizeof(int); + +struct Pred +{ + bool + operator()(const rvalstruct& x) const + { return (x.val % 2) == 0; } +}; + +// 25.2.12 stable_partition() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + + std::stable_partition(con.begin(), con.end(), Pred()); + VERIFY( std::equal(s1, s1 + N, B) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc new file mode 100644 index 00000000000..09d6129c06c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 25.3.1.2 [lib.stable.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, random_access_iterator_wrapper> Container; + +const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; +const int N = sizeof(A) / sizeof(int); + +// 25.3.1.2 stable_sort() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end()); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc new file mode 100644 index 00000000000..86ff353967d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// <http://www.gnu.org/licenses/>. + +// 25.3.1.2 [lib.stable.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> +#include <testsuite_rvalref.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container<rvalstruct, random_access_iterator_wrapper> Container; + +const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; +const int N = sizeof(A) / sizeof(int); + +bool order(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +// 25.3.1.2 stable_sort() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end(), order); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc index 328dd71d0bb..6c8498e7b10 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc @@ -31,7 +31,7 @@ test01() { bool test __attribute__((unused)) = true; - typedef std::subtract_with_carry_engine<long, 24, 10, 24> + typedef std::subtract_with_carry_engine<unsigned long, 24, 10, 24> base_engine; base_engine b; diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc index 990dc9b3fe9..fabe17a2b56 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc @@ -31,7 +31,7 @@ test01() { bool test __attribute__((unused)) = true; - typedef std::subtract_with_carry_engine<long, 24, 10, 24> + typedef std::subtract_with_carry_engine<unsigned long, 24, 10, 24> base_engine; std::discard_block_engine<base_engine, 389, 24> diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc index 17fea5bdb47..926bb2c24db 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc @@ -33,7 +33,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine<long, 24, 10, 24>, + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, 389, 24 > e; } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc index efe194c99f0..4cedeb85d39 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc @@ -35,7 +35,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine<long, 24, 10, 24>, + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, 389, 24 > e(seed); } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc index 82f6fdb1c74..b66752c2b6e 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc @@ -35,7 +35,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine<long, 24, 10, 24>, + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, 389, 24 > e(seed); } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc index 58f0f1c392a..aa86b9afedc 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc @@ -35,7 +35,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine<long, 24, 10, 24>, + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, 389, 24 > e(seq); } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc index db2497540a3..5d63114fef3 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc @@ -33,7 +33,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine<long, 24, 10, 24>, + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, 389, 24 > u, v; diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc index 1d39a213f47..7aec649c03b 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc @@ -35,7 +35,7 @@ test01() std::stringstream str; std::discard_block_engine < - std::subtract_with_carry_engine<long, 24, 10, 24>, + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, 389, 24 > u, v; diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc index 379b3aeb978..6e23316caa1 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc @@ -31,7 +31,7 @@ test01() { typedef std::discard_block_engine < - std::subtract_with_carry_engine<long, 24, 10, 24>, + std::subtract_with_carry_engine<unsigned long, 24, 10, 24>, 389, 24 > test_type; diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc index f54d76ada07..18fb44fdac5 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc @@ -19,7 +19,7 @@ // <http://www.gnu.org/licenses/>. // { dg-do compile } -// { dg-options "-std=c++0x -D_GLIBCXX_CONCEPT_CHECKS" } +// { dg-options "-std=c++0x" } // { dg-require-cstdint "" } // { dg-error "not a valid type" "" { target *-*-* } 32 } // { dg-error "invalid type" "" { target *-*-* } 32 } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.c b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.c new file mode 100644 index 00000000000..3fd2f2c799d --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.c @@ -0,0 +1,34 @@ +// { dg-options "-x c -shared-libgcc -lstdc++" } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <cassert> +#include <stdatomic.h> + +// libstdc++/40826 +// libstdc++/40654 +int main() +{ + atomic_flag f = ATOMIC_FLAG_INIT; + + atomic_flag_clear(&f); // set to false + assert( false == atomic_flag_test_and_set(&f) ); // return previous false, set to true + assert( true == atomic_flag_test_and_set(&f) ); // return true + + return 0; +} diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc new file mode 100644 index 00000000000..6cb09f34b7a --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/clear/1.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// <http://www.gnu.org/licenses/>. + +#include <cstdatomic> +#include <testsuite_hooks.h> + +int main() +{ + bool test __attribute__((unused)) = true; + std::atomic_flag f = ATOMIC_FLAG_INIT; + + f.clear(); // set to false + VERIFY( false == f.test_and_set() ); // return previous false, set to true + VERIFY( true == f.test_and_set() ); // return true + + return 0; +} diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_flag/cons/1.cc b/libstdc++-v3/testsuite/29_atomics/atomic_flag/cons/1.cc new file mode 100644 index 00000000000..cfb0c1bbb7a --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic_flag/cons/1.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 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 <stdatomic.h> + +void test01() +{ + using namespace std; + atomic_flag af = ATOMIC_FLAG_INIT; +} diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc index 0bad6ba2f32..db3baf35772 100644 --- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc @@ -33,4 +33,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 32 } -// { dg-error "deleted function" "" { target *-*-* } 862 } +// { dg-error "deleted function" "" { target *-*-* } 912 } diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc index 655ca8c2f95..8e57d3198f4 100644 --- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc @@ -32,4 +32,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 31 } -// { dg-error "deleted function" "" { target *-*-* } 861 } +// { dg-error "deleted function" "" { target *-*-* } 911 } diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc index f2fbf178c36..5e16d145ccc 100644 --- a/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc @@ -33,4 +33,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 32 } -// { dg-error "deleted function" "" { target *-*-* } 588 } +// { dg-error "deleted function" "" { target *-*-* } 630 } diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc index 17757aed0ad..1e857977927 100644 --- a/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc @@ -32,4 +32,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 31 } -// { dg-error "deleted function" "" { target *-*-* } 572 } +// { dg-error "deleted function" "" { target *-*-* } 614 } diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc index 868e0b8a4b8..26211fe1c76 100644 --- a/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc @@ -35,4 +35,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 34 } -// { dg-error "deleted function" "" { target *-*-* } 481 } +// { dg-error "deleted function" "" { target *-*-* } 514 } diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc index f8f5a690cf4..e29148ee785 100644 --- a/libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc @@ -35,4 +35,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 34 } -// { dg-error "deleted function" "" { target *-*-* } 401 } +// { dg-error "deleted function" "" { target *-*-* } 440 } diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc index 95b5a1d7d9a..8134c7d9219 100644 --- a/libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc @@ -34,4 +34,4 @@ void test01() } // { dg-error "used here" "" { target *-*-* } 33 } -// { dg-error "deleted function" "" { target *-*-* } 400 } +// { dg-error "deleted function" "" { target *-*-* } 439 } diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index da2a59ad8bc..cae3d6c07fe 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -299,7 +299,7 @@ libgomp_flags = -B${glibcxx_builddir}/../libgomp \ atomic_flags = $(ATOMIC_FLAGS) parallel_flags = "unix/-D_GLIBCXX_PARALLEL/-fopenmp" -# Runs the testsuite in profile +# Runs the testsuite in profile mode. profile_flags = "unix/-D_GLIBCXX_PROFILE" # By adding these files here, automake will remove them for 'make clean' @@ -652,7 +652,7 @@ check-profile: site.exp fi; \ srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ EXPECT=$(EXPECT); export EXPECT; \ - $(MAKE) CXXFLAGS="$(atomic_flags)" RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; ) + $(MAKE) CXXFLAGS="$(atomic_flags) " RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; ) .PHONY: baseline_symbols new-abi-baseline \ check-abi check-compile check-performance check-parallel check-profile diff --git a/libstdc++-v3/testsuite/decimal/binary-arith.cc b/libstdc++-v3/testsuite/decimal/binary-arith.cc new file mode 100644 index 00000000000..180bca57167 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/binary-arith.cc @@ -0,0 +1,372 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.8 Binary arithmetic operators. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +decimal32 d32 (5); +decimal64 d64 (-10); +decimal128 d128 (25); +int si = -20; +unsigned int ui = 50; +long sl = -10; +unsigned long ul = 20; +long long sll = -25; +unsigned long long ull = 50; + +void +binary_add_32 (void) +{ + decimal32 a (1000), b; + + b = si + a; VERIFY (b == 980); + b = ui + a; VERIFY (b == 1050); + b = sl + a; VERIFY (b == 990); + b = ul + a; VERIFY (b == 1020); + b = sll + a; VERIFY (b == 975); + b = ull + a; VERIFY (b == 1050); + b = d32 + a; VERIFY (b == 1005); + b = (decimal32)(d64 + a); VERIFY (b == 990); + b = (decimal32)(d128 + a); VERIFY (b == 1025); + + b = a + si; VERIFY (b == 980); + b = a + ui; VERIFY (b == 1050); + b = a + sl; VERIFY (b == 990); + b = a + ul; VERIFY (b == 1020); + b = a + sll; VERIFY (b == 975); + b = a + ull; VERIFY (b == 1050); + b = a + d32; VERIFY (b == 1005); + b = (decimal32)(a + d64); VERIFY (b == 990); + b = (decimal32)(a + d128); VERIFY (b == 1025); +} + +void +binary_subtract_32 (void) +{ + decimal32 a (1000), b; + + b = a - si; VERIFY (b == 1020); + b = a - ui; VERIFY (b == 950); + b = a - sl; VERIFY (b == 1010); + b = a - ul; VERIFY (b == 980); + b = a - sll; VERIFY (b == 1025); + b = a - ull; VERIFY (b == 950); + b = a - d32; VERIFY (b == 995); + b = (decimal32)(a - d64); VERIFY (b == 1010); + b = (decimal32)(a - d128); VERIFY (b == 975); + + a = -1000; + b = si - a; VERIFY (b == 980); + b = ui - a; VERIFY (b == 1050); + b = sl - a; VERIFY (b == 990); + b = ul - a; VERIFY (b == 1020); + b = sll - a; VERIFY (b == 975); + b = ull - a; VERIFY (b == 1050); + b = d32 - a; VERIFY (b == 1005); + b = (decimal32)(d64 - a); VERIFY (b == 990); + b = (decimal32)(d128 - a); VERIFY (b == 1025); +} + +void +binary_multiply_32 (void) +{ + decimal32 a (1000), b; + + b = a * si; VERIFY (b == -20000); + b = a * ui; VERIFY (b == 50000); + b = a * sl; VERIFY (b == -10000); + b = a * ul; VERIFY (b == 20000); + b = a * sll; VERIFY (b == -25000); + b = a * ull; VERIFY (b == 50000); + b = a * d32; VERIFY (b == 5000); + b = (decimal32)(a * d64); VERIFY (b == -10000); + b = (decimal32)(a * d128); VERIFY (b == 25000); + + b = si * a; VERIFY (b == -20000); + b = ui * a; VERIFY (b == 50000); + b = sl * a; VERIFY (b == -10000); + b = ul * a; VERIFY (b == 20000); + b = sll * a; VERIFY (b == -25000); + b = ull * a; VERIFY (b == 50000); + b = d32 * a; VERIFY (b == 5000); + b = (decimal32)(d64 * a); VERIFY (b == -10000); + b = (decimal32)(d128 * a); VERIFY (b == 25000); +} + +void +binary_divide_32 (void) +{ + decimal32 a (1000), b; + + b = a / si; VERIFY (b == -50); + b = a / ui; VERIFY (b == 20); + b = a / sl; VERIFY (b == -100); + b = a / ul; VERIFY (b == 50); + b = a / sll; VERIFY (b == -40); + b = a / ull; VERIFY (b == 20); + b = a / d32; VERIFY (b == 200); + b = (decimal32)(a / d64); VERIFY (b == -100); + b = (decimal32)(a / d128); VERIFY (b == 40); + + a = 5; + b = si / a; VERIFY (b == -4); + b = ui / a; VERIFY (b == 10); + b = sl / a; VERIFY (b == -2); + b = ul / a; VERIFY (b == 4); + b = sll / a; VERIFY (b == -5); + b = ull / a; VERIFY (b == 10); + b = d32 / a; VERIFY (b == 1); + b = (decimal32)(d64 / a); VERIFY (b == -2); + b = (decimal32)(d128 / a); VERIFY (b == 5); +} + +void +binary_add_64 (void) +{ + decimal64 a (1000), b; + + b = a + si; VERIFY (b == 980); + b = a + ui; VERIFY (b == 1050); + b = a + sl; VERIFY (b == 990); + b = a + ul; VERIFY (b == 1020); + b = a + sll; VERIFY (b == 975); + b = a + ull; VERIFY (b == 1050); + b = a + d32; VERIFY (b == 1005); + b = a + d64; VERIFY (b == 990); + b = (decimal64)(a + d128); VERIFY (b == 1025); + + b = a + si; VERIFY (b == 980); + b = a + ui; VERIFY (b == 1050); + b = a + sl; VERIFY (b == 990); + b = a + ul; VERIFY (b == 1020); + b = a + sll; VERIFY (b == 975); + b = a + ull; VERIFY (b == 1050); + b = a + d32; VERIFY (b == 1005); + b = a + d64; VERIFY (b == 990); + b = (decimal64)(a + d128); VERIFY (b == 1025); +} + +void +binary_subtract_64 (void) +{ + decimal64 a (1000), b; + + b = a - si; VERIFY (b == 1020); + b = a - ui; VERIFY (b == 950); + b = a - sl; VERIFY (b == 1010); + b = a - ul; VERIFY (b == 980); + b = a - sll; VERIFY (b == 1025); + b = a - ull; VERIFY (b == 950); + b = a - d32; VERIFY (b == 995); + b = a - d64; VERIFY (b == 1010); + b = (decimal64)(a - d128); VERIFY (b == 975); + + a = -1000; + b = si - a; VERIFY (b == 980); + b = ui - a; VERIFY (b == 1050); + b = sl - a; VERIFY (b == 990); + b = ul - a; VERIFY (b == 1020); + b = sll - a; VERIFY (b == 975); + b = ull - a; VERIFY (b == 1050); + b = d32 - a; VERIFY (b == 1005); + b = d64 - a; VERIFY (b == 990); + b = (decimal64)(d128 - a); VERIFY (b == 1025); +} + +void +binary_multiply_64 (void) +{ + decimal64 a (1000), b; + + b = a * si; VERIFY (b == -20000); + b = a * ui; VERIFY (b == 50000); + b = a * sl; VERIFY (b == -10000); + b = a * ul; VERIFY (b == 20000); + b = a * sll; VERIFY (b == -25000); + b = a * ull; VERIFY (b == 50000); + b = a * d32; VERIFY (b == 5000); + b = a * d64; VERIFY (b == -10000); + b = (decimal64)(a * d128); VERIFY (b == 25000); + + b = si * a; VERIFY (b == -20000); + b = ui * a; VERIFY (b == 50000); + b = sl * a; VERIFY (b == -10000); + b = ul * a; VERIFY (b == 20000); + b = sll * a; VERIFY (b == -25000); + b = ull * a; VERIFY (b == 50000); + b = d32 * a; VERIFY (b == 5000); + b = d64 * a; VERIFY (b == -10000); + b = (decimal64)(d128 * a); VERIFY (b == 25000); +} + +void +binary_divide_64 (void) +{ + decimal64 a (1000), b; + + b = a / si; VERIFY (b == -50); + b = a / ui; VERIFY (b == 20); + b = a / sl; VERIFY (b == -100); + b = a / ul; VERIFY (b == 50); + b = a / sll; VERIFY (b == -40); + b = a / ull; VERIFY (b == 20); + b = a / d32; VERIFY (b == 200); + b = a / d64; VERIFY (b == -100); + b = (decimal64)(a / d128); VERIFY (b == 40); + + a = 5; + b = si / a; VERIFY (b == -4); + b = ui / a; VERIFY (b == 10); + b = sl / a; VERIFY (b == -2); + b = ul / a; VERIFY (b == 4); + b = sll / a; VERIFY (b == -5); + b = ull / a; VERIFY (b == 10); + b = d32 / a; VERIFY (b == 1); + b = d64 / a; VERIFY (b == -2); + b = (decimal64)(d128 / a); VERIFY (b == 5); +} + +void +binary_add_128 (void) +{ + decimal128 a (1000), b; + + b = a + si; VERIFY (b == 980); + b = a + ui; VERIFY (b == 1050); + b = a + sl; VERIFY (b == 990); + b = a + ul; VERIFY (b == 1020); + b = a + sll; VERIFY (b == 975); + b = a + ull; VERIFY (b == 1050); + b = a + d32; VERIFY (b == 1005); + b = a + d64; VERIFY (b == 990); + b = a + d128; VERIFY (b == 1025); + + b = a + si; VERIFY (b == 980); + b = a + ui; VERIFY (b == 1050); + b = a + sl; VERIFY (b == 990); + b = a + ul; VERIFY (b == 1020); + b = a + sll; VERIFY (b == 975); + b = a + ull; VERIFY (b == 1050); + b = a + d32; VERIFY (b == 1005); + b = a + d64; VERIFY (b == 990); + b = a + d128; VERIFY (b == 1025); +} + +void +binary_subtract_128 (void) +{ + decimal128 a (1000), b; + + b = a - si; VERIFY (b == 1020); + b = a - ui; VERIFY (b == 950); + b = a - sl; VERIFY (b == 1010); + b = a - ul; VERIFY (b == 980); + b = a - sll; VERIFY (b == 1025); + b = a - ull; VERIFY (b == 950); + b = a - d32; VERIFY (b == 995); + b = a - d64; VERIFY (b == 1010); + b = a - d128; VERIFY (b == 975); + + a = -1000; + b = si - a; VERIFY (b == 980); + b = ui - a; VERIFY (b == 1050); + b = sl - a; VERIFY (b == 990); + b = ul - a; VERIFY (b == 1020); + b = sll - a; VERIFY (b == 975); + b = ull - a; VERIFY (b == 1050); + b = d32 - a; VERIFY (b == 1005); + b = d64 - a; VERIFY (b == 990); + b = d128 - a; VERIFY (b == 1025); +} + +void +binary_multiply_128 (void) +{ + decimal128 a (1000), b; + + b = a * si; VERIFY (b == -20000); + b = a * ui; VERIFY (b == 50000); + b = a * sl; VERIFY (b == -10000); + b = a * ul; VERIFY (b == 20000); + b = a * sll; VERIFY (b == -25000); + b = a * ull; VERIFY (b == 50000); + b = a * d32; VERIFY (b == 5000); + b = a * d64; VERIFY (b == -10000); + b = a * d128; VERIFY (b == 25000); + + b = si * a; VERIFY (b == -20000); + b = ui * a; VERIFY (b == 50000); + b = sl * a; VERIFY (b == -10000); + b = ul * a; VERIFY (b == 20000); + b = sll * a; VERIFY (b == -25000); + b = ull * a; VERIFY (b == 50000); + b = d32 * a; VERIFY (b == 5000); + b = d64 * a; VERIFY (b == -10000); + b = d128 * a; VERIFY (b == 25000); +} + +void +binary_divide_128 (void) +{ + decimal128 a (1000), b; + + b = a / si; VERIFY (b == -50); + b = a / ui; VERIFY (b == 20); + b = a / sl; VERIFY (b == -100); + b = a / ul; VERIFY (b == 50); + b = a / sll; VERIFY (b == -40); + b = a / ull; VERIFY (b == 20); + b = a / d32; VERIFY (b == 200); + b = a / d64; VERIFY (b == -100); + b = a / d128; VERIFY (b == 40); + + a = 5; + b = si / a; VERIFY (b == -4); + b = ui / a; VERIFY (b == 10); + b = sl / a; VERIFY (b == -2); + b = ul / a; VERIFY (b == 4); + b = sll / a; VERIFY (b == -5); + b = ull / a; VERIFY (b == 10); + b = d32 / a; VERIFY (b == 1); + b = d64 / a; VERIFY (b == -2); + b = d128 / a; VERIFY (b == 5); +} + +int +main () +{ + binary_add_32 (); + binary_subtract_32 (); + binary_multiply_32 (); + binary_divide_32 (); + + binary_add_64 (); + binary_subtract_64 (); + binary_multiply_64 (); + binary_divide_64 (); + + binary_add_128 (); + binary_subtract_128 (); + binary_multiply_128 (); + binary_divide_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/cast_neg.cc b/libstdc++-v3/testsuite/decimal/cast_neg.cc new file mode 100644 index 00000000000..23749ba5e75 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/cast_neg.cc @@ -0,0 +1,62 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 doesn't say explicitly that the conversion from a +// decimal floating-point type to a generic float type is prohibited but +// it implies that in section 4.3 when it says "In C, objects of decimal +// floating-oint type can be converted to generic floating-point type by +// means of an explicit cast. In C++ this is not possible." Check that +// attempt to do a cast are flagged as errors. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +float f; +double d; +long double ld; +decimal32 d32; +decimal64 d64; +decimal128 d128; + +void +foo (void) +{ + f = d32; // { dg-error "error" } + f = d64; // { dg-error "error" } + f = d128; // { dg-error "error" } + d = d32; // { dg-error "error" } + d = d64; // { dg-error "error" } + d = d128; // { dg-error "error" } + ld = d32; // { dg-error "error" } + ld = d64; // { dg-error "error" } + ld = d128; // { dg-error "error" } + + f = (float)d32; // { dg-error "error" } + f = (float)d64; // { dg-error "error" } + f = (float)d128; // { dg-error "error" } + d = (double)d32; // { dg-error "error" } + d = (double)d64; // { dg-error "error" } + d = (double)d128; // { dg-error "error" } + ld = (long double)d32; // { dg-error "error" } + ld = (long double)d64; // { dg-error "error" } + ld = (long double)d128; // { dg-error "error" } +} diff --git a/libstdc++-v3/testsuite/decimal/comparison.cc b/libstdc++-v3/testsuite/decimal/comparison.cc new file mode 100644 index 00000000000..1efa637ac4a --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/comparison.cc @@ -0,0 +1,546 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.9 Comparison operators. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +decimal32 d32 (5); +decimal64 d64 (-10); +decimal128 d128 (25); +int si = -20; +unsigned int ui = 50; +long sl = -10; +unsigned long ul = 20; +long long sll = -25; +unsigned long long ull = 50; + +void +compare_eq_32 (void) +{ + decimal32 a; + + a = si; VERIFY (a == si); VERIFY (si == a); + a = ui; VERIFY (a == ui); VERIFY (ui == a); + a = sl; VERIFY (a == sl); VERIFY (sl == a); + a = ul; VERIFY (a == ul); VERIFY (ul == a); + a = sll; VERIFY (a == sll); VERIFY (sll == a); + a = ull; VERIFY (a == ull); VERIFY (ull == a); + a = d32; VERIFY (a == d32); VERIFY (d32 == a); + a = (decimal32)d64; VERIFY (a == d64); VERIFY (d64 == a); + a = (decimal32)d128; VERIFY (a == d128); VERIFY (d128 == a); +} + +void +compare_ne_32 (void) +{ + decimal32 a = 100; + + VERIFY (a != si); VERIFY (si != a); + VERIFY (a != ui); VERIFY (ui != a); + VERIFY (a != sl); VERIFY (sl != a); + VERIFY (a != ul); VERIFY (ul != a); + VERIFY (a != sll); VERIFY (sll != a); + VERIFY (a != ull); VERIFY (ull != a); + VERIFY (a != d32); VERIFY (d32 != a); + VERIFY (a != d64); VERIFY (d64 != a); + VERIFY (a != d128); VERIFY (d128 != a); +} + +void +compare_lt_32 (void) +{ + decimal32 a = -100; + + VERIFY (a < si); + VERIFY (a < ui); + VERIFY (a < sl); + VERIFY (a < ul); + VERIFY (a < sll); + VERIFY (a < ull); + VERIFY (a < d32); + VERIFY (a < d64); + VERIFY (a < d128); + + a = 100; + VERIFY (si < a); + VERIFY (ui < a); + VERIFY (sl < a); + VERIFY (ul < a); + VERIFY (sll < a); + VERIFY (ull < a); + VERIFY (d32 < a); + VERIFY (d64 < a); + VERIFY (d128 < a); +} + +void +compare_le_32 (void) +{ + decimal32 a; + + a = si; VERIFY (a <= si); VERIFY (si <= a); + a = ui; VERIFY (a <= ui); VERIFY (ui <= a); + a = sl; VERIFY (a <= sl); VERIFY (sl <= a); + a = ul; VERIFY (a <= ul); VERIFY (ul <= a); + a = sll; VERIFY (a <= sll); VERIFY (sll <= a); + a = ull; VERIFY (a <= ull); VERIFY (ull <= a); + a = d32; VERIFY (a <= d32); VERIFY (d32 <= a); + a = (decimal32)d64; VERIFY (a <= d64); VERIFY (d64 <= a); + a = (decimal32)d128; VERIFY (a <= d128); VERIFY (d128 <= a); + + a = -100; + VERIFY (a <= si); + VERIFY (a <= ui); + VERIFY (a <= sl); + VERIFY (a <= ul); + VERIFY (a <= sll); + VERIFY (a <= ull); + VERIFY (a <= d32); + VERIFY (a <= d64); + VERIFY (a <= d128); + + a = 100; + VERIFY (si <= a); + VERIFY (ui <= a); + VERIFY (sl <= a); + VERIFY (ul <= a); + VERIFY (sll <= a); + VERIFY (ull <= a); + VERIFY (d32 <= a); + VERIFY (d64 <= a); + VERIFY (d128 <= a); +} + +void +compare_gt_32 (void) +{ + decimal32 a = 100; + + VERIFY (a > si); + VERIFY (a > ui); + VERIFY (a > sl); + VERIFY (a > ul); + VERIFY (a > sll); + VERIFY (a > ull); + VERIFY (a > d32); + VERIFY (a > d64); + VERIFY (a > d128); + + a = -100; + VERIFY (si > a); + VERIFY (ui > a); + VERIFY (sl > a); + VERIFY (ul > a); + VERIFY (sll > a); + VERIFY (ull > a); + VERIFY (d32 > a); + VERIFY (d64 > a); + VERIFY (d128 > a); +} + +void +compare_ge_32 (void) +{ + decimal32 a; + + a = si; VERIFY (a >= si); VERIFY (si <= a); + a = ui; VERIFY (a >= ui); VERIFY (ui <= a); + a = sl; VERIFY (a >= sl); VERIFY (sl <= a); + a = ul; VERIFY (a >= ul); VERIFY (ul <= a); + a = sll; VERIFY (a >= sll); VERIFY (sll <= a); + a = ull; VERIFY (a >= ull); VERIFY (ull <= a); + a = d32; VERIFY (a >= d32); VERIFY (d32 <= a); + a = (decimal32)d64; VERIFY (a >= d64); VERIFY (d64 <= a); + a = (decimal32)d128; VERIFY (a >= d128); VERIFY (d128 <= a); + + a = 100; + VERIFY (a >= si); + VERIFY (a >= ui); + VERIFY (a >= sl); + VERIFY (a >= ul); + VERIFY (a >= sll); + VERIFY (a >= ull); + VERIFY (a >= d32); + VERIFY (a >= d64); + VERIFY (a >= d128); + + a = -100; + VERIFY (si >= a); + VERIFY (ui >= a); + VERIFY (sl >= a); + VERIFY (ul >= a); + VERIFY (sll >= a); + VERIFY (ull >= a); + VERIFY (d32 >= a); + VERIFY (d64 >= a); + VERIFY (d128 >= a); +} + +void +compare_eq_64 (void) +{ + decimal64 a; + + a = si; VERIFY (a == si); VERIFY (si == a); + a = ui; VERIFY (a == ui); VERIFY (ui == a); + a = sl; VERIFY (a == sl); VERIFY (sl == a); + a = ul; VERIFY (a == ul); VERIFY (ul == a); + a = sll; VERIFY (a == sll); VERIFY (sll == a); + a = ull; VERIFY (a == ull); VERIFY (ull == a); + a = d32; VERIFY (a == d32); VERIFY (d32 == a); + a = d64; VERIFY (a == d64); VERIFY (d64 == a); + a = (decimal64)d128; VERIFY (a == d128); VERIFY (d128 == a); +} + +void +compare_ne_64 (void) +{ + decimal64 a = 100; + + VERIFY (a != si); VERIFY (si != a); + VERIFY (a != ui); VERIFY (ui != a); + VERIFY (a != sl); VERIFY (sl != a); + VERIFY (a != ul); VERIFY (ul != a); + VERIFY (a != sll); VERIFY (sll != a); + VERIFY (a != ull); VERIFY (ull != a); + VERIFY (a != d32); VERIFY (d32 != a); + VERIFY (a != d64); VERIFY (d64 != a); + VERIFY (a != d128); VERIFY (d128 != a); +} + +void +compare_lt_64 (void) +{ + decimal64 a = -100; + + VERIFY (a < si); + VERIFY (a < ui); + VERIFY (a < sl); + VERIFY (a < ul); + VERIFY (a < sll); + VERIFY (a < ull); + VERIFY (a < d32); + VERIFY (a < d64); + VERIFY (a < d128); + + a = 100; + VERIFY (si < a); + VERIFY (ui < a); + VERIFY (sl < a); + VERIFY (ul < a); + VERIFY (sll < a); + VERIFY (ull < a); + VERIFY (d32 < a); + VERIFY (d64 < a); + VERIFY (d128 < a); +} + +void +compare_le_64 (void) +{ + decimal64 a; + + a = si; VERIFY (a <= si); VERIFY (si <= a); + a = ui; VERIFY (a <= ui); VERIFY (ui <= a); + a = sl; VERIFY (a <= sl); VERIFY (sl <= a); + a = ul; VERIFY (a <= ul); VERIFY (ul <= a); + a = sll; VERIFY (a <= sll); VERIFY (sll <= a); + a = ull; VERIFY (a <= ull); VERIFY (ull <= a); + a = d32; VERIFY (a <= d32); VERIFY (d32 <= a); + a = (decimal32)d64; VERIFY (a <= d64); VERIFY (d64 <= a); + a = (decimal32)d128; VERIFY (a <= d128); VERIFY (d128 <= a); + + a = -100; + VERIFY (a <= si); + VERIFY (a <= ui); + VERIFY (a <= sl); + VERIFY (a <= ul); + VERIFY (a <= sll); + VERIFY (a <= ull); + VERIFY (a <= d32); + VERIFY (a <= d64); + VERIFY (a <= d128); + + a = 100; + VERIFY (si <= a); + VERIFY (ui <= a); + VERIFY (sl <= a); + VERIFY (ul <= a); + VERIFY (sll <= a); + VERIFY (ull <= a); + VERIFY (d32 <= a); + VERIFY (d64 <= a); + VERIFY (d128 <= a); +} + +void +compare_gt_64 (void) +{ + decimal64 a = 100; + + VERIFY (a > si); + VERIFY (a > ui); + VERIFY (a > sl); + VERIFY (a > ul); + VERIFY (a > sll); + VERIFY (a > ull); + VERIFY (a > d32); + VERIFY (a > d64); + VERIFY (a > d128); + + a = -100; + VERIFY (si > a); + VERIFY (ui > a); + VERIFY (sl > a); + VERIFY (ul > a); + VERIFY (sll > a); + VERIFY (ull > a); + VERIFY (d32 > a); + VERIFY (d64 > a); + VERIFY (d128 > a); +} + +void +compare_ge_64 (void) +{ + decimal64 a; + + a = si; VERIFY (a >= si); VERIFY (si <= a); + a = ui; VERIFY (a >= ui); VERIFY (ui <= a); + a = sl; VERIFY (a >= sl); VERIFY (sl <= a); + a = ul; VERIFY (a >= ul); VERIFY (ul <= a); + a = sll; VERIFY (a >= sll); VERIFY (sll <= a); + a = ull; VERIFY (a >= ull); VERIFY (ull <= a); + a = d32; VERIFY (a >= d32); VERIFY (d32 <= a); + a = (decimal32)d64; VERIFY (a >= d64); VERIFY (d64 <= a); + a = (decimal32)d128; VERIFY (a >= d128); VERIFY (d128 <= a); + + a = 100; + VERIFY (a >= si); + VERIFY (a >= ui); + VERIFY (a >= sl); + VERIFY (a >= ul); + VERIFY (a >= sll); + VERIFY (a >= ull); + VERIFY (a >= d32); + VERIFY (a >= d64); + VERIFY (a >= d128); + + a = -100; + VERIFY (si >= a); + VERIFY (ui >= a); + VERIFY (sl >= a); + VERIFY (ul >= a); + VERIFY (sll >= a); + VERIFY (ull >= a); + VERIFY (d32 >= a); + VERIFY (d64 >= a); + VERIFY (d128 >= a); +} + +void +compare_eq_128 (void) +{ + decimal128 a; + + a = si; VERIFY (a == si); VERIFY (si == a); + a = ui; VERIFY (a == ui); VERIFY (ui == a); + a = sl; VERIFY (a == sl); VERIFY (sl == a); + a = ul; VERIFY (a == ul); VERIFY (ul == a); + a = sll; VERIFY (a == sll); VERIFY (sll == a); + a = ull; VERIFY (a == ull); VERIFY (ull == a); + a = d32; VERIFY (a == d32); VERIFY (d32 == a); + a = d64; VERIFY (a == d64); VERIFY (d64 == a); + a = d128; VERIFY (a == d128); VERIFY (d128 == a); +} + +void +compare_ne_128 (void) +{ + decimal128 a = 100; + + VERIFY (a != si); VERIFY (si != a); + VERIFY (a != ui); VERIFY (ui != a); + VERIFY (a != sl); VERIFY (sl != a); + VERIFY (a != ul); VERIFY (ul != a); + VERIFY (a != sll); VERIFY (sll != a); + VERIFY (a != ull); VERIFY (ull != a); + VERIFY (a != d32); VERIFY (d32 != a); + VERIFY (a != d64); VERIFY (d64 != a); + VERIFY (a != d128); VERIFY (d128 != a); +} + +void +compare_lt_128 (void) +{ + decimal128 a = -100; + + VERIFY (a < si); + VERIFY (a < ui); + VERIFY (a < sl); + VERIFY (a < ul); + VERIFY (a < sll); + VERIFY (a < ull); + VERIFY (a < d32); + VERIFY (a < d64); + VERIFY (a < d128); + + a = 100; + VERIFY (si < a); + VERIFY (ui < a); + VERIFY (sl < a); + VERIFY (ul < a); + VERIFY (sll < a); + VERIFY (ull < a); + VERIFY (d32 < a); + VERIFY (d64 < a); + VERIFY (d128 < a); +} + +void +compare_le_128 (void) +{ + decimal128 a; + + a = si; VERIFY (a <= si); VERIFY (si <= a); + a = ui; VERIFY (a <= ui); VERIFY (ui <= a); + a = sl; VERIFY (a <= sl); VERIFY (sl <= a); + a = ul; VERIFY (a <= ul); VERIFY (ul <= a); + a = sll; VERIFY (a <= sll); VERIFY (sll <= a); + a = ull; VERIFY (a <= ull); VERIFY (ull <= a); + a = d32; VERIFY (a <= d32); VERIFY (d32 <= a); + a = (decimal32)d64; VERIFY (a <= d64); VERIFY (d64 <= a); + a = (decimal32)d128; VERIFY (a <= d128); VERIFY (d128 <= a); + + a = -100; + VERIFY (a <= si); + VERIFY (a <= ui); + VERIFY (a <= sl); + VERIFY (a <= ul); + VERIFY (a <= sll); + VERIFY (a <= ull); + VERIFY (a <= d32); + VERIFY (a <= d64); + VERIFY (a <= d128); + + a = 100; + VERIFY (si <= a); + VERIFY (ui <= a); + VERIFY (sl <= a); + VERIFY (ul <= a); + VERIFY (sll <= a); + VERIFY (ull <= a); + VERIFY (d32 <= a); + VERIFY (d64 <= a); + VERIFY (d128 <= a); +} + +void +compare_gt_128 (void) +{ + decimal128 a = 100; + + VERIFY (a > si); + VERIFY (a > ui); + VERIFY (a > sl); + VERIFY (a > ul); + VERIFY (a > sll); + VERIFY (a > ull); + VERIFY (a > d32); + VERIFY (a > d64); + VERIFY (a > d128); + + a = -100; + VERIFY (si > a); + VERIFY (ui > a); + VERIFY (sl > a); + VERIFY (ul > a); + VERIFY (sll > a); + VERIFY (ull > a); + VERIFY (d32 > a); + VERIFY (d64 > a); + VERIFY (d128 > a); +} + +void +compare_ge_128 (void) +{ + decimal128 a; + + a = si; VERIFY (a >= si); VERIFY (si <= a); + a = ui; VERIFY (a >= ui); VERIFY (ui <= a); + a = sl; VERIFY (a >= sl); VERIFY (sl <= a); + a = ul; VERIFY (a >= ul); VERIFY (ul <= a); + a = sll; VERIFY (a >= sll); VERIFY (sll <= a); + a = ull; VERIFY (a >= ull); VERIFY (ull <= a); + a = d32; VERIFY (a >= d32); VERIFY (d32 <= a); + a = (decimal32)d64; VERIFY (a >= d64); VERIFY (d64 <= a); + a = (decimal32)d128; VERIFY (a >= d128); VERIFY (d128 <= a); + + a = 100; + VERIFY (a >= si); + VERIFY (a >= ui); + VERIFY (a >= sl); + VERIFY (a >= ul); + VERIFY (a >= sll); + VERIFY (a >= ull); + VERIFY (a >= d32); + VERIFY (a >= d64); + VERIFY (a >= d128); + + a = -100; + VERIFY (si >= a); + VERIFY (ui >= a); + VERIFY (sl >= a); + VERIFY (ul >= a); + VERIFY (sll >= a); + VERIFY (ull >= a); + VERIFY (d32 >= a); + VERIFY (d64 >= a); + VERIFY (d128 >= a); +} + +int +main () +{ + compare_eq_32 (); + compare_ne_32 (); + compare_lt_32 (); + compare_le_32 (); + compare_gt_32 (); + compare_ge_32 (); + + compare_eq_64 (); + compare_ne_64 (); + compare_lt_64 (); + compare_le_64 (); + compare_gt_64 (); + compare_ge_64 (); + + compare_eq_128 (); + compare_ne_128 (); + compare_lt_128 (); + compare_le_128 (); + compare_gt_128 (); + compare_ge_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/compound-assignment-memfunc.cc b/libstdc++-v3/testsuite/decimal/compound-assignment-memfunc.cc new file mode 100644 index 00000000000..c216faa8095 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/compound-assignment-memfunc.cc @@ -0,0 +1,250 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.6 Compound assignment (decimal32). +// ISO/IEC TR 24733 3.2.3.6 Compound assignment (decimal64). +// ISO/IEC TR 24733 3.2.4.6 Compound assignment (decimal128). + +// Access member functions directly. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +decimal32 d32 (5); +decimal64 d64 (-10); +decimal128 d128 (25); +int si = -2; +unsigned int ui = 5; +long sl = -10; +unsigned long ul = 20; +long long sll = -25; +unsigned long long ull = 50; + +void +compound_assignment_add_32 (void) +{ + decimal32 a (1000), b; + + b = a; b.operator+=(d32); VERIFY (b == 1005); + b = a; b.operator+=(d64); VERIFY (b == 990); + b = a; b.operator+=(d128); VERIFY (b == 1025); + b = a; b.operator+=(si); VERIFY (b == 998); + b = a; b.operator+=(ui); VERIFY (b == 1005); + b = a; b.operator+=(sl); VERIFY (b == 990); + b = a; b.operator+=(ul); VERIFY (b == 1020); + b = a; b.operator+=(sll); VERIFY (b == 975); + b = a; b.operator+=(ull); VERIFY (b == 1050); +} + +void +compound_assignment_subtract_32 (void) +{ + decimal32 a (1000), b; + + b = a; b.operator-=(d32); VERIFY (b == 995); + b = a; b.operator-=(d64); VERIFY (b == 1010); + b = a; b.operator-=(d128); VERIFY (b == 975); + b = a; b.operator-=(si); VERIFY (b == 1002); + b = a; b.operator-=(ui); VERIFY (b == 995); + b = a; b.operator-=(sl); VERIFY (b == 1010); + b = a; b.operator-=(ul); VERIFY (b == 980); + b = a; b.operator-=(sll); VERIFY (b == 1025); + b = a; b.operator-=(ull); VERIFY (b == 950); +} + +void +compound_assignment_multiply_32 (void) +{ + decimal32 a (1000), b; + + b = a; b.operator*=(d32); VERIFY (b == 5000); + b = a; b.operator*=(d64); VERIFY (b == -10000); + b = a; b.operator*=(d128); VERIFY (b == 25000); + b = a; b.operator*=(si); VERIFY (b == -2000); + b = a; b.operator*=(ui); VERIFY (b == 5000); + b = a; b.operator*=(sl); VERIFY (b == -10000); + b = a; b.operator*=(ul); VERIFY (b == 20000); + b = a; b.operator*=(sll); VERIFY (b == -25000); + b = a; b.operator*=(ull); VERIFY (b == 50000); +} + +void +compound_assignment_divide_32 (void) +{ + decimal32 a (1000), b; + + b = a; b.operator/=(d32); VERIFY (b == 200); + b = a; b.operator/=(d64); VERIFY (b == -100); + b = a; b.operator/=(d128); VERIFY (b == 40); + b = a; b.operator/=(si); VERIFY (b == -500); + b = a; b.operator/=(ui); VERIFY (b == 200); + b = a; b.operator/=(sl); VERIFY (b == -100); + b = a; b.operator/=(ul); VERIFY (b == 50); + b = a; b.operator/=(sll); VERIFY (b == -40); + b = a; b.operator/=(ull); VERIFY (b == 20); +} + +void +compound_assignment_add_64 (void) +{ + decimal64 a (1000), b; + + b = a; b.operator+=(d32); VERIFY (b == 1005); + b = a; b.operator+=(d64); VERIFY (b == 990); + b = a; b.operator+=(d128); VERIFY (b == 1025); + b = a; b.operator+=(si); VERIFY (b == 998); + b = a; b.operator+=(ui); VERIFY (b == 1005); + b = a; b.operator+=(sl); VERIFY (b == 990); + b = a; b.operator+=(ul); VERIFY (b == 1020); + b = a; b.operator+=(sll); VERIFY (b == 975); + b = a; b.operator+=(ull); VERIFY (b == 1050); +} + +void +compound_assignment_subtract_64 (void) +{ + decimal64 a (1000), b; + + b = a; b.operator-=(d32); VERIFY (b == 995); + b = a; b.operator-=(d64); VERIFY (b == 1010); + b = a; b.operator-=(d128); VERIFY (b == 975); + b = a; b.operator-=(si); VERIFY (b == 1002); + b = a; b.operator-=(ui); VERIFY (b == 995); + b = a; b.operator-=(sl); VERIFY (b == 1010); + b = a; b.operator-=(ul); VERIFY (b == 980); + b = a; b.operator-=(sll); VERIFY (b == 1025); + b = a; b.operator-=(ull); VERIFY (b == 950); +} + +void +compound_assignment_multiply_64 (void) +{ + decimal64 a (1000), b; + + b = a; b.operator*=(d32); VERIFY (b == 5000); + b = a; b.operator*=(d64); VERIFY (b == -10000); + b = a; b.operator*=(d128); VERIFY (b == 25000); + b = a; b.operator*=(si); VERIFY (b == -2000); + b = a; b.operator*=(ui); VERIFY (b == 5000); + b = a; b.operator*=(sl); VERIFY (b == -10000); + b = a; b.operator*=(ul); VERIFY (b == 20000); + b = a; b.operator*=(sll); VERIFY (b == -25000); + b = a; b.operator*=(ull); VERIFY (b == 50000); +} + +void +compound_assignment_divide_64 (void) +{ + decimal64 a (1000), b; + + b = a; b.operator/=(d32); VERIFY (b == 200); + b = a; b.operator/=(d64); VERIFY (b == -100); + b = a; b.operator/=(d128); VERIFY (b == 40); + b = a; b.operator/=(si); VERIFY (b == -500); + b = a; b.operator/=(ui); VERIFY (b == 200); + b = a; b.operator/=(sl); VERIFY (b == -100); + b = a; b.operator/=(ul); VERIFY (b == 50); + b = a; b.operator/=(sll); VERIFY (b == -40); + b = a; b.operator/=(ull); VERIFY (b == 20); +} + +void +compound_assignment_add_128 (void) +{ + decimal128 a (1000), b; + + b = a; b.operator+=(d32); VERIFY (b == 1005); + b = a; b.operator+=(d64); VERIFY (b == 990); + b = a; b.operator+=(d128); VERIFY (b == 1025); + b = a; b.operator+=(si); VERIFY (b == 998); + b = a; b.operator+=(ui); VERIFY (b == 1005); + b = a; b.operator+=(sl); VERIFY (b == 990); + b = a; b.operator+=(ul); VERIFY (b == 1020); + b = a; b.operator+=(sll); VERIFY (b == 975); + b = a; b.operator+=(ull); VERIFY (b == 1050); +} + +void +compound_assignment_subtract_128 (void) +{ + decimal128 a (1000), b; + + b = a; b.operator-=(d32); VERIFY (b == 995); + b = a; b.operator-=(d64); VERIFY (b == 1010); + b = a; b.operator-=(d128); VERIFY (b == 975); + b = a; b.operator-=(si); VERIFY (b == 1002); + b = a; b.operator-=(ui); VERIFY (b == 995); + b = a; b.operator-=(sl); VERIFY (b == 1010); + b = a; b.operator-=(ul); VERIFY (b == 980); + b = a; b.operator-=(sll); VERIFY (b == 1025); + b = a; b.operator-=(ull); VERIFY (b == 950); +} + +void +compound_assignment_multiply_128 (void) +{ + decimal128 a (1000), b; + + b = a; b.operator*=(d32); VERIFY (b == 5000); + b = a; b.operator*=(d64); VERIFY (b == -10000); + b = a; b.operator*=(d128); VERIFY (b == 25000); + b = a; b.operator*=(si); VERIFY (b == -2000); + b = a; b.operator*=(ui); VERIFY (b == 5000); + b = a; b.operator*=(sl); VERIFY (b == -10000); + b = a; b.operator*=(ul); VERIFY (b == 20000); + b = a; b.operator*=(sll); VERIFY (b == -25000); + b = a; b.operator*=(ull); VERIFY (b == 50000); +} + +void +compound_assignment_divide_128 (void) +{ + decimal128 a (1000), b; + + b = a; b.operator/=(d32); VERIFY (b == 200); + b = a; b.operator/=(d64); VERIFY (b == -100); + b = a; b.operator/=(d128); VERIFY (b == 40); + b = a; b.operator/=(si); VERIFY (b == -500); + b = a; b.operator/=(ui); VERIFY (b == 200); + b = a; b.operator/=(sl); VERIFY (b == -100); + b = a; b.operator/=(ul); VERIFY (b == 50); + b = a; b.operator/=(sll); VERIFY (b == -40); + b = a; b.operator/=(ull); VERIFY (b == 20); +} + +int +main () +{ + compound_assignment_add_32 (); + compound_assignment_subtract_32 (); + compound_assignment_multiply_32 (); + compound_assignment_divide_32 (); + + compound_assignment_add_64 (); + compound_assignment_subtract_64 (); + compound_assignment_multiply_64 (); + compound_assignment_divide_64 (); + + compound_assignment_add_128 (); + compound_assignment_subtract_128 (); + compound_assignment_multiply_128 (); + compound_assignment_divide_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/compound-assignment.cc b/libstdc++-v3/testsuite/decimal/compound-assignment.cc new file mode 100644 index 00000000000..2a1f4a7218c --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/compound-assignment.cc @@ -0,0 +1,248 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.6 Compound assignment (decimal32). +// ISO/IEC TR 24733 3.2.3.6 Compound assignment (decimal64). +// ISO/IEC TR 24733 3.2.4.6 Compound assignment (decimal128). + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +decimal32 d32 (5); +decimal64 d64 (-10); +decimal128 d128 (25); +int si = -2; +unsigned int ui = 5; +long sl = -10; +unsigned long ul = 20; +long long sll = -25; +unsigned long long ull = 50; + +void +compound_assignment_add_32 (void) +{ + decimal32 a (1000), b; + + b = a; b += d32; VERIFY (b == 1005); + b = a; b += d64; VERIFY (b == 990); + b = a; b += d128; VERIFY (b == 1025); + b = a; b += si; VERIFY (b == 998); + b = a; b += ui; VERIFY (b == 1005); + b = a; b += sl; VERIFY (b == 990); + b = a; b += ul; VERIFY (b == 1020); + b = a; b += sll; VERIFY (b == 975); + b = a; b += ull; VERIFY (b == 1050); +} + +void +compound_assignment_subtract_32 (void) +{ + decimal32 a (1000), b; + + b = a; b -= d32; VERIFY (b == 995); + b = a; b -= d64; VERIFY (b == 1010); + b = a; b -= d128; VERIFY (b == 975); + b = a; b -= si; VERIFY (b == 1002); + b = a; b -= ui; VERIFY (b == 995); + b = a; b -= sl; VERIFY (b == 1010); + b = a; b -= ul; VERIFY (b == 980); + b = a; b -= sll; VERIFY (b == 1025); + b = a; b -= ull; VERIFY (b == 950); +} + +void +compound_assignment_multiply_32 (void) +{ + decimal32 a (1000), b; + + b = a; b *= d32; VERIFY (b == 5000); + b = a; b *= d64; VERIFY (b == -10000); + b = a; b *= d128; VERIFY (b == 25000); + b = a; b *= si; VERIFY (b == -2000); + b = a; b *= ui; VERIFY (b == 5000); + b = a; b *= sl; VERIFY (b == -10000); + b = a; b *= ul; VERIFY (b == 20000); + b = a; b *= sll; VERIFY (b == -25000); + b = a; b *= ull; VERIFY (b == 50000); +} + +void +compound_assignment_divide_32 (void) +{ + decimal32 a (1000), b; + + b = a; b /= d32; VERIFY (b == 200); + b = a; b /= d64; VERIFY (b == -100); + b = a; b /= d128; VERIFY (b == 40); + b = a; b /= si; VERIFY (b == -500); + b = a; b /= ui; VERIFY (b == 200); + b = a; b /= sl; VERIFY (b == -100); + b = a; b /= ul; VERIFY (b == 50); + b = a; b /= sll; VERIFY (b == -40); + b = a; b /= ull; VERIFY (b == 20); +} + +void +compound_assignment_add_64 (void) +{ + decimal64 a (1000), b; + + b = a; b += d32; VERIFY (b == 1005); + b = a; b += d64; VERIFY (b == 990); + b = a; b += d128; VERIFY (b == 1025); + b = a; b += si; VERIFY (b == 998); + b = a; b += ui; VERIFY (b == 1005); + b = a; b += sl; VERIFY (b == 990); + b = a; b += ul; VERIFY (b == 1020); + b = a; b += sll; VERIFY (b == 975); + b = a; b += ull; VERIFY (b == 1050); +} + +void +compound_assignment_subtract_64 (void) +{ + decimal64 a (1000), b; + + b = a; b -= d32; VERIFY (b == 995); + b = a; b -= d64; VERIFY (b == 1010); + b = a; b -= d128; VERIFY (b == 975); + b = a; b -= si; VERIFY (b == 1002); + b = a; b -= ui; VERIFY (b == 995); + b = a; b -= sl; VERIFY (b == 1010); + b = a; b -= ul; VERIFY (b == 980); + b = a; b -= sll; VERIFY (b == 1025); + b = a; b -= ull; VERIFY (b == 950); +} + +void +compound_assignment_multiply_64 (void) +{ + decimal64 a (1000), b; + + b = a; b *= d32; VERIFY (b == 5000); + b = a; b *= d64; VERIFY (b == -10000); + b = a; b *= d128; VERIFY (b == 25000); + b = a; b *= si; VERIFY (b == -2000); + b = a; b *= ui; VERIFY (b == 5000); + b = a; b *= sl; VERIFY (b == -10000); + b = a; b *= ul; VERIFY (b == 20000); + b = a; b *= sll; VERIFY (b == -25000); + b = a; b *= ull; VERIFY (b == 50000); +} + +void +compound_assignment_divide_64 (void) +{ + decimal64 a (1000), b; + + b = a; b /= d32; VERIFY (b == 200); + b = a; b /= d64; VERIFY (b == -100); + b = a; b /= d128; VERIFY (b == 40); + b = a; b /= si; VERIFY (b == -500); + b = a; b /= ui; VERIFY (b == 200); + b = a; b /= sl; VERIFY (b == -100); + b = a; b /= ul; VERIFY (b == 50); + b = a; b /= sll; VERIFY (b == -40); + b = a; b /= ull; VERIFY (b == 20); +} + +void +compound_assignment_add_128 (void) +{ + decimal128 a (1000), b; + + b = a; b += d32; VERIFY (b == 1005); + b = a; b += d64; VERIFY (b == 990); + b = a; b += d128; VERIFY (b == 1025); + b = a; b += si; VERIFY (b == 998); + b = a; b += ui; VERIFY (b == 1005); + b = a; b += sl; VERIFY (b == 990); + b = a; b += ul; VERIFY (b == 1020); + b = a; b += sll; VERIFY (b == 975); + b = a; b += ull; VERIFY (b == 1050); +} + +void +compound_assignment_subtract_128 (void) +{ + decimal128 a (1000), b; + + b = a; b -= d32; VERIFY (b == 995); + b = a; b -= d64; VERIFY (b == 1010); + b = a; b -= d128; VERIFY (b == 975); + b = a; b -= si; VERIFY (b == 1002); + b = a; b -= ui; VERIFY (b == 995); + b = a; b -= sl; VERIFY (b == 1010); + b = a; b -= ul; VERIFY (b == 980); + b = a; b -= sll; VERIFY (b == 1025); + b = a; b -= ull; VERIFY (b == 950); +} + +void +compound_assignment_multiply_128 (void) +{ + decimal128 a (1000), b; + + b = a; b *= d32; VERIFY (b == 5000); + b = a; b *= d64; VERIFY (b == -10000); + b = a; b *= d128; VERIFY (b == 25000); + b = a; b *= si; VERIFY (b == -2000); + b = a; b *= ui; VERIFY (b == 5000); + b = a; b *= sl; VERIFY (b == -10000); + b = a; b *= ul; VERIFY (b == 20000); + b = a; b *= sll; VERIFY (b == -25000); + b = a; b *= ull; VERIFY (b == 50000); +} + +void +compound_assignment_divide_128 (void) +{ + decimal128 a (1000), b; + + b = a; b /= d32; VERIFY (b == 200); + b = a; b /= d64; VERIFY (b == -100); + b = a; b /= d128; VERIFY (b == 40); + b = a; b /= si; VERIFY (b == -500); + b = a; b /= ui; VERIFY (b == 200); + b = a; b /= sl; VERIFY (b == -100); + b = a; b /= ul; VERIFY (b == 50); + b = a; b /= sll; VERIFY (b == -40); + b = a; b /= ull; VERIFY (b == 20); +} + +int +main () +{ + compound_assignment_add_32 (); + compound_assignment_subtract_32 (); + compound_assignment_multiply_32 (); + compound_assignment_divide_32 (); + + compound_assignment_add_64 (); + compound_assignment_subtract_64 (); + compound_assignment_multiply_64 (); + compound_assignment_divide_64 (); + + compound_assignment_add_128 (); + compound_assignment_subtract_128 (); + compound_assignment_multiply_128 (); + compound_assignment_divide_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/conversion-from-float.cc b/libstdc++-v3/testsuite/decimal/conversion-from-float.cc new file mode 100644 index 00000000000..c1824a827cc --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/conversion-from-float.cc @@ -0,0 +1,101 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.2 Conversion from floating-point type (decimal32). +// ISO/IEC TR 24733 3.2.3.2 Conversion from floating-point type (decimal64). +// ISO/IEC TR 24733 3.2.4.2 Conversion from floating-point type (decimal128). + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +void +conversion_from_float_32 () +{ + decimal32 d32(123); + decimal64 d64(234); + decimal128 d128(345); + float f = 456.F; + double d = 567.; + long double ld = 678.L; + + d32 = (decimal32) d64; + VERIFY (d32 == make_decimal32 (234LL, 0)); + d32 = (decimal32) d128; + VERIFY (d32 == make_decimal32 (345LL, 0)); + d32 = (decimal32) f; + VERIFY (d32 == make_decimal32 (456LL, 0)); + d32 = (decimal32) d; + VERIFY (d32 == make_decimal32 (567LL, 0)); + d32 = (decimal32) ld; + VERIFY (d32 == make_decimal32 (678LL, 0)); +} + +void +conversion_from_float_64 () +{ + decimal32 d32(123); + decimal64 d64(234); + decimal128 d128(345); + float f = 456.F; + double d = 567.; + long double ld = 678.L; + + d64 = d32; + VERIFY (d64 == make_decimal64 (123LL, 0)); + d64 = (decimal64) d128; + VERIFY (d64 == make_decimal64 (345LL, 0)); + d64 = (decimal64) f; + VERIFY (d64 == make_decimal64 (456LL, 0)); + d64 = (decimal64) d; + VERIFY (d64 == make_decimal64 (567LL, 0)); + d64 = (decimal64) ld; + VERIFY (d64 == make_decimal64 (678LL, 0)); +} + +void +conversion_from_float_128 () +{ + decimal32 d32(123); + decimal64 d64(234); + decimal128 d128(345); + float f = 456.F; + double d = 567.; + long double ld = 678.L; + + d128 = d32; + VERIFY (d128 == make_decimal128 (123LL, 0)); + d128 = d64; + VERIFY (d128 == make_decimal128 (234LL, 0)); + d128 = (decimal128) f; + VERIFY (d128 == make_decimal128 (456LL, 0)); + d128 = (decimal128) d; + VERIFY (d128 == make_decimal128 (567LL, 0)); + d128 = (decimal128) ld; + VERIFY (d128 == make_decimal128 (678LL, 0)); +} + +int +main () +{ + conversion_from_float_32 (); + conversion_from_float_64 (); + conversion_from_float_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/conversion-from-integral.cc b/libstdc++-v3/testsuite/decimal/conversion-from-integral.cc new file mode 100644 index 00000000000..78d5eb76a79 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/conversion-from-integral.cc @@ -0,0 +1,193 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.3 Conversion from integral type (decimal32). +// ISO/IEC TR 24733 3.2.3.3 Conversion from integral type (decimal64). +// ISO/IEC TR 24733 3.2.4.3 Conversion from integral type (decimal128). + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +void +conversion_from_integral_p32 () +{ + decimal32 d; + decimal32 from_si (1); + decimal32 from_ui (2U); + decimal32 from_sl (3L); + decimal32 from_ul (4UL); + decimal32 from_sll (5LL); + decimal32 from_ull (6ULL); + + d++; VERIFY (from_si == d); + d++; VERIFY (from_ui == d); + d++; VERIFY (from_sl == d); + d++; VERIFY (from_ul == d); + d++; VERIFY (from_sll == d); + d++; VERIFY (from_ull == d); + + from_si = 7; + d++; VERIFY (from_si == d); + from_ui = 8U; + d++; VERIFY (from_ui == d); + from_sl = 9L; + d++; VERIFY (from_sl == d); + from_ul = 10UL; + d++; VERIFY (from_ul == d); + from_sll = 11LL; + d++; VERIFY (from_sll == d); + from_ull = 12ULL; + d++; VERIFY (from_ull == d); +} + +void +conversion_from_integral_m32 () +{ + decimal32 d; + decimal32 from_si (-1); + decimal32 from_sl (-2L); + decimal32 from_sll (-3LL); + + d--; VERIFY (from_si == d); + d--; VERIFY (from_sl == d); + d--; VERIFY (from_sll == d); + + from_si = -4; + d--; VERIFY (from_si == d); + from_sl = -5L; + d--; VERIFY (from_sl == d); + from_sll = -6LL; + d--; VERIFY (from_sll == d); +} + +void +conversion_from_integral_p64 () +{ + decimal64 d; + decimal64 from_si (1); + decimal64 from_ui (2U); + decimal64 from_sl (3L); + decimal64 from_ul (4UL); + decimal64 from_sll (5LL); + decimal64 from_ull (6ULL); + + d++; VERIFY (from_si == d); + d++; VERIFY (from_ui == d); + d++; VERIFY (from_sl == d); + d++; VERIFY (from_ul == d); + d++; VERIFY (from_sll == d); + d++; VERIFY (from_ull == d); + + from_si = 7; + d++; VERIFY (from_si == d); + from_ui = 8U; + d++; VERIFY (from_ui == d); + from_sl = 9L; + d++; VERIFY (from_sl == d); + from_ul = 10UL; + d++; VERIFY (from_ul == d); + from_sll = 11LL; + d++; VERIFY (from_sll == d); + from_ull = 12ULL; + d++; VERIFY (from_ull == d); +} + +void +conversion_from_integral_m64 () +{ + decimal64 d; + decimal64 from_si (-1); + decimal64 from_sl (-2L); + decimal64 from_sll (-3LL); + + d--; VERIFY (from_si == d); + d--; VERIFY (from_sl == d); + d--; VERIFY (from_sll == d); + + from_si = -4; + d--; VERIFY (from_si == d); + from_sl = -5L; + d--; VERIFY (from_sl == d); + from_sll = -6LL; + d--; VERIFY (from_sll == d); +} + +void +conversion_from_integral_p128 () +{ + decimal128 d; + decimal128 from_si (1); + decimal128 from_ui (2U); + decimal128 from_sl (3L); + decimal128 from_ul (4UL); + decimal128 from_sll (5LL); + decimal128 from_ull (6ULL); + + d++; VERIFY (from_si == d); + d++; VERIFY (from_ui == d); + d++; VERIFY (from_sl == d); + d++; VERIFY (from_ul == d); + d++; VERIFY (from_sll == d); + d++; VERIFY (from_ull == d); + + from_si = 7; + d++; VERIFY (from_si == d); + from_ui = 8U; + d++; VERIFY (from_ui == d); + from_sl = 9L; + d++; VERIFY (from_sl == d); + from_ul = 10UL; + d++; VERIFY (from_ul == d); + from_sll = 11LL; + d++; VERIFY (from_sll == d); + from_ull = 12ULL; +} + +void +conversion_from_integral_m128 () +{ + decimal128 d; + decimal128 from_si (-1); + decimal128 from_sl (-2L); + decimal128 from_sll (-3LL); + + d--; VERIFY (from_si == d); + d--; VERIFY (from_sl == d); + d--; VERIFY (from_sll == d); + + from_si = -4; + d--; VERIFY (from_si == d); + from_sl = -5L; + d--; VERIFY (from_sl == d); + from_sll = -6LL; + d--; VERIFY (from_sll == d); +} + +int +main () +{ + conversion_from_integral_p32 (); + conversion_from_integral_m32 (); + conversion_from_integral_p64 (); + conversion_from_integral_m64 (); + conversion_from_integral_p128 (); + conversion_from_integral_m128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/conversion-to-generic-float.cc b/libstdc++-v3/testsuite/decimal/conversion-to-generic-float.cc new file mode 100644 index 00000000000..bac0c820ee6 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/conversion-to-generic-float.cc @@ -0,0 +1,105 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.6 Conversion to generic floating-point type. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +void +conversion_to_generic_float_32 () +{ + std::decimal::decimal32 d32(123); + float f; + double d; + long double ld; + + f = decimal32_to_float (d32); + VERIFY (f == 123.F); + d = decimal32_to_double (d32); + VERIFY (d == 123.); + ld = decimal32_to_long_double (d32); + VERIFY (ld == 123.L); + + d32++; + f = decimal_to_float (d32); + VERIFY (f == 124.F); + d = decimal_to_double (d32); + VERIFY (d == 124.); + ld = decimal_to_long_double (d32); + VERIFY (ld == 124.L); +} + +void +conversion_to_generic_float_64 () +{ + std::decimal::decimal64 d64(234); + float f; + double d; + long double ld; + + f = decimal64_to_float (d64); + VERIFY (f == 234.F); + d = decimal64_to_double (d64); + VERIFY (d == 234.); + ld = decimal64_to_long_double (d64); + VERIFY (ld == 234.L); + + d64++; + f = decimal_to_float (d64); + VERIFY (f == 235.F); + d = decimal_to_double (d64); + VERIFY (d == 235.); + ld = decimal_to_long_double (d64); + VERIFY (ld == 235.L); +} + +void +conversion_to_generic_float_128 () +{ + std::decimal::decimal128 d128(345); + float f; + double d; + long double ld; + + f = decimal128_to_float (d128); + VERIFY (f == 345.F); + d = decimal128_to_double (d128); + VERIFY (d == 345.); + ld = decimal128_to_long_double (d128); + VERIFY (ld == 345.L); + + d128++; + f = decimal_to_float (d128); + VERIFY (f == 346.F); + d = decimal_to_double (d128); + VERIFY (d == 346.); + ld = decimal_to_long_double (d128); + VERIFY (ld == 346.L); +} + +int +main () +{ + conversion_to_generic_float_32 (); + conversion_to_generic_float_64 (); + conversion_to_generic_float_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/conversion-to-integral.cc b/libstdc++-v3/testsuite/decimal/conversion-to-integral.cc new file mode 100644 index 00000000000..9322c1bc78f --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/conversion-to-integral.cc @@ -0,0 +1,85 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.4 Conversion to integral type (decimal32). +// ISO/IEC TR 24733 3.2.3.4 Conversion to integral type (decimal64). +// ISO/IEC TR 24733 3.2.4.4 Conversion to integral type (decimal128). + +#include <decimal/decimal> +#include <climits> +#include <cstdio> +#include <testsuite_hooks.h> + +// Use extension to replace implicit long long conversion with function call. +#define LONGLONG(X) decimal_to_long_long(X) + +using namespace std::decimal; + +void +conversion_to_integral_32 (void) +{ + #undef MAXVAL + #define MAXVAL 999999LL + decimal32 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL); + long long ll; + + ll = LONGLONG (a); VERIFY (ll == 0LL); + ll = LONGLONG (b); VERIFY (ll == 1LL); + ll = LONGLONG (c); VERIFY (ll == -1LL); + ll = LONGLONG (d); VERIFY (ll == MAXVAL); + ll = LONGLONG (e); VERIFY (ll == -MAXVAL); +} + +void +conversion_to_integral_64 (void) +{ + #undef MAXVAL + #define MAXVAL 999999999999999LL + decimal64 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL); + long long ll; + + ll = LONGLONG (a); VERIFY (ll == 0LL); + ll = LONGLONG (b); VERIFY (ll == 1LL); + ll = LONGLONG (c); VERIFY (ll == -1LL); + ll = LONGLONG (d); VERIFY (ll == MAXVAL); + ll = LONGLONG (e); VERIFY (ll == -MAXVAL); +} + +void +conversion_to_integral_128 (void) +{ + #undef MAXVAL + #define MAXVAL LONG_LONG_MAX + decimal128 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL); + long long ll; + + ll = LONGLONG (a); VERIFY (ll == 0LL); + ll = LONGLONG (b); VERIFY (ll == 1LL); + ll = LONGLONG (c); VERIFY (ll == -1LL); + ll = LONGLONG (d); VERIFY (ll == MAXVAL); + ll = LONGLONG (e); VERIFY (ll == -MAXVAL); +} + +int +main () +{ + conversion_to_integral_32 (); + conversion_to_integral_64 (); + conversion_to_integral_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/ctor.cc b/libstdc++-v3/testsuite/decimal/ctor.cc new file mode 100644 index 00000000000..84e04ade691 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/ctor.cc @@ -0,0 +1,65 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.1 Construct/copy/destroy (decimal32). +// ISO/IEC TR 24733 3.2.3.1 Construct/copy/destroy (decimal64). +// ISO/IEC TR 24733 3.2.4.1 Construct/copy/destroy (decimal128). + +// Test the default constructor. + +#include <decimal/decimal> +#include <cstring> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +void +ctor_32 (void) +{ + decimal32 a; + float b __attribute__((mode(SD))) = 0.e-101DF; + + VERIFY (memcmp (&a, &b, 4) == 0); +} + +void +ctor_64 (void) +{ + decimal64 a; + float b __attribute__((mode(DD))) = 0.e-398DD; + + VERIFY (memcmp (&a, &b, 8) == 0); +} + +void +ctor_128 (void) +{ + decimal128 a; + float b __attribute__((mode(TD))) = 0.e-6176DL; + + VERIFY (memcmp (&a, &b, 16) == 0); +} + +int +main () +{ + ctor_32 (); + ctor_64 (); + ctor_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/incdec-memfunc.cc b/libstdc++-v3/testsuite/decimal/incdec-memfunc.cc new file mode 100644 index 00000000000..f2d1178a6f1 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/incdec-memfunc.cc @@ -0,0 +1,181 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32). +// ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64). +// ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128). + +// Access member functions directly. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +// Use extension to replace implicit long long conversion with function call. +#define LONGLONG(X) decimal_to_long_long(X) + +using namespace std::decimal; + +void +incdec32 (void) +{ + int ival; + std::decimal::decimal32 a(11), b, c; + + // Verify that we get the expected value of b after assignment. + b = a; + ival = LONGLONG (b); VERIFY (ival == 11); + + // Check that the increment and decrement operators change the value + // of the original class. + b = a; + b.operator++(); + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b.operator++(1); + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b.operator--(); + ival = LONGLONG (b); VERIFY (ival == 10); + + b = a; + b.operator--(1); + ival = LONGLONG (b); VERIFY (ival == 10); + + // Check that the increment and decrement operators return the + // correct value. + b = a; + c = b.operator++(); + ival = LONGLONG (c); VERIFY (ival == 12); + + b = a; + c = b.operator++(1); + ival = LONGLONG (c); VERIFY (ival == 11); + + b = a; + c = b.operator--(); + ival = LONGLONG (c); VERIFY (ival == 10); + + b = a; + c = b.operator--(1); + ival = LONGLONG (c); VERIFY (ival == 11); +} + +void +incdec64 (void) +{ + int ival; + std::decimal::decimal64 a(11), b, c; + + // Verify that we get the expected value of b after assignment. + b = a; + ival = LONGLONG (b); VERIFY (ival == 11); + + // Check that the increment and decrement operators change the value + // of the original class. + b = a; + b.operator++(); + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b.operator++(1); + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b.operator--(); + ival = LONGLONG (b); VERIFY (ival == 10); + + b = a; + b.operator--(1); + ival = LONGLONG (b); VERIFY (ival == 10); + + // Check that the increment and decrement operators return the + // correct value. + b = a; + c = b.operator++(); + ival = LONGLONG (c); VERIFY (ival == 12); + + b = a; + c = b.operator++(1); + ival = LONGLONG (c); VERIFY (ival == 11); + + b = a; + c = b.operator--(); + ival = LONGLONG (c); VERIFY (ival == 10); + + b = a; + c = b.operator--(1); + ival = LONGLONG (c); VERIFY (ival == 11); +} + +void +incdec128 (void) +{ + int ival; + std::decimal::decimal128 a(11), b, c; + + // Verify that we get the expected value of b after assignment. + b = a; + ival = LONGLONG (b); VERIFY (ival == 11); + + // Check that the increment and decrement operators change the value + // of the original class. + b = a; + b.operator++(); + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b.operator++(1); + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b.operator--(); + ival = LONGLONG (b); VERIFY (ival == 10); + + b = a; + b.operator--(1); + ival = LONGLONG (b); VERIFY (ival == 10); + + // Check that the increment and decrement operators return the + // correct value. + b = a; + c = b.operator++(); + ival = LONGLONG (c); VERIFY (ival == 12); + + b = a; + c = b.operator++(1); + ival = LONGLONG (c); VERIFY (ival == 11); + + b = a; + c = b.operator--(); + ival = LONGLONG (c); VERIFY (ival == 10); + + b = a; + c = b.operator--(1); + ival = LONGLONG (c); VERIFY (ival == 11); +} + +int +main () +{ + incdec32 (); + incdec64 (); + incdec128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/incdec.cc b/libstdc++-v3/testsuite/decimal/incdec.cc new file mode 100644 index 00000000000..45211b1de21 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/incdec.cc @@ -0,0 +1,179 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32). +// ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64). +// ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128). + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +// Use extension to replace implicit long long conversion with function call. +#define LONGLONG(X) decimal_to_long_long(X) + +using namespace std::decimal; + +void +incdec32 (void) +{ + int ival; + std::decimal::decimal32 a(11), b, c; + + // Verify that we get the expected value of b after assignment. + b = a; + ival = LONGLONG (b); VERIFY (ival == 11); + + // Check that the increment and decrement operators change the value + // of the original class. + b = a; + ++b; + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b++; + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + --b; + ival = LONGLONG (b); VERIFY (ival == 10); + + b = a; + b--; + ival = LONGLONG (b); VERIFY (ival == 10); + + // Check that the increment and decrement operators return the + // correct value. + b = a; + c = ++b; + ival = LONGLONG (c); VERIFY (ival == 12); + + b = a; + c = b++; + ival = LONGLONG (c); VERIFY (ival == 11); + + b = a; + c = --b; + ival = LONGLONG (c); VERIFY (ival == 10); + + b = a; + c = b--; + ival = LONGLONG (c); VERIFY (ival == 11); +} + +void +incdec64 (void) +{ + int ival; + std::decimal::decimal64 a(11), b, c; + + // Verify that we get the expected value of b after assignment. + b = a; + ival = LONGLONG (b); VERIFY (ival == 11); + + // Check that the increment and decrement operators change the value + // of the original class. + b = a; + ++b; + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b++; + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + --b; + ival = LONGLONG (b); VERIFY (ival == 10); + + b = a; + b--; + ival = LONGLONG (b); VERIFY (ival == 10); + + // Check that the increment and decrement operators return the + // correct value. + b = a; + c = ++b; + ival = LONGLONG (c); VERIFY (ival == 12); + + b = a; + c = b++; + ival = LONGLONG (c); VERIFY (ival == 11); + + b = a; + c = --b; + ival = LONGLONG (c); VERIFY (ival == 10); + + b = a; + c = b--; + ival = LONGLONG (c); VERIFY (ival == 11); +} + +void +incdec128 (void) +{ + int ival; + std::decimal::decimal128 a(11), b, c; + + // Verify that we get the expected value of b after assignment. + b = a; + ival = LONGLONG (b); VERIFY (ival == 11); + + // Check that the increment and decrement operators change the value + // of the original class. + b = a; + ++b; + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + b++; + ival = LONGLONG (b); VERIFY (ival == 12); + + b = a; + --b; + ival = LONGLONG (b); VERIFY (ival == 10); + + b = a; + b--; + ival = LONGLONG (b); VERIFY (ival == 10); + + // Check that the increment and decrement operators return the + // correct value. + b = a; + c = ++b; + ival = LONGLONG (c); VERIFY (ival == 12); + + b = a; + c = b++; + ival = LONGLONG (c); VERIFY (ival == 11); + + b = a; + c = --b; + ival = LONGLONG (c); VERIFY (ival == 10); + + b = a; + c = b--; + ival = LONGLONG (c); VERIFY (ival == 11); +} + +int +main () +{ + incdec32 (); + incdec64 (); + incdec128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/make-decimal.cc b/libstdc++-v3/testsuite/decimal/make-decimal.cc new file mode 100644 index 00000000000..be4fa4632ad --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/make-decimal.cc @@ -0,0 +1,132 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.5 Initialization from coefficient and exponent. + +#include <decimal/decimal> +#include <cstring> +#include <testsuite_hooks.h> + +#define PASTE2(A,B) A ## B +#define PASTE(A,B) PASTE2(A,B) + +#define TESTVAL_NEG(COEFF,ESIGN,EXP,SUF,NUM,SIZE) \ + x = PASTE(PASTE(PASTE(PASTE(PASTE(COEFF,.),E),ESIGN),EXP),SUF); \ + sll = PASTE(COEFF,LL); \ + i = ESIGN EXP; \ + a = PASTE(make_decimal,32) (sll, i); \ + b = PASTE(make_decimal,32) (PASTE(COEFF,LL), ESIGN EXP); \ + VERIFY ((__builtin_memcmp ((void *)&x, (void *)&a, SIZE) == 0) \ + && (__builtin_memcmp ((void *)&x, (void *)&b,SIZE) == 0)); + +#define TESTVAL_NONNEG(COEFF,ESIGN,EXP,SUF,NUM,SIZE) \ + x = PASTE(PASTE(PASTE(PASTE(PASTE(COEFF,.),E),ESIGN),EXP),SUF); \ + sll = PASTE(COEFF,LL); \ + ull = PASTE(COEFF,ULL); \ + i = ESIGN EXP; \ + a = PASTE(make_decimal,32) (sll, i); \ + b = PASTE(make_decimal,32) (PASTE(COEFF,LL), ESIGN EXP); \ + c = PASTE(make_decimal,32) (ull, i); \ + d = PASTE(make_decimal,32) (PASTE(COEFF,ULL), ESIGN EXP); \ + VERIFY ((__builtin_memcmp ((void *)&x, (void *)&a, SIZE) == 0) \ + && (__builtin_memcmp ((void *)&x, (void *)&b,SIZE) == 0) \ + && (__builtin_memcmp ((void *)&x, (void *)&c,SIZE) == 0) \ + && (__builtin_memcmp ((void *)&x, (void *)&d,SIZE) == 0)); + +using namespace std::decimal; + +void +make_decimal_32 (void) +{ + decimal32 a, b, c, d; + float x __attribute__((mode(SD))); + int i; + unsigned long sz = sizeof (decimal32); + volatile long long sll; + volatile unsigned long long ull; + + TESTVAL_NONNEG (0, +, 0, DF, 32, sz); + TESTVAL_NONNEG (5, +, 1, DF, 32, sz); + TESTVAL_NONNEG (50, +, 0, DF, 32, sz); + TESTVAL_NONNEG (500, +, 0, DF, 32, sz); + TESTVAL_NEG (-25, -, 3, DF, 32, sz) + TESTVAL_NEG (-500, +, 0, DF, 32, sz); + TESTVAL_NONNEG (999999, +, 91, DF, 32, sz); + TESTVAL_NONNEG (1, -, 9, DF, 32, sz); + TESTVAL_NONNEG (1, -, 90, DF, 32, sz); + TESTVAL_NONNEG (1, -, 95, DF, 32, sz); + TESTVAL_NONNEG (1, -, 101, DF, 32, sz); + TESTVAL_NEG (-1, -, 101, DF, 32, sz); +} + +void +make_decimal_64 (void) +{ + decimal64 a, b, c, d; + float x __attribute__((mode(DD))); + int i; + unsigned long sz = sizeof (decimal64); + volatile long long sll; + volatile unsigned long long ull; + + TESTVAL_NONNEG (0, +, 0, DF, 64, sz); + TESTVAL_NONNEG (5, +, 1, DF, 64, sz); + TESTVAL_NONNEG (50, +, 0, DF, 64, sz); + TESTVAL_NONNEG (500, +, 0, DF, 64, sz); + TESTVAL_NEG (-25, -, 3, DF, 64, sz) + TESTVAL_NEG (-500, +, 0, DF, 64, sz); + TESTVAL_NONNEG (999999, +, 91, DF, 64, sz); + TESTVAL_NONNEG (1, -, 9, DF, 64, sz); + TESTVAL_NONNEG (1, -, 90, DF, 64, sz); + TESTVAL_NONNEG (1, -, 95, DF, 64, sz); + TESTVAL_NONNEG (1, -, 101, DF, 64, sz); + TESTVAL_NEG (-1, -, 101, DF, 64, sz); +} + +void +make_decimal_128 (void) +{ + decimal128 a, b, c, d; + float x __attribute__((mode(TD))); + int i; + unsigned long sz = sizeof (decimal128); + volatile long long sll; + volatile unsigned long long ull; + + TESTVAL_NONNEG (0, +, 0, DF, 128, sz); + TESTVAL_NONNEG (5, +, 1, DF, 128, sz); + TESTVAL_NONNEG (50, +, 0, DF, 128, sz); + TESTVAL_NONNEG (500, +, 0, DF, 128, sz); + TESTVAL_NEG (-25, -, 3, DF, 128, sz) + TESTVAL_NEG (-500, +, 0, DF, 128, sz); + TESTVAL_NONNEG (999999, +, 91, DF, 128, sz); + TESTVAL_NONNEG (1, -, 9, DF, 128, sz); + TESTVAL_NONNEG (1, -, 90, DF, 128, sz); + TESTVAL_NONNEG (1, -, 95, DF, 128, sz); + TESTVAL_NONNEG (1, -, 101, DF, 128, sz); + TESTVAL_NEG (-1, -, 101, DF, 128, sz); +} + +int +main () +{ + make_decimal_32 (); + make_decimal_64 (); + make_decimal_128 (); +} diff --git a/libstdc++-v3/testsuite/decimal/mixed-mode_neg.cc b/libstdc++-v3/testsuite/decimal/mixed-mode_neg.cc new file mode 100644 index 00000000000..7f9da43ed43 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/mixed-mode_neg.cc @@ -0,0 +1,206 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-require-effective-target dfp } + +// Test that binary operators do not accept mixed decimal and generic +// floating-point operands. This isn't explicity prohibited in +// ISO/IEC TR 24733 but it is prohibited in C, and in C++ there should +// not be an implicit conversion from a decimal floating-point type to +// a generic floating-point type. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +decimal32 a32, b32, c32; +decimal64 a64, b64, c64; +decimal128 a128, b128, c128; +float f; +double d; +long double ld; +bool b1, b2, b3, b4, b5, b6; + +void +bad_add (void) +{ + a32 = b32 + f; // { dg-error "error" } + a32 = ld + b32; // { dg-error "error" } + a64 = b64 + d; // { dg-error "error" } + a64 = ld + b64; // { dg-error "error" } + a128 = b128 + ld; // { dg-error "error" } + a128 = d + b128; // { dg-error "error" } +} + +void +bad_subtract (void) +{ + a32 = b32 - f; // { dg-error "error" } + a32 = ld - b32; // { dg-error "error" } + a64 = b64 - d; // { dg-error "error" } + a64 = ld - b64; // { dg-error "error" } + a128 = b128 - ld; // { dg-error "error" } + a128 = d - b128; // { dg-error "error" } +} + +void +bad_multiply (void) +{ + a32 = b32 * f; // { dg-error "error" } + a32 = ld * b32; // { dg-error "error" } + a64 = b64 * d; // { dg-error "error" } + a64 = ld * b64; // { dg-error "error" } + a128 = b128 * ld; // { dg-error "error" } + a128 = d * b128; // { dg-error "error" } +} + +void +bad_divide (void) +{ + a32 = b32 / f; // { dg-error "error" } + a32 = ld / b32; // { dg-error "error" } + a64 = b64 / d; // { dg-error "error" } + a64 = ld / b64; // { dg-error "error" } + a128 = b128 / ld; // { dg-error "error" } + a128 = d / b128; // { dg-error "error" } +} + +void +bad_eq (void) +{ + b1 = b32 == f; // { dg-error "error" } + b2 = ld == b32; // { dg-error "error" } + b3 = b64 == d; // { dg-error "error" } + b4 = ld == b64; // { dg-error "error" } + b5 = b128 == ld; // { dg-error "error" } + b6 = d == b128; // { dg-error "error" } +} + +void +bad_ne (void) +{ + b1 = b32 != f; // { dg-error "error" } + b2 = ld != b32; // { dg-error "error" } + b3 = b64 != d; // { dg-error "error" } + b4 = ld != b64; // { dg-error "error" } + b5 = b128 != ld; // { dg-error "error" } + b6 = d != b128; // { dg-error "error" } +} + +void +bad_lt (void) +{ + b1 = b32 < f; // { dg-error "error" } + b2 = ld < b32; // { dg-error "error" } + b3 = b64 < d; // { dg-error "error" } + b4 = ld < b64; // { dg-error "error" } + b5 = b128 < ld; // { dg-error "error" } + b6 = d < b128; // { dg-error "error" } +} + +void +bad_le (void) +{ + b1 = b32 <= f; // { dg-error "error" } + b2 = ld <= b32; // { dg-error "error" } + b3 = b64 <= d; // { dg-error "error" } + b4 = ld <= b64; // { dg-error "error" } + b5 = b128 <= ld; // { dg-error "error" } + b6 = d <= b128; // { dg-error "error" } +} + +void +bad_gt (void) +{ + b1 = b32 > f; // { dg-error "error" } + b2 = ld > b32; // { dg-error "error" } + b3 = b64 > d; // { dg-error "error" } + b4 = ld > b64; // { dg-error "error" } + b5 = b128 > ld; // { dg-error "error" } + b6 = d > b128; // { dg-error "error" } +} + +void +bad_ge (void) +{ + b1 = b32 >= f; // { dg-error "error" } + b2 = ld >= b32; // { dg-error "error" } + b3 = b64 >= d; // { dg-error "error" } + b4 = ld >= b64; // { dg-error "error" } + b5 = b128 >= ld; // { dg-error "error" } + b6 = d >= b128; // { dg-error "error" } +} + +void +bad_pluseq (void) +{ + a32 += f; // { dg-error "error" } + a32 += d; // { dg-error "error" } + a32 += ld; // { dg-error "error" } + a64 += f; // { dg-error "error" } + a64 += d; // { dg-error "error" } + a64 += ld; // { dg-error "error" } + a128 += f; // { dg-error "error" } + a128 += d; // { dg-error "error" } + a128 += ld; // { dg-error "error" } +} + +void +bad_minuseq (void) +{ + a32 -= f; // { dg-error "error" } + a32 -= d; // { dg-error "error" } + a32 -= ld; // { dg-error "error" } + a64 -= f; // { dg-error "error" } + a64 -= d; // { dg-error "error" } + a64 -= ld; // { dg-error "error" } + a128 -= f; // { dg-error "error" } + a128 -= d; // { dg-error "error" } + a128 -= ld; // { dg-error "error" } +} + +void +bad_timeseq (void) +{ + a32 *= f; // { dg-error "error" } + a32 *= d; // { dg-error "error" } + a32 *= ld; // { dg-error "error" } + a64 *= f; // { dg-error "error" } + a64 *= d; // { dg-error "error" } + a64 *= ld; // { dg-error "error" } + a128 *= f; // { dg-error "error" } + a128 *= d; // { dg-error "error" } + a128 *= ld; // { dg-error "error" } +} + +void +bad_divideeq (void) +{ + a32 /= f; // { dg-error "error" } + a32 /= d; // { dg-error "error" } + a32 /= ld; // { dg-error "error" } + a64 /= f; // { dg-error "error" } + a64 /= d; // { dg-error "error" } + a64 /= ld; // { dg-error "error" } + a128 /= f; // { dg-error "error" } + a128 /= d; // { dg-error "error" } + a128 /= ld; // { dg-error "error" } +} + +// { dg-excess-errors "notes about candidates" } diff --git a/libstdc++-v3/testsuite/decimal/operator_neg.cc b/libstdc++-v3/testsuite/decimal/operator_neg.cc new file mode 100644 index 00000000000..fff81d1c06f --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/operator_neg.cc @@ -0,0 +1,160 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-do compile } +// { dg-require-effective-target dfp } + +// Test that C++ binary operators that are restricted to integer operands +// do not accept decimal float operands. + +#include <decimal/decimal> + +using namespace std::decimal; + +decimal32 a32, b32, c32; +decimal64 a64, b64, c64; +decimal128 a128, b128, c128; + +void +modulus (void) +{ + a32 = b32 % c32; // { dg-error "error" } + a64 = b64 % c64; // { dg-error "error" } + a128 = b128 % c128; // { dg-error "error" } + a128 = b32 % c128; // { dg-error "error" } + a128 = b64 % c128; // { dg-error "error" } + a32 = 100 % c32; // { dg-error "error" } + a64 = 10 % c64; // { dg-error "error" } + a128 = 1000 % c128; // { dg-error "error" } + a32 = b32 % 7; // { dg-error "error" } + a64 = b64 % 5; // { dg-error "error" } + a128 = b128 % 3; // { dg-error "error" } +} + +void +bitwise_right_shift (void) +{ + a32 = b32 >> c32; // { dg-error "error" } + a64 = b64 >> c64; // { dg-error "error" } + a128 = b128 >> c128; // { dg-error "error" } + a128 = b32 >> c128; // { dg-error "error" } + a128 = b64 >> c128; // { dg-error "error" } + a32 = 100 >> c32; // { dg-error "error" } + a64 = 10 >> c64; // { dg-error "error" } + a128 = 1000 >> c128; // { dg-error "error" } + a32 = b32 >> 7; // { dg-error "error" } + a64 = b64 >> 5; // { dg-error "error" } + a128 = b128 >> 3; // { dg-error "error" } +} + +void +bitwise_left_shift (void) +{ + a32 = b32 << c32; // { dg-error "error" } + a64 = b64 << c64; // { dg-error "error" } + a128 = b128 << c128; // { dg-error "error" } + a128 = b32 << c128; // { dg-error "error" } + a128 = b64 << c128; // { dg-error "error" } + a32 = 100 << c32; // { dg-error "error" } + a64 = 10 << c64; // { dg-error "error" } + a128 = 1000 << c128; // { dg-error "error" } + a32 = b32 << 7; // { dg-error "error" } + a64 = b64 << 5; // { dg-error "error" } + a128 = b128 << 3; // { dg-error "error" } +} + +void +bitwise_exclusive_or (void) +{ + a32 = b32 ^ c32; // { dg-error "error" } + a64 = b64 ^ c64; // { dg-error "error" } + a128 = b128 ^ c128; // { dg-error "error" } + a128 = b32 ^ c128; // { dg-error "error" } + a128 = b64 ^ c128; // { dg-error "error" } + a32 = 100 ^ c32; // { dg-error "error" } + a64 = 10 ^ c64; // { dg-error "error" } + a128 = 1000 ^ c128; // { dg-error "error" } + a32 = b32 ^ 7; // { dg-error "error" } + a64 = b64 ^ 5; // { dg-error "error" } + a128 = b128 ^ 3; // { dg-error "error" } +} + +void +bitwise_inclusive_or (void) +{ + a32 = b32 | c32; // { dg-error "error" } + a64 = b64 | c64; // { dg-error "error" } + a128 = b128 | c128; // { dg-error "error" } + a128 = b32 | c128; // { dg-error "error" } + a128 = b64 | c128; // { dg-error "error" } + a32 = 100 | c32; // { dg-error "error" } + a64 = 10 | c64; // { dg-error "error" } + a128 = 1000 | c128; // { dg-error "error" } + a32 = b32 | 7; // { dg-error "error" } + a64 = b64 | 5; // { dg-error "error" } + a128 = b128 | 3; // { dg-error "error" } +} + +void +logical_and (void) +{ + a32 = b32 && c32; // { dg-error "error" } + a64 = b64 && c64; // { dg-error "error" } + a128 = b128 && c128; // { dg-error "error" } + a128 = b32 && c128; // { dg-error "error" } + a128 = b64 && c128; // { dg-error "error" } + a32 = 100 && c32; // { dg-error "error" } + a64 = 10 && c64; // { dg-error "error" } + a128 = 1000 && c128; // { dg-error "error" } + a32 = b32 && 7; // { dg-error "error" } + a64 = b64 && 5; // { dg-error "error" } + a128 = b128 && 3; // { dg-error "error" } +} + +void +logical_or (void) +{ + a32 = b32 || c32; // { dg-error "error" } + a64 = b64 || c64; // { dg-error "error" } + a128 = b128 || c128; // { dg-error "error" } + a128 = b32 || c128; // { dg-error "error" } + a128 = b64 || c128; // { dg-error "error" } + a32 = 100 || c32; // { dg-error "error" } + a64 = 10 || c64; // { dg-error "error" } + a128 = 1000 || c128; // { dg-error "error" } + a32 = b32 || 7; // { dg-error "error" } + a64 = b64 || 5; // { dg-error "error" } + a128 = b128 || 3; // { dg-error "error" } +} + +void +bitwise_complement (void) +{ + a32 = ~b32; // { dg-error "error" } + a64 = ~b64; // { dg-error "error" } + a128 = ~b128; // { dg-error "error" } +} + +void +logical_not (void) +{ + a32 = !b32; // { dg-error "error" } + a64 = !b64; // { dg-error "error" } + a128 = !b128; // { dg-error "error" } +} + +// { dg-excess-errors "" { target *-*-* } } diff --git a/libstdc++-v3/testsuite/decimal/unary-arith.cc b/libstdc++-v3/testsuite/decimal/unary-arith.cc new file mode 100644 index 00000000000..d32b98d0d51 --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/unary-arith.cc @@ -0,0 +1,93 @@ +// 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 +// <http://www.gnu.org/licenses/>. + +// { dg-require-effective-target dfp } + +// ISO/IEC TR 24733 3.2.7 Unary arithmetic operators. + +#include <decimal/decimal> +#include <testsuite_hooks.h> + +using namespace std::decimal; + +decimal32 a32 (20), b32 (-20); +decimal64 a64 (124), b64 (-124); +decimal128 a128 (5001), b128 (-5001); + +void +unary_plus_32 (void) +{ + decimal32 a; + + a = +a32; VERIFY (a == a32); + a = +b32; VERIFY (a == b32); +} + +void +unary_minus_32 (void) +{ + decimal32 a; + + a = -a32; VERIFY (a == b32); + a = -b32; VERIFY (a == a32); +} + +void +unary_plus_64 (void) +{ + decimal64 a; + + a = +a64; VERIFY (a == a64); + a = +b64; VERIFY (a == b64); +} + +void +unary_minus_64 (void) +{ + decimal64 a; + + a = -a64; VERIFY (a == b64); + a = -b64; VERIFY (a == a64); +} + +void +unary_plus_128 (void) +{ + decimal128 a; + + a = +a128; VERIFY (a == a128); + a = +b128; VERIFY (a == b128); +} + +void +unary_minus_128 (void) +{ + decimal128 a; + + a = -a128; VERIFY (a == b128); + a = -b128; VERIFY (a == a128); +} + +int main () +{ + unary_plus_32 (); + unary_minus_32 (); + unary_plus_64 (); + unary_minus_64 (); + unary_plus_128 (); + unary_minus_128 (); +} diff --git a/libstdc++-v3/testsuite/ext/profile/mh.cc b/libstdc++-v3/testsuite/ext/profile/mh.cc index dc910949867..44a667c0442 100644 --- a/libstdc++-v3/testsuite/ext/profile/mh.cc +++ b/libstdc++-v3/testsuite/ext/profile/mh.cc @@ -1,3 +1,6 @@ +// { dg-options "-D_GLIBCXX_PROFILE" } +// { dg-do compile { target *-*-linux* } } + // -*- C++ -*- // Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. @@ -17,9 +20,6 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-options "-D_GLIBCXX_PROFILE" } -// { dg-do compile } - #include <stdio.h> #include <malloc.h> #include <vector> @@ -58,7 +58,8 @@ my_malloc_hook (size_t size, const void *caller) } -int main() { +int main() +{ int* test = (int*) malloc(sizeof(int)); *test = 1; return *test; diff --git a/libstdc++-v3/testsuite/ext/profile/mutex_extensions.cc b/libstdc++-v3/testsuite/ext/profile/mutex_extensions.cc index c8bcf720e1d..5237107da1f 100644 --- a/libstdc++-v3/testsuite/ext/profile/mutex_extensions.cc +++ b/libstdc++-v3/testsuite/ext/profile/mutex_extensions.cc @@ -22,5 +22,5 @@ #include <vector> -// { dg-error "Cannot use -D_GLIBCXX_PROFILE with " "" { target *-*-* } 166 } +// { dg-error "Cannot use -D_GLIBCXX_PROFILE with " "" { target *-*-* } 165 } // { dg-excess-errors "In file included from" } diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 1d9af09a3a6..60e9b78fdba 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -80,15 +80,6 @@ proc dg-require-time { args } { return } -proc dg-require-rvalref { args } { - if { ![ check_v3_target_rvalref ] } { - upvar dg-do-what dg-do-what - set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] - return - } - return -} - proc dg-require-cstdint { args } { if { ![ check_v3_target_cstdint ] } { upvar dg-do-what dg-do-what diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 05a9b5db860..c71991afc90 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -805,61 +805,6 @@ proc check_v3_target_time { } { return $et_time_saved } -proc check_v3_target_rvalref { } { - global et_rvalref_saved - global et_rvalref_target_name - global tool - - if { ![info exists et_rvalref_target_name] } { - set et_rvalref_target_name "" - } - - # If the target has changed since we set the cached value, clear it. - set current_target [current_target_name] - if { $current_target != $et_rvalref_target_name } { - verbose "check_v3_target_rvalref: `$et_rvalref_target_name'" 2 - set et_rvalref_target_name $current_target - if [info exists et_rvalref_saved] { - verbose "check_v3_target_rvalref: removing cached result" 2 - unset et_rvalref_saved - } - } - - if [info exists et_rvalref_saved] { - verbose "check_v3_target_rvalref: using cached result" 2 - } else { - set et_rvalref_saved 0 - - # Set up and compile a C++ test program that tries to use - # the library components of rval references - set src rvalref[pid].cc - set exe rvalref[pid].x - - set f [open $src "w"] - puts $f "#include <iterator>" - puts $f "#include <utility>" - puts $f "using std::move;" - puts $f "using std::identity;" - puts $f "using std::forward;" - puts $f "using std::move_iterator;" - puts $f "using std::make_move_iterator;" - close $f - - set lines [v3_target_compile $src $exe executable ""] - file delete $src - - if [string match "" $lines] { - # No error message, compilation succeeded. - verbose "check_v3_target_rvalref: compilation succeeded" 2 - remote_file build delete $exe - set et_rvalref_saved 1 - } else { - verbose "check_v3_target_rvalref: compilation failed" 2 - } - } - return $et_rvalref_saved -} - proc check_v3_target_namedlocale { } { global et_namedlocale_saved global et_namedlocale_target_name diff --git a/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp b/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp index fa3d087ddac..ae339496cda 100644 --- a/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp +++ b/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp @@ -58,6 +58,7 @@ if {[info exists tests_file] && [file exists $tests_file]} { lappend subdirs "$srcdir/ext" lappend subdirs "$srcdir/performance" lappend subdirs "$srcdir/tr1" + lappend subdirs "$srcdir/decimal" verbose "subdirs are $subdirs" # Find all the tests. |