diff mbox series

C++ PATCH to add test for c++/88744

Message ID 20190108235252.GQ28316@redhat.com
State New
Headers show
Series C++ PATCH to add test for c++/88744 | expand

Commit Message

Marek Polacek Jan. 8, 2019, 11:52 p.m. UTC
I got confused and opened this PR thinking we've got another problem here.
Turns out things work as expected with the recent patch of mine.  Well, at
least we have another testcase.

Bootstrapped/regtested on x86_64-linux, applying to trunk.

2019-01-08  Marek Polacek  <polacek@redhat.com>

	PR c++/88744
	* g++.dg/cpp2a/nontype-class12.C: New test.
diff mbox series

Patch

diff --git gcc/testsuite/g++.dg/cpp2a/nontype-class12.C gcc/testsuite/g++.dg/cpp2a/nontype-class12.C
new file mode 100644
index 00000000000..11f8c12f3ff
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp2a/nontype-class12.C
@@ -0,0 +1,23 @@ 
+// PR c++/88744
+// { dg-do compile { target c++2a } }
+
+#define SA(X) static_assert((X),#X)
+
+struct S {
+  int a;
+  int b;
+  constexpr S(int a_, int b_) : a{a_}, b{b_} { }
+};
+
+template<S s = {1, 2}>
+struct X {
+  static constexpr int i = s.a;
+  static constexpr int j = s.b;
+};
+X x; // ok, X<{1, 2}>
+X<{3, 4}> x2;
+
+SA (x.i == 1);
+SA (x.j == 2);
+SA (x2.i == 3);
+SA (x2.j == 4);