annotate libgfortran/runtime/main.c @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1 /* Copyright (C) 2002-2018 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
2 Contributed by Andy Vaught and Paul Brook <paul@nowt.org>
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of the GNU Fortran runtime library (libgfortran).
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 Libgfortran is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
8 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
9 any later version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 Libgfortran is distributed in the hope that it will be useful,
kono
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
14 GNU General Public License for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
17 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
18 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
21 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
23 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 #include "libgfortran.h"
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 /* Stupid function to be sure the constructor is always linked in, even
kono
parents:
diff changeset
29 in the case of static linking. See PR libfortran/22298 for details. */
kono
parents:
diff changeset
30 void
kono
parents:
diff changeset
31 stupid_function_name_for_static_linking (void)
kono
parents:
diff changeset
32 {
kono
parents:
diff changeset
33 return;
kono
parents:
diff changeset
34 }
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 static int argc_save;
kono
parents:
diff changeset
38 static char **argv_save;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 /* Set the saved values of the command line arguments. */
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 void
kono
parents:
diff changeset
44 set_args (int argc, char **argv)
kono
parents:
diff changeset
45 {
kono
parents:
diff changeset
46 argc_save = argc;
kono
parents:
diff changeset
47 argv_save = argv;
kono
parents:
diff changeset
48 }
kono
parents:
diff changeset
49 iexport(set_args);
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* Retrieve the saved values of the command line arguments. */
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 void
kono
parents:
diff changeset
55 get_args (int *argc, char ***argv)
kono
parents:
diff changeset
56 {
kono
parents:
diff changeset
57 *argc = argc_save;
kono
parents:
diff changeset
58 *argv = argv_save;
kono
parents:
diff changeset
59 }
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 /* Initialize the runtime library. */
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 static void __attribute__((constructor))
kono
parents:
diff changeset
65 init (void)
kono
parents:
diff changeset
66 {
kono
parents:
diff changeset
67 /* Must be first */
kono
parents:
diff changeset
68 init_variables ();
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 init_units ();
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* If (and only if) the user asked for it, set up the FPU state. */
kono
parents:
diff changeset
73 if (options.fpe != 0)
kono
parents:
diff changeset
74 set_fpu ();
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 init_compile_options ();
kono
parents:
diff changeset
77 }
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 /* Cleanup the runtime library. */
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 static void __attribute__((destructor))
kono
parents:
diff changeset
83 cleanup (void)
kono
parents:
diff changeset
84 {
kono
parents:
diff changeset
85 close_units ();
kono
parents:
diff changeset
86 }