Skip to content
Snippets Groups Projects
Commit 338d687e authored by Joseph Myers's avatar Joseph Myers
Browse files

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.
parent 4574f15b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment