From c5269263b072de87f9b4476ef87499e7408f7cd6 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 11 Jan 2018 19:38:52 +0000 Subject: [PATCH] Add some reproducers for issues found developing the location-wrappers patch gcc/testsuite/ChangeLog: PR c++/43486 * g++.dg/wrappers: New subdirectory. * g++.dg/wrappers/README: New file. * g++.dg/wrappers/alloc.C: New test case. * g++.dg/wrappers/cow-istream-string.C: New test case. * g++.dg/wrappers/cp-stdlib.C: New test case. * g++.dg/wrappers/sanitizer_coverage_libcdep_new.C: New test case. * g++.dg/wrappers/wrapper-around-type-pack-expansion.C: New test case. From-SVN: r256552 --- gcc/testsuite/ChangeLog | 12 ++ gcc/testsuite/g++.dg/wrappers/README | 2 + gcc/testsuite/g++.dg/wrappers/alloc.C | 43 +++++++ .../g++.dg/wrappers/cow-istream-string.C | 15 +++ gcc/testsuite/g++.dg/wrappers/cp-stdlib.C | 117 ++++++++++++++++++ .../wrappers/sanitizer_coverage_libcdep_new.C | 22 ++++ .../wrapper-around-type-pack-expansion.C | 50 ++++++++ 7 files changed, 261 insertions(+) create mode 100644 gcc/testsuite/g++.dg/wrappers/README create mode 100644 gcc/testsuite/g++.dg/wrappers/alloc.C create mode 100644 gcc/testsuite/g++.dg/wrappers/cow-istream-string.C create mode 100644 gcc/testsuite/g++.dg/wrappers/cp-stdlib.C create mode 100644 gcc/testsuite/g++.dg/wrappers/sanitizer_coverage_libcdep_new.C create mode 100644 gcc/testsuite/g++.dg/wrappers/wrapper-around-type-pack-expansion.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f1eb59b80b1..1ba529d00cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2018-01-11 David Malcolm + + PR c++/43486 + * g++.dg/wrappers: New subdirectory. + * g++.dg/wrappers/README: New file. + * g++.dg/wrappers/alloc.C: New test case. + * g++.dg/wrappers/cow-istream-string.C: New test case. + * g++.dg/wrappers/cp-stdlib.C: New test case. + * g++.dg/wrappers/sanitizer_coverage_libcdep_new.C: New test case. + * g++.dg/wrappers/wrapper-around-type-pack-expansion.C: New test + case. + 2018-01-11 Jan Hubicka PR middle-end/83718 diff --git a/gcc/testsuite/g++.dg/wrappers/README b/gcc/testsuite/g++.dg/wrappers/README new file mode 100644 index 00000000000..9cba9701d12 --- /dev/null +++ b/gcc/testsuite/g++.dg/wrappers/README @@ -0,0 +1,2 @@ +This directory contains reproducers for issues seen when adding location +wrapper nodes to the C++ frontend (ICEs and behavior changes). diff --git a/gcc/testsuite/g++.dg/wrappers/alloc.C b/gcc/testsuite/g++.dg/wrappers/alloc.C new file mode 100644 index 00000000000..e004470dbe9 --- /dev/null +++ b/gcc/testsuite/g++.dg/wrappers/alloc.C @@ -0,0 +1,43 @@ +// { dg-do compile { target c++11 } } + +template class _Op, typename... _Args> +struct __detector +{ + using type = _Op<_Args...>; +}; +template class _Op, typename... _Args> +using __detected_or = __detector<_Default, void, _Op, _Args...>; +template class _Op, typename... _Args> +using __detected_or_t = typename __detected_or<_Default, _Op, _Args...>::type; +template +struct allocator_traits { + template + using __pointer = typename _Tp::pointer; + using pointer = __detected_or_t; +}; +template +struct _Pointer_adapter { + typedef typename _Storage_policy::element_type element_type; + typedef element_type& reference; +}; +template +inline _Tp* addressof(_Tp& __r); // { dg-warning "used but never defined" } +template +struct __allocated_ptr { + __allocated_ptr() + { + using pointer = typename allocator_traits<_Alloc>::pointer; + typename _Pointer_adapter::reference __r = *(int*)0; + addressof(__r); + } +}; +template +struct _Std_pointer_impl { + typedef _Tp element_type; +}; +template +struct CustomPointerAlloc { + typedef Tp value_type; + typedef _Pointer_adapter<_Std_pointer_impl> pointer; +}; +__allocated_ptr> __guard_ptr; diff --git a/gcc/testsuite/g++.dg/wrappers/cow-istream-string.C b/gcc/testsuite/g++.dg/wrappers/cow-istream-string.C new file mode 100644 index 00000000000..23b0585c111 --- /dev/null +++ b/gcc/testsuite/g++.dg/wrappers/cow-istream-string.C @@ -0,0 +1,15 @@ +template +struct basic_string { + static const _CharT _S_terminal; + static void assign(const _CharT& __c2); + void _M_set_length_and_sharable() { + assign(_S_terminal); + } +}; + +template +const _CharT basic_string<_CharT>::_S_terminal = _CharT(); + +void getline(basic_string& __str) { + __str._M_set_length_and_sharable(); +} diff --git a/gcc/testsuite/g++.dg/wrappers/cp-stdlib.C b/gcc/testsuite/g++.dg/wrappers/cp-stdlib.C new file mode 100644 index 00000000000..d29585f48a3 --- /dev/null +++ b/gcc/testsuite/g++.dg/wrappers/cp-stdlib.C @@ -0,0 +1,117 @@ +/* At one time this triggered ICEs with location wrapper nodes, + apparently requiring error-recovery (hence the various syntax + errors in this file. */ + +// { dg-excess-errors "expected to be full of errors, but not an ICE" } + +namespace std +{ + inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } +} +namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) +{ + template + class new_allocator + { + typedef _Tp value_type; + }; +} +namespace std +{ + template + using __allocator_base = __gnu_cxx::new_allocator<_Tp>; +} +namespace std __attribute__ ((__visibility__ ("default"))) +{ + { + }; + template + class allocator : public __allocator_base<_Tp> + { + }; + template + struct allocator_traits : __allocator_traits_base + { + }; + template + struct allocator_traits> + { + using allocator_type = allocator<_Tp>; + template + using rebind_alloc = allocator<_Up>; + allocate(allocator_type& __a, size_type __n) + }; +} +namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) +{ +template + struct __alloc_traits + : std::allocator_traits<_Alloc> + { + typedef std::allocator_traits<_Alloc> _Base_type; + template + struct rebind + { typedef typename _Base_type::template rebind_alloc<_Tp> other; }; + }; +{ + { + } + } + } + { + { + } +} +namespace std __attribute__ ((__visibility__ ("default"))) +{ + struct char_traits; +namespace __cxx11 { + template, + typename _Alloc = allocator<_CharT> > + class basic_string; + } +} +namespace std __attribute__ ((__visibility__ ("default"))) +{ +namespace __cxx11 { + template + class basic_string + { + typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template + rebind<_CharT>::other _Char_alloc_type; + typedef __gnu_cxx::__alloc_traits<_Char_alloc_type> _Alloc_traits; + public: + { + { + } + } + operator=(const basic_string& __str) + { + { + { + { + const auto __len = __str.size(); + auto __alloc = __str._M_get_allocator(); + auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1); + } + } + } + } + { + } + size() const noexcept + } +namespace filesystem +{ + class path + { + typedef char value_type; + typedef std::basic_string string_type; + { + } + string_type _M_pathname; + }; + class directory_entry + { + void assign(const filesystem::path& __p) { _M_path = __p; } + filesystem::path _M_path; diff --git a/gcc/testsuite/g++.dg/wrappers/sanitizer_coverage_libcdep_new.C b/gcc/testsuite/g++.dg/wrappers/sanitizer_coverage_libcdep_new.C new file mode 100644 index 00000000000..2be140b1b49 --- /dev/null +++ b/gcc/testsuite/g++.dg/wrappers/sanitizer_coverage_libcdep_new.C @@ -0,0 +1,22 @@ +namespace __sanitizer { + +enum FileAccessMode { + RdOnly, + WrOnly, + RdWr +}; + +int OpenFile(const char *filename, int mode, + int *errno_p); +} + +using namespace __sanitizer; + +namespace __sancov { + +static int OpenFile(const char* path) { + int err; + int fd = OpenFile(path, WrOnly, &err); + return fd; +} +} diff --git a/gcc/testsuite/g++.dg/wrappers/wrapper-around-type-pack-expansion.C b/gcc/testsuite/g++.dg/wrappers/wrapper-around-type-pack-expansion.C new file mode 100644 index 00000000000..5072d1ad59d --- /dev/null +++ b/gcc/testsuite/g++.dg/wrappers/wrapper-around-type-pack-expansion.C @@ -0,0 +1,50 @@ +// { dg-do compile { target c++11 } } + +typedef long unsigned int size_t; + +template +struct remove_reference {}; + +template +constexpr _Tp&& +forward(typename remove_reference<_Tp>::type& __t) noexcept +{ +} + +struct __allocator_traits_base { + template + struct __rebind + { + using type = typename _Tp::template rebind<_Up>::other; + }; +}; + +template +using __alloc_rebind = typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type; + +template struct allocator_traits { + template using rebind_alloc = __alloc_rebind<_Alloc, _Tp>; + template + static auto construct(_Alloc& __a, _Tp* __p, _Args&&... __args) + -> decltype(_S_construct(__a, __p, forward<_Args>(__args)...)) { } +}; + +template +struct __alloc_traits : allocator_traits<_Alloc> { + typedef allocator_traits<_Alloc> _Base_type; + template struct rebind { typedef typename _Base_type::template rebind_alloc<_Tp> other; }; +}; + +template class allocator { + typedef _Tp value_type; + template struct rebind { typedef allocator<_Tp1> other; }; +}; + +template +class basic_string { + typedef typename __alloc_traits<_Alloc>::template rebind<_CharT>::other _Char_alloc_type; +}; + +template struct _Base_bitset { + static void foo (basic_string >) {} +}; -- 2.30.2