1 // RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-output=text -verify %s
3 #include "Inputs/system-header-simulator-for-valist.h"
5 // This is called in call_inlined_uses_arg(),
6 // and the warning is generated during the analysis of call_inlined_uses_arg().
7 void inlined_uses_arg(va_list arg
) {
8 (void)va_arg(arg
, int); // expected-warning{{va_arg() is called on an uninitialized va_list}}
9 // expected-note@-1{{va_arg() is called on an uninitialized va_list}}
12 void call_inlined_uses_arg(int fst
, ...) {
14 inlined_uses_arg(va
); // expected-note{{Calling 'inlined_uses_arg'}}
17 void f6(va_list *fst
, ...) {
19 (void)va_arg(*fst
, int);
23 int va_list_get_int(va_list *va
) {
24 return va_arg(*va
, int); // no-warning
30 int va_list_get_int2(struct MyVaList
*va
) {
31 return va_arg(va
->l
, int); // no-warning
34 void call_vprintf_bad(int isstring
, ...) {
36 vprintf(isstring
? "%s" : "%d", va
); // expected-warning{{Function 'vprintf' is called with an uninitialized va_list argument}}
37 // expected-note@-1{{Function 'vprintf' is called with an uninitialized va_list argument}}
38 // expected-note@-2{{Assuming 'isstring' is 0}}
39 // expected-note@-3{{'?' condition is false}}
42 void call_vsprintf_bad(char *buffer
, ...) {
44 va_start(va
, buffer
); // expected-note{{Initialized va_list}}
45 va_end(va
); // expected-note{{Ended va_list}}
46 vsprintf(buffer
, "%s %d %d %lf %03d", va
); // expected-warning{{Function 'vsprintf' is called with an uninitialized va_list argument}}
47 // expected-note@-1{{Function 'vsprintf' is called with an uninitialized va_list argument}}