OSDN Git Service

* c-lang.c (finish_file case ndef ASM_OUTPUT_{CON,DE}STRUCTOR):
[pf3gnuchains/gcc-fork.git] / gcc / c-lang.c
1 /* Language-specific hook definitions for C front end.
2    Copyright (C) 1991, 1995, 1997, 1998 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 "ggc.h"
32
33 #if USE_CPPLIB
34 #include "cpplib.h"
35 extern char *yy_cur;
36 extern cpp_reader  parse_in;
37 extern cpp_options parse_options;
38 #endif
39
40 /* Each of the functions defined here
41    is an alternative to a function in objc-actions.c.  */
42    
43 int
44 lang_decode_option (argc, argv)
45      int argc;
46      char **argv;
47 {
48   return c_decode_option (argc, argv);
49 }
50
51 void
52 lang_init_options ()
53 {
54 #if USE_CPPLIB
55   cpp_reader_init (&parse_in);
56   parse_in.opts = &parse_options;
57   cpp_options_init (&parse_options);
58 #endif
59 }
60
61 void
62 lang_init ()
63 {
64   /* the beginning of the file is a new line; check for # */
65   /* With luck, we discover the real source file's name from that
66      and put it in input_filename.  */
67 #if !USE_CPPLIB
68   ungetc (check_newline (), finput);
69 #else
70   check_newline ();
71   yy_cur--;
72 #endif 
73
74   save_lang_status = &push_c_function_context;
75   restore_lang_status = &pop_c_function_context;
76   mark_lang_status = &mark_c_function_context;
77
78   c_parse_init ();
79 }
80
81 void
82 lang_finish ()
83 {
84 }
85
86 const char *
87 lang_identify ()
88 {
89   return "c";
90 }
91
92 void
93 print_lang_statistics ()
94 {
95 }
96
97 /* used by print-tree.c */
98
99 void
100 lang_print_xnode (file, node, indent)
101      FILE *file ATTRIBUTE_UNUSED;
102      tree node ATTRIBUTE_UNUSED;
103      int indent ATTRIBUTE_UNUSED;
104 {
105 }
106
107 /* Used by c-lex.c, but only for objc.  */
108
109 tree
110 lookup_interface (arg)
111      tree arg ATTRIBUTE_UNUSED;
112 {
113   return 0;
114 }
115
116 tree
117 is_class_name (arg)
118     tree arg ATTRIBUTE_UNUSED;
119 {
120   return 0;
121 }
122
123 void
124 maybe_objc_check_decl (decl)
125      tree decl ATTRIBUTE_UNUSED;
126 {
127 }
128
129 int
130 maybe_objc_comptypes (lhs, rhs, reflexive)
131      tree lhs ATTRIBUTE_UNUSED;
132      tree rhs ATTRIBUTE_UNUSED;
133      int reflexive ATTRIBUTE_UNUSED;
134 {
135   return -1;
136 }
137
138 tree
139 maybe_objc_method_name (decl)
140     tree decl ATTRIBUTE_UNUSED;
141 {
142   return 0;
143 }
144
145 tree
146 maybe_building_objc_message_expr ()
147 {
148   return 0;
149 }
150
151 int
152 recognize_objc_keyword ()
153 {
154   return 0;
155 }
156
157 tree
158 build_objc_string (len, str)
159     int len ATTRIBUTE_UNUSED;
160     const char *str ATTRIBUTE_UNUSED;
161 {
162   abort ();
163   return NULL_TREE;
164 }
165
166 /* Called at end of parsing, but before end-of-file processing.  */
167
168 void
169 finish_file ()
170 {
171 #ifndef ASM_OUTPUT_CONSTRUCTOR
172   extern tree static_ctors;
173 #endif
174 #ifndef ASM_OUTPUT_DESTRUCTOR
175   extern tree static_dtors;
176 #endif
177   extern tree build_function_call                 PROTO((tree, tree));
178 #if !defined(ASM_OUTPUT_CONSTRUCTOR) || !defined(ASM_OUTPUT_DESTRUCTOR)
179   tree void_list_node_1 = build_tree_list (NULL_TREE, void_type_node);
180 #endif
181 #ifndef ASM_OUTPUT_CONSTRUCTOR
182   if (static_ctors)
183     {
184       tree fnname = get_file_function_name ('I');
185       start_function (void_list_node_1,
186                       build_parse_node (CALL_EXPR, fnname, 
187                                         tree_cons (NULL_TREE, NULL_TREE, 
188                                                    void_list_node_1),
189                                         NULL_TREE),
190                       NULL_TREE, NULL_TREE, 0);
191       fnname = DECL_ASSEMBLER_NAME (current_function_decl);
192       store_parm_decls ();
193
194       for (; static_ctors; static_ctors = TREE_CHAIN (static_ctors))
195         expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors),
196                                                NULL_TREE));
197
198       finish_function (0);
199
200       assemble_constructor (IDENTIFIER_POINTER (fnname));
201     }
202 #endif
203 #ifndef ASM_OUTPUT_DESTRUCTOR
204   if (static_dtors)
205     {
206       tree fnname = get_file_function_name ('D');
207       start_function (void_list_node_1,
208                       build_parse_node (CALL_EXPR, fnname, 
209                                         tree_cons (NULL_TREE, NULL_TREE,
210                                                    void_list_node_1),
211                                         NULL_TREE),
212                       NULL_TREE, NULL_TREE, 0);
213       fnname = DECL_ASSEMBLER_NAME (current_function_decl);
214       store_parm_decls ();
215
216       for (; static_dtors; static_dtors = TREE_CHAIN (static_dtors))
217         expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors),
218                                                NULL_TREE));
219
220       finish_function (0);
221
222       assemble_destructor (IDENTIFIER_POINTER (fnname));
223     }
224 #endif
225 }