From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/20_util/reference_wrapper/24803.cc | 80 +++++++++++ .../testsuite/20_util/reference_wrapper/41792.cc | 34 +++++ .../20_util/reference_wrapper/invoke-2.cc | 46 +++++++ .../testsuite/20_util/reference_wrapper/invoke.cc | 120 +++++++++++++++++ .../testsuite/20_util/reference_wrapper/ref_neg.cc | 44 ++++++ .../20_util/reference_wrapper/result_type.cc | 42 ++++++ .../20_util/reference_wrapper/typedefs-2.cc | 69 ++++++++++ .../20_util/reference_wrapper/typedefs-3.cc | 148 +++++++++++++++++++++ .../20_util/reference_wrapper/typedefs.cc | 59 ++++++++ 9 files changed, 642 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc create mode 100644 libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc (limited to 'libstdc++-v3/testsuite/20_util/reference_wrapper') diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc new file mode 100644 index 000000000..4bf61485c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/24803.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include + +struct test_type +{ + int member(); + int cmember()const; + int member2(char); + int cmember2(char)const; +}; + +struct functor1 : public std::unary_function +{ + double operator()(int) const; +}; + +struct functor2 : public std::binary_function +{ + double operator()(int, char) const; +}; + +template +void verify_return_type(T, T) +{ +} + +void test01() +{ + test_type* null_tt = 0; + const test_type* null_ttc = 0; + int zero; + + std::reference_wrapper* pr1(0); + verify_return_type((*pr1)(0), double()); + std::reference_wrapper* pr2(0); + verify_return_type((*pr2)(0), double()); + std::reference_wrapper* pr3(0); + verify_return_type((*pr3)(null_tt), int()); + std::reference_wrapper* pr4(0); + verify_return_type((*pr4)(null_ttc), int()); + std::reference_wrapper* pr5(0); + + // libstdc++/24803 + verify_return_type((*pr5)(0), double()); + verify_return_type((*pr5)(zero), double()); + + std::reference_wrapper* pr1b(0); + verify_return_type((*pr1b)(0, 0), double()); + std::reference_wrapper* pr2b(0); + verify_return_type((*pr2b)(0, 0), double()); + std::reference_wrapper* pr3b(0); + verify_return_type((*pr3b)(null_tt,zero), int()); + std::reference_wrapper* pr4b(0); + verify_return_type((*pr4b)(null_ttc), int()); + std::reference_wrapper* pr5b(0); + + // libstdc++/24803 + verify_return_type((*pr5b)(0, 0), double()); + verify_return_type((*pr5b)(zero, zero), double()); +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc new file mode 100644 index 000000000..b167d7122 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/41792.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-05-20 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/41792 +void test01() +{ + using namespace __gnu_test; + + OverloadedAddress* ao1 = new OverloadedAddress(); + std::reference_wrapper rw1(*ao1); +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc new file mode 100644 index 000000000..c1b62932f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke-2.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile} +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.6.4 function object return types [func.ret] +#include + +struct X +{ + int f(int) { return 0; } + int i; +}; + +void test01() +{ + typedef int (X::*mfp)(int); + typedef int X::*mp; + mfp m = &X::f; + mp m2 = &X::i; + X x = { }; + std::ref(m)(x, 1); + std::ref(m)(&x, 1); + int& i1 = std::ref(m2)(x); + int& i2 = std::ref(m2)(&x); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc new file mode 100644 index 000000000..7b694c764 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/invoke.cc @@ -0,0 +1,120 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +using namespace __gnu_test; + +bool test __attribute__((unused)) = true; + +struct X +{ + typedef int result_type; + + X() : bar(17) {} + + int foo(float x) { return truncate_float(x); } + int foo_c(float x) const { return truncate_float(x); } + int foo_v(float x) volatile { return truncate_float(x); } + int foo_cv(float x) const volatile { return truncate_float(x); } + int foo_varargs(float x, ...) { return truncate_float(x); } + + int operator()(float x) + { + return foo(x) + 1; + } + + int operator()(float x) const + { + return foo_c(x) + 2; + } + + int bar; + + private: + X(const X&); + X& operator=(const X&); +}; + +int seventeen() { return 17; } + +struct get_seventeen +{ + typedef int result_type; + int operator()() const { return 17; } +}; + +void test01() +{ + using std::ref; + using std::cref; + + ::get_seventeen get_sev; + ::X x; + ::X* xp = &x; + int (::X::* p_foo)(float) = &::X::foo; + int (::X::* p_foo_c)(float) const = &::X::foo_c; + int (::X::* p_foo_v)(float) volatile = &::X::foo_v; + int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv; + int (::X::* p_foo_varargs)(float, ...) = &::X::foo_varargs; + int ::X::* p_bar = &::X::bar; + + const float pi = 3.14; + + // Functions + VERIFY(ref(truncate_float)(pi) == 3); + VERIFY(ref(seventeen)() == 17); + + // Function pointers + VERIFY(cref(truncate_float)(pi) == 3); + VERIFY(cref(seventeen)() == 17); + + // Member function pointers + VERIFY(ref(p_foo)(x, pi) == 3); + VERIFY(ref(p_foo)(xp, pi) == 3); + VERIFY(ref(p_foo_c)(x, pi) == 3); + VERIFY(ref(p_foo_c)(xp, pi) == 3); + VERIFY(ref(p_foo_v)(x, pi) == 3); + VERIFY(ref(p_foo_v)(xp, pi) == 3); + VERIFY(ref(p_foo_cv)(x, pi) == 3); + VERIFY(ref(p_foo_cv)(xp, pi) == 3); + // VERIFY(ref(p_foo_varargs)(x, pi) == 3); + // VERIFY(ref(p_foo_varargs)(xp, pi, 1, 1) == 3); + // VERIFY(ref(p_foo_varargs)(x, pi, 1, 1) == 3); + // VERIFY(ref(p_foo_varargs)(xp, pi) == 3); + + // Member data pointers + VERIFY(ref(p_bar)(x) == 17); + VERIFY(ref(p_bar)(xp) == 17); + + // Function objects + VERIFY(ref(get_sev)() == 17); + VERIFY(cref(get_sev)() == 17); + VERIFY(ref(x)(pi) == 4); + VERIFY(cref(x)(pi) == 5); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc new file mode 100644 index 000000000..947a9b02f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/ref_neg.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 20.8.3 Class template reference_wrapper + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include + +struct X { }; +X rval(); +X&& rvalref(); + +void test01() +{ + std::ref(1); // { dg-error "deleted" } + std::cref(1); // { dg-error "deleted" } + std::ref( int() ); // { dg-error "deleted" } + std::cref( int() ); // { dg-error "deleted" } + std::ref(rval()); // { dg-error "deleted" } + std::cref(rvalref()); // { dg-error "deleted" } +} + +int main() +{ + test02(); +} + +// { dg-excess-errors "" } diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc new file mode 100644 index 000000000..911e9a944 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/result_type.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-10-06 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +using namespace std; + +struct T; + +reference_wrapper::result_type i01; +reference_wrapper::result_type i02; +reference_wrapper::result_type i03; +reference_wrapper::result_type i04; + +reference_wrapper::result_type i05; +reference_wrapper::result_type i06; +reference_wrapper::result_type i07; +reference_wrapper::result_type i08; + +reference_wrapper::result_type i09; +reference_wrapper::result_type i10; +reference_wrapper::result_type i11; +reference_wrapper::result_type i12; diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc new file mode 100644 index 000000000..8b1b7e3f1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-2.cc @@ -0,0 +1,69 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2010-10-06 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +using namespace std; + +reference_wrapper::argument_type i01; +reference_wrapper::argument_type i02; +reference_wrapper::argument_type i03; +reference_wrapper::argument_type i04; +reference_wrapper::result_type i05; +reference_wrapper::result_type i06; +reference_wrapper::result_type i07; +reference_wrapper::result_type i08; + +reference_wrapper::argument_type i09; +reference_wrapper::argument_type i10; +reference_wrapper::argument_type i11; +reference_wrapper::argument_type i12; +reference_wrapper::result_type i13; +reference_wrapper::result_type i14; +reference_wrapper::result_type i15; +reference_wrapper::result_type i16; + +reference_wrapper::first_argument_type i17; +reference_wrapper::first_argument_type i18; +reference_wrapper::first_argument_type i19; +reference_wrapper::first_argument_type i20; +reference_wrapper::second_argument_type i21; +reference_wrapper::second_argument_type i22; +reference_wrapper::second_argument_type i23; +reference_wrapper::second_argument_type i24; +reference_wrapper::result_type i25; +reference_wrapper::result_type i26; +reference_wrapper::result_type i27; +reference_wrapper::result_type i28; + +reference_wrapper::first_argument_type i29; +reference_wrapper::first_argument_type i30; +reference_wrapper::first_argument_type i31; +reference_wrapper::first_argument_type i32; +reference_wrapper::second_argument_type i33; +reference_wrapper::second_argument_type i34; +reference_wrapper::second_argument_type i35; +reference_wrapper::second_argument_type i36; +reference_wrapper::result_type i37; +reference_wrapper::result_type i38; +reference_wrapper::result_type i39; +reference_wrapper::result_type i40; diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc new file mode 100644 index 000000000..2fea52eed --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs-3.cc @@ -0,0 +1,148 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct S { }; + +struct S0 +{ + typedef int argument_type; +}; + +struct S1 +{ + typedef float first_argument_type; +}; + +struct S2 +{ + typedef char second_argument_type; +}; + +struct S01 : S0, S1 { }; +struct S02 : S0, S2 { }; +struct S12 : S1, S2 { }; + +struct S012 : S0, S1, S2 { }; + +using std::__sfinae_types; +using std::integral_constant; +using std::remove_cv; + +_GLIBCXX_HAS_NESTED_TYPE(argument_type) +_GLIBCXX_HAS_NESTED_TYPE(first_argument_type) +_GLIBCXX_HAS_NESTED_TYPE(second_argument_type) + +template + struct has_arg_type : __has_argument_type + { }; + +template + struct has_1st_arg_type : __has_first_argument_type + { }; + +template + struct has_2nd_arg_type : __has_second_argument_type + { }; + +template::value> +struct test_arg_type +{ + static_assert( !has_arg_type>::value, + "reference_wrapper has no nested argument_type"); +}; + +template +struct test_arg_type +{ + typedef std::reference_wrapper ref; + + static_assert( has_arg_type::value, + "reference_wrapper has nested argument_type"); + + static_assert( + std::is_same< typename T::argument_type, + typename ref::argument_type >::value, + "reference_wrapper has the correct argument_type"); +}; + +template::value && has_2nd_arg_type::value> +struct test_1st_2nd_arg_types +{ + typedef std::reference_wrapper ref; + + static_assert( !has_1st_arg_type::value, + "reference_wrapper has no nested first_argument_type"); + + static_assert( !has_2nd_arg_type::value, + "reference_wrapper has no nested second_argument_type"); +}; + +template +struct test_1st_2nd_arg_types +{ + typedef std::reference_wrapper ref; + + static_assert( has_1st_arg_type::value, + "reference_wrapper has nested first_argument_type"); + + static_assert( has_2nd_arg_type::value, + "reference_wrapper has nested second_argument_type"); + + static_assert( + std::is_same< typename T::first_argument_type, + typename ref::first_argument_type>::value, + "reference_wrapper has correct first_argument_type"); + + static_assert( + std::is_same< typename T::second_argument_type, + typename ref::second_argument_type>::value, + "reference_wrapper has correct second_argument_type"); +}; + + +template + void test() + { + test_arg_type t; + test_arg_type tc; + test_arg_type tv; + test_arg_type tcv; + test_1st_2nd_arg_types t12; + test_1st_2nd_arg_types t12c; + test_1st_2nd_arg_types t12v; + test_1st_2nd_arg_types t12cv; + } + +int main() +{ + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} + diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc new file mode 100644 index 000000000..815700f1c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/typedefs.cc @@ -0,0 +1,59 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +struct X {}; + +struct int_result_type { typedef int result_type; }; + +struct derives_unary : std::unary_function {}; + +struct derives_binary : std::binary_function {}; + +struct derives_unary_binary + : std::unary_function, + std::binary_function +{ + typedef int result_type; +}; + +void test01() +{ + using std::reference_wrapper; + using std::is_same; + + // Check result_type typedef + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); + static_assert( is_same::result_type, int>::value, "has result_type" ); +} + +int main() +{ + test01(); + return 0; +} -- cgit v1.2.3