llvm-capstone/clang/test/Frontend/no-knr-functions.c
Aaron Ballman 9955f14aaf [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
2022-04-20 13:28:15 -04:00

12 lines
761 B
C

// Ensure that we cannot disable strict prototypes, no matter how hard we try.
// RUN: not %clang_cc1 -fno-no-knr-functions -x c++ %s 2>&1 | FileCheck --check-prefixes=NONO %s
// RUN: not %clang_cc1 -fno-no-knr-functions -x c %s 2>&1 | FileCheck --check-prefixes=NONO %s
// RUN: not %clang_cc1 -fno-no-knr-functions -std=c89 -x c %s 2>&1 | FileCheck --check-prefixes=NONO %s
// RUN: not %clang_cc1 -fknr-functions -x c++ %s 2>&1 | FileCheck --check-prefixes=POS %s
// RUN: not %clang_cc1 -fknr-functions -x c %s 2>&1 | FileCheck --check-prefixes=POS %s
// RUN: not %clang_cc1 -fknr-functions -std=c89 -x c %s 2>&1 | FileCheck --check-prefixes=POS %s
// NONO: error: unknown argument: '-fno-no-knr-functions'
// POS: error: unknown argument: '-fknr-functions'