Skip to content

[C23][Parser] Accept single variadic parameter function declarator in type name #145362

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 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ C23 Feature Support
type. Fixes #GH140887
- Documented `WG14 N3006 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3006.htm>`_
which clarified how Clang is handling underspecified object declarations.
- Clang now accepts single variadic parameter in type-name. It's a part of
`WG14 N2975 <https://open-std.org/JTC1/SC22/WG14/www/docs/n2975.pdf>`_

C11 Feature Support
^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7048,7 +7048,8 @@ void Parser::ParseParenDeclarator(Declarator &D) {
// paren, because we haven't seen the identifier yet.
isGrouping = true;
} else if (Tok.is(tok::r_paren) || // 'int()' is a function.
(getLangOpts().CPlusPlus && Tok.is(tok::ellipsis) &&
((getLangOpts().CPlusPlus || getLangOpts().C23) &&
Tok.is(tok::ellipsis) &&
NextToken().is(tok::r_paren)) || // C++ int(...)
isDeclarationSpecifier(
ImplicitTypenameContext::No) || // 'int(int)' is a function.
Expand Down
12 changes: 12 additions & 0 deletions clang/test/C/C23/n2975.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ void use(void) {
// ...including conversion errors.
fp other_local = diag; // expected-error {{incompatible function pointer types initializing 'fp' (aka 'void (*)(...)') with an expression of type 'void (int, int, ...)'}}
}

// int(...) not parsed as variadic function type.
// https://github.com/llvm/llvm-project/issues/145250
int va_fn(...); // expected-warning {{'...' as the only parameter of a function is incompatible with C standards before C23}}

// As typeof() argument
typeof(int(...))*fn_ptr = &va_fn; // expected-warning {{'...' as the only parameter of a function is incompatible with C standards before C23}} \
// expected-warning {{'typeof' is incompatible with C standards before C23}}

// As _Generic association type
int i = _Generic(typeof(va_fn), int(...):1); // expected-warning {{'...' as the only parameter of a function is incompatible with C standards before C23}} \
// expected-warning {{'typeof' is incompatible with C standards before C23}}
Loading