1 /* PR c/78673 - sprintf missing attribute nonnull on destination argument
2 Test to verify that calls to user-defined functions declared with
3 the "nonnull" function attribute are diagnosed. */
4 /* { dg-do compile } */
5 /* { dg-options "-O2 -Wnonnull" } */
7 #define N(...) __attribute__ ((nonnull (__VA_ARGS__)))
9 void N (1) f1_1 (void*);
11 void N (1) f2_1 (void*, void*);
12 void N (1) N (2) f2_1_2 (void*, void*);
14 void N (1) N (3) f3_1_3 (void*, void*, void*);
16 void N (1, 2) N (4) g4_1_2_4 (void*, void*, void*, void*);
17 void N (1, 3) N (4) g4_1_3_4 (void*, void*, void*, void*);
18 void N (2, 3, 4) g4_2_3_4 (void*, void*, void*, void*);
20 void N () g4_all (void*, void*, void*, void*);
22 void N (1, 3, 5, 7, 11, 13)
23 g16_1_3_5_7_11_13 (void*, void*, void*, void*,
24 void*, void*, void*, void*,
25 void*, void*, void*, void*,
26 void*, void*, void*, void*);
28 void* null (void) { return 0; }
35 f1_1 (p0
); /* { dg-warning "argument 1 null where non-null expected " } */
38 f2_1 (p0
, px
); /* { dg-warning "argument 1 null" } */
40 f2_1 (p0
, p0
); /* { dg-warning "argument 1 null" } */
42 f2_1_2 (p0
, px
); /* { dg-warning "argument 1 null" } */
43 f2_1_2 (px
, p0
); /* { dg-warning "argument 2 null" } */
44 f2_1_2 (p0
, p0
); /* { dg-warning "argument 1 null" } */
45 /* { dg-warning "argument 2 null" "argument 2" { target *-*-* } .-1 } */
47 f3_1_3 (p0
, px
, px
); /* { dg-warning "argument 1 null" } */
49 f3_1_3 (px
, px
, p0
); /* { dg-warning "argument 3 null" } */
50 f3_1_3 (p0
, p0
, px
); /* { dg-warning "argument 1 null" } */
51 f3_1_3 (px
, p0
, p0
); /* { dg-warning "argument 3 null" } */
52 f3_1_3 (p0
, p0
, p0
); /* { dg-warning "argument 1 null" } */
53 /* { dg-warning "argument 3 null" "argument 3" { target *-*-* } .-1 } */
55 g4_1_2_4 (p0
, px
, px
, px
); /* { dg-warning "argument 1 null" } */
56 g4_1_2_4 (px
, p0
, px
, px
); /* { dg-warning "argument 2 null" } */
57 g4_1_2_4 (px
, px
, p0
, px
);
58 g4_1_2_4 (px
, px
, px
, p0
); /* { dg-warning "argument 4 null" } */
60 g4_1_3_4 (p0
, px
, px
, px
); /* { dg-warning "argument 1 null" } */
61 g4_1_3_4 (px
, p0
, px
, px
);
62 g4_1_3_4 (px
, px
, p0
, px
); /* { dg-warning "argument 3 null" } */
63 g4_1_3_4 (px
, px
, px
, p0
); /* { dg-warning "argument 4 null" } */
65 g4_2_3_4 (p0
, px
, px
, px
);
66 g4_2_3_4 (px
, p0
, px
, px
); /* { dg-warning "argument 2 null" } */
67 g4_2_3_4 (px
, px
, p0
, px
); /* { dg-warning "argument 3 null" } */
68 g4_2_3_4 (px
, px
, px
, p0
); /* { dg-warning "argument 4 null" } */
70 g4_all (p0
, px
, px
, px
); /* { dg-warning "argument 1 null" } */
71 g4_all (px
, p0
, px
, px
); /* { dg-warning "argument 2 null" } */
72 g4_all (px
, px
, p0
, px
); /* { dg-warning "argument 3 null" } */
73 g4_all (px
, px
, px
, p0
); /* { dg-warning "argument 4 null" } */
75 g16_1_3_5_7_11_13 (px
, px
, px
, px
, px
, px
, px
, px
,
76 px
, px
, px
, px
, px
, px
, px
, px
);
78 g16_1_3_5_7_11_13 (px
, p0
, px
, p0
, px
, p0
, px
, p0
, p0
, p0
, px
, p0
, p0
, p0
, p0
, p0
); /* { dg-warning "argument 13 null" } */