1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // Error cases. 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc [[gnu::this_attribute_does_not_exist]] int unknown_attr; 6*f4a2713aSLionel Sambuc // expected-warning@-1 {{unknown attribute 'this_attribute_does_not_exist' ignored}} 7*f4a2713aSLionel Sambuc int [[gnu::unused]] attr_on_type; 8*f4a2713aSLionel Sambuc // expected-error@-1 {{'unused' attribute cannot be applied to types}} 9*f4a2713aSLionel Sambuc int *[[gnu::unused]] attr_on_ptr; 10*f4a2713aSLionel Sambuc // expected-warning@-1 {{attribute 'unused' ignored, because it cannot be applied to a type}} 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc // Valid cases. 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc void aliasb [[gnu::alias("_Z6alias1v")]] (); alias1()15*f4a2713aSLionel Sambucvoid alias1() {} 16*f4a2713aSLionel Sambuc void aliasa [[gnu::alias("_Z6alias1v")]] (); 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc [[gnu::aligned(8)]] int aligned; 19*f4a2713aSLionel Sambuc void aligned_fn [[gnu::aligned(32)]] (); 20*f4a2713aSLionel Sambuc struct [[gnu::aligned(8)]] aligned_struct {}; 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc void always_inline [[gnu::always_inline]] (); 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc __thread int tls_model [[gnu::tls_model("local-exec")]]; 25*f4a2713aSLionel Sambuc cleanup(int * p)26*f4a2713aSLionel Sambucvoid cleanup(int *p) { 27*f4a2713aSLionel Sambuc int n [[gnu::cleanup(cleanup)]]; 28*f4a2713aSLionel Sambuc } 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc void deprecated1 [[gnu::deprecated]] (); // expected-note {{here}} 31*f4a2713aSLionel Sambuc [[gnu::deprecated("custom message")]] void deprecated2(); // expected-note {{here}} deprecated3()32*f4a2713aSLionel Sambucvoid deprecated3() { 33*f4a2713aSLionel Sambuc deprecated1(); // expected-warning {{deprecated}} 34*f4a2713aSLionel Sambuc deprecated2(); // expected-warning {{custom message}} 35*f4a2713aSLionel Sambuc } 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc [[gnu::naked(1,2,3)]] void naked(); // expected-error {{takes no arguments}} 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc void nonnull [[gnu::nonnull]] (); // expected-warning {{applied to function with no pointer arguments}} 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuc // [[gnu::noreturn]] appertains to a declaration, and marks the innermost 42*f4a2713aSLionel Sambuc // function declarator in that declaration as being noreturn. 43*f4a2713aSLionel Sambuc int noreturn [[gnu::noreturn]]; // expected-warning {{'noreturn' only applies to function types}} 44*f4a2713aSLionel Sambuc int noreturn_fn_1(); 45*f4a2713aSLionel Sambuc int noreturn_fn_2() [[gnu::noreturn]]; // expected-warning {{cannot be applied to a type}} 46*f4a2713aSLionel Sambuc int noreturn_fn_3 [[gnu::noreturn]] (); 47*f4a2713aSLionel Sambuc [[gnu::noreturn]] int noreturn_fn_4(); 48*f4a2713aSLionel Sambuc int (*noreturn_fn_ptr_1 [[gnu::noreturn]])() = &noreturn_fn_1; // expected-error {{cannot initialize}} 49*f4a2713aSLionel Sambuc int (*noreturn_fn_ptr_2 [[gnu::noreturn]])() = &noreturn_fn_3; 50*f4a2713aSLionel Sambuc [[gnu::noreturn]] int (*noreturn_fn_ptr_3)() = &noreturn_fn_1; // expected-error {{cannot initialize}} 51*f4a2713aSLionel Sambuc [[gnu::noreturn]] int (*noreturn_fn_ptr_4)() = &noreturn_fn_3; 52*f4a2713aSLionel Sambuc 53*f4a2713aSLionel Sambuc struct [[gnu::packed]] packed { char c; int n; }; 54*f4a2713aSLionel Sambuc static_assert(sizeof(packed) == sizeof(char) + sizeof(int), "not packed"); 55