1831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs
2831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith
3831421f24057b93ea28bc92d8bd6290631a43cafRichard Smithint (^block) (int, const char *,...) __attribute__((__format__(__printf__,2,3))) = ^ __attribute__((__format__(__printf__,2,3))) (int arg, const char *format,...) {return 5;};
4831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith
5831421f24057b93ea28bc92d8bd6290631a43cafRichard Smithclass HasNoCStr {
6831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith  const char *str;
7831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith public:
8831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith  HasNoCStr(const char *s): str(s) { }
9831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith  const char *not_c_str() {return str;}
10831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith};
11831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith
12831421f24057b93ea28bc92d8bd6290631a43cafRichard Smithvoid test_block() {
13831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith  const char str[] = "test";
14831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith  HasNoCStr hncs(str);
15831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith  int n = 4;
16831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith  block(n, "%s %d", str, n); // no-warning
17ddcfbc9ad1817f545610999d655ac6c28d4c0c12Jordan Rose  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'}}
18831421f24057b93ea28bc92d8bd6290631a43cafRichard Smith}
19