c++: Member template function lookup failure [PR94799]
authorMarek Polacek <polacek@redhat.com>
Mon, 19 Oct 2020 22:13:42 +0000 (18:13 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 28 Oct 2020 19:25:51 +0000 (15:25 -0400)
commit323dd4255203479d8c456b85513db4f8e0041d04
tree97ae87500e1c9b433833060be3b20272e028ff4c
parent43cb72263fb3b7b97a74fb38d71364a1d5cf0448
c++: Member template function lookup failure [PR94799]

My earlier patch for this PR, r11-86, broke pybind11.  That patch
changed cp_parser_class_name to also consider the object expression
scope (parser->context->object_type) to fix parsing of

  p->template A<T>::foo(); // consider p's scope too

Here we reject

  b.operator typename B<T>::type();

because 'typename_p' in cp_parser_class_name uses 'scope', which means
that 'typename_p' will be true for the example above.  Then we create
a TYPENAME_TYPE via make_typename_type, which fails when tsubsting it;
the code basically created 'typename B::B' and then we complain that there
is no member named 'B' in 'A<int>'.  So, when deciding if we should
create a TYPENAME_TYPE, don't consider the object_type scope, like we
did pre-r11-86.

gcc/cp/ChangeLog:

PR c++/94799
* parser.c (cp_parser_class_name): Use parser->scope when
setting typename_p.

gcc/testsuite/ChangeLog:

PR c++/94799
* g++.dg/template/lookup16.C: New test.
gcc/cp/parser.c
gcc/testsuite/g++.dg/template/lookup16.C [new file with mode: 0644]