aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-10-04 10:46:57 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2024-10-04 20:30:03 +1000
commit6a1e109158940ce3a2d1ceed3e1b614ea6c9a2de (patch)
tree779047dda8867ef16202b793cfb83211b7129392
parent7fb6526652ddd722931407f749a176cfea779147 (diff)
downloadgcc-6a1e109158940ce3a2d1ceed3e1b614ea6c9a2de.zip
gcc-6a1e109158940ce3a2d1ceed3e1b614ea6c9a2de.tar.gz
gcc-6a1e109158940ce3a2d1ceed3e1b614ea6c9a2de.tar.bz2
c++: Return the underlying decl rather than the USING_DECL from update_binding [PR116913]
Users of pushdecl assume that the returned decl will be a possibly updated decl matching the one that was passed in. My r15-3910 change broke this since in some cases we would now return USING_DECLs; this patch fixes the situation. PR c++/116913 gcc/cp/ChangeLog: * name-lookup.cc (update_binding): Return the strip_using'd old decl rather than the binding. gcc/testsuite/ChangeLog: * g++.dg/lookup/using70.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
-rw-r--r--gcc/cp/name-lookup.cc4
-rw-r--r--gcc/testsuite/g++.dg/lookup/using70.C13
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 4754ef5..609bd6e 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -3101,7 +3101,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot,
{
if (same_type_p (TREE_TYPE (old), TREE_TYPE (decl)))
/* Two type decls to the same type. Do nothing. */
- return old_bval;
+ return old;
else
goto conflict;
}
@@ -3114,7 +3114,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot,
/* The new one must be an alias at this point. */
gcc_assert (DECL_NAMESPACE_ALIAS (decl));
- return old_bval;
+ return old;
}
else if (TREE_CODE (old) == VAR_DECL)
{
diff --git a/gcc/testsuite/g++.dg/lookup/using70.C b/gcc/testsuite/g++.dg/lookup/using70.C
new file mode 100644
index 0000000..14838ee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/using70.C
@@ -0,0 +1,13 @@
+// PR c++/116913
+// { dg-do compile { target c++11 } }
+
+namespace ns {
+ struct c {};
+ using d = int;
+}
+
+using ns::c;
+using ns::d;
+
+using c = ns::c;
+using d = ns::d;