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.
PR c++/86374
* g++.dg/pr86374.C: New.
===================================================================
@@ -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);
}
===================================================================
@@ -9368,8 +9368,15 @@ lookup_template_class_1 (tree d1, tree a
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;
===================================================================
@@ -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.
+};