blob: 33e8d40076dc0b1a3fd83bfca3d152b495c6d0f4 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001//RUN: %clang_cc1 -fsyntax-only -verify %s
Ryan Flynn4403a5e2009-08-06 03:00:50 +00002
3#include <stdarg.h>
4
5// same as format(printf(...))...
6void a2(const char *a, ...) __attribute__((format(printf0, 1,2))); // no-error
7void b2(const char *a, ...) __attribute__((format(printf0, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
8void c2(const char *a, ...) __attribute__((format(printf0, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
9void d2(const char *a, int c) __attribute__((format(printf0, 1,2))); // expected-error {{format attribute requires variadic function}}
10void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expected-error {{format argument not a string type}}
11
12// FreeBSD usage
13#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
14void null(int i, const char *a, ...) __printf0like(2,0); // no-error
15void null(int i, const char *a, ...) {
16 if (a)
17 (void)0/* vprintf(...) would go here */;
18}
19
20void callnull(void){
21 null(0, 0); // no error
22 null(0, (char*)0); // no error
23 null(0, (void*)0); // no error
24 null(0, (int*)0); // expected-warning {{incompatible pointer types}}
25}
26