Re: [PATCH] Add some reproducers for issues found when developing the location-wrappers patch

2018-01-10 Thread Jeff Law
On 01/09/2018 02:13 PM, David Malcolm wrote:
> Whilst developing the location-wrapper patch kit, I accumulated various
> source files for which my work-in-progress patched-cc1plus had different
> behavior to an unpatched cc1plus: some of these were crashes, others
> were erroneous diagnostics.
> 
> All of these are now fixed, but it seems appropriate to capture them
> in our testsuite, hence this patch.
> 
> Tested in conjunction with the patch kit;
> adds 12 PASS, 2 UNSUPPORTED and 3 XFAILs to g++.sum.
> 
> The XFAILs are due to the use of dg-excess-errors in
>   g++.dg/wrappers/cp-stdlib.C.
> This source file is full of syntax errors, but used to ICE my cc1plus
> *somewhere* in error recovery, and I wasn't able to minimize it further
> at the time.  I fixed the ICE, but it seems worth keeping as a test case.
> I checked hacking in an ICE, and dg-excess-errors will FAIL on it
> (rather than merely XFAIL, on all of the syntax errors).
> 
> OK for trunk?
> 
> 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.
OK.
jeff


[PATCH] Add some reproducers for issues found when developing the location-wrappers patch

2018-01-09 Thread David Malcolm
Whilst developing the location-wrapper patch kit, I accumulated various
source files for which my work-in-progress patched-cc1plus had different
behavior to an unpatched cc1plus: some of these were crashes, others
were erroneous diagnostics.

All of these are now fixed, but it seems appropriate to capture them
in our testsuite, hence this patch.

Tested in conjunction with the patch kit;
adds 12 PASS, 2 UNSUPPORTED and 3 XFAILs to g++.sum.

The XFAILs are due to the use of dg-excess-errors in
  g++.dg/wrappers/cp-stdlib.C.
This source file is full of syntax errors, but used to ICE my cc1plus
*somewhere* in error recovery, and I wasn't able to minimize it further
at the time.  I fixed the ICE, but it seems worth keeping as a test case.
I checked hacking in an ICE, and dg-excess-errors will FAIL on it
(rather than merely XFAIL, on all of the syntax errors).

OK for trunk?

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.
---
 gcc/testsuite/g++.dg/wrappers/README   |   2 +
 gcc/testsuite/g++.dg/wrappers/alloc.C  |  43 
 gcc/testsuite/g++.dg/wrappers/cow-istream-string.C |  15 +++
 gcc/testsuite/g++.dg/wrappers/cp-stdlib.C  | 117 +
 .../wrappers/sanitizer_coverage_libcdep_new.C  |  22 
 .../wrappers/wrapper-around-type-pack-expansion.C  |  50 +
 6 files changed, 249 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/g++.dg/wrappers/README 
b/gcc/testsuite/g++.dg/wrappers/README
new file mode 100644
index 000..9cba970
--- /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 000..e004470
--- /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 000..23b0585
--- /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 000..d29585f
--- /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"