aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-10-12 09:23:24 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-10-12 09:23:24 +0200
commit6089393b7401123b37e4e59a6853c0c196c423c5 (patch)
treeb7e456f1cc40bd8b1c31a95b0bc707d690c99e52 /gcc
parent281ff779cc1efadd5004248e7de6ef3cfc8c30df (diff)
downloadgcc-6089393b7401123b37e4e59a6853c0c196c423c5.zip
gcc-6089393b7401123b37e4e59a6853c0c196c423c5.tar.gz
gcc-6089393b7401123b37e4e59a6853c0c196c423c5.tar.bz2
re PR c++/82159 (ICE: in assign_temp, at function.c:961)
PR c++/82159 * expr.c (store_field): Don't optimize away bitsize == 0 store from CALL_EXPR with addressable return type. * g++.dg/opt/pr82159-2.C: New test. From-SVN: r253673
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/expr.c7
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/opt/pr82159-2.C65
4 files changed, 79 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 40fa8f5..12cf2d3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/82159
+ * expr.c (store_field): Don't optimize away bitsize == 0 store
+ from CALL_EXPR with addressable return type.
+
2017-10-11 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.h (TARGET_ISEL64): Delete.
diff --git a/gcc/expr.c b/gcc/expr.c
index d2e4d04..1bba933 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6749,8 +6749,11 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos,
return const0_rtx;
/* If we have nothing to store, do nothing unless the expression has
- side-effects. */
- if (bitsize == 0)
+ side-effects. Don't do that for zero sized addressable lhs of
+ calls. */
+ if (bitsize == 0
+ && (!TREE_ADDRESSABLE (TREE_TYPE (exp))
+ || TREE_CODE (exp) != CALL_EXPR))
return expand_expr (exp, const0_rtx, VOIDmode, EXPAND_NORMAL);
if (GET_CODE (target) == CONCAT)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c0d873d..eaf1ce5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2017-10-12 Jakub Jelinek <jakub@redhat.com>
+ PR c++/82159
+ * g++.dg/opt/pr82159-2.C: New test.
+
PR target/82353
* gcc.target/i386/i386.exp (tests): Revert the '.C' extension change.
* gcc.target/i386/pr82353.C: Moved to ...
diff --git a/gcc/testsuite/g++.dg/opt/pr82159-2.C b/gcc/testsuite/g++.dg/opt/pr82159-2.C
new file mode 100644
index 0000000..f153c29
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr82159-2.C
@@ -0,0 +1,65 @@
+// PR c++/82159
+// { dg-do compile }
+// { dg-options "" }
+
+template <typename T> struct D { T e; };
+struct F : D<int[0]> {
+ F(const F &);
+};
+struct G : F {
+ template <class T> G operator-(T);
+};
+template <class T> struct I {
+ typedef typename T::template J<I> ak;
+};
+template <class T> struct K { typename I<T>::ak an; };
+struct H {
+ G l;
+};
+struct C {
+ ~C();
+};
+template <class T> struct M : T {
+ template <typename U, typename V> M(U, V);
+ H h;
+ virtual void foo() { T::bar(&h); }
+};
+template <int, typename> class A;
+template <class> struct B {
+ typedef int BT;
+ struct BC {};
+ template <class T> struct BD {
+ G g;
+ BD(BT, T n) : g(n.l - 0) {}
+ };
+ B(BT, BC);
+};
+template <typename> struct O;
+template <int T, typename U>
+struct O<B<A<T, U> > > : public B<A<T, U> >::BC {};
+struct L : B<A<2, double> > {
+ struct P : C {
+ void bar(H *x) {
+ BT a;
+ BD<H>(a, *x);
+ }
+ };
+ template <typename U, typename V> L(U x, V n) : B(x, n) {}
+ int ll;
+ virtual int baz() { M<P>(this, ll); }
+};
+template <typename> class Q {
+ O<B<A<2, double> > > q;
+ virtual L baz() { L(0, q); }
+};
+template <template <class> class T> struct R {
+ R() { T<int>(); }
+};
+struct S {
+ template <class> class J : R<Q> {};
+};
+void foo() { K<S> c; }
+
+int main() {
+ return 0;
+}