blob: 66304796127f47b44b56dc7009f5809941a1c233 [file] [log] [blame]
Fariborz Jahanian236673e2009-05-14 18:00:00 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3#define NULL (void*)0
4
5#define ATTR __attribute__ ((__sentinel__))
6
7void foo1 (int x, ...) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
8void foo5 (int x, ...) __attribute__ ((__sentinel__(1))); // expected-note {{function has been explicitly marked sentinel here}}
9void foo6 (int x, ...) __attribute__ ((__sentinel__(5))); // expected-note {{function has been explicitly marked sentinel here}}
10void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{function has been explicitly marked sentinel here}}
11void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1)));
12void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
13
14int main ()
15{
16
17 foo1(1, NULL); // OK
18 foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
19 foo5(1, NULL, 2); // OK
20 foo5(1,2,NULL, 1); // OK
21 foo5(1, NULL, 2, 1); // expected-warning {{missing sentinel in function call}}
22
23 foo6(1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
24 foo6(1,NULL,3,4,5,6,7); // OK
25 foo7(1); // expected-warning {{not enough variable arguments in 'foo7' declaration to fit a sentinel}}
26 foo7(1, NULL); // OK
27
28 foo12(1); // expected-warning {{not enough variable arguments in 'foo12' declaration to fit a sentinel}}
29}
30