1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c2x %s 2 3 struct S {}; 4 struct S * [[clang::address_space(1)]] Foo; 5 6 enum [[clang::enum_extensibility(open)]] EnumOpen { 7 C0 = 1, C1 = 10 8 }; 9 10 enum [[clang::flag_enum]] EnumFlag { 11 D0 = 1, D1 = 8 12 }; 13 14 void foo(void *c) [[clang::overloadable]]; 15 void foo(char *c) [[clang::overloadable]]; 16 17 void context_okay(void *context [[clang::swift_context]]) [[clang::swiftcall]]; 18 void context_okay2(void *context [[clang::swift_context]], void *selfType, char **selfWitnessTable) [[clang::swiftcall]]; 19 20 void *f1(void) [[clang::ownership_returns(foo)]]; 21 void *f2() [[clang::ownership_returns(foo)]]; // expected-warning {{'ownership_returns' attribute only applies to non-K&R-style functions}} 22 23 void foo2(void) [[clang::unavailable("not available - replaced")]]; // expected-note {{'foo2' has been explicitly marked unavailable here}} bar(void)24void bar(void) { 25 foo2(); // expected-error {{'foo2' is unavailable: not available - replaced}} 26 } 27 28 [[nodiscard]] int without_underscores(void); 29 [[__nodiscard__]] int underscores(void); 30 31 // Match GCC's behavior for C attributes as well. 32 [[gnu::constructor]] void ctor_func(void); 33 [[gnu::destructor]] void dtor_func(void); 34 [[gnu::hot]] void hot_func(void); 35 [[__gnu__::hot]] void hot_func2(void); 36 [[gnu::__hot__]] void hot_func3(void); 37 [[__gnu__::__hot__]] void hot_func4(void); 38 39 // Note how not all GCC attributes are supported in C. 40 [[gnu::abi_tag("")]] void abi_func(void); // expected-warning {{unknown attribute 'abi_tag' ignored}} 41 struct S s [[gnu::init_priority(1)]]; // expected-warning {{unknown attribute 'init_priority' ignored}} 42