https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114816
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Joseph Myers <js...@gcc.gnu.org>: https://gcc.gnu.org/g:338d687e2a32f4e152d26c02319db1cb00401c3f commit r15-5576-g338d687e2a32f4e152d26c02319db1cb00401c3f Author: Joseph Myers <josmy...@redhat.com> Date: Thu Nov 21 21:46:00 2024 +0000 c: Give errors more consistently for void parameters [PR114816] Cases of void parameters, other than a parameter list of (void) (or equivalent with a typedef for void) in its entirety, have been made a constraint violation in C2Y (N3344 alternative 1 was adopted), as part of a series of changes to eliminate unnecessary undefined behavior by turning it into constraint violations, implementation-defined behavior or something else with stricter bounds on what behavior is allowed. Previously, these were implicitly undefined behavior (see DR#295), with only some cases listed in Annex J as undefined (but even those cases not having wording in the normative text to make them explicitly undefined). As discussed in bug 114816, GCC is not entirely consistent about diagnosing such usages; unnamed void parameters get errors when not the entire parameter list, while qualified and register void (the cases listed in Annex J) get errors as a single unnamed parameter, but named void parameters are accepted with a warning (in a declaration that's not a definition; it's not possible to define a function with incomplete parameter types). Following C2Y, make all these cases into errors. The errors are not conditional on the standard version, given that this was previously implicit undefined behavior. Since it wasn't possible anyway to define such functions, only declare them without defining them (or otherwise use such parameters in function type names that can't correspond to any defined function), hopefully the risks of compatibility issues are small. Bootstrapped with no regressions for x86-64-pc-linux-gnu. PR c/114816 gcc/c/ * c-decl.cc (grokparms): Do not warn for void parameter type here. (get_parm_info): Give errors for void parameters even when named. gcc/testsuite/ * gcc.dg/c2y-void-parm-1.c: New test. * gcc.dg/noncompile/920616-2.c, gcc.dg/noncompile/921116-1.c, gcc.dg/parm-incomplete-1.c: Update expected diagnostics.