c++: Readd [LR]ROTATE_EXPR support to constexpr.c [PR94067]
authorJakub Jelinek <jakub@redhat.com>
Mon, 9 Mar 2020 20:52:18 +0000 (21:52 +0100)
committerJakub Jelinek <jakub@redhat.com>
Mon, 9 Mar 2020 20:52:18 +0000 (21:52 +0100)
Since r10-6527-gaaa26bf496a646778ac861aed124d960b5bf549f fold_for_warn
will perform maybe_constant_value even on some cp_fold produced trees and
so can include rotate exprs which were removed last fall from constexpr.c

2020-03-09  Jakub Jelinek  <jakub@redhat.com>

PR c++/94067
Revert
2019-10-11  Paolo Carlini  <paolo.carlini@oracle.com>

* constexpr.c (cxx_eval_constant_expression): Do not handle
RROTATE_EXPR and LROTATE_EXPR.

* g++.dg/warn/Wconversion-pr94067.C: New test.

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wconversion-pr94067.C [new file with mode: 0644]

index 5fc3e7def6bd72717aac6a917fd47c344214cba2..7b3b9560571d0ffa4d32dc6b7c1004addd29702f 100644 (file)
@@ -1,3 +1,12 @@
+2020-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94067
+       Revert
+       2019-10-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * constexpr.c (cxx_eval_constant_expression): Do not handle
+       RROTATE_EXPR and LROTATE_EXPR.
+
 2020-03-09  Marek Polacek  <polacek@redhat.com>
 
        PR c++/94050 - ABI issue with alignas on armv7hl.
index 521c87f62103a08a1cf12a690c952295943dc222..76af0d710c403455b51f1356e44412e487bfff67 100644 (file)
@@ -5730,6 +5730,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
     case MAX_EXPR:
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
+    case LROTATE_EXPR:
+    case RROTATE_EXPR:
     case BIT_IOR_EXPR:
     case BIT_XOR_EXPR:
     case BIT_AND_EXPR:
@@ -7853,6 +7855,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
     case MAX_EXPR:
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
+    case LROTATE_EXPR:
+    case RROTATE_EXPR:
     case BIT_IOR_EXPR:
     case BIT_XOR_EXPR:
     case BIT_AND_EXPR:
index 6c0fab654201418b54966426e759956872ed9f87..44f65ffa2049396c7a685efdd732db57309ce7cd 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94067
+       * g++.dg/warn/Wconversion-pr94067.C: New test.
+
 2020-03-09  Marek Polacek  <polacek@redhat.com>
 
        PR c++/94050 - ABI issue with alignas on armv7hl.
diff --git a/gcc/testsuite/g++.dg/warn/Wconversion-pr94067.C b/gcc/testsuite/g++.dg/warn/Wconversion-pr94067.C
new file mode 100644 (file)
index 0000000..c103101
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/94067
+// { dg-do compile }
+// { dg-options "-Wconversion" }
+
+static inline unsigned short
+swap (unsigned short x)
+{
+  return (x >> 8) | static_cast<unsigned short>(x << 8);
+}