diff options
author | Simon Martin <simon@nasilyan.com> | 2025-01-05 10:36:47 +0100 |
---|---|---|
committer | Simon Martin <simon@nasilyan.com> | 2025-01-17 09:30:19 +0100 |
commit | b5a069203fc074ab75d994c4a7e0f2db6a0a00fd (patch) | |
tree | dd585c24df6ef1b465505c0dd686947f8ff4989c /libphobos/src | |
parent | 44d21551362f9076617200595f49d4260d1f40a9 (diff) | |
download | gcc-b5a069203fc074ab75d994c4a7e0f2db6a0a00fd.zip gcc-b5a069203fc074ab75d994c4a7e0f2db6a0a00fd.tar.gz gcc-b5a069203fc074ab75d994c4a7e0f2db6a0a00fd.tar.bz2 |
c++: Friend classes don't shadow enclosing template class paramater [PR118255]
We currently reject the following code
=== code here ===
template <int non_template> struct S { friend class non_template; };
class non_template {};
S<0> s;
=== code here ===
While EDG agrees with the current behaviour, clang and MSVC don't (see
https://godbolt.org/z/69TGaabhd), and I believe that this code is valid,
since the friend clause does not actually declare a type, so it cannot
shadow anything. The fact that we didn't error out if the non_template
class was declared before S backs this up as well.
This patch fixes this by skipping the call to check_template_shadow for
hidden bindings.
PR c++/118255
gcc/cp/ChangeLog:
* name-lookup.cc (pushdecl): Don't call check_template_shadow
for hidden bindings.
gcc/testsuite/ChangeLog:
* g++.dg/lookup/pr99116-1.C: Adjust test expectation.
* g++.dg/template/friend84.C: New test.
Diffstat (limited to 'libphobos/src')
0 files changed, 0 insertions, 0 deletions