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