xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/attr-sentinel.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc void f(int, ...) __attribute__((sentinel));
4*f4a2713aSLionel Sambuc 
g()5*f4a2713aSLionel Sambuc void g() {
6*f4a2713aSLionel Sambuc   f(1, 2, __null);
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc typedef __typeof__(sizeof(int)) size_t;
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc struct S {
12*f4a2713aSLionel Sambuc   S(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
13*f4a2713aSLionel Sambuc   void a(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
14*f4a2713aSLionel Sambuc   void* operator new(size_t,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
15*f4a2713aSLionel Sambuc   void operator()(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
16*f4a2713aSLionel Sambuc };
17*f4a2713aSLionel Sambuc 
class_test()18*f4a2713aSLionel Sambuc void class_test() {
19*f4a2713aSLionel Sambuc   S s(1,2,3); // expected-warning {{missing sentinel in function call}}
20*f4a2713aSLionel Sambuc   S* s2 = new (1,2,3) S(1, __null); // expected-warning {{missing sentinel in function call}}
21*f4a2713aSLionel Sambuc   s2->a(1,2,3); // expected-warning {{missing sentinel in function call}}
22*f4a2713aSLionel Sambuc   s(1,2,3); // expected-warning {{missing sentinel in function call}}
23*f4a2713aSLionel Sambuc }
24