c, c++: attribute format on a ctor with a vbase [PR101833, PR47634]
[official-gcc.git] / gcc / testsuite / g++.dg / ext / attr-format2.C
blob7e6eec58047c66309d9971adb343f09d5a6fa407
1 // PR c++/101833
2 // { dg-do compile }
3 // { dg-options "-Wall" }
5 struct B { };
7 struct V : virtual B {
8   V(int, const char *, ...) __attribute__((format(printf, 3, 4)));
9 };
11 struct D : B {
12   D(int, const char *, ...) __attribute__((format(printf, 3, 4)));
15 struct D2 : B {
16   template<typename T>
17   D2(T, const char *, ...) __attribute__((format(printf, 3, 4)));
20 struct V2 : virtual B {
21   template<typename T>
22   V2(T, const char *, ...) __attribute__((format(printf, 3, 4)));
25 struct X {
26   template<typename T>
27   X(T, ...) __attribute__((format(printf, 2, 3)));
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);
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" }