aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-09-20 00:47:12 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2024-09-28 09:00:52 +1000
commit2196a20b82bdde2aeb099bcfd164fa29a698e837 (patch)
tree120cf7dfec42883c9d47aba40f9083ecef1a05f8 /gcc/cp
parentb9ac51a843f9dc807b00ab7f49f64968807a4ee8 (diff)
downloadgcc-2196a20b82bdde2aeb099bcfd164fa29a698e837.zip
gcc-2196a20b82bdde2aeb099bcfd164fa29a698e837.tar.gz
gcc-2196a20b82bdde2aeb099bcfd164fa29a698e837.tar.bz2
c++: Implement resolution for DR 36 [PR116160]
This implements part of P1787 to no longer complain about redeclaring an entity via using-decl other than in a class scope. PR c++/116160 gcc/cp/ChangeLog: * name-lookup.cc (supplement_binding): Allow redeclaration via USING_DECL if not in class scope. (do_nonmember_using_decl): Remove function-scope exemption. (push_using_decl_bindings): Remove outdated comment. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/using-enum-3.C: No longer expect an error. * g++.dg/lookup/using53.C: Remove XFAIL. * g++.dg/cpp2a/using-enum-11.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/name-lookup.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index a2f94e0..4754ef5 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -2874,6 +2874,12 @@ supplement_binding (cxx_binding *binding, tree decl)
"%<-std=c++2c%> or %<-std=gnu++2c%>");
binding->value = name_lookup::ambiguous (decl, binding->value);
}
+ else if (binding->scope->kind != sk_class
+ && TREE_CODE (decl) == USING_DECL
+ && decls_match (target_bval, target_decl))
+ /* Since P1787 (DR 36) it is OK to redeclare entities via using-decl,
+ except in class scopes. */
+ ok = false;
else
{
if (!error_operand_p (bval))
@@ -5377,8 +5383,7 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p,
else if (value
/* Ignore anticipated builtins. */
&& !anticipated_builtin_p (value)
- && (fn_scope_p
- || !decls_match (lookup.value, strip_using_decl (value))))
+ && !decls_match (lookup.value, strip_using_decl (value)))
{
diagnose_name_conflict (lookup.value, value);
failed = true;
@@ -6651,9 +6656,6 @@ push_using_decl_bindings (name_lookup *lookup, tree name, tree value)
type = binding->type;
}
- /* DR 36 questions why using-decls at function scope may not be
- duplicates. Disallow it, as C++11 claimed and PR 20420
- implemented. */
if (lookup)
do_nonmember_using_decl (*lookup, true, true, &value, &type);