xref: /freebsd/contrib/mandoc/test-attribute.c (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1 /* $Id: test-attribute.c,v 1.1 2020/06/22 20:00:38 schwarze Exp $ */
2 /*
3  * Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #include <stdarg.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 
22 void	 var_arg(const char *, ...)
23 		__attribute__((__format__ (__printf__, 1, 2)));
24 void	 no_ret(int)
25 		__attribute__((__noreturn__));
26 
27 void
28 var_arg(const char *fmt, ...)
29 {
30 	va_list	 ap;
31 
32 	va_start(ap, fmt);
33 	vprintf(fmt, ap);
34 	va_end(ap);
35 }
36 
37 void
38 no_ret(int i)
39 {
40 	exit(i);
41 }
42 
43 int
44 main(void)
45 {
46 	var_arg("Test output: %d\n", 42);
47 	no_ret(0);
48 }
49