diff --git a/compiler/src/dmd/hdrgen.d b/compiler/src/dmd/hdrgen.d index b456f6cc52ca..6c9120677e85 100644 --- a/compiler/src/dmd/hdrgen.d +++ b/compiler/src/dmd/hdrgen.d @@ -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) @@ -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(""); break; case VarArg.variadic: diff --git a/compiler/test/fail_compilation/diag23177.d b/compiler/test/fail_compilation/diag23177.d index 2bec867df896..aa20cd7a7223 100644 --- a/compiler/test/fail_compilation/diag23177.d +++ b/compiler/test/fail_compilation/diag23177.d @@ -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() 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(int a))` -fail_compilation/diag23177.d(26): cannot pass argument `& f` of type `extern (C) int function(int a)` 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 --- */