From bcbdfa4ce0ba21fe081b96dffef4b9bbb43cfae4 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 20 Feb 2017 01:06:20 -0500 Subject: [PATCH] PR c++/79606 - ICE with this->base_member in NSDMI * class.c (build_base_path): Check processing_template_decl. From-SVN: r245593 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/class.c | 1 + gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C | 14 ++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3ae889317f4..7258348ec9e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2017-02-19 Jason Merrill + PR c++/79606 - ICE with this->base_member in NSDMI + * class.c (build_base_path): Check processing_template_decl. + PR c++/79607 - ICE with T{} initializer * decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 1442b55cfe9..9e4b4c4fd32 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -375,6 +375,7 @@ build_base_path (enum tree_code code, set up properly yet, and the value doesn't matter there either; we're just interested in the result of overload resolution. */ if (cp_unevaluated_operand != 0 + || processing_template_decl || in_template_function ()) { expr = build_nop (ptr_target_type, expr); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C new file mode 100644 index 00000000000..58dec7b5844 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-template16.C @@ -0,0 +1,14 @@ +// PR c++/79606 +// { dg-do compile { target c++11 } } + +struct A +{ + int i = 0; +}; + +template struct B : A +{ + int j = this->i; +}; + +B<0> b; -- 2.30.2