-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Add tests for CWG issues about friend declaration matching #106117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
65307bd
[clang] Add tests for CWG issues about friend declaration matching
Endilll affb324
Add test for CWG1900
Endilll 271a3ae
Merge remote-tracking branch 'upstream/main' into decl-matching-friends
Endilll d97e494
Update cxx_dr_status.html
Endilll 22de748
Add references to N4988
Endilll 3e23ad4
Refence CWG1477 analysis in CWG1900 test
Endilll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1369,6 +1369,78 @@ namespace cwg385 { // cwg385: 2.8 | |
// expected-note@#cwg385-n {{member is declared here}} | ||
} | ||
|
||
namespace cwg386 { // cwg386: no | ||
namespace example1 { | ||
namespace N1 { | ||
// Binds name 'f' in N1. Target scope is N1. | ||
template<typename T> void f( T* x ) { | ||
// ... other stuff ... | ||
delete x; | ||
} | ||
} | ||
|
||
namespace N2 { | ||
// Bind name 'f' in N2. When a single search find this declaration, | ||
// it's replaced with N1::f declaration. | ||
using N1::f; | ||
|
||
// According to _N4988_.[dcl.meaning]/3.3: | ||
// `f<int>` is not a qualified-id, so its target scope is N2. | ||
// `f<int>` is a template-id, so 'f' undergoes (unqualified) lookup. | ||
// Search performed by unqualified lookup finds N1::f via using-declaration, | ||
// but this result is not considered, because it's not nominable in N2, | ||
// which is because its target scope is N1. | ||
// So unqualified lookup doesn't find anything, making this declaration ill-formed. | ||
template<> void f<int>( int* ); | ||
// expected-error@-1 {{no function template matches function template specialization 'f'}} | ||
|
||
class Test { | ||
~Test() { } | ||
// According to _N4988_.[dcl.meaning]/2.2: | ||
// `f<>` is a template-id and not a template declaration, | ||
// so its terminal name 'f' undergoes (unqualified) lookup. | ||
// Search in N2 performed by unqualified lookup finds | ||
// (single) N1::f declaration via using-declaration. | ||
// N1::f is replaced with N1::f<> specialization after deduction, | ||
// and this is the result of the unqualified lookup. | ||
// This friend declaration correspond to the result of the lookup. | ||
// All lookup results target the same scope, which is N1, | ||
// so target scope of this friend declaration is also N1. | ||
// FIXME: This is well-formed. | ||
friend void f<>( Test* x ); | ||
// expected-error@-1 {{no function template matches function template specialization 'f'}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, it's confused by the namespaces - or more likely, the using declarations |
||
}; | ||
} | ||
} // namespace example1 | ||
|
||
namespace example2 { | ||
namespace N1 { | ||
// Binds name 'f' in N1. Target scope is N1. | ||
void f(); // #cwg386-ex2-N1-f | ||
} | ||
|
||
namespace N2 { | ||
// Bind name 'f' in N2. When a single search finds this declaration, | ||
// it's replaced with N1::f declaration. | ||
using N1::f; // #cwg386-ex2-using | ||
class A { | ||
// According to _N4988_.[dcl.meaning]/2.2: | ||
// `N2::f` is a qualified-id, so its terminal name 'f' undergoes (qualified) lookup. | ||
// Search in N2 performed by qualified lookup finds N1::f via using-declaration, | ||
// which is the (only) result of qualified lookup. | ||
// This friend declaration corresponds to the result of the lookup. | ||
// All lookup results target the same scope, which is N1, | ||
// so target scope of this friend declaration is also N1. | ||
// FIXME: This is well-formed. | ||
friend void N2::f(); | ||
// expected-error@-1 {{cannot befriend target of using declaration}} | ||
// expected-note@#cwg386-ex2-N1-f {{target of using declaration}} | ||
// expected-note@#cwg386-ex2-using {{using declaration}} | ||
}; | ||
} | ||
} // namespace example2 | ||
} // namespace cwg386 | ||
|
||
namespace cwg387 { // cwg387: 2.8 | ||
namespace old { | ||
template<typename T> class number { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to try to fix this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has that good first issue feel, so I'll refrain for now. But I'll get to all name lookup issues when I'm done with writing tests for P1787R6.