diff options
author | Nathan Sidwell <nathan@acm.org> | 2018-07-13 15:33:27 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2018-07-13 15:33:27 +0000 |
commit | 6b34716ba421d05190d66ab4660a48c0446f76c7 (patch) | |
tree | 10a7cb12aede7c35ae3a03774338d1323e23b47b | |
parent | b2272b138c1e7f6a1cb867d614951d516f88a9f1 (diff) | |
download | gcc-6b34716ba421d05190d66ab4660a48c0446f76c7.zip gcc-6b34716ba421d05190d66ab4660a48c0446f76c7.tar.gz gcc-6b34716ba421d05190d66ab4660a48c0446f76c7.tar.bz2 |
[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.
* parser.c (cp_parser_template_id): Combine entering_scope decl &
initializer.
PR c++/86374
* g++.dg/pr86374.C: New.
From-SVN: r262637
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/parser.c | 7 | ||||
-rw-r--r-- | gcc/cp/pt.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/pr86374.C | 20 |
5 files changed, 45 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a640259..1d5d669 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2018-07-13 Nathan Sidwell <nathan@acm.org> + + PR c++/86374 + * pt.c (lookup_template_class_1): Use tsubst_aggr_type for + contexts that are classes. + * parser.c (cp_parser_template_id): Combine entering_scope decl & + initializer. + 2018-07-12 Jakub Jelinek <jakub@redhat.com> * decl2.c (cplus_decl_attributes): Don't diagnose vars without mappable diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 366a0d8..d0f1e1e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15973,15 +15973,14 @@ cp_parser_template_id (cp_parser *parser, else if (DECL_TYPE_TEMPLATE_P (templ) || DECL_TEMPLATE_TEMPLATE_PARM_P (templ)) { - bool entering_scope; /* In "template <typename T> ... A<T>::", A<T> is the abstract A template (rather than some instantiation thereof) only if is not nested within some other construct. For example, in "template <typename T> void f(T) { A<T>::", A<T> is just an instantiation of A. */ - entering_scope = (template_parm_scope_p () - && cp_lexer_next_token_is (parser->lexer, - CPP_SCOPE)); + bool entering_scope + = (template_parm_scope_p () + && cp_lexer_next_token_is (parser->lexer, CPP_SCOPE)); template_id = finish_template_type (templ, arguments, entering_scope); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index eae9e14..9de9f50 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9368,8 +9368,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 0c61e97..1780ca0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-13 Nathan Sidwell <nathan@acm.org> + + PR c++/86374 + * g++.dg/pr86374.C: New. + 2018-07-13 Qing Zhao <qing.zhao@oracle.com> PR middle-end/78809 diff --git a/gcc/testsuite/g++.dg/pr86374.C b/gcc/testsuite/g++.dg/pr86374.C new file mode 100644 index 0000000..fd71156 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr86374.C @@ -0,0 +1,20 @@ +// pr C++/86374 +// bogus lookup error +template<typename LIST> +struct list { + static const int index = 1; + template <typename> struct addWithChecking {}; +}; + +template<typename container, int ix = container::index> +struct find { + static const int result = 0; +}; + +template <class LIST> +template<class O> +struct list<LIST>::addWithChecking<O*> +{ + static const int xres = + find<list<LIST> >::result; // bogus error about index here. +}; |