gcc_attribute_func.c revision 1.4
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
12void deprecated_function(void)
13    __attribute__((__noreturn__))
14    __attribute__((__aligned__(8), __cold__))
15    __attribute__((__deprecated__("do not use while driving")));
16
17__attribute__((__cold__))
18void attribute_as_prefix(void);
19
20void __attribute__((__cold__)) attribute_after_type_spec(void);
21void *__attribute__((__cold__)) attribute_before_name(void);
22/*TODO: do not allow __attribute__ after function name */
23void *attribute_after_name __attribute__((__cold__))(void);
24void *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] */
31static void __attribute__((used))
32used_function(void)
33{
34}
35
36/* expect+2: warning: static function 'unused_function' unused [236] */
37static void
38unused_function(void)
39{
40}
41