Commit cd1588c4 by Patrick Palka

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
parent 80636611
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
......
......@@ -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
&& ((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
......
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
......
// 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 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment