-
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
Changes from 1 commit
ffcae3a
98d249c
66e7804
ca3d970
425d560
e4ef5af
b0a33c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8119,6 +8119,14 @@ void Parser::ParseParameterDeclarationClause( | |
} | ||
|
||
if (TryConsumeToken(tok::ellipsis, EllipsisLoc)) { | ||
if (getLangOpts().CPlusPlus26) { | ||
// C++26 [dcl.dcl.fct]p3: | ||
// A parameter-declaration-clause of the form | ||
// parameter-list '...' is deprecated | ||
Diag(EllipsisLoc, diag::warn_deprecated_missing_comma_before_ellipsis) | ||
<< FixItHint::CreateInsertion(EllipsisLoc, ", "); | ||
} | ||
|
||
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. below: 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. I had intended to fallthrough to those if blocks so that the 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. Hum, nah, lets leave it like that |
||
if (!getLangOpts().CPlusPlus) { | ||
// We have ellipsis without a preceding ',', which is ill-formed | ||
// in C. Complain and provide the fix. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %clang_cc1 -std=c++2c -fsyntax-only -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 {{variadic parameters that are not preceded by a comma are 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 {{variadic parameters that are not preceded by a comma are deprecated}} | ||
void g(auto x, ...); | ||
|
||
void h(auto... x...); // expected-warning {{variadic parameters that are not preceded by a comma are 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 ...T> | ||
void j(T... t...); // expected-warning {{variadic parameters that are not preceded by a comma are 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 k(T... t, ...); | ||
|
||
void l(int...); // expected-warning {{variadic parameters that are not preceded by a comma are deprecated}} | ||
void m(int, ...); | ||
|
||
void n(int x...); // expected-warning {{variadic parameters that are not preceded by a comma are deprecated}} | ||
void o(int x, ...); | ||
|
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.
Maybe "declaration of a variadic function without a comma before '...' is deprecated"
("variadic parameter" is not defined and somewhat confusing)
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've updated the diagnostic to use your suggested wording.