diff options
author | Jason Merrill <jason@redhat.com> | 2021-09-17 14:18:55 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2021-09-17 22:43:00 -0400 |
commit | 18b57c1d4a8777bedfe4ed47166f033e71bc144b (patch) | |
tree | 77d10eab04edfa1319754c9df851a29dc500a866 /gcc/cp/pt.c | |
parent | 8618f9e58c475389adbdfdb4127ebb8c18caba4c (diff) | |
download | gcc-18b57c1d4a8777bedfe4ed47166f033e71bc144b.zip gcc-18b57c1d4a8777bedfe4ed47166f033e71bc144b.tar.gz gcc-18b57c1d4a8777bedfe4ed47166f033e71bc144b.tar.bz2 |
c++: improve lookup of member-qualified names
I've been working on the resolution of CWG1835 by P1787, which among many
other things clarified that a name after -> or . is looked up first in the
class of the object expression even if it's dependent. This patch does not
make that change; this is a smaller change extracted from that work in
progress to make the lookup in the object type work better in cases where
unqualified lookup doesn't find anything.
Basically, if we see "t.foo::" we know that looking up foo in t needs to
find a type, so we build an implicit TYPENAME_TYPE for it.
This also implements the change from P1787 to assume that a name followed by
< in a type-only context names a template, since the less-than operator
can't appear in a type context. This makes some of the lines in dtor11.C
work.
I introduce the predicate 'dependentish_scope_p' for the case where the
current instantiation has dependent bases, so even though we can perform
name lookup, we can't conclude that a lookup failure is conclusive.
gcc/cp/ChangeLog:
* cp-tree.h (dependentish_scope_p): Declare.
* pt.c (dependentish_scope_p): New.
* parser.c (cp_parser_lookup_name): Return a TYPENAME_TYPE
for lookup of a type in a dependent object.
(cp_parser_template_id): Handle TYPENAME_TYPE.
(cp_parser_template_name): If we're looking for a type,
a name followed by < names a template.
gcc/testsuite/ChangeLog:
* g++.dg/template/dtor5.C: Adjust expected error.
* g++.dg/cpp23/lookup2.C: New test.
* g++.dg/template/dtor11.C: New test.
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 12c8812..4d42899 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -26970,6 +26970,15 @@ dependent_scope_p (tree scope) && !currently_open_class (scope)); } +/* True if we might find more declarations in SCOPE during instantiation than + we can when parsing the template. */ + +bool +dependentish_scope_p (tree scope) +{ + return dependent_scope_p (scope) || any_dependent_bases_p (scope); +} + /* T is a SCOPE_REF. Return whether it represents a non-static member of an unknown base of 'this' (and is therefore instantiation-dependent). */ |