1 /* $NetBSD: gcc_attribute_func.c,v 1.3 2022/06/11 11:52:13 rillig Exp $ */ 2 # 3 "gcc_attribute_func.c" 3 4 /* 5 * Tests for the GCC __attribute__ for functions. 6 * 7 * https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html 8 */ 9 10 void deprecated_function(void) 11 __attribute__((__noreturn__)) 12 __attribute__((__aligned__(8), __cold__)) 13 __attribute__((__deprecated__("do not use while driving"))); 14 15 __attribute__((__cold__)) 16 void attribute_as_prefix(void); 17 18 void __attribute__((__cold__)) attribute_after_type_spec(void); 19 void *__attribute__((__cold__)) attribute_before_name(void); 20 /*TODO: do not allow __attribute__ after function name */ 21 void *attribute_after_name __attribute__((__cold__))(void); 22 void *attribute_after_parameters(void) __attribute__((__cold__)); 23 24 /* 25 * The attribute 'used' does not influence static functions, it only 26 * applies to function parameters. 27 */ 28 /* expect+2: warning: static function 'used_function' unused [236] */ 29 static void __attribute__((used)) 30 used_function(void) 31 { 32 } 33 34 /* expect+2: warning: static function 'unused_function' unused [236] */ 35 static void 36 unused_function(void) 37 { 38 } 39