OSDN Git Service

2007-01-18 Francois-Xavier Coudert <coudert@clipper.ens.fr>
[pf3gnuchains/gcc-fork.git] / libgfortran / runtime / compile_options.c
1 /* Handling of compile-time options that influence the library.
2    Copyright (C) 2005 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
39 /* Prototypes */
40 extern void set_std (GFC_INTEGER_4, GFC_INTEGER_4, GFC_INTEGER_4,
41                      GFC_INTEGER_4);
42 export_proto(set_std);
43
44
45 void
46 set_std (GFC_INTEGER_4 warn_std, GFC_INTEGER_4 allow_std,
47          GFC_INTEGER_4 pedantic, GFC_INTEGER_4 dump_core)
48 {
49   compile_options.pedantic = pedantic;
50   compile_options.warn_std = warn_std;
51   compile_options.allow_std = allow_std;
52   compile_options.dump_core = dump_core;
53 }
54
55
56 /* Default values for the compile-time options.  Keep in sync with
57    gcc/fortran/options.c (gfc_init_options).  */
58 void
59 init_compile_options (void)
60 {
61   compile_options.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
62     | GFC_STD_F2003 | GFC_STD_LEGACY;
63   compile_options.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
64     | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_GNU | GFC_STD_LEGACY;
65   compile_options.pedantic = 0;
66   compile_options.dump_core = 0;
67 }
68
69 /* Function called by the front-end to tell us the
70    default for unformatted data conversion.  */
71
72 extern void set_convert (int);
73 export_proto (set_convert);
74
75 void
76 set_convert (int conv)
77 {
78   compile_options.convert = conv;
79 }
80
81 extern void set_record_marker (int);
82 export_proto (set_record_marker);
83
84
85 void
86 set_record_marker (int val)
87 {
88
89   switch(val)
90     {
91     case 4:
92       compile_options.record_marker = sizeof (GFC_INTEGER_4);
93       break;
94
95     case 8:
96       compile_options.record_marker = sizeof (GFC_INTEGER_8);
97       break;
98
99     default:
100       runtime_error ("Invalid value for record marker");
101       break;
102     }
103 }
104
105 extern void set_max_subrecord_length (int);
106 export_proto (set_max_subrecord_length);
107
108 void set_max_subrecord_length(int val)
109 {
110   if (val > GFC_MAX_SUBRECORD_LENGTH || val < 1)
111     {
112       runtime_error ("Invalid value for maximum subrecord length");
113       return;
114     }
115
116   compile_options.max_subrecord_length = val;
117 }