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.
Showing
- gcc/c-family/c-opts.cc 3 additions, 0 deletionsgcc/c-family/c-opts.cc
- gcc/c-family/c.opt 4 additions, 0 deletionsgcc/c-family/c.opt
- gcc/c-family/c.opt.urls 3 additions, 0 deletionsgcc/c-family/c.opt.urls
- gcc/c/c-decl.cc 18 additions, 0 deletionsgcc/c/c-decl.cc
- gcc/c/c-typeck.cc 22 additions, 4 deletionsgcc/c/c-typeck.cc
- gcc/doc/invoke.texi 11 additions, 1 deletiongcc/doc/invoke.texi
- gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-1.c 24 additions, 0 deletionsgcc/testsuite/gcc.dg/Wdeprecated-non-prototype-1.c
- gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-2.c 22 additions, 0 deletionsgcc/testsuite/gcc.dg/Wdeprecated-non-prototype-2.c
- gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-3.c 18 additions, 0 deletionsgcc/testsuite/gcc.dg/Wdeprecated-non-prototype-3.c
- gcc/testsuite/gcc.dg/Wdeprecated-non-prototype-4.c 22 additions, 0 deletionsgcc/testsuite/gcc.dg/Wdeprecated-non-prototype-4.c
Loading
Please register or sign in to comment