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
29 #include "diagnostic.h"
39 static int c_tree_printer
PARAMS ((output_buffer
*));
40 static int c_missing_noreturn_ok_p
PARAMS ((tree
));
41 static void c_init
PARAMS ((void));
42 static void c_init_options
PARAMS ((void));
43 static void c_post_options
PARAMS ((void));
45 /* Each front end provides its own. */
46 struct lang_hooks lang_hooks
= {c_init
,
52 /* Post-switch processing. */
56 cpp_post_options (parse_in
);
62 /* Make identifier nodes long enough for the language-specific slots. */
63 set_identifier_size (sizeof (struct lang_identifier
));
65 parse_in
= cpp_create_reader (ident_hash
, CLK_GNUC89
);
67 /* Mark as "unspecified". */
68 flag_bounds_check
= -1;
74 c_common_lang_init ();
76 /* If still unspecified, make it match -std=c99
77 (allowing for -pedantic-errors). */
78 if (mesg_implicit_function_declaration
< 0)
81 mesg_implicit_function_declaration
= flag_pedantic_errors
? 2 : 1;
83 mesg_implicit_function_declaration
= 0;
86 save_lang_status
= &push_c_function_context
;
87 restore_lang_status
= &pop_c_function_context
;
88 mark_lang_status
= &mark_c_function_context
;
89 lang_expand_expr
= &c_expand_expr
;
90 lang_safe_from_p
= &c_safe_from_p
;
91 diagnostic_format_decoder (global_dc
) = &c_tree_printer
;
92 lang_expand_decl_stmt
= &c_expand_decl_stmt
;
93 lang_missing_noreturn_ok_p
= &c_missing_noreturn_ok_p
;
105 print_lang_statistics ()
109 /* used by print-tree.c */
112 lang_print_xnode (file
, node
, indent
)
113 FILE *file ATTRIBUTE_UNUSED
;
114 tree node ATTRIBUTE_UNUSED
;
115 int indent ATTRIBUTE_UNUSED
;
119 /* Used by c-lex.c, but only for objc. */
122 lookup_interface (arg
)
123 tree arg ATTRIBUTE_UNUSED
;
130 tree arg ATTRIBUTE_UNUSED
;
136 maybe_objc_check_decl (decl
)
137 tree decl ATTRIBUTE_UNUSED
;
142 maybe_objc_comptypes (lhs
, rhs
, reflexive
)
143 tree lhs ATTRIBUTE_UNUSED
;
144 tree rhs ATTRIBUTE_UNUSED
;
145 int reflexive ATTRIBUTE_UNUSED
;
151 maybe_building_objc_message_expr ()
157 recognize_objc_keyword ()
162 /* Used by c-typeck.c (build_external_ref), but only for objc. */
165 lookup_objc_ivar (id
)
166 tree id ATTRIBUTE_UNUSED
;
171 #if !defined(ASM_OUTPUT_CONSTRUCTOR) || !defined(ASM_OUTPUT_DESTRUCTOR)
172 extern tree static_ctors
;
173 extern tree static_dtors
;
175 static tree start_cdtor
PARAMS ((int));
176 static void finish_cdtor
PARAMS ((tree
));
179 start_cdtor (method_type
)
182 tree fnname
= get_file_function_name (method_type
);
183 tree void_list_node_1
= build_tree_list (NULL_TREE
, void_type_node
);
186 start_function (void_list_node_1
,
187 build_nt (CALL_EXPR
, fnname
,
188 tree_cons (NULL_TREE
, NULL_TREE
, void_list_node_1
),
193 current_function_cannot_inline
194 = "static constructors and destructors cannot be inlined";
196 body
= c_begin_compound_stmt ();
200 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
212 scope
= add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
213 block
= poplevel (0, 0, 0);
214 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope
)) = block
;
215 SCOPE_STMT_BLOCK (TREE_VALUE (scope
)) = block
;
217 RECHAIN_STMTS (body
, COMPOUND_BODY (body
));
223 /* Called at end of parsing, but before end-of-file processing. */
228 #ifndef ASM_OUTPUT_CONSTRUCTOR
231 tree body
= start_cdtor ('I');
233 for (; static_ctors
; static_ctors
= TREE_CHAIN (static_ctors
))
234 c_expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors
),
240 #ifndef ASM_OUTPUT_DESTRUCTOR
243 tree body
= start_cdtor ('D');
245 for (; static_dtors
; static_dtors
= TREE_CHAIN (static_dtors
))
246 c_expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors
),
254 (*back_end_hook
) (getdecls ());
258 FILE *stream
= dump_begin (TDI_all
, &flags
);
262 dump_node (getdecls (), flags
& ~TDF_SLIM
, stream
);
263 dump_end (TDI_all
, stream
);
268 /* Called during diagnostic message formatting process to print a
269 source-level entity onto BUFFER. The meaning of the format specifiers
272 %F: a function declaration,
275 These format specifiers form a subset of the format specifiers set used
276 by the C++ front-end.
277 Please notice when called, the `%' part was already skipped by the
278 diagnostic machinery. */
280 c_tree_printer (buffer
)
281 output_buffer
*buffer
;
283 tree t
= va_arg (output_buffer_format_args (buffer
), tree
);
285 switch (*output_buffer_text_cursor (buffer
))
291 const char *n
= DECL_NAME (t
)
292 ? (*decl_printable_name
) (t
, 2)
294 output_add_string (buffer
, n
);
304 c_missing_noreturn_ok_p (decl
)
307 /* A missing noreturn is not ok for freestanding implementations and
308 ok for the `main' function in hosted implementations. */
309 return flag_hosted
&& MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl
));