This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add test for CWG2007
ClosedPublic

Authored by Endill on Apr 7 2023, 10:22 PM.

Details

Reviewers
shafik
Group Reviewers
Restricted Project
Commits
rGa4beecef8f40: [clang] Add test for CWG2007
Summary

P1787: CWG2007 is resolved by skipping unqualified lookup for operators that must be member functions.
Wording: For the operators =, [], or ->, the set of non-member candidates is empty; otherwise, it includes the result of the unqualified lookup for operator@... ([over.match.oper]/3)

Diff Detail

Event Timeline

Endill created this revision.Apr 7 2023, 10:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 10:22 PM
Endill requested review of this revision.Apr 7 2023, 10:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 10:22 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added a subscriber: shafik.Apr 10 2023, 10:52 AM
shafik added inline comments.
clang/test/CXX/drs/dr20xx.cpp
20

It looks like gcc and MSVC also instantiate A<void> for this case: https://godbolt.org/z/8W8eYoa38

I have to think about it some more but if we believe clang is wrong here, you should file a bug report.

shafik added inline comments.Apr 10 2023, 11:19 AM
clang/test/CXX/drs/dr20xx.cpp
20

I think unary & is triggering the instantiation.

Endill added inline comments.Apr 10 2023, 11:43 AM
clang/test/CXX/drs/dr20xx.cpp
20

Does it mean that we should craft a better example?

shafik added inline comments.Apr 10 2023, 5:20 PM
clang/test/CXX/drs/dr20xx.cpp
20

Yes, we need a better example, something like this will work, maybe something like:

cpp
B<A<void> > arr[2];
auto x = arr->foo;
Endill updated this revision to Diff 512365.Apr 11 2023, 1:42 AM

Replace unary & with __builtin_addressof(). It prevents unnecessary template instantiation (presumably to find overloaded unary &), and make Clang compliant since 3.4

Replace unary & with __builtin_addressof(). It prevents unnecessary template instantiation (presumably to find overloaded unary &), and make Clang compliant since 3.4

Nice approach!

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

LGTM, thank you again for all the effort in documenting these and adding tests, it is much appreciated.

This revision is now accepted and ready to land.Apr 11 2023, 10:23 AM

Replace unary & with __builtin_addressof(). It prevents unnecessary template instantiation (presumably to find overloaded unary &), and make Clang compliant since 3.4

Nice approach!

Credits go to Aaron, actually. We discussed this DR during his office hours yesterday.

LGTM, thank you again for all the effort in documenting these and adding tests, it is much appreciated.

Thank you for giving them thorough review.

This revision was landed with ongoing or failed builds.Apr 11 2023, 12:13 PM
This revision was automatically updated to reflect the committed changes.