summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1y/constexpr-switch4.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp1y/constexpr-switch4.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/constexpr-switch4.C27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-switch4.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch4.C
new file mode 100644
index 0000000000..383bde934b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-switch4.C
@@ -0,0 +1,27 @@
+// PR c++/72868
+// { dg-do compile }
+// { dg-options "-std=gnu++14" }
+
+constexpr int
+foo (int i)
+{
+ switch (i)
+ {
+ case 11 ... 12:
+ return 4;
+ case 0 ... 9:
+ return 3;
+ default:
+ return 7;
+ }
+}
+
+#define SA(X) static_assert((X),#X)
+SA (foo (-1) == 7);
+SA (foo (0) == 3);
+SA (foo (3) == 3);
+SA (foo (9) == 3);
+SA (foo (10) == 7);
+SA (foo (11) == 4);
+SA (foo (12) == 4);
+SA (foo (13) == 7);