From: ppalka Date: Wed, 23 Mar 2016 21:02:34 +0000 (+0000) Subject: Fix PR c++/70332 (ICE due to aggregate initialization of NSDMI) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=36ce5faa297922776986adc05cb43a074c6a7820;p=thirdparty%2Fgcc.git Fix PR c++/70332 (ICE due to aggregate initialization of NSDMI) gcc/cp/ChangeLog: PR c++/70332 * pt.c (tsubst_copy) [PARM_DECL]: Handle the use of 'this' in an NSDMI that's part of an aggregrate initialization. gcc/testsuite/ChangeLog: PR c++/70332 * g++.dg/cpp1y/nsdmi-aggr5.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234442 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 42c705463783..984a030286b7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-03-23 Patrick Palka + + PR c++/70332 + * pt.c (tsubst_copy) [PARM_DECL]: Handle the use of 'this' in an + NSDMI that's part of an aggregrate initialization. + 2016-03-23 Jakub Jelinek PR c++/70001 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 68374389f3be..a6398c04f85e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13878,10 +13878,13 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (r == NULL_TREE) { - /* We get here for a use of 'this' in an NSDMI. */ + /* We get here for a use of 'this' in an NSDMI as part of a + constructor call or as part of an aggregate initialization. */ if (DECL_NAME (t) == this_identifier - && current_function_decl - && DECL_CONSTRUCTOR_P (current_function_decl)) + && ((current_function_decl + && DECL_CONSTRUCTOR_P (current_function_decl)) + || (current_class_ref + && TREE_CODE (current_class_ref) == PLACEHOLDER_EXPR))) return current_class_ptr; /* This can happen for a parameter name used later in a function diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1b3283286c37..5e3227643855 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-03-23 Patrick Palka + + PR c++/70332 + * g++.dg/cpp1y/nsdmi-aggr5.C: New test. + 2016-03-23 Jakub Jelinek PR c++/70001 diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr5.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr5.C new file mode 100644 index 000000000000..fe377c399c80 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr5.C @@ -0,0 +1,24 @@ +// PR c++/70332 +// { dg-do run { target c++14 } } + +template +struct C +{ + T m; + T *n = &m; +}; + +C c { }; + +int +main () +{ + *c.n = 5; + if (c.m != 5) + __builtin_abort (); + + C d { 10 }; + *d.n = *d.n + 1; + if (d.m != 11) + __builtin_abort (); +}