diff options
author | Patrick Palka <ppalka@redhat.com> | 2024-07-17 20:54:14 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-07-17 20:54:14 -0400 |
commit | 313afcfdabeab3e6705ac0bd1273627075be0023 (patch) | |
tree | a1ba5cefc0e5099ed446343a8f7e2e7f356a1559 /gcc/testsuite/g++.dg/cpp0x | |
parent | 30875fa698e2ffed536f7a7d15a430e69a6a28ba (diff) | |
download | gcc-313afcfdabeab3e6705ac0bd1273627075be0023.zip gcc-313afcfdabeab3e6705ac0bd1273627075be0023.tar.gz gcc-313afcfdabeab3e6705ac0bd1273627075be0023.tar.bz2 |
c++: diagnose failed qualified lookup into current inst
When the scope of a qualified name is the current instantiation, and
qualified lookup finds nothing at template definition time, then we
know it'll find nothing at instantiation time (unless the current
instantiation has dependent bases). So such qualified name lookup
failure can be diagnosed ahead of time as per [temp.res.general]/6.
This patch implements that, for qualified names of the form (where
the current instantiation is A<T>):
this->non_existent
a.non_existent
A::non_existent
typename A::non_existent
It turns out we already optimistically attempt qualified lookup of
seemingly every qualified name, even when it's dependently scoped, and
then suppress issuing a lookup failure diagnostic after the fact.
So implementing this is mostly a matter of restricting the diagnostic
suppression to "dependentish" scopes (i.e. dependent scopes or the
current instantiation with dependent bases), rather than suppressing
for any dependently-typed scope as we currently do.
The cp_parser_conversion_function_id change is needed to avoid regressing
lookup/using8.C:
using A<T>::operator typename A<T>::Nested*;
When looking up A<T>::Nested we consider it not dependently scoped since
we entered A<T> from cp_parser_conversion_function_id earlier. But this
A<T> is the implicit instantiation A<T> not the primary template type A<T>,
and so the lookup fails which we now diagnose. This patch works around
this by not entering the template scope of a qualified conversion
function-id in this case, i.e. if we're in an expression vs declaration
context, by seeing if the type already went through finish_template_type
with entering_scope=true.
gcc/cp/ChangeLog:
* decl.cc (make_typename_type): Restrict name lookup failure
punting to dependentish_scope_p instead of dependent_type_p.
* error.cc (qualified_name_lookup_error): Improve diagnostic
when the scope is the current instantiation.
* parser.cc (cp_parser_diagnose_invalid_type_name): Likewise.
(cp_parser_conversion_function_id): Don't call push_scope on
a template scope unless we're in a declaration context.
(cp_parser_lookup_name): Restrict name lookup failure
punting to dependentish_scope_p instead of depedent_type_p.
* semantics.cc (finish_id_expression_1): Likewise.
* typeck.cc (finish_class_member_access_expr): Likewise.
libstdc++-v3/ChangeLog:
* include/experimental/socket
(basic_socket_iostream::basic_socket_iostream): Fix typo.
* include/tr2/dynamic_bitset
(__dynamic_bitset_base::_M_is_proper_subset_of): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/alignas18.C: Expect name lookup error for U::X.
* g++.dg/cpp0x/forw_enum13.C: Expect name lookup error for
D3::A and D4<T>::A.
* g++.dg/parse/access13.C: Declare A::E::V to avoid name lookup
failure and preserve intent of the test.
* g++.dg/parse/enum11.C: Expect extra errors, matching the
non-template case.
* g++.dg/template/crash123.C: Avoid name lookup failure to
preserve intent of the test.
* g++.dg/template/crash124.C: Likewise.
* g++.dg/template/crash7.C: Adjust expected diagnostics.
* g++.dg/template/dtor6.C: Declare A::~A() to avoid name lookup
failure and preserve intent of the test.
* g++.dg/template/error22.C: Adjust expected diagnostics.
* g++.dg/template/static30.C: Avoid name lookup failure to
preserve intent of the test.
* g++.old-deja/g++.other/decl5.C: Adjust expected diagnostics.
* g++.dg/template/non-dependent34.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/alignas18.C | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/forw_enum13.C | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas18.C b/gcc/testsuite/g++.dg/cpp0x/alignas18.C index 820bdd2..9c25cd0 100644 --- a/gcc/testsuite/g++.dg/cpp0x/alignas18.C +++ b/gcc/testsuite/g++.dg/cpp0x/alignas18.C @@ -3,6 +3,5 @@ template <typename T> struct S { using U = S; - // FIXME: This is ill-formed; see PR90847. - void fn() alignas(U::X); + void fn() alignas(U::X); // { dg-error "not a member" } }; diff --git a/gcc/testsuite/g++.dg/cpp0x/forw_enum13.C b/gcc/testsuite/g++.dg/cpp0x/forw_enum13.C index b8027f0..37ffad9 100644 --- a/gcc/testsuite/g++.dg/cpp0x/forw_enum13.C +++ b/gcc/testsuite/g++.dg/cpp0x/forw_enum13.C @@ -18,13 +18,13 @@ class D2 template <typename T> class D3 { - enum D3::A { foo } c; // { dg-error "extra qualification not allowed" } + enum D3::A { foo } c; // { dg-error "does not name an enumeration" } }; template <typename T> class D4 { - enum D4<T>::A { foo } c; // { dg-error "extra qualification not allowed" } + enum D4<T>::A { foo } c; // { dg-error "does not name an enumeration" } }; template <typename T> @@ -32,7 +32,7 @@ class D5 { class D6 { - enum D6::A { foo } c; // { dg-error "extra qualification not allowed" } + enum D6::A { foo } c; // { dg-error "does not name an enumeration" } }; }; |