From d397e3948ec945c8c3b4dc695e1b0b5820365a39 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 5 Feb 2019 23:28:25 +0100 Subject: [PATCH] re PR c++/89187 (ICE in initialize_argument_information, at calls.c:2023) PR c++/89187 * optimize.c (maybe_thunk_body): Clear TREE_ADDRESSABLE on PARM_DECLs of the thunk. * lambda.c (maybe_add_lambda_conv_op): Likewise. * g++.dg/opt/pr89187.C: New test. From-SVN: r268564 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/lambda.c | 3 +++ gcc/cp/optimize.c | 2 ++ gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/opt/pr89187.C | 23 +++++++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr89187.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ebbc1266ed..660d746ef74 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-02-05 Jakub Jelinek + + PR c++/89187 + * optimize.c (maybe_thunk_body): Clear TREE_ADDRESSABLE on + PARM_DECLs of the thunk. + * lambda.c (maybe_add_lambda_conv_op): Likewise. + 2019-02-05 Marek Polacek PR c++/89158 - by-value capture of constexpr variable broken. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index c31b06e2b1e..2290fe0efee 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -1130,6 +1130,9 @@ maybe_add_lambda_conv_op (tree type) { tree new_node = copy_node (src); + /* Clear TREE_ADDRESSABLE on thunk arguments. */ + TREE_ADDRESSABLE (new_node) = 0; + if (!fn_args) fn_args = tgt = new_node; else diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 7b6edfc0e49..aace7dea684 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -417,6 +417,8 @@ maybe_thunk_body (tree fn, bool force) gcc_assert (clone_parm); DECL_ABSTRACT_ORIGIN (clone_parm) = NULL; args[parmno] = clone_parm; + /* Clear TREE_ADDRESSABLE on thunk arguments. */ + TREE_ADDRESSABLE (clone_parm) = 0; clone_parm = TREE_CHAIN (clone_parm); } if (fn_parm_typelist) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 616741669fa..ac70c728139 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,9 @@ -2019-02-05 Andrea Corallo +2019-02-05 Jakub Jelinek + + PR c++/89187 + * g++.dg/opt/pr89187.C: New test. + +2019-02-05 Andrea Corallo * jit.dg/add-driver-options-testlib.c: Add support file for test-add-driver-options.c testcase. diff --git a/gcc/testsuite/g++.dg/opt/pr89187.C b/gcc/testsuite/g++.dg/opt/pr89187.C new file mode 100644 index 00000000000..3e24a8fe72e --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr89187.C @@ -0,0 +1,23 @@ +// PR c++/89187 +// { dg-do compile { target c++11 } } +// { dg-options "-Os -fno-tree-ccp -fno-tree-sra -fno-inline" } + +template struct A { + typedef T __attribute__((vector_size (N))) type; +}; +template using B = typename A::type; +template using C = B; +struct D { + D (C x) : d{x[3]} {} + D foo () { return d; } + C d; +}; +extern D d; +struct { D bar () { return d; } } l; +struct E { void baz () const; }; + +void +E::baz () const +{ + l.bar ().foo (); +} -- 2.30.2