re PR c++/88410 (internal compiler error: output_operand: invalid expression as operand)
authorJakub Jelinek <jakub@redhat.com>
Mon, 17 Dec 2018 21:54:37 +0000 (22:54 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 17 Dec 2018 21:54:37 +0000 (22:54 +0100)
PR c++/88410
* cp-gimplify.c (cp_fold) <case ADDR_EXPR>: For offsetof-like folding,
call maybe_constant_value on val to see if it is INTEGER_CST.

* g++.dg/cpp0x/pr88410.C: New test.

From-SVN: r267220

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr88410.C [new file with mode: 0644]

index a7ec887d9c02afd56b9572f0fa30ef3100e72e43..ed652bd8a4723458f17998fea2f7f96ac17fb2e1 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88410
+       * cp-gimplify.c (cp_fold) <case ADDR_EXPR>: For offsetof-like folding,
+       call maybe_constant_value on val to see if it is INTEGER_CST.
+
 2018-12-17  Jonathan Wakely  <jwakely@redhat.com>
 
        PR c++/52321
index 5cb54adf60f96f944575d1753ee733016d227b3e..d27e39c2a3a6a9ae3b67d52067aed79a11b78a39 100644 (file)
@@ -2317,6 +2317,7 @@ cp_fold (tree x)
            {
              val = TREE_OPERAND (val, 0);
              STRIP_NOPS (val);
+             val = maybe_constant_value (val);
              if (TREE_CODE (val) == INTEGER_CST)
                return fold_offsetof (op0, TREE_TYPE (x));
            }
index fa121033fbe5e7dfa5d1837c801be081d7dc73c5..50ff5322a4beff0fc1d0aa18387bd0f1fd81342f 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88410
+       * g++.dg/cpp0x/pr88410.C: New test.
+
 2018-12-17  Steve Ellcey  <sellcey@cavium.com>
 
        * gcc.target/aarch64/torture/aarch64-torture.exp: New file.
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr88410.C b/gcc/testsuite/g++.dg/cpp0x/pr88410.C
new file mode 100644 (file)
index 0000000..c64e62d
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/88410
+// { dg-do compile { target c++11 } }
+
+typedef __UINTPTR_TYPE__ uintptr_t;
+const uintptr_t a = 32;
+struct C { int b; int c; };
+uintptr_t d { uintptr_t (&reinterpret_cast<C *>(a)->c) - a };