annotate tests/test-noreturn.c @ 40186:8964917f9574

autoupdate
author Karl Berry <karl@freefriends.org>
date Mon, 18 Feb 2019 08:02:49 -0800
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18822
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of macros for declaring functions as non-returning.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2017-2019 Free Software Foundation, Inc.
18822
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18822
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18822
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2017. */
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <noreturn.h>
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 /* Test _GL_NORETURN_FUNC on function declarations. */
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 _GL_NORETURN_FUNC extern void func1 (void);
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 extern _GL_NORETURN_FUNC void func2 (void);
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 extern void _GL_NORETURN_FUNC func3 (void);
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 /* Test _GL_NORETURN_FUNC on function definitions. */
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 _GL_NORETURN_FUNC void funcd (void)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 {
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 for (;;)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 ;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 }
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 /* Test _GL_NORETURN_FUNCPTR. */
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 _GL_NORETURN_FUNCPTR void (*func1_ptr) (void) = func1;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 _GL_NORETURN_FUNCPTR void (*func2_ptr) (void) = func2;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 _GL_NORETURN_FUNCPTR void (*func3_ptr) (void) = func3;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 _GL_NORETURN_FUNCPTR void (*funcd_ptr) (void) = funcd;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 /* These could also be defined in a separate compilation unit. */
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 void func1 (void)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 {
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 for (;;)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 ;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 }
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 void func2 (void)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 {
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 for (;;)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 ;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 }
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 void func3 (void)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 {
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 for (;;)
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 ;
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 }
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 int
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 main ()
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 {
31d2a7e57ad6 noreturn: New module.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 }