comparison gcc/testsuite/g++.dg/warn/Wformat-method.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 // { dg-options "-Wformat -fdiagnostics-show-caret" }
2
3 class logger
4 {
5 public:
6 void log (const char *fmt, ...) __attribute__((format (printf, 2, 3)));
7 };
8
9 void test ()
10 {
11 logger out;
12 out.log ("before %s after", 42); // { dg-warning "argument 3 has type 'int'" }
13 /* { dg-begin-multiline-output "" }
14 out.log ("before %s after", 42);
15 ~^ ~~
16 | |
17 char* int
18 %d
19 { dg-end-multiline-output "" } */
20 }
21
22 template <typename T>
23 class logger_2
24 {
25 public:
26 void log (const char *fmt, ...) __attribute__((format (printf, 2, 3)));
27 };
28
29 void test_2 ()
30 {
31 logger_2<int> out;
32 out.log ("before %s after", 42); // { dg-warning "argument 3 has type 'int'" }
33 /* { dg-begin-multiline-output "" }
34 out.log ("before %s after", 42);
35 ~^ ~~
36 | |
37 char* int
38 %d
39 { dg-end-multiline-output "" } */
40 }