1 /* Language-specific hook definitions for C front end.
2 Copyright (C) 1991, 1995, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
34 #include "langhooks.h"
35 #include "langhooks-def.h"
37 static const char *c_init
PARAMS ((const char *));
38 static void c_init_options
PARAMS ((void));
39 static void c_post_options
PARAMS ((void));
41 /* ### When changing hooks, consider if ObjC needs changing too!! ### */
43 #undef LANG_HOOKS_NAME
44 #define LANG_HOOKS_NAME "GNU C"
45 #undef LANG_HOOKS_INIT
46 #define LANG_HOOKS_INIT c_init
47 #undef LANG_HOOKS_FINISH
48 #define LANG_HOOKS_FINISH c_common_finish
49 #undef LANG_HOOKS_INIT_OPTIONS
50 #define LANG_HOOKS_INIT_OPTIONS c_init_options
51 #undef LANG_HOOKS_DECODE_OPTION
52 #define LANG_HOOKS_DECODE_OPTION c_decode_option
53 #undef LANG_HOOKS_POST_OPTIONS
54 #define LANG_HOOKS_POST_OPTIONS c_post_options
55 #undef LANG_HOOKS_GET_ALIAS_SET
56 #define LANG_HOOKS_GET_ALIAS_SET c_common_get_alias_set
57 #undef LANG_HOOKS_SAFE_FROM_P
58 #define LANG_HOOKS_SAFE_FROM_P c_safe_from_p
59 #undef LANG_HOOKS_STATICP
60 #define LANG_HOOKS_STATICP c_staticp
61 #undef LANG_HOOKS_PRINT_IDENTIFIER
62 #define LANG_HOOKS_PRINT_IDENTIFIER c_print_identifier
63 #undef LANG_HOOKS_SET_YYDEBUG
64 #define LANG_HOOKS_SET_YYDEBUG c_set_yydebug
66 #undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
67 #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
68 c_cannot_inline_tree_fn
69 #undef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS
70 #define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \
71 c_disregard_inline_limits
72 #undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
73 #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \
76 /* ### When changing hooks, consider if ObjC needs changing too!! ### */
78 /* Each front end provides its own. */
79 const struct lang_hooks lang_hooks
= LANG_HOOKS_INITIALIZER
;
81 static varray_type deferred_fns
;
83 /* Post-switch processing. */
87 c_common_post_options ();
93 c_common_init_options (clk_c
);
100 filename
= c_objc_common_init (filename
);
102 VARRAY_TREE_INIT (deferred_fns
, 32, "deferred_fns");
103 ggc_add_tree_varray_root (&deferred_fns
, 1);
108 /* Used by c-lex.c, but only for objc. */
111 lookup_interface (arg
)
112 tree arg ATTRIBUTE_UNUSED
;
119 tree arg ATTRIBUTE_UNUSED
;
125 maybe_objc_check_decl (decl
)
126 tree decl ATTRIBUTE_UNUSED
;
131 maybe_objc_comptypes (lhs
, rhs
, reflexive
)
132 tree lhs ATTRIBUTE_UNUSED
;
133 tree rhs ATTRIBUTE_UNUSED
;
134 int reflexive ATTRIBUTE_UNUSED
;
140 maybe_building_objc_message_expr ()
146 recognize_objc_keyword ()
151 /* Used by c-typeck.c (build_external_ref), but only for objc. */
154 lookup_objc_ivar (id
)
155 tree id ATTRIBUTE_UNUSED
;
160 extern tree static_ctors
;
161 extern tree static_dtors
;
163 static tree start_cdtor
PARAMS ((int));
164 static void finish_cdtor
PARAMS ((tree
));
167 start_cdtor (method_type
)
170 tree fnname
= get_file_function_name (method_type
);
171 tree void_list_node_1
= build_tree_list (NULL_TREE
, void_type_node
);
174 start_function (void_list_node_1
,
175 build_nt (CALL_EXPR
, fnname
,
176 tree_cons (NULL_TREE
, NULL_TREE
, void_list_node_1
),
181 current_function_cannot_inline
182 = "static constructors and destructors cannot be inlined";
184 body
= c_begin_compound_stmt ();
188 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
200 scope
= add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
201 block
= poplevel (0, 0, 0);
202 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope
)) = block
;
203 SCOPE_STMT_BLOCK (TREE_VALUE (scope
)) = block
;
205 RECHAIN_STMTS (body
, COMPOUND_BODY (body
));
210 /* Register a function tree, so that its optimization and conversion
211 to RTL is only done at the end of the compilation. */
217 VARRAY_PUSH_TREE (deferred_fns
, fn
);
222 /* Called at end of parsing, but before end-of-file processing. */
229 for (i
= 0; i
< VARRAY_ACTIVE_SIZE (deferred_fns
); i
++)
231 tree decl
= VARRAY_TREE (deferred_fns
, i
);
233 if (! TREE_ASM_WRITTEN (decl
))
235 /* For static inline functions, delay the decision whether to
236 emit them or not until wrapup_global_declarations. */
237 if (! TREE_PUBLIC (decl
))
238 DECL_DEFER_OUTPUT (decl
) = 1;
239 c_expand_deferred_function (decl
);
242 VARRAY_FREE (deferred_fns
);
246 tree body
= start_cdtor ('I');
248 for (; static_ctors
; static_ctors
= TREE_CHAIN (static_ctors
))
249 c_expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors
),
256 tree body
= start_cdtor ('D');
258 for (; static_dtors
; static_dtors
= TREE_CHAIN (static_dtors
))
259 c_expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors
),
267 FILE *stream
= dump_begin (TDI_all
, &flags
);
271 dump_node (getdecls (), flags
& ~TDF_SLIM
, stream
);
272 dump_end (TDI_all
, stream
);