1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -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 // FIXME: There should be no warning for this.
20 (void)va_arg(*fst, int); // expected-warning{{va_arg() is called on an uninitialized va_list}}
21 // expected-note@-1{{va_arg() is called on an uninitialized va_list}}
25 void call_vprintf_bad(int isstring, ...) {
27 vprintf(isstring ? "%s" : "%d", va); // expected-warning{{Function 'vprintf' is called with an uninitialized va_list argument}}
28 // expected-note@-1{{Function 'vprintf' is called with an uninitialized va_list argument}}
29 // expected-note@-2{{Assuming 'isstring' is 0}}
30 // expected-note@-3{{'?' condition is false}}
33 void call_vsprintf_bad(char *buffer, ...) {
35 va_start(va, buffer); // expected-note{{Initialized va_list}}
36 va_end(va); // expected-note{{Ended va_list}}
37 vsprintf(buffer, "%s %d %d %lf %03d", va); // expected-warning{{Function 'vsprintf' is called with an uninitialized va_list argument}}
38 // expected-note@-1{{Function 'vsprintf' is called with an uninitialized va_list argument}}