diff options
author | Patrick Palka <ppalka@gcc.gnu.org> | 2016-03-23 21:02:34 +0000 |
---|---|---|
committer | Patrick Palka <ppalka@gcc.gnu.org> | 2016-03-23 21:02:34 +0000 |
commit | cd1588c4d60162730a103b6ca3a30139d88a57e3 (patch) | |
tree | 14bfa7e79e1654780fbe7af110d52eca7878e111 /gcc | |
parent | 80636611f3a1490d8164509f1b206d009d153b61 (diff) | |
download | gcc-cd1588c4d60162730a103b6ca3a30139d88a57e3.zip gcc-cd1588c4d60162730a103b6ca3a30139d88a57e3.tar.gz gcc-cd1588c4d60162730a103b6ca3a30139d88a57e3.tar.bz2 |
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.
From-SVN: r234442
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr5.C | 24 |
4 files changed, 41 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 42c7054..984a030 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-03-23 Patrick Palka <ppalka@gcc.gnu.org> + + 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 <jakub@redhat.com> PR c++/70001 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6837438..a6398c0 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 1b32832..5e32276 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-03-23 Patrick Palka <ppalka@gcc.gnu.org> + + PR c++/70332 + * g++.dg/cpp1y/nsdmi-aggr5.C: New test. + 2016-03-23 Jakub Jelinek <jakub@redhat.com> 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 0000000..fe377c3 --- /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 <class T> +struct C +{ + T m; + T *n = &m; +}; + +C<int> c { }; + +int +main () +{ + *c.n = 5; + if (c.m != 5) + __builtin_abort (); + + C<int> d { 10 }; + *d.n = *d.n + 1; + if (d.m != 11) + __builtin_abort (); +} |