re PR c++/86240 (ice: unexpected expression absu_expr)
authorMarek Polacek <polacek@redhat.com>
Wed, 20 Jun 2018 15:46:02 +0000 (15:46 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 20 Jun 2018 15:46:02 +0000 (15:46 +0000)
PR c++/86240
* constexpr.c (cxx_eval_constant_expression): Handle ABSU_EXPR.
(fold_simple_1): Likewise.
* error.c (dump_expr): Likewise.

* g++.dg/pr86240.C: New test.

From-SVN: r261809

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr86240.C [new file with mode: 0644]

index 822a18acc2ea088391fc98c2ea4b20b187d0ab0b..72cd388f5782fbbe9e3cb5509413761b54db80e6 100644 (file)
@@ -1,3 +1,10 @@
+2018-06-20  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/86240
+       * constexpr.c (cxx_eval_constant_expression): Handle ABSU_EXPR.
+       (fold_simple_1): Likewise.
+       * error.c (dump_expr): Likewise.
+
 2018-06-20  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/85634
index 216eecd4b06558d7386b12eeda8a3e77dfd86bc1..44f3093ab471e78c0d7838481edfd5b506db1c6d 100644 (file)
@@ -4412,6 +4412,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
     case FLOAT_EXPR:
     case NEGATE_EXPR:
     case ABS_EXPR:
+    case ABSU_EXPR:
     case BIT_NOT_EXPR:
     case TRUTH_NOT_EXPR:
     case FIXED_CONVERT_EXPR:
@@ -5056,6 +5057,7 @@ fold_simple_1 (tree t)
       return fold_sizeof_expr (t);
 
     case ABS_EXPR:
+    case ABSU_EXPR:
     case CONJ_EXPR:
     case REALPART_EXPR:
     case IMAGPART_EXPR:
index 6a261132afb95a43ea0085e566eec332d80cd3cb..b0d8e322e6507e17f24f350b52a67e58a4072b60 100644 (file)
@@ -2764,6 +2764,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
     case VEC_DELETE_EXPR:
     case MODOP_EXPR:
     case ABS_EXPR:
+    case ABSU_EXPR:
     case CONJ_EXPR:
     case VECTOR_CST:
     case FIXED_CST:
index ce89b3348f66f941fe92d09af751835261a55034..36305cb29fa92fb13f77cc1453656854b50eb526 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-20  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/86240
+       * g++.dg/pr86240.C: New test.
+
 2018-06-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/86194
diff --git a/gcc/testsuite/g++.dg/pr86240.C b/gcc/testsuite/g++.dg/pr86240.C
new file mode 100644 (file)
index 0000000..16ae89c
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+extern "C" int abs (int);
+struct a {
+  short b;
+} e;
+short c;
+bool
+foo ()
+{
+  return abs(c) >= e.b;
+}