Skip to content
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
12 changes: 7 additions & 5 deletions compiler/src/dmd/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -3656,6 +3656,13 @@ const(char)* parameterToChars(Parameter parameter, TypeFunction tf, bool fullQua
private void parametersToBuffer(ParameterList pl, ref OutBuffer buf, ref HdrGenState hgs)
{
buf.put('(');
if (pl.varargs == VarArg.KRvariadic)
{
if (!hgs.hdrgen)
buf.put("..."); // essentially C23 variadic with no named parameter
buf.put(')');
return;
}
foreach (i; 0 .. pl.length)
{
if (i)
Expand All @@ -3665,12 +3672,7 @@ private void parametersToBuffer(ParameterList pl, ref OutBuffer buf, ref HdrGenS
final switch (pl.varargs)
{
case VarArg.none:
break;

case VarArg.KRvariadic:
// Diagnostic-only spelling; header/.di output keeps plain `()`.
if (!hgs.hdrgen)
buf.put("<K&R variadics>");
break;

case VarArg.variadic:
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/fail_compilation/diag23177.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
TEST_OUTPUT:
---
fail_compilation/diag23177.d(25): Error: function `run1` is not callable using argument types `(extern (C) int function())`
fail_compilation/diag23177.d(25): cannot pass argument `& callback` of type `extern (C) int function()` to parameter `extern (C) int function(<K&R variadics>) fn`
fail_compilation/imports/imp23177.c(4): `imp23177.run1(extern (C) int function(<K&R variadics>) fn)` declared here
fail_compilation/diag23177.d(26): Error: function `run2` is not callable using argument types `(extern (C) int function(int a<K&R variadics>))`
fail_compilation/diag23177.d(26): cannot pass argument `& f` of type `extern (C) int function(int a<K&R variadics>)` to parameter `extern (C) int function(int a) fn`
fail_compilation/diag23177.d(25): cannot pass argument `& callback` of type `extern (C) int function()` to parameter `extern (C) int function(...) fn`
fail_compilation/imports/imp23177.c(4): `imp23177.run1(extern (C) int function(...) fn)` declared here
fail_compilation/diag23177.d(26): Error: function `run2` is not callable using argument types `(extern (C) int function(...))`
fail_compilation/diag23177.d(26): cannot pass argument `& f` of type `extern (C) int function(...)` to parameter `extern (C) int function(int a) fn`
fail_compilation/imports/imp23177.c(14): `imp23177.run2(extern (C) int function(int a) fn)` declared here
---
*/
Expand Down
Loading