Integrated preprocessor.
[official-gcc.git] / gcc / c-lang.c
blobf8dd30b8f4398d04b40afce77b822bf7fcd111ad
1 /* Language-specific hook definitions for C front end.
2 Copyright (C) 1991, 1995, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "config.h"
24 #include "system.h"
25 #include "tree.h"
26 #include "function.h"
27 #include "input.h"
28 #include "c-tree.h"
29 #include "c-lex.h"
30 #include "toplev.h"
31 #include "diagnostic.h"
32 #include "output.h"
33 #include "flags.h"
34 #include "ggc.h"
36 static int c_tree_printer PARAMS ((output_buffer *));
38 #if USE_CPPLIB
39 #include "cpplib.h"
40 extern cpp_reader parse_in;
41 #endif
43 /* Each of the functions defined here
44 is an alternative to a function in objc-actions.c. */
46 int
47 lang_decode_option (argc, argv)
48 int argc;
49 char **argv;
51 return c_decode_option (argc, argv);
54 void
55 lang_init_options ()
57 #if USE_CPPLIB
58 cpp_init ();
59 cpp_reader_init (&parse_in);
60 #endif
61 /* Mark as "unspecified". */
62 flag_bounds_check = -1;
65 void
66 lang_init ()
68 /* If still "unspecified", make it match -fbounded-pointers. */
69 if (flag_bounds_check < 0)
70 flag_bounds_check = flag_bounded_pointers;
72 /* If still unspecified, make it match pedantic && -std=c99. */
73 if (mesg_implicit_function_declaration < 0)
75 if (pedantic && flag_isoc99)
76 mesg_implicit_function_declaration = flag_pedantic_errors ? 2 : 1;
77 else
78 mesg_implicit_function_declaration = 0;
81 /* the beginning of the file is a new line; check for # */
82 /* With luck, we discover the real source file's name from that
83 and put it in input_filename. */
84 #if !USE_CPPLIB
85 ungetc (check_newline (), finput);
86 #endif
88 save_lang_status = &push_c_function_context;
89 restore_lang_status = &pop_c_function_context;
90 mark_lang_status = &mark_c_function_context;
92 lang_printer = c_tree_printer;
94 c_parse_init ();
97 void
98 lang_finish ()
102 const char *
103 lang_identify ()
105 return "c";
108 void
109 print_lang_statistics ()
113 /* used by print-tree.c */
115 void
116 lang_print_xnode (file, node, indent)
117 FILE *file ATTRIBUTE_UNUSED;
118 tree node ATTRIBUTE_UNUSED;
119 int indent ATTRIBUTE_UNUSED;
123 /* Used by c-lex.c, but only for objc. */
125 tree
126 lookup_interface (arg)
127 tree arg ATTRIBUTE_UNUSED;
129 return 0;
132 tree
133 is_class_name (arg)
134 tree arg ATTRIBUTE_UNUSED;
136 return 0;
139 void
140 maybe_objc_check_decl (decl)
141 tree decl ATTRIBUTE_UNUSED;
146 maybe_objc_comptypes (lhs, rhs, reflexive)
147 tree lhs ATTRIBUTE_UNUSED;
148 tree rhs ATTRIBUTE_UNUSED;
149 int reflexive ATTRIBUTE_UNUSED;
151 return -1;
154 tree
155 maybe_objc_method_name (decl)
156 tree decl ATTRIBUTE_UNUSED;
158 return 0;
161 tree
162 maybe_building_objc_message_expr ()
164 return 0;
168 recognize_objc_keyword ()
170 return 0;
173 /* Used by c-typeck.c (build_external_ref), but only for objc. */
175 tree
176 lookup_objc_ivar (id)
177 tree id ATTRIBUTE_UNUSED;
179 return 0;
182 /* Called at end of parsing, but before end-of-file processing. */
184 void
185 finish_file ()
187 #ifndef ASM_OUTPUT_CONSTRUCTOR
188 extern tree static_ctors;
189 #endif
190 #ifndef ASM_OUTPUT_DESTRUCTOR
191 extern tree static_dtors;
192 #endif
193 extern tree build_function_call PARAMS ((tree, tree));
194 #if !defined(ASM_OUTPUT_CONSTRUCTOR) || !defined(ASM_OUTPUT_DESTRUCTOR)
195 tree void_list_node_1 = build_tree_list (NULL_TREE, void_type_node);
196 #endif
197 #ifndef ASM_OUTPUT_CONSTRUCTOR
198 if (static_ctors)
200 tree fnname = get_file_function_name ('I');
201 start_function (void_list_node_1,
202 build_parse_node (CALL_EXPR, fnname,
203 tree_cons (NULL_TREE, NULL_TREE,
204 void_list_node_1),
205 NULL_TREE),
206 NULL_TREE, NULL_TREE);
207 fnname = DECL_ASSEMBLER_NAME (current_function_decl);
208 store_parm_decls ();
210 for (; static_ctors; static_ctors = TREE_CHAIN (static_ctors))
211 expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors),
212 NULL_TREE));
214 finish_function (0);
216 assemble_constructor (IDENTIFIER_POINTER (fnname));
218 #endif
219 #ifndef ASM_OUTPUT_DESTRUCTOR
220 if (static_dtors)
222 tree fnname = get_file_function_name ('D');
223 start_function (void_list_node_1,
224 build_parse_node (CALL_EXPR, fnname,
225 tree_cons (NULL_TREE, NULL_TREE,
226 void_list_node_1),
227 NULL_TREE),
228 NULL_TREE, NULL_TREE);
229 fnname = DECL_ASSEMBLER_NAME (current_function_decl);
230 store_parm_decls ();
232 for (; static_dtors; static_dtors = TREE_CHAIN (static_dtors))
233 expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors),
234 NULL_TREE));
236 finish_function (0);
238 assemble_destructor (IDENTIFIER_POINTER (fnname));
240 #endif
243 /* Called during diagnostic message formatting process to print a
244 source-level entity onto BUFFER. The meaning of the format specifiers
245 is as follows:
246 %D: a general decl,
247 %F: a function declaration,
248 %T: a type.
250 These format specifiers form a subset of the format specifiers set used
251 by the C++ front-end.
252 Please notice when called, the `%' part was already skipped by the
253 diagnostic machinery. */
254 static int
255 c_tree_printer (buffer)
256 output_buffer *buffer;
258 tree t = va_arg (output_buffer_format_args (buffer), tree);
260 switch (*output_buffer_text_cursor (buffer))
262 case 'D':
263 case 'F':
264 case 'T':
266 const char *n = DECL_NAME (t)
267 ? (*decl_printable_name) (t, 2)
268 : "({anonymous})";
269 output_add_string (buffer, n);
271 return 1;
273 default:
274 return 0;