| 1 |
// RUN: %clang_analyze_cc1 -verify %s \ |
| 2 |
// RUN: -analyzer-checker=core \ |
| 3 |
// RUN: -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \ |
| 4 |
// RUN: -analyzer-config core.CallAndMessage:ArgPointeeInitializednessComplete=true \ |
| 5 |
// RUN: -analyzer-config core.CallAndMessage:ArgInitializedness=false |
| 6 |
|
| 7 |
// RUN: %clang_analyze_cc1 -verify %s \ |
| 8 |
// RUN: -analyzer-checker=core \ |
| 9 |
// RUN: -analyzer-config core.CallAndMessage:ArgPointeeInitializedness=true \ |
| 10 |
// RUN: -analyzer-config core.CallAndMessage:ArgInitializedness=false |
| 11 |
|
| 12 |
typedef __typeof(sizeof(int)) size_t; |
| 13 |
typedef __WCHAR_TYPE__ wchar_t; |
| 14 |
typedef __CHAR16_TYPE__ char16_t; |
| 15 |
typedef long time_t; |
| 16 |
typedef struct { |
| 17 |
int x; |
| 18 |
int y; |
| 19 |
} mbstate_t; |
| 20 |
struct tm { |
| 21 |
int x; |
| 22 |
int y; |
| 23 |
}; |
| 24 |
extern size_t mbrlen(const char *restrict, size_t, mbstate_t *restrict); |
| 25 |
extern size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict src, |
| 26 |
size_t nwc, size_t len, mbstate_t *restrict ps); |
| 27 |
extern size_t mbrtoc16(char16_t *restrict pc16, const char *restrict s, |
| 28 |
size_t n, mbstate_t *restrict ps); |
| 29 |
extern time_t mktime(struct tm *timeptr); |
| 30 |
|
| 31 |
void uninit_mbrlen(const char *mbs) { |
| 32 |
mbstate_t state; |
| 33 |
mbrlen(mbs, 1, &state); // expected-warning{{3rd function call argument points to an uninitialized value}} |
| 34 |
} |
| 35 |
|
| 36 |
void init_mbrlen(const char *mbs) { |
| 37 |
mbstate_t state; |
| 38 |
state.x = 0; |
| 39 |
mbrlen(mbs, 1, &state); |
| 40 |
} |
| 41 |
|
| 42 |
void uninit_wcsnrtombs(const wchar_t *src) { |
| 43 |
char dst[10]; |
| 44 |
mbstate_t state; |
| 45 |
wcsnrtombs(dst, &src, 1, 2, &state); // expected-warning{{5th function call argument points to an uninitialized value}} |
| 46 |
} |
| 47 |
|
| 48 |
void uninit_mbrtoc16(const char *s) { |
| 49 |
char16_t pc16[10]; |
| 50 |
mbstate_t state; |
| 51 |
mbrtoc16(pc16, s, 1, &state); // expected-warning{{4th function call argument points to an uninitialized value}} |
| 52 |
} |
| 53 |
|
| 54 |
void uninit_mktime() { |
| 55 |
struct tm time; |
| 56 |
mktime(&time); // expected-warning{{1st function call argument points to an uninitialized value}} |
| 57 |
} |