This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add test for CWG2370
ClosedPublic

Authored by Endill on Apr 8 2023, 4:04 AM.

Details

Reviewers
shafik
Group Reviewers
Restricted Project
Commits
rGfeb93d28b02c: [clang] Add test for CWG2370
Summary

P1787: CWG2370 is resolved by performing a search in (only) the immediate scope of any friend, per the CWG opinion from San Diego.
Wording: In a friend declaration declarator whose declarator-id is a qualified-id whose lookup context is a class or namespace S, lookup for an unqualified name that appears after the declarator-id performs a search in the scope associated with S. If that lookup finds nothing, it undergoes unqualified name lookup. ([basic.lookup.unqual]/6).

Clarification for P1787 description: when applied to the test in this patch, "immediate scope" refers to N, and "(only)" refers to the fact that type is not searched in parent scope of N. See example after the wording if additional clarification is needed. The most relevant line there is friend void A::f(F); // OK.

Diff Detail

Event Timeline

Endill created this revision.Apr 8 2023, 4:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2023, 4:04 AM
Endill requested review of this revision.Apr 8 2023, 4:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2023, 4:04 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added a subscriber: shafik.Apr 10 2023, 1:59 PM
shafik added inline comments.
clang/test/CXX/drs/dr23xx.cpp
182

The implementation seems to all accept this example: https://godbolt.org/z/vE6bEP6xa

but the examples from the p1787 have a decidely mixed conformance: https://godbolt.org/z/dhq7oEKaY

but the A::F(F) you point out in your example clang does get wrong and gcc does not. So at minimum please file bug reports against the examples that clang does not get right from p1787 and we need to dig into why your example above seems to not the same since that is what you intended.

Endill added inline comments.Apr 11 2023, 1:25 AM
clang/test/CXX/drs/dr23xx.cpp
182

Are you sure behavior is different for my N::g(type) when compared to A::f(F)? Clang is the only one to reject both examples: https://godbolt.org/z/MKb6fE8K5

shafik accepted this revision.Apr 11 2023, 10:07 AM

LGTM

clang/test/CXX/drs/dr23xx.cpp
182

Oh wow, I someone how missed the commented line of code and thought you were referring to the uncomment line.

This revision is now accepted and ready to land.Apr 11 2023, 10:07 AM
This revision was automatically updated to reflect the committed changes.