2018-05-03 23:33:50 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -Wno-gcc-compat -verify %s
|
2013-01-14 16:57:42 +08:00
|
|
|
|
|
|
|
// Error cases.
|
|
|
|
|
|
|
|
[[gnu::this_attribute_does_not_exist]] int unknown_attr;
|
|
|
|
// expected-warning@-1 {{unknown attribute 'this_attribute_does_not_exist' ignored}}
|
|
|
|
int [[gnu::unused]] attr_on_type;
|
2013-01-29 18:02:16 +08:00
|
|
|
// expected-error@-1 {{'unused' attribute cannot be applied to types}}
|
2013-01-14 16:57:42 +08:00
|
|
|
int *[[gnu::unused]] attr_on_ptr;
|
|
|
|
// expected-warning@-1 {{attribute 'unused' ignored, because it cannot be applied to a type}}
|
2015-05-29 19:24:32 +08:00
|
|
|
[[gnu::fastcall]] void pr17424_1();
|
2019-03-21 21:30:56 +08:00
|
|
|
// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
|
2015-05-29 19:24:32 +08:00
|
|
|
[[gnu::fastcall]] [[gnu::stdcall]] void pr17424_2();
|
2019-03-21 21:30:56 +08:00
|
|
|
// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
|
|
|
|
// expected-warning@-2 {{'stdcall' calling convention ignored for this target}}
|
2015-05-29 19:24:32 +08:00
|
|
|
[[gnu::fastcall]] __stdcall void pr17424_3();
|
2019-03-21 21:30:56 +08:00
|
|
|
// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
|
|
|
|
// expected-warning@-2 {{'__stdcall' calling convention ignored for this target}}
|
2015-05-29 19:24:32 +08:00
|
|
|
[[gnu::fastcall]] void pr17424_4() [[gnu::stdcall]];
|
2019-03-21 21:30:56 +08:00
|
|
|
// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
|
|
|
|
// expected-warning@-2 {{'stdcall' calling convention ignored for this target}}
|
2015-05-29 19:24:32 +08:00
|
|
|
void pr17424_5 [[gnu::fastcall]]();
|
2019-03-21 21:30:56 +08:00
|
|
|
// expected-warning@-1 {{'fastcall' calling convention ignored for this target}}
|
2013-01-14 16:57:42 +08:00
|
|
|
|
|
|
|
// Valid cases.
|
|
|
|
|
2013-10-22 02:24:30 +08:00
|
|
|
void aliasb [[gnu::alias("_Z6alias1v")]] ();
|
2013-01-14 16:57:42 +08:00
|
|
|
void alias1() {}
|
2013-10-22 02:24:30 +08:00
|
|
|
void aliasa [[gnu::alias("_Z6alias1v")]] ();
|
2013-01-14 16:57:42 +08:00
|
|
|
|
2015-02-08 18:55:14 +08:00
|
|
|
extern struct PR22493Ty {
|
|
|
|
} PR22493 [[gnu::alias("_ZN7pcrecpp2RE6no_argE")]];
|
|
|
|
|
2013-01-14 16:57:42 +08:00
|
|
|
[[gnu::aligned(8)]] int aligned;
|
|
|
|
void aligned_fn [[gnu::aligned(32)]] ();
|
|
|
|
struct [[gnu::aligned(8)]] aligned_struct {};
|
|
|
|
|
|
|
|
void always_inline [[gnu::always_inline]] ();
|
|
|
|
|
|
|
|
__thread int tls_model [[gnu::tls_model("local-exec")]];
|
|
|
|
|
|
|
|
void cleanup(int *p) {
|
|
|
|
int n [[gnu::cleanup(cleanup)]];
|
|
|
|
}
|
|
|
|
|
|
|
|
void deprecated1 [[gnu::deprecated]] (); // expected-note {{here}}
|
|
|
|
[[gnu::deprecated("custom message")]] void deprecated2(); // expected-note {{here}}
|
|
|
|
void deprecated3() {
|
|
|
|
deprecated1(); // expected-warning {{deprecated}}
|
|
|
|
deprecated2(); // expected-warning {{custom message}}
|
|
|
|
}
|
|
|
|
|
|
|
|
[[gnu::naked(1,2,3)]] void naked(); // expected-error {{takes no arguments}}
|
|
|
|
|
|
|
|
void nonnull [[gnu::nonnull]] (); // expected-warning {{applied to function with no pointer arguments}}
|
|
|
|
|
2013-01-15 10:48:13 +08:00
|
|
|
// [[gnu::noreturn]] appertains to a declaration, and marks the innermost
|
|
|
|
// function declarator in that declaration as being noreturn.
|
2013-01-14 16:57:42 +08:00
|
|
|
int noreturn [[gnu::noreturn]]; // expected-warning {{'noreturn' only applies to function types}}
|
2013-01-15 10:48:13 +08:00
|
|
|
int noreturn_fn_1();
|
|
|
|
int noreturn_fn_2() [[gnu::noreturn]]; // expected-warning {{cannot be applied to a type}}
|
|
|
|
int noreturn_fn_3 [[gnu::noreturn]] ();
|
|
|
|
[[gnu::noreturn]] int noreturn_fn_4();
|
|
|
|
int (*noreturn_fn_ptr_1 [[gnu::noreturn]])() = &noreturn_fn_1; // expected-error {{cannot initialize}}
|
|
|
|
int (*noreturn_fn_ptr_2 [[gnu::noreturn]])() = &noreturn_fn_3;
|
|
|
|
[[gnu::noreturn]] int (*noreturn_fn_ptr_3)() = &noreturn_fn_1; // expected-error {{cannot initialize}}
|
|
|
|
[[gnu::noreturn]] int (*noreturn_fn_ptr_4)() = &noreturn_fn_3;
|
2013-01-14 16:57:42 +08:00
|
|
|
|
|
|
|
struct [[gnu::packed]] packed { char c; int n; };
|
|
|
|
static_assert(sizeof(packed) == sizeof(char) + sizeof(int), "not packed");
|