OSDN Git Service

2007-07-24 Thomas Koenig <tkoenig@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / libgfortran / runtime / compile_options.c
1 /* Handling of compile-time options that influence the library.
2    Copyright (C) 2005, 2007 Free Software Foundation, Inc.
3
4 This file is part of the GNU Fortran 95 runtime library (libgfortran).
5
6 Libgfortran is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file.  (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
18 executable.)
19
20 Libgfortran is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with libgfortran; see the file COPYING.  If not, write to
27 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
28 Boston, MA 02110-1301, USA.  */
29
30 #include "config.h"
31
32 #include "libgfortran.h"
33
34
35 /* Useful compile-time options will be stored in here.  */
36 compile_options_t compile_options;
37
38 /* Set the usual compile-time options.  */
39 extern void set_options (int , int []);
40 export_proto(set_options);
41
42 void
43 set_options (int num, int options[])
44 {
45   if (num >= 1)
46     compile_options.warn_std = options[0];
47   if (num >= 2)
48     compile_options.allow_std = options[1];
49   if (num >= 3)
50     compile_options.pedantic = options[2];
51   if (num >= 4)
52     compile_options.dump_core = options[3];
53   if (num >= 5)
54     compile_options.backtrace = options[4];
55   if (num >= 6)
56     compile_options.sign_zero = options[5];
57   if (num >= 7)
58     compile_options.bounds_check = options[6];
59 }
60
61
62 /* Default values for the compile-time options.  Keep in sync with
63    gcc/fortran/options.c (gfc_init_options).  */
64 void
65 init_compile_options (void)
66 {
67   compile_options.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
68     | GFC_STD_F2003 | GFC_STD_LEGACY;
69   compile_options.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
70     | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU | GFC_STD_LEGACY;
71   compile_options.pedantic = 0;
72   compile_options.dump_core = 0;
73   compile_options.backtrace = 0;
74   compile_options.sign_zero = 1;
75 }
76
77 /* Function called by the front-end to tell us the
78    default for unformatted data conversion.  */
79
80 extern void set_convert (int);
81 export_proto (set_convert);
82
83 void
84 set_convert (int conv)
85 {
86   compile_options.convert = conv;
87 }
88
89 extern void set_record_marker (int);
90 export_proto (set_record_marker);
91
92
93 void
94 set_record_marker (int val)
95 {
96
97   switch(val)
98     {
99     case 4:
100       compile_options.record_marker = sizeof (GFC_INTEGER_4);
101       break;
102
103     case 8:
104       compile_options.record_marker = sizeof (GFC_INTEGER_8);
105       break;
106
107     default:
108       runtime_error ("Invalid value for record marker");
109       break;
110     }
111 }
112
113 extern void set_max_subrecord_length (int);
114 export_proto (set_max_subrecord_length);
115
116 void set_max_subrecord_length(int val)
117 {
118   if (val > GFC_MAX_SUBRECORD_LENGTH || val < 1)
119     {
120       runtime_error ("Invalid value for maximum subrecord length");
121       return;
122     }
123
124   compile_options.max_subrecord_length = val;
125 }