-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Implement P3176R1: The Oxford variadic comma #117524
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
7 commits
Select commit
Hold shift + click to select a range
ffcae3a
[clang] Implement P3176R1: The Oxford variadic comma
antangelo 98d249c
Change diagnostic warning wording
antangelo 66e7804
Add additional test cases
antangelo ca3d970
Merge remote-tracking branch 'upstream/main' into p3176r1
antangelo 425d560
Update comment to add full-stop
antangelo e4ef5af
Merge remote-tracking branch 'upstream/main' into p3176r1
antangelo b0a33c7
Add test cases for type specifiers, lambdas and blocks
antangelo 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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// RUN: %clang_cc1 -std=c++2c -fsyntax-only -fblocks -verify %s | ||
|
||
void a(...); | ||
Sirraide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void b(auto...); | ||
void c(auto, ...); | ||
|
||
void d(auto......); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \ | ||
// expected-warning {{'...' in this location creates a C-style varargs function}} \ | ||
// expected-note {{preceding '...' declares a function parameter pack}} \ | ||
// expected-note {{insert ',' before '...' to silence this warning}} | ||
void e(auto..., ...); | ||
|
||
void f(auto x...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} | ||
void g(auto x, ...); | ||
|
||
void h(auto... x...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \ | ||
// expected-warning {{'...' in this location creates a C-style varargs function}} \ | ||
// expected-note {{preceding '...' declares a function parameter pack}} \ | ||
// expected-note {{insert ',' before '...' to silence this warning}} | ||
void i(auto... x, ...); | ||
|
||
template<class ...Ts> | ||
void j(Ts... t...) {}; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \ | ||
// expected-warning {{'...' in this location creates a C-style varargs function}} \ | ||
// expected-note {{preceding '...' declares a function parameter pack}} \ | ||
// expected-note {{insert ',' before '...' to silence this warning}} | ||
template<class ...Ts> | ||
void k(Ts... t, ...) {} | ||
|
||
void l(int...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} | ||
void m(int, ...); | ||
|
||
void n(int x...); // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} | ||
void o(int x, ...); | ||
|
||
struct S { | ||
void p(this S...) {} // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} | ||
}; | ||
|
||
template<class ...Ts> | ||
void q(Ts......) {} // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} \ | ||
// expected-warning {{'...' in this location creates a C-style varargs function}} \ | ||
// expected-note {{preceding '...' declares a function parameter pack}} \ | ||
// expected-note {{insert ',' before '...' to silence this warning}} | ||
|
||
template<class T> | ||
void r(T...) {} // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} | ||
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. Other test cases:
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. Thanks, I've added these test cases |
||
|
||
auto type_specifier = (void (*)(int...)) nullptr; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} | ||
|
||
auto lambda = [](int...) {}; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} | ||
|
||
auto block = ^(int...){}; // expected-warning {{declaration of a variadic function without a comma before '...' is deprecated}} |
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
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.
below:
else if (!getLangOpts().CPlusPlus) {
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.
I had intended to fallthrough to those if blocks so that the
else if (ParmDeclarator.getEllipsisLoc().isValid() || Actions.containsUnexpandedParameterPacks(ParmDeclarator))
block would be evaluated to also emit the parameter pack diagnostics. Do you think those should be omitted in this case?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.
Hum, nah, lets leave it like that