Skip to content
Snippets Groups Projects
Commit 701d8e7e authored by Florian Weimer's avatar Florian Weimer
Browse files

c: Implement -Wdeprecated-non-prototype

This warning covers the C23 incompibilities resulting from using
() as parameter lists in function declarations.

The warning name comes from Clang.  The implementation is not
perfect because GCC treats these two declarations as equivalent:

  void f ();
  void f (not_a_type);

This is a bit confusing because they are clearly visually distinct.
However, as of GCC 14, the second form is an error by default, so
treating both the same as far as  -Wdeprecated-non-prototype does
not seem so bad from a user experience view.

gcc/c-family/

	PR c/95445
	* c-opts.cc (c_common_post_options): Initialize
	warn_deprecated_non_prototype.
	* c.opt (Wdeprecated-non-prototype): New option.
	* c.opt.urls: Regenerate.

gcc/c/

	PR c/95445
	* c-decl.cc (start_function): Warn about parameters
	after parameter-less declaration.
	* c-typeck.cc (build_function_call_vec): Pass fntype
	to convert_arguments.
	(convert_arguments): Change argument to fntype and
	compute typelist.  Warn about parameter list mismatches
	on first parameter.

gcc/

	PR c/95445
	* doc/invoke.texi: Document -Wdeprecated-non-prototype.

gcc/testsuite/

	PR c/95445
	* gcc.dg/Wdeprecated-non-prototype-1.c: New test.
	* gcc.dg/Wdeprecated-non-prototype-2.c: New test.
	* gcc.dg/Wdeprecated-non-prototype-3.c: New test.
	* gcc.dg/Wdeprecated-non-prototype-4.c: New test.
parent 3e89a4d5
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