From: Jakub Jelinek Date: Mon, 17 Dec 2018 21:54:37 +0000 (+0100) Subject: re PR c++/88410 (internal compiler error: output_operand: invalid expression as operand) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1e9d69235a88347d293dec7927e34dd38f6ee580;p=gcc.git re PR c++/88410 (internal compiler error: output_operand: invalid expression as operand) PR c++/88410 * cp-gimplify.c (cp_fold) : 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a7ec887d9c0..ed652bd8a47 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-12-17 Jakub Jelinek + + PR c++/88410 + * cp-gimplify.c (cp_fold) : For offsetof-like folding, + call maybe_constant_value on val to see if it is INTEGER_CST. + 2018-12-17 Jonathan Wakely PR c++/52321 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 5cb54adf60f..d27e39c2a3a 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -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)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa121033fbe..50ff5322a4b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-17 Jakub Jelinek + + PR c++/88410 + * g++.dg/cpp0x/pr88410.C: New test. + 2018-12-17 Steve Ellcey * 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 index 00000000000..c64e62df162 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr88410.C @@ -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(a)->c) - a };