OSDN Git Service

* boehm.cc: Don't include boehm-config.h.
[pf3gnuchains/gcc-fork.git] / gcc / c-lang.c
1 /* Language-specific hook definitions for C front end.
2    Copyright (C) 1991, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC 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 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21
22 #include "config.h"
23 #include "system.h"
24 #include "tree.h"
25 #include "function.h"
26 #include "input.h"
27 #include "c-tree.h"
28 #include "c-lex.h"
29 #include "toplev.h"
30 #include "output.h"
31 #include "flags.h"
32 #include "ggc.h"
33
34 #if USE_CPPLIB
35 #include "cpplib.h"
36 extern char *yy_cur;
37 extern cpp_reader  parse_in;
38 extern cpp_options parse_options;
39 #endif
40
41 /* Each of the functions defined here
42    is an alternative to a function in objc-actions.c.  */
43    
44 int
45 lang_decode_option (argc, argv)
46      int argc;
47      char **argv;
48 {
49   return c_decode_option (argc, argv);
50 }
51
52 void
53 lang_init_options ()
54 {
55 #if USE_CPPLIB
56   cpp_reader_init (&parse_in);
57   parse_in.opts = &parse_options;
58   cpp_options_init (&parse_options);
59 #endif
60   /* Mark as "unspecified".  */
61   flag_bounds_check = -1;
62 }
63
64 void
65 lang_init ()
66 {
67   /* If still "unspecified", make it match -fbounded-pointers.  */
68   if (flag_bounds_check < 0)
69     flag_bounds_check = flag_bounded_pointers;
70
71   /* the beginning of the file is a new line; check for # */
72   /* With luck, we discover the real source file's name from that
73      and put it in input_filename.  */
74 #if !USE_CPPLIB
75   ungetc (check_newline (), finput);
76 #else
77   check_newline ();
78   yy_cur--;
79 #endif 
80
81   save_lang_status = &push_c_function_context;
82   restore_lang_status = &pop_c_function_context;
83   mark_lang_status = &mark_c_function_context;
84
85   c_parse_init ();
86 }
87
88 void
89 lang_finish ()
90 {
91 }
92
93 const char *
94 lang_identify ()
95 {
96   return "c";
97 }
98
99 void
100 print_lang_statistics ()
101 {
102 }
103
104 /* used by print-tree.c */
105
106 void
107 lang_print_xnode (file, node, indent)
108      FILE *file ATTRIBUTE_UNUSED;
109      tree node ATTRIBUTE_UNUSED;
110      int indent ATTRIBUTE_UNUSED;
111 {
112 }
113
114 /* Used by c-lex.c, but only for objc.  */
115
116 tree
117 lookup_interface (arg)
118      tree arg ATTRIBUTE_UNUSED;
119 {
120   return 0;
121 }
122
123 tree
124 is_class_name (arg)
125     tree arg ATTRIBUTE_UNUSED;
126 {
127   return 0;
128 }
129
130 void
131 maybe_objc_check_decl (decl)
132      tree decl ATTRIBUTE_UNUSED;
133 {
134 }
135
136 int
137 maybe_objc_comptypes (lhs, rhs, reflexive)
138      tree lhs ATTRIBUTE_UNUSED;
139      tree rhs ATTRIBUTE_UNUSED;
140      int reflexive ATTRIBUTE_UNUSED;
141 {
142   return -1;
143 }
144
145 tree
146 maybe_objc_method_name (decl)
147     tree decl ATTRIBUTE_UNUSED;
148 {
149   return 0;
150 }
151
152 tree
153 maybe_building_objc_message_expr ()
154 {
155   return 0;
156 }
157
158 int
159 recognize_objc_keyword ()
160 {
161   return 0;
162 }
163
164 tree
165 build_objc_string (len, str)
166     int len ATTRIBUTE_UNUSED;
167     const char *str ATTRIBUTE_UNUSED;
168 {
169   abort ();
170   return NULL_TREE;
171 }
172
173 /* Called at end of parsing, but before end-of-file processing.  */
174
175 void
176 finish_file ()
177 {
178 #ifndef ASM_OUTPUT_CONSTRUCTOR
179   extern tree static_ctors;
180 #endif
181 #ifndef ASM_OUTPUT_DESTRUCTOR
182   extern tree static_dtors;
183 #endif
184   extern tree build_function_call                 PROTO((tree, tree));
185 #if !defined(ASM_OUTPUT_CONSTRUCTOR) || !defined(ASM_OUTPUT_DESTRUCTOR)
186   tree void_list_node_1 = build_tree_list (NULL_TREE, void_type_node);
187 #endif
188 #ifndef ASM_OUTPUT_CONSTRUCTOR
189   if (static_ctors)
190     {
191       tree fnname = get_file_function_name ('I');
192       start_function (void_list_node_1,
193                       build_parse_node (CALL_EXPR, fnname, 
194                                         tree_cons (NULL_TREE, NULL_TREE, 
195                                                    void_list_node_1),
196                                         NULL_TREE),
197                       NULL_TREE, NULL_TREE, 0);
198       fnname = DECL_ASSEMBLER_NAME (current_function_decl);
199       store_parm_decls ();
200
201       for (; static_ctors; static_ctors = TREE_CHAIN (static_ctors))
202         expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors),
203                                                NULL_TREE));
204
205       finish_function (0);
206
207       assemble_constructor (IDENTIFIER_POINTER (fnname));
208     }
209 #endif
210 #ifndef ASM_OUTPUT_DESTRUCTOR
211   if (static_dtors)
212     {
213       tree fnname = get_file_function_name ('D');
214       start_function (void_list_node_1,
215                       build_parse_node (CALL_EXPR, fnname, 
216                                         tree_cons (NULL_TREE, NULL_TREE,
217                                                    void_list_node_1),
218                                         NULL_TREE),
219                       NULL_TREE, NULL_TREE, 0);
220       fnname = DECL_ASSEMBLER_NAME (current_function_decl);
221       store_parm_decls ();
222
223       for (; static_dtors; static_dtors = TREE_CHAIN (static_dtors))
224         expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors),
225                                                NULL_TREE));
226
227       finish_function (0);
228
229       assemble_destructor (IDENTIFIER_POINTER (fnname));
230     }
231 #endif
232 }