xref: /netbsd-src/tests/usr.bin/xlint/lint1/gcc_attribute_func.c (revision b2baa50111d645353fa30b4deab0f79d93650c8c)
1 /*	$NetBSD: gcc_attribute_func.c,v 1.4 2023/03/28 14:44:34 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 /*
27  * The attribute 'used' does not influence static functions, it only
28  * applies to function parameters.
29  */
30 /* expect+2: warning: static function 'used_function' unused [236] */
31 static void __attribute__((used))
32 used_function(void)
33 {
34 }
35 
36 /* expect+2: warning: static function 'unused_function' unused [236] */
37 static void
38 unused_function(void)
39 {
40 }
41