Richard Smith | 831421f | 2012-06-25 20:30:08 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs |
| 2 | |
| 3 | int (^block) (int, const char *,...) __attribute__((__format__(__printf__,2,3))) = ^ __attribute__((__format__(__printf__,2,3))) (int arg, const char *format,...) {return 5;}; |
| 4 | |
| 5 | class HasNoCStr { |
| 6 | const char *str; |
| 7 | public: |
| 8 | HasNoCStr(const char *s): str(s) { } |
| 9 | const char *not_c_str() {return str;} |
| 10 | }; |
| 11 | |
| 12 | void test_block() { |
| 13 | const char str[] = "test"; |
| 14 | HasNoCStr hncs(str); |
| 15 | int n = 4; |
| 16 | block(n, "%s %d", str, n); // no-warning |
Jordan Rose | ddcfbc9 | 2012-07-19 18:10:23 +0000 | [diff] [blame] | 17 | block(n, "%s %s", hncs, n); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic block; expected type from format string was 'char *'}} expected-warning{{format specifies type 'char *' but the argument has type 'int'}} |
Richard Smith | 831421f | 2012-06-25 20:30:08 +0000 | [diff] [blame] | 18 | } |