diff options
author | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 554bcb69c2d785a011a30e7db87a36a87fe7db10 (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /test/SemaCXX/printf-block.cpp | |
parent | bb67ca86b31f67faee50bd10c3b036d65751745a (diff) | |
download | FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.zip FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.tar.gz |
Vendor import of clang trunk r161861:
http://llvm.org/svn/llvm-project/cfe/trunk@161861
Diffstat (limited to 'test/SemaCXX/printf-block.cpp')
-rw-r--r-- | test/SemaCXX/printf-block.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/SemaCXX/printf-block.cpp b/test/SemaCXX/printf-block.cpp new file mode 100644 index 0000000..4a58003 --- /dev/null +++ b/test/SemaCXX/printf-block.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs + +int (^block) (int, const char *,...) __attribute__((__format__(__printf__,2,3))) = ^ __attribute__((__format__(__printf__,2,3))) (int arg, const char *format,...) {return 5;}; + +class HasNoCStr { + const char *str; + public: + HasNoCStr(const char *s): str(s) { } + const char *not_c_str() {return str;} +}; + +void test_block() { + const char str[] = "test"; + HasNoCStr hncs(str); + int n = 4; + block(n, "%s %d", str, n); // no-warning + 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'}} +} |