From 56b722459a756a283e97c8508c8e187a1c813333 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss <[email protected]>
Date: Fri, 18 Nov 2022 09:23:33 +1100
Subject: [PATCH 18/56] Fix regression around friend declarations in local
classes [PR69410].
gcc/cp/ChangeLog:
* name-lookup.cc (pop_local_binding): Remove checking assert.
(pushdecl): Remove overzealous check for friend declarations finding a matching declaration in a nearby scope.
---
gcc/cp/name-lookup.cc | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index dfa6fb40675..b5f6e84cad9 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -2481,7 +2481,6 @@ pop_local_binding (tree id, tree decl)
binding->value = NULL_TREE;
else
{
- gcc_checking_assert (binding->type == decl);
binding->type = NULL_TREE;
}
@@ -3746,24 +3745,7 @@ pushdecl (tree decl, bool hiding)
check_template_shadow (decl);
if (DECL_DECLARES_FUNCTION_P (decl))
- {
- check_default_args (decl);
-
- if (hiding)
- {
- if (level->kind != sk_namespace)
- {
- /* In a local class, a friend function declaration must
- find a matching decl in the innermost non-class scope.
- [class.friend/11] */
- error_at (DECL_SOURCE_LOCATION (decl),
- "friend declaration %qD in local class without "
- "prior local declaration", decl);
- /* Don't attempt to push it. */
- return error_mark_node;
- }
- }
- }
+ check_default_args (decl);
if (level->kind != sk_namespace)
{
--
2.38.1