diff mbox series

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

Message ID 20190816204101.GU14737@redhat.com
State New
Headers show
Series C++ PATCH to add test for c++/85827 | expand

Commit Message

Marek Polacek Aug. 16, 2019, 8:41 p.m. UTC
This one was fixed in r269433

Tested on x86_64-linux, applying to trunk.

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

	PR c++/85827
	* g++.dg/cpp1z/constexpr-if29.C: New test.
diff mbox series

Patch

diff --git gcc/testsuite/g++.dg/cpp1z/constexpr-if29.C gcc/testsuite/g++.dg/cpp1z/constexpr-if29.C
new file mode 100644
index 00000000000..a40912a6fa5
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1z/constexpr-if29.C
@@ -0,0 +1,28 @@ 
+// PR c++/85827
+// { dg-do compile { target c++17 } }
+// { dg-options "-Wunused-variable -Wunused-parameter" }
+
+template <int N> int f()
+{
+    constexpr bool _1 = N == 1;
+    constexpr bool _2 = N == 2;
+    constexpr bool _3 = N == 3;
+    
+    if constexpr (_1) {
+        return 5;
+    } else if constexpr (_2) {
+        return 1;
+    } else if constexpr (_3) {
+        return 7;
+    }
+}
+
+int a() {
+    return f<1>();
+}
+int b() {
+    return f<2>();
+}
+int c() {
+    return f<3>();
+}