xref: /netbsd-src/tests/usr.bin/xlint/lint1/gcc_attribute_func.c (revision 681e50705c1ffccd4b0ce0d827fa60e0f78a9a9b)
1 /*	$NetBSD: gcc_attribute_func.c,v 1.5 2024/11/13 03:43:00 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 /* lint1-extra-flags: -X 351 */
11 
12 void deprecated_function(void)
13     __attribute__((__noreturn__))
14     __attribute__((__aligned__(8), __cold__))
15     __attribute__((__deprecated__("do not use while driving")));
16 
17 __attribute__((__cold__))
18 void attribute_as_prefix(void);
19 
20 void __attribute__((__cold__)) attribute_after_type_spec(void);
21 void *__attribute__((__cold__)) attribute_before_name(void);
22 /*TODO: do not allow __attribute__ after function name */
23 void *attribute_after_name __attribute__((__cold__))(void);
24 void *attribute_after_parameters(void) __attribute__((__cold__));
25 
26 static void __attribute__((used))
27 used_function(void)
28 {
29 }
30 
31 /* expect+2: warning: static function 'unused_function' unused [236] */
32 static void
33 unused_function(void)
34 {
35 }
36