Backported from mainline
2016-08-11 Jakub Jelinek <jakub@redhat.com>
PR c++/72868
* constexpr.c (label_matches): Handle case range expressions.
* g++.dg/cpp1y/constexpr-switch4.C: New test.
From-SVN: r248595
+2017-05-30 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2016-08-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/72868
+ * constexpr.c (label_matches): Handle case range expressions.
+
2017-01-12 Nathan Sidwell <nathan@acm.org>
PR c++/77812
{
if (!CASE_LOW (stmt))
default_label = i;
+ else if (CASE_HIGH (stmt))
+ {
+ if (tree_int_cst_le (CASE_LOW (stmt), *jump_target)
+ && tree_int_cst_le (*jump_target, CASE_HIGH (stmt)))
+ return true;
+ }
else if (tree_int_cst_equal (*jump_target, CASE_LOW (stmt)))
return true;
}
Backported from mainline
2016-08-11 Jakub Jelinek <jakub@redhat.com>
+ PR c++/72868
+ * g++.dg/cpp1y/constexpr-switch4.C: New test.
+
PR c/72816
* gcc.dg/pr72816.c: Remove dg-error.
--- /dev/null
+// 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);