xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/attr-gnu.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=gnu++11 -fsyntax-only -fms-compatibility -verify %s
2*0a6a1f1dSLionel Sambuc 
f()3*0a6a1f1dSLionel Sambuc void f() {
4*0a6a1f1dSLionel Sambuc   // GNU-style attributes are prohibited in this position.
5*0a6a1f1dSLionel Sambuc   auto P = new int * __attribute__((vector_size(8))); // expected-error {{an attribute list cannot appear here}} \
6*0a6a1f1dSLionel Sambuc                                                       // expected-error {{invalid vector element type 'int *'}}
7*0a6a1f1dSLionel Sambuc 
8*0a6a1f1dSLionel Sambuc   // Ensure that MS type attribute keywords are still supported in this
9*0a6a1f1dSLionel Sambuc   // position.
10*0a6a1f1dSLionel Sambuc   auto P2 = new int * __sptr; // Ok
11*0a6a1f1dSLionel Sambuc }
12*0a6a1f1dSLionel Sambuc 
13*0a6a1f1dSLionel Sambuc void g(int a[static [[]] 5]); // expected-error {{static array size is a C99 feature, not permitted in C++}}
14*0a6a1f1dSLionel Sambuc 
15*0a6a1f1dSLionel Sambuc namespace {
16*0a6a1f1dSLionel Sambuc class B {
17*0a6a1f1dSLionel Sambuc public:
test()18*0a6a1f1dSLionel Sambuc   virtual void test() {}
test2()19*0a6a1f1dSLionel Sambuc   virtual void test2() {}
test3()20*0a6a1f1dSLionel Sambuc   virtual void test3() {}
21*0a6a1f1dSLionel Sambuc };
22*0a6a1f1dSLionel Sambuc 
23*0a6a1f1dSLionel Sambuc class D : public B {
24*0a6a1f1dSLionel Sambuc public:
test()25*0a6a1f1dSLionel Sambuc   void test() __attribute__((deprecated)) final {} // expected-warning {{GCC does not allow an attribute in this position on a function declaration}}
test2()26*0a6a1f1dSLionel Sambuc   void test2() [[]] override {} // Ok
test3()27*0a6a1f1dSLionel Sambuc   void test3() __attribute__((cf_unknown_transfer)) override {} // Ok, not known to GCC.
28*0a6a1f1dSLionel Sambuc };
29*0a6a1f1dSLionel Sambuc }
30