This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add test for CWG399
ClosedPublic

Authored by Endill on Apr 10 2023, 1:38 AM.

Details

Reviewers
aaron.ballman
shafik
Group Reviewers
Restricted Project
Commits
rG14f245d01a1e: [clang] Add test for CWG399
Summary

P1787: CWG399 is resolved by explicitly appealing to the lookup for the last component of any suitable nested-name-specifier.
Wording: Otherwise, its nested-name-specifier N shall nominate a type. If N has another nested-name-specifier S, Q is looked up as if its lookup context were that nominated by S. ([basic.lookup.qual]/6.2)

CWG399 revisits a resolution to older CWG244. Our test for CWG244 covers many examples from CWG399, and it was updated in 2020 presumably aware of P1787, so I reused CWG244 test. This approach to reusing was discussed in a CWG405 patch review.

Diff Detail

Event Timeline

Endill created this revision.Apr 10 2023, 1:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2023, 1:38 AM
Endill requested review of this revision.Apr 10 2023, 1:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2023, 1:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Endill added inline comments.Apr 10 2023, 1:45 AM
clang/test/CXX/drs/dr3xx.cpp
1439

Despite a couple of FIXME in CWG244 test (out of dozens of examples), it claims full availability since Clang 11. I'd take a more conservative approach, declaring partial support, but I think that declaring different availability for the same test would bring unnecessary confusion. So I followed CWG244 availability.

Alternative is to demote CWG244 to partial, but I'm not sure we should go back on our claims for CWG support that has been out for so long.

shafik added a subscriber: shafik.Apr 10 2023, 4:52 PM
shafik added inline comments.
clang/test/CXX/drs/dr3xx.cpp
1492

You say we accept the next line but it has an expected-error on it?

I think I haven't stressed it enough, but this whole test is copied from dr244, which is written by Richard.

clang/test/CXX/drs/dr3xx.cpp
1492

It's an error because of -pedantic-errors. It's a warning by default.

shafik added inline comments.
clang/test/CXX/drs/dr3xx.cpp
1439

I think the bugs are not awful, we should file bug reports if we don't already have them. Some of them seem like they should be not too bad to fix.

CC @aaron.ballman to get a second opinion

1492

That makes a lot more sense, I was wondering what was I missing.

Can we note that in the comment b/c it is pretty confusing otherwise.

I wonder if there is a good reason to not make this ill-formed by default? Worth a bug report.

I think I haven't stressed it enough, but this whole test is copied from dr244, which is written by Richard.

Understood, I appreciate the patience in explaining what I am missing. Sometimes that means things could be explained better.

I think I haven't stressed it enough, but this whole test is copied from dr244, which is written by Richard.

Understood, I appreciate the patience in explaining what I am missing. Sometimes that means things could be explained better.

No worries. Those DRs are involved enough that it could be challenging to understand the context quickly.

clang/test/CXX/drs/dr3xx.cpp
1492

Can we note that in the comment b/c it is pretty confusing otherwise.

I get where you come from, but all DR testing is done under -pedantic-errors. Do you have ideas for a more systematic approach? One of the options is to use -Wpedantic instead, but I expect that to require a decent amount of mechanical replacements for existing tests, which LLVM community doesn't appreciate, as far as I know. I'll edit the comment if we won't come up with something better.

I wonder if there is a good reason to not make this ill-formed by default? Worth a bug report.

Does the fact that we accepted such code since (at least) 3.5 through 10 make for a good reason? https://godbolt.org/z/16GYWh3Po

Endill added inline comments.Apr 11 2023, 11:25 AM
clang/test/CXX/drs/dr3xx.cpp
1439

If we are to file bug reports, I'm not sure what wording makes those examples ill-formed. Is it qual.general-4.6: The type-name that is or contains Q shall refer to its (original) lookup context (ignoring cv-qualification) under the interpretation established by at least one (successful) lookup performed.? I interpret it as requiring names to the left and to the right of ~ to be found in the same scope (lookup context; namespace dr244 in our case). Could it actually mean that they have to refer to the same type?

shafik added a subscriber: rsmith.Apr 12 2023, 8:33 PM
shafik added inline comments.
clang/test/CXX/drs/dr3xx.cpp
1439

I am not sure maybe @rsmith might be able to help us here.

aaron.ballman added inline comments.
clang/test/CXX/drs/dr3xx.cpp
1439

I think we want to start being more conservative with claiming support for features and DRs, and that means being more honest with "partial" markings (with comments as to WHY the support is only partial, what's still left to be done, etc). I don't think it's a problem to say "we've discovered enough issues with this that we no longer claim to support it" when that's accurate.

I don't think we have a hard and fast rule for when a bug is sufficiently worrying to merit partial vs full support; it's going to depend on the situation, I think. Failing to diagnose incorrect code is a different kind of problem from diagnosing correct code from crashing bugs from etc. and it's going to be up to the patch author and reviewers to make a value judgement. But that's why I think it's fine for us to update the status when we learn more information, too.

That said, when we do have partial support, we definitely need to file issues to address the remaining bits at some point.

I interpret it as requiring names to the left and to the right of ~ to be found in the same scope (lookup context; namespace dr244 in our case). Could it actually mean that they have to refer to the same type?

I've read that wording a few times now and can't make heads or tails of what it's trying to say. Perhaps @rsmith or @hubert.reinterpretcast can help illuminate us?

aaron.ballman accepted this revision.May 8 2023, 12:17 PM
aaron.ballman added inline comments.
clang/test/CXX/drs/dr3xx.cpp
1439

@Endill reminded me off-list that the FIXME comments here are existing comments; some of these test cases are lifted from the dr244 test cases. Given that and it's been a few weeks and we've not determine what issues to file, I think we should unblock this review as it makes forward progress on our test coverage for dr399. Filing issues would be good, but not a prerequisite for landing this. WDYT @shafik?

This revision is now accepted and ready to land.May 8 2023, 12:17 PM

@shafik ping

clang/test/CXX/drs/dr3xx.cpp
1439

@Endill reminded me off-list that the FIXME comments here are existing comments; some of these test cases are lifted from the dr244 test cases. Given that and it's been a few weeks and we've not determine what issues to file, I think we should unblock this review as it makes forward progress on our test coverage for dr399. Filing issues would be good, but not a prerequisite for landing this. WDYT @shafik?

shafik accepted this revision.May 17 2023, 2:15 PM

LGTM, apologies, it fell off my radar

This revision was landed with ongoing or failed builds.May 20 2023, 1:18 AM
This revision was automatically updated to reflect the committed changes.
Endill marked an inline comment as not done.

I'm seeing test failures on main

error: 'error' diagnostics expected but not seen: 
  File /home/cor3ntin/dev/compilers/LLVM/llvm-project/clang/test/CXX/drs/dr3xx.cpp Line 1456: refers to a member in namespace
  File /home/cor3ntin/dev/compilers/LLVM/llvm-project/clang/test/CXX/drs/dr3xx.cpp Line 1457: refers to a member in namespace
error: 'error' diagnostics seen but not expected: 
  File /home/cor3ntin/dev/compilers/LLVM/llvm-project/clang/test/CXX/drs/dr3xx.cpp Line 1456: use of undeclared identifier 'dr244'
  File /home/cor3ntin/dev/compilers/LLVM/llvm-project/clang/test/CXX/drs/dr3xx.cpp Line 1457: use of undeclared identifier 'dr244'
error: 'note' diagnostics expected but not seen: 
  File /home/cor3ntin/dev/compilers/LLVM/llvm-project/clang/test/CXX/drs/dr3xx.cpp Line 1441: type 'dr244::B' found by destructor name lookup
error: 'note' diagnostics seen but not expected: 
  File /home/cor3ntin/dev/compilers/LLVM/llvm-project/clang/test/CXX/drs/dr3xx.cpp Line 1441: type 'dr399::B' found by destructor name lookup
6 errors generated.

Thank you!
I'm going to fix this now.