[C++] Add test for c++/65175

Message ID 20190609231744.GA5989@redhat.com
State New
Headers show
Series
  • [C++] Add test for c++/65175
Related show

Commit Message

Marek Polacek June 9, 2019, 11:17 p.m.
This one was fairly difficult to reduce but finally I've come up with something
that compiles without warnings with trunk/clang++/icc.

It was fixed by r261709 which has a much simpler test but I suppose there's
value in exercising more involved code.

Tested on x86_64-linux, applying to trunk.

2019-06-09  Marek Polacek  <polacek@redhat.com>

	PR c++/65175
	* g++.dg/cpp0x/alias-decl-69.C: New test.

Patch

diff --git gcc/testsuite/g++.dg/cpp0x/alias-decl-69.C gcc/testsuite/g++.dg/cpp0x/alias-decl-69.C
new file mode 100644
index 00000000000..7dd7aa2379c
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp0x/alias-decl-69.C
@@ -0,0 +1,40 @@ 
+// PR c++/65175
+// { dg-do compile { target c++11 } }
+
+template <class a> using au = typename a::av;
+template <bool, class a> using az = a;
+template <template <class...> class b, class... bf> struct d {
+  template <class bh> struct f { typedef bh e; };
+  static auto g(int) -> f<b<bf...>>;
+  typedef typename decltype(g(0))::e e;
+};
+template <class = void> class h;
+template <class, class, template <class...> class, class...> struct i;
+struct j {
+  typedef int bu;
+};
+namespace bv {
+template <class> struct k : j {};
+template <class bx> struct l : i<int, void, k, bx> {};
+} // namespace bv
+template <class bx> auto bw(bx) -> az<bv::l<bx>::c, typename bv::l<bx>::bz>;
+template <class, class cd, class> struct n : j { au<cd> av; };
+template <class, class cd, class> struct K : j { au<cd> av; };
+template <class cj> struct o {
+  typedef typename cj::e e;
+  static const bool c = true;
+  typedef h<typename e::bu> bz;
+};
+template <class, class, template <class...> class cj, class... bf>
+struct i : o<d<cj, bf...>> {};
+template <class> class h {
+public:
+  typedef int av;
+  struct : i<int, int, K, int, h, int> {} s;
+  template <class> struct p : i<int, int, n, int, h<h>, int> {};
+  template <class bx, class cl>
+  auto m_fn2(bx, cl) -> az<p<cl>::c, typename p<cl>::bz>;
+  template <class bx> static auto q(int, int, bx cm) -> decltype(bw(cm));
+};
+int a, b;
+void c() { h<>::q(b, 5, a).m_fn2(5, a); }