brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 348519d Raw
71 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -Wno-gcc-compat -verify %s2 3// Error cases.4 5[[gnu::this_attribute_does_not_exist]] int unknown_attr;6// expected-warning@-1 {{unknown attribute 'gnu::this_attribute_does_not_exist' ignored}}7int [[gnu::unused]] attr_on_type;8// expected-error@-1 {{'gnu::unused' attribute cannot be applied to types}}9int *[[gnu::unused]] attr_on_ptr;10// expected-warning@-1 {{attribute 'gnu::unused' ignored, because it cannot be applied to a type}}11[[gnu::fastcall]] void pr17424_1();12// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}13[[gnu::fastcall]] [[gnu::stdcall]] void pr17424_2();14// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}15// expected-warning@-2 {{'gnu::stdcall' calling convention is not supported for this target}}16[[gnu::fastcall]] __stdcall void pr17424_3();17// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}18// expected-warning@-2 {{'__stdcall' calling convention is not supported for this target}}19[[gnu::fastcall]] void pr17424_4() [[gnu::stdcall]];20// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}21// expected-warning@-2 {{'gnu::stdcall' calling convention is not supported for this target}}22void pr17424_5 [[gnu::fastcall]]();23// expected-warning@-1 {{'gnu::fastcall' calling convention is not supported for this target}}24 25// Valid cases.26 27void aliasb [[gnu::alias("_Z6alias1v")]] ();28void alias1() {}29void aliasa [[gnu::alias("_Z6alias1v")]] ();30 31extern struct PR22493Ty {32} PR22493 [[gnu::alias("_ZN7pcrecpp2RE6no_argE")]];33 34[[gnu::aligned(8)]] int aligned;35void aligned_fn [[gnu::aligned(32)]] ();36struct [[gnu::aligned(8)]] aligned_struct {};37 38void always_inline [[gnu::always_inline]] ();39 40__thread int tls_model [[gnu::tls_model("local-exec")]];41 42void cleanup(int *p) {43  int n [[gnu::cleanup(cleanup)]];44}45 46void deprecated1 [[gnu::deprecated]] (); // expected-note {{here}}47[[gnu::deprecated("custom message")]] void deprecated2(); // expected-note {{here}}48void deprecated3() {49  deprecated1(); // expected-warning {{deprecated}}50  deprecated2(); // expected-warning {{custom message}}51}52 53[[gnu::naked(1,2,3)]] void naked(); // expected-error {{takes no arguments}}54 55void nonnull [[gnu::nonnull]] (); // expected-warning {{applied to function with no pointer arguments}}56 57// [[gnu::noreturn]] appertains to a declaration, and marks the innermost58// function declarator in that declaration as being noreturn.59int noreturn [[gnu::noreturn]]; // expected-warning {{'noreturn' only applies to function types}}60int noreturn_fn_1();61int noreturn_fn_2() [[gnu::noreturn]]; // expected-warning {{cannot be applied to a type}}62int noreturn_fn_3 [[gnu::noreturn]] ();63[[gnu::noreturn]] int noreturn_fn_4();64int (*noreturn_fn_ptr_1 [[gnu::noreturn]])() = &noreturn_fn_1; // expected-error {{cannot initialize}}65int (*noreturn_fn_ptr_2 [[gnu::noreturn]])() = &noreturn_fn_3;66[[gnu::noreturn]] int (*noreturn_fn_ptr_3)() = &noreturn_fn_1; // expected-error {{cannot initialize}}67[[gnu::noreturn]] int (*noreturn_fn_ptr_4)() = &noreturn_fn_3;68 69struct [[gnu::packed]] packed { char c; int n; };70static_assert(sizeof(packed) == sizeof(char) + sizeof(int), "not packed");71