mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-30 00:26:06 +00:00

Functions without prototypes in C (also known as K&R C functions) were introduced into C89 as a deprecated feature and C2x is now reclaiming that syntax space with different semantics. However, Clang's -Wstrict-prototypes diagnostic is off-by-default (even in pedantic mode) and does not suffice to warn users about issues in their code. This patch changes the behavior of -Wstrict-prototypes to only diagnose declarations and definitions which are not going to change behavior in C2x mode, and enables the diagnostic in -pedantic mode. The diagnostic is now specifically about the fact that the feature is deprecated. It also adds -Wdeprecated-non-prototype, which is grouped under -Wstrict-prototypes and diagnoses declarations or definitions which will change behavior in C2x mode. This diagnostic is enabled by default because the risk is higher for the user to continue to use the deprecated feature. Differential Revision: https://reviews.llvm.org/D122895
16 lines
523 B
C
16 lines
523 B
C
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c99
|
|
|
|
int f3(y, x, // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}}
|
|
x) // expected-error {{redefinition of parameter}}
|
|
int y,
|
|
x, // expected-note {{previous declaration is here}}
|
|
x; // expected-error {{redefinition of parameter}}
|
|
{
|
|
return x + y;
|
|
}
|
|
|
|
void f4(void) {
|
|
f3 (1, 1, 2, 3, 4); // expected-warning{{too many arguments}}
|
|
}
|
|
|