diff options
author | Joseph Myers <josmyers@redhat.com> | 2024-11-21 21:46:00 +0000 |
---|---|---|
committer | Joseph Myers <josmyers@redhat.com> | 2024-11-21 21:46:00 +0000 |
commit | 338d687e2a32f4e152d26c02319db1cb00401c3f (patch) | |
tree | 323a923525596c9a4e76d1928c4184f67c11930b /gcc/doc/cpp.texi | |
parent | 4574f15bb305204fb615756148da8f214156c787 (diff) | |
download | gcc-338d687e2a32f4e152d26c02319db1cb00401c3f.zip gcc-338d687e2a32f4e152d26c02319db1cb00401c3f.tar.gz gcc-338d687e2a32f4e152d26c02319db1cb00401c3f.tar.bz2 |
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.
Diffstat (limited to 'gcc/doc/cpp.texi')
0 files changed, 0 insertions, 0 deletions