[C2x] Disallow functions without prototypes/functions with identifier lists
authorAaron Ballman <aaron@aaronballman.com>
Wed, 20 Apr 2022 17:26:38 +0000 (13:26 -0400)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 20 Apr 2022 17:28:15 +0000 (13:28 -0400)
commit9955f14aaf9995f6f0f7bf058ac740463003c470
treec596045609299a6625a58bcab9bb108377f7ad22
parent9c069374cebe0162bc4f0b9d0397cf2b1c5febf6
[C2x] Disallow functions without prototypes/functions with identifier lists

WG14 has elected to remove support for K&R C functions in C2x. The
feature was introduced into C89 already deprecated, so after this long
of a deprecation period, the committee has made an empty parameter list
mean the same thing in C as it means in C++: the function accepts no
arguments exactly as if the function were written with (void) as the
parameter list.

This patch implements WG14 N2841 No function declarators without
prototypes (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm)
and WG14 N2432 Remove support for function definitions with identifier
lists (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf).

It also adds The -fno-knr-functions command line option to opt into
this behavior in other language modes.

Differential Revision: https://reviews.llvm.org/D123955
16 files changed:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Driver/Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/test/Driver/no-knr-functions.c [new file with mode: 0644]
clang/test/Frontend/no-knr-functions.c [new file with mode: 0644]
clang/test/Parser/c2x-attributes.c
clang/test/Parser/c2x-func-prototype.c [new file with mode: 0644]
clang/test/Sema/attr-c2x.c
clang/test/Sema/c2x-func-prototype.c [new file with mode: 0644]
clang/www/c_status.html