Deleted Added
sdiff udiff text old ( 107590 ) new ( 117395 )
full compact
1/* Some code common to C and ObjC front ends.
2 Copyright (C) 2001 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 2, or (at your option) any later

--- 19 unchanged lines hidden (view full) ---

28#include "c-tree.h"
29#include "function.h"
30#include "flags.h"
31#include "toplev.h"
32#include "diagnostic.h"
33#include "tree-inline.h"
34#include "varray.h"
35#include "ggc.h"
36#include "langhooks.h"
37#include "target.h"
38
39static bool c_tree_printer PARAMS ((output_buffer *, text_info *));
40static tree inline_forbidden_p PARAMS ((tree *, int *, void *));
41static void expand_deferred_fns PARAMS ((void));
42static tree start_cdtor PARAMS ((int));
43static void finish_cdtor PARAMS ((tree));
44
45static GTY(()) varray_type deferred_fns;
46
47int
48c_missing_noreturn_ok_p (decl)
49 tree decl;
50{
51 /* A missing noreturn is not ok for freestanding implementations and
52 ok for the `main' function in hosted implementations. */
53 return flag_hosted && MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl));

--- 33 unchanged lines hidden (view full) ---

87 /* We cannot inline functions that call setjmp. */
88 if (setjmp_call_p (t))
89 return node;
90
91 switch (DECL_FUNCTION_CODE (t))
92 {
93 /* We cannot inline functions that take a variable number of
94 arguments. */
95 case BUILT_IN_VA_START:
96 case BUILT_IN_STDARG_START:
97#if 0
98 /* Functions that need information about the address of the
99 caller can't (shouldn't?) be inlined. */
100 case BUILT_IN_RETURN_ADDRESS:
101#endif
102 return node;
103

--- 12 unchanged lines hidden (view full) ---

116
117 case GOTO_STMT:
118 case GOTO_EXPR:
119 t = TREE_OPERAND (node, 0);
120
121 /* We will not inline a function which uses computed goto. The
122 addresses of its local labels, which may be tucked into
123 global storage, are of course not constant across
124 instantiations, which causes unexpected behavior. */
125 if (TREE_CODE (t) != LABEL_DECL)
126 return node;
127
128 /* We cannot inline a nested function that jumps to a nonlocal
129 label. */
130 if (TREE_CODE (t) == LABEL_DECL
131 && DECL_CONTEXT (t) && DECL_CONTEXT (t) != fn)
132 return node;

--- 31 unchanged lines hidden (view full) ---

164 tree t;
165
166 if (flag_really_no_inline
167 && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
168 return 1;
169
170 /* Don't auto-inline anything that might not be bound within
171 this unit of translation. */
172 if (!DECL_DECLARED_INLINE_P (fn) && !(*targetm.binds_local_p) (fn))
173 goto cannot_inline;
174
175 if (! function_attribute_inlinable_p (fn))
176 goto cannot_inline;
177
178 /* If a function has pending sizes, we must not defer its
179 compilation, and we can't inline it as a tree. */
180 if (fn == current_function_decl)
181 {
182 t = get_pending_sizes ();
183 put_pending_sizes (t);
184
185 if (t)
186 goto cannot_inline;
187 }
188
189 if (DECL_CONTEXT (fn))
190 {
191 /* If a nested function has pending sizes, we may have already
192 saved them. */
193 if (DECL_LANG_SPECIFIC (fn)->pending_sizes)
194 goto cannot_inline;
195 }
196 else
197 {
198 /* We rely on the fact that this function is called upfront,
199 just before we start expanding a function. If FN is active
200 (i.e., it's the current_function_decl or a parent thereof),
201 we have to walk FN's saved tree. Otherwise, we can safely
202 assume we have done it before and, if we didn't mark it as

--- 5 unchanged lines hidden (view full) ---

208 t = current_function_decl;
209
210 while (t && t != fn)
211 t = DECL_CONTEXT (t);
212 if (! t)
213 return 0;
214 }
215
216 if (walk_tree_without_duplicates
217 (&DECL_SAVED_TREE (fn), inline_forbidden_p, fn))
218 goto cannot_inline;
219
220 return 0;
221
222 cannot_inline:
223 DECL_UNINLINABLE (fn) = 1;
224 return 1;
225}
226
227/* Called from check_global_declarations. */
228
229bool
230c_warn_unused_global_decl (decl)
231 tree decl;
232{
233 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
234 return false;
235 if (DECL_IN_SYSTEM_HEADER (decl))
236 return false;
237
238 return true;
239}
240
241/* Initialization common to C and Objective-C front ends. */
242const char *
243c_objc_common_init (filename)
244 const char *filename;
245{
246 c_init_decl_processing ();
247
248 filename = c_common_init (filename);
249 if (filename == NULL)
250 return NULL;
251
252 lang_expand_decl_stmt = c_expand_decl_stmt;
253
254 /* These were not defined in the Objective-C front end, but I'm
255 putting them here anyway. The diagnostic format decoder might
256 want an enhanced ObjC implementation. */
257 diagnostic_format_decoder (global_dc) = &c_tree_printer;
258 lang_missing_noreturn_ok_p = &c_missing_noreturn_ok_p;
259
260 /* If still unspecified, make it match -std=c99
261 (allowing for -pedantic-errors). */
262 if (mesg_implicit_function_declaration < 0)
263 {
264 if (flag_isoc99)
265 mesg_implicit_function_declaration = flag_pedantic_errors ? 2 : 1;
266 else
267 mesg_implicit_function_declaration = 0;
268 }
269
270 VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
271
272 return filename;
273}
274
275/* Register a function tree, so that its optimization and conversion
276 to RTL is only done at the end of the compilation. */
277
278int

--- 21 unchanged lines hidden (view full) ---

300 /* For static inline functions, delay the decision whether to
301 emit them or not until wrapup_global_declarations. */
302 if (! TREE_PUBLIC (decl))
303 DECL_DEFER_OUTPUT (decl) = 1;
304 c_expand_deferred_function (decl);
305 }
306 }
307
308 deferred_fns = 0;
309}
310
311static tree
312start_cdtor (method_type)
313 int method_type;
314{
315 tree fnname = get_file_function_name (method_type);
316 tree void_list_node_1 = build_tree_list (NULL_TREE, void_type_node);

--- 82 unchanged lines hidden (view full) ---

399 %D: a general decl,
400 %F: a function declaration,
401 %T: a type.
402
403 These format specifiers form a subset of the format specifiers set used
404 by the C++ front-end.
405 Please notice when called, the `%' part was already skipped by the
406 diagnostic machinery. */
407static bool
408c_tree_printer (buffer, text)
409 output_buffer *buffer;
410 text_info *text;
411{
412 tree t = va_arg (*text->args_ptr, tree);
413
414 switch (*text->format_spec)
415 {
416 case 'D':
417 case 'F':
418 case 'T':
419 {
420 const char *n = DECL_NAME (t)
421 ? (*lang_hooks.decl_printable_name) (t, 2)
422 : "({anonymous})";
423 output_add_string (buffer, n);
424 }
425 return true;
426
427 default:
428 return false;
429 }
430}
431
432#include "gt-c-objc-common.h"