mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 09:16:04 +00:00

A significant number of our tests in C accidentally use functions without prototypes. This patch converts the function signatures to have a prototype for the situations where the test is not specific to K&R C declarations. e.g., void func(); becomes void func(void); This is the eighth batch of tests being updated (there are a significant number of other tests left to be updated).
31 lines
858 B
C
31 lines
858 B
C
// RUN: rm -f %t
|
|
// RUN: %clang_analyze_cc1 -fblocks \
|
|
// RUN: -analyzer-checker=core \
|
|
// RUN: -analyzer-checker=unix.Malloc \
|
|
// RUN: -analyzer-checker=unix.cstring.NullArg \
|
|
// RUN: -analyzer-disable-checker=alpha.unix.cstring.OutOfBounds \
|
|
// RUN: -analyzer-output=plist -o %t %s
|
|
// RUN: FileCheck -input-file %t %s
|
|
|
|
typedef __typeof(sizeof(int)) size_t;
|
|
void *malloc(size_t);
|
|
void free(void *);
|
|
char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
|
|
|
|
|
|
|
|
void cstringchecker_bounds_nocrash(void) {
|
|
char *p = malloc(2);
|
|
strncpy(p, "AAA", sizeof("AAA")); // we don't expect warning as the checker is disabled
|
|
free(p);
|
|
}
|
|
|
|
// CHECK: <key>diagnostics</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: <key>files</key>
|
|
// CHECK-NEXT: <array>
|
|
// CHECK-NEXT: </array>
|
|
// CHECK-NEXT: </dict>
|
|
// CHECK-NEXT: </plist>
|