This catches places where a function without a prototype is accidentally used, potentially passing an incorrect number of arguments, and is a follow-up to the work done in https://reviews.llvm.org/D122895 and described in the RFC (https://discourse.llvm.org/t/rfc-enabling-wstrict-prototypes-by-default-in-c). The diagnostic is grouped under the new -Wdeprecated-non-prototypes warning group and is enabled by default. The diagnostic is disabled if the function being called was implicitly declared (the user already gets an on-by-default warning about the creation of the implicit function declaration, so no need to warn them twice on the same line). Additionally, the diagnostic is disabled if the declaration of the function without a prototype was in a location where the user explicitly disabled deprecation warnings for functions without prototypes (this allows the provider of the API a way to disable the diagnostic at call sites because the lack of prototype is intentional).
21 lines
693 B
C
21 lines
693 B
C
// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -Wno-deprecated-non-prototype -verify %s
|
|
void clang_analyzer_denote(int, const char *);
|
|
void clang_analyzer_express(int);
|
|
|
|
void SymbolCast_of_float_type_aux(int *p) {
|
|
*p += 0;
|
|
// FIXME: Ideally, all unknown values should be symbolicated.
|
|
clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
|
|
|
|
*p += 1;
|
|
// This should NOT be (float)$x + 1. Symbol $x was never casted to float.
|
|
// FIXME: Ideally, this should be $x + 1.
|
|
clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
|
|
}
|
|
|
|
void SymbolCast_of_float_type(void) {
|
|
extern float x;
|
|
void (*f)() = SymbolCast_of_float_type_aux;
|
|
f(&x);
|
|
}
|