xref: /aosp_15_r20/external/clang/test/Parser/cxx-attributes.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li class c {
4*67e74705SXin Li   virtual void f1(const char* a, ...)
5*67e74705SXin Li     __attribute__ (( __format__(__printf__,2,3) )) = 0;
f2(const char * a,...)6*67e74705SXin Li   virtual void f2(const char* a, ...)
7*67e74705SXin Li     __attribute__ (( __format__(__printf__,2,3) )) {}
8*67e74705SXin Li };
9*67e74705SXin Li 
10*67e74705SXin Li template <typename T> class X {
11*67e74705SXin Li   template <typename S> void X<S>::f() __attribute__((locks_excluded())); // expected-error{{nested name specifier 'X<S>::' for declaration does not refer into a class, class template or class template partial specialization}} \
12*67e74705SXin Li                                                                           // expected-warning{{attribute locks_excluded ignored, because it is not attached to a declaration}}
13*67e74705SXin Li };
14*67e74705SXin Li 
15*67e74705SXin Li namespace PR17666 {
16*67e74705SXin Li   const int A = 1;
17*67e74705SXin Li   typedef int __attribute__((__aligned__(A))) T1;
18*67e74705SXin Li   int check1[__alignof__(T1) == 1 ? 1 : -1];
19*67e74705SXin Li 
20*67e74705SXin Li   typedef int __attribute__((aligned(int(1)))) T1;
21*67e74705SXin Li   typedef int __attribute__((aligned(int))) T2; // expected-error {{expected '(' for function-style cast}}
22*67e74705SXin Li }
23*67e74705SXin Li 
24*67e74705SXin Li __attribute((typename)) int x; // expected-warning {{unknown attribute 'typename' ignored}}
25