From 950c7ddb563d0f91ef6db973f0393e7edba811f1 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 13 Jul 2018 16:46:08 +0000 Subject: [PR c++/86374] Name lookup failure in enclosing template https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00701.html PR c++/86374 * pt.c (lookup_template_class_1): Use tsubst_aggr_type for contexts that are classes. PR c++/86374 * g++.dg/pr86374.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@262639 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 11 +++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr86374.C | 20 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr86374.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fff998d29a42..cc79aabc5725 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-07-13 Nathan Sidwell + + PR c++/86374 + * pt.c (lookup_template_class_1): Use tsubst_aggr_type for + contexts that are classes. + 2018-07-12 Jakub Jelinek * decl2.c (cplus_decl_attributes): Don't diagnose vars without mappable diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a57e737d8806..66b0957cf652 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9373,8 +9373,15 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, return found; } - context = tsubst (DECL_CONTEXT (gen_tmpl), arglist, - complain, in_decl); + context = DECL_CONTEXT (gen_tmpl); + if (context && TYPE_P (context)) + { + context = tsubst_aggr_type (context, arglist, complain, in_decl, true); + context = complete_type (context); + } + else + context = tsubst (context, arglist, complain, in_decl); + if (context == error_mark_node) return error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8bc77b3acc29..687aaed9a90a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-13 Nathan Sidwell + + PR c++/86374 + * g++.dg/pr86374.C: New. + 2018-07-12 Jakub Jelinek * c-c++-common/gomp/declare-target-3.c: New test. diff --git a/gcc/testsuite/g++.dg/pr86374.C b/gcc/testsuite/g++.dg/pr86374.C new file mode 100644 index 000000000000..fd7115626e10 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr86374.C @@ -0,0 +1,20 @@ +// pr C++/86374 +// bogus lookup error +template +struct list { + static const int index = 1; + template struct addWithChecking {}; +}; + +template +struct find { + static const int result = 0; +}; + +template +template +struct list::addWithChecking +{ + static const int xres = + find >::result; // bogus error about index here. +}; -- cgit v1.2.3