This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add test for CWG600
ClosedPublic

Authored by Endill on Dec 2 2022, 12:25 AM.

Details

Reviewers
aaron.ballman
Group Reviewers
Restricted Project
Commits
rG7e31d0723dbf: [clang] Add test for CWG600
Summary

P1787: CWG600 is resolved by explaining that accessibility affects naming a member in the sense of the ODR.
Wording: see changes to [class.access] p1 and p4.
Additional references: basic.def.odr/8: A function is odr-used if it is named by a potentially-evaluated expression or conversion.

Diff Detail

Event Timeline

Endill created this revision.Dec 2 2022, 12:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2022, 12:25 AM
Endill requested review of this revision.Dec 2 2022, 12:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2022, 12:26 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
shafik added a subscriber: shafik.Dec 2 2022, 8:58 AM
shafik added inline comments.
clang/test/CXX/drs/dr6xx.cpp
18

Maybe add a comment above this saying something like:

// access control is applied after overload resolution
// [class.access.general]p4 "For an overload set, access control is applied only to the function selected by overload resolution."
shafik added a comment.Dec 2 2022, 8:58 AM

Thank you for updating the DR statuses! This is much appreciated.

Endill added inline comments.Dec 2 2022, 9:11 AM
clang/test/CXX/drs/dr6xx.cpp
18

I tend to like the idea, but I wonder about general rule for adding such explanations. Currently DR tests contain very little of those.

If we're going to add explanations, we should also decide whether we're going to cite the standard, or paraphrase (and/or) explain intent. My concern is that both references to standard and citations could grow old relatively quickly, and we don't have any tools to help, at least yet.

Endill added inline comments.
clang/test/CXX/drs/dr6xx.cpp
18

@aaron.ballman What do you think?

aaron.ballman added inline comments.Dec 2 2022, 10:57 AM
clang/test/CXX/drs/dr6xx.cpp
18

We don't typically add a significant amount of comments to test files unless what is being tested needs some explanation. So, IMO, if the DR test case is "tricky" in some way and we're trying to demonstrate that we're testing a specific sentence or two from the standard, then I think a comment with standards wording is reasonable (please don't just cite [foo.bar]p12 though -- add the standards wording!). However, if the test is pretty straightforward, or the DR explains in more detail what's going on, then I don't think we need to add the comment (the references get stale rather quickly, even with stable names as in C++).

All that said, if you're on the fence about whether to add a comment or not, go ahead and add it (IMO).

Endill added inline comments.Dec 2 2022, 11:06 AM
clang/test/CXX/drs/dr6xx.cpp
18

I think that this one is the case when DR explains it better, because that's what it is about. Adding a comment seems more appropriate for something that's not given enough attention or accent in the whole context of a DR test, as opposed to test code itself.

@shafik Is it fine by you if I don't add any comment?

shafik added inline comments.Dec 2 2022, 1:43 PM
clang/test/CXX/drs/dr6xx.cpp
18

I would be satisfied with this comment alone, it would avoid the concern about wording and paragraph numbering shifting around in subsequent drafts:

// access control is applied after overload resolution

While the DR does explain the issue it is not obvious what the resolution is without spending some time digging, but at least with the comment you know what your looking for if you want to do the digging.

Endill updated this revision to Diff 479818.Dec 3 2022, 2:43 AM

Add a comment per @shafik request

This revision is now accepted and ready to land.Dec 5 2022, 6:32 AM
This revision was automatically updated to reflect the committed changes.