Debian Codegraph @

gcc/testsuite/g++.dg/ext/attr-format2.C

raw
1 // PR c++/101833
2 // { dg-do compile }
3 // { dg-options "-Wall" }
4
5 struct B { };
6
7 struct V : virtual B {
8 V(int, const char *, ...) __attribute__((format(printf, 3, 4)));
9 };
10
11 struct D : B {
12 D(int, const char *, ...) __attribute__((format(printf, 3, 4)));
13 };
14
15 struct D2 : B {
16 template<typename T>
17 D2(T, const char *, ...) __attribute__((format(printf, 3, 4)));
18 };
19
20 struct V2 : virtual B {
21 template<typename T>
22 V2(T, const char *, ...) __attribute__((format(printf, 3, 4)));
23 };
24
25 struct X {
26 template<typename T>
27 X(T, ...) __attribute__((format(printf, 2, 3)));
28 };
29
30 V v(1, "%s %d", "foo", 1);
31 D d(1, "%s %d", "foo", 1);
32 D2 d2(1, "%s %d", "foo", 1);
33 V2 v2(1, "%s %d", "foo", 1);
34
35 // Test that it actually works.
36 V e1(1, "%d", 1L); // { dg-warning "expects argument of type" }
37 D e2(1, "%d", 1L); // { dg-warning "expects argument of type" }
38 X e3("%d", 1L); // { dg-warning "expects argument of type" }