On 3/6/20 7:57 AM, Jakub Jelinek wrote:
Hi!

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

OK. It's unfortunate that we're folding twice here, but probably better to leave fixing that for GCC 11.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2020-03-06  Jakub Jelinek  <ja...@redhat.com>

        PR c++/94067
        Revert
        2019-10-11  Paolo Carlini  <paolo.carl...@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/constexpr.c.jj       2020-03-05 07:58:02.578137680 +0100
+++ gcc/cp/constexpr.c  2020-03-06 11:55:27.126682726 +0100
@@ -5730,6 +5730,8 @@ cxx_eval_constant_expression (const cons
      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,
      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:
--- gcc/testsuite/g++.dg/warn/Wconversion-pr94067.C.jj  2020-03-06 
11:57:08.335191087 +0100
+++ gcc/testsuite/g++.dg/warn/Wconversion-pr94067.C     2020-03-06 
11:59:55.843722307 +0100
@@ -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);
+}

        Jakub


s

Reply via email to