OSDN Git Service

* cccp.c, cexp.y, cexp.c, cccp.1: Removed.
[pf3gnuchains/gcc-fork.git] / gcc / ch / lang.c
1 /* Language-specific hook definitions for CHILL front end.
2    Copyright (C) 1992, 93, 94, 98, 99, 2000 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 "ch-tree.h"
26 #include "lex.h"
27 #include "input.h"
28 #include "toplev.h"
29
30 /* Type node for boolean types.  */
31
32 tree boolean_type_node;
33
34 /* True if STRING(INDEX) yields a CHARS(1) (or BOOLS(1)) rather than
35    a CHAR (or BOOL).  Also, makes CHARS(1) similar for CHAR,
36    and BOOLS(1) similar to BOOL.  This is for compatibility
37    for the 1984 version of Z.200.*/
38 int flag_old_strings = 0;
39
40 /* This is set non-zero to force user input tokens to lower case.
41    This is non-standard.  See Z.200, page 8. */
42 int ignore_case = 1;
43
44 /* True if reserved and predefined words ('special' words in the Z.200
45    terminology) are in uppercase.  Obviously, this had better not be 
46    true if we're ignoring input case. */
47 int special_UC = 0;
48
49 /* The actual name of the input file, regardless of any #line directives */
50 char* chill_real_input_filename;
51 extern FILE* finput;
52
53 static int deep_const_expr                      PARAMS ((tree));
54 static void chill_print_error_function          PARAMS ((const char *));
55 \f
56 /* return 1 if the expression tree given has all
57    constant nodes as its leaves; return 0 otherwise. */
58 static int
59 deep_const_expr (exp)
60      tree exp;
61 {
62   enum chill_tree_code code;
63   int length;
64   int i;
65
66   if (exp == NULL_TREE)
67     return 0;
68
69   code = TREE_CODE (exp);
70   length = tree_code_length[(int) code];
71
72   /* constant leaf?  return TRUE */
73   if (TREE_CODE_CLASS (code) == 'c')
74     return 1;
75
76   /* recursively check next level down */
77   for (i = 0; i < length; i++)
78     if (! deep_const_expr (TREE_OPERAND (exp, i)))
79       return 0;
80   return 1;      
81 }
82
83
84 tree
85 const_expr (exp)
86      tree exp;
87 {
88   if (TREE_CODE (exp) == INTEGER_CST)
89     return exp;
90   if (TREE_CODE (exp) == CONST_DECL)
91     return const_expr (DECL_INITIAL (exp));
92   if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd'
93       && DECL_INITIAL (exp) != NULL_TREE
94       && TREE_READONLY (exp))
95     return DECL_INITIAL (exp);
96   if (deep_const_expr (exp))
97     return exp;
98   if (TREE_CODE (exp) != ERROR_MARK)
99     error ("non-constant expression");
100   return error_mark_node;
101 }
102
103 /* Each of the functions defined here
104    is an alternative to a function in objc-actions.c.  */
105    
106 /* Used by c-lex.c, but only for objc.  */
107 tree
108 lookup_interface (arg)
109      tree arg ATTRIBUTE_UNUSED;
110 {
111   return 0;
112 }
113
114 int
115 maybe_objc_comptypes (lhs, rhs)
116      tree lhs ATTRIBUTE_UNUSED, rhs ATTRIBUTE_UNUSED;
117 {
118   return -1;
119 }
120
121 tree
122 maybe_building_objc_message_expr ()
123 {
124   return 0;
125 }
126
127 int
128 recognize_objc_keyword ()
129 {
130   return 0;
131 }
132
133 void
134 lang_init_options ()
135 {
136 }
137
138 /* used by print-tree.c */
139
140 void
141 lang_print_xnode (file, node, indent)
142      FILE *file ATTRIBUTE_UNUSED;
143      tree node ATTRIBUTE_UNUSED;
144      int indent ATTRIBUTE_UNUSED;
145 {
146 }
147
148 void
149 GNU_xref_begin ()
150 {
151   fatal ("GCC does not yet support XREF");
152 }
153
154 void
155 GNU_xref_end ()
156 {
157   fatal ("GCC does not yet support XREF");
158 }
159 \f
160 /*
161  * process chill-specific compiler command-line options
162  * do not complain if the option is not recognised
163  */
164 int
165 lang_decode_option (argc, argv)
166      int argc;
167      char **argv;
168 {
169   char *p = argv[0];
170   static int explicit_ignore_case = 0;
171   if (!strcmp(p, "-lang-chill"))
172     ; /* do nothing */
173   else if (!strcmp (p, "-fruntime-checking"))
174     {
175       range_checking = 1;
176       empty_checking = 1;
177     }
178   else if (!strcmp (p, "-fno-runtime-checking"))
179     {
180       range_checking = 0;
181       empty_checking = 0;
182       runtime_checking_flag = 0;
183     }
184   else if (!strcmp (p, "-flocal-loop-counter"))
185     flag_local_loop_counter = 1;
186   else if (!strcmp (p, "-fno-local-loop-counter"))
187     flag_local_loop_counter = 0;
188   else if (!strcmp (p, "-fold-strings"))
189     flag_old_strings = 1;
190   else if (!strcmp (p, "-fno-old-strings"))
191     flag_old_strings = 0;
192   else if (!strcmp (p, "-fignore-case"))
193     {
194       explicit_ignore_case = 1;
195       if (special_UC)
196         {
197           error ("Ignoring case upon input and");
198           error ("making special words uppercase wouldn't work.");
199         }
200       else
201         ignore_case = 1;
202     }
203   else if (!strcmp (p, "-fno-ignore-case"))
204     ignore_case = 0;
205   else if (!strcmp (p, "-fspecial_UC"))
206     {
207       if (explicit_ignore_case)
208         {
209           error ("Making special words uppercase and");
210           error (" ignoring case upon input wouldn't work.");
211         }
212       else
213         special_UC = 1, ignore_case = 0;
214     }
215   else if (!strcmp (p, "-fspecial_LC"))
216     special_UC = 0;
217   else if (!strcmp (p, "-fpack"))
218     maximum_field_alignment = BITS_PER_UNIT;
219   else if (!strcmp (p, "-fno-pack"))
220     maximum_field_alignment = 0;
221   else if (!strcmp (p, "-fchill-grant-only"))
222     grant_only_flag = 1;
223   else if (!strcmp (p, "-fgrant-only"))
224     grant_only_flag = 1;
225   /* user has specified a seize-file path */
226   else if (p[0] == '-' && p[1] == 'I')
227     register_seize_path (&p[2]);
228   if (!strcmp(p, "-itu"))        /* Force Z.200 semantics */
229     {
230       pedantic = 1;   /* FIXME: new flag name? */
231       flag_local_loop_counter = 1;      
232     }
233   else
234     return c_decode_option (argc, argv);
235
236   return 1;
237 }
238
239 static void
240 chill_print_error_function (file)
241      const char *file;
242 {
243   static tree last_error_function = NULL_TREE;
244   static struct module *last_error_module = NULL;
245
246   if (last_error_function == current_function_decl
247       && last_error_module == current_module)
248     return;
249
250   last_error_function = current_function_decl;
251   last_error_module = current_module;
252
253   if (file)
254     fprintf (stderr, "%s: ", file);
255
256   if (current_function_decl == global_function_decl
257       || current_function_decl == NULL_TREE)
258     {
259       if (current_module == NULL)
260         fprintf (stderr, "At top level:\n");
261       else
262         fprintf (stderr, "In module %s:\n",
263                  IDENTIFIER_POINTER (current_module->name));
264     }
265   else
266     {
267       const char *kind = "function";
268       const char *name = (*decl_printable_name) (current_function_decl, 2);
269       fprintf (stderr, "In %s `%s':\n", kind, name);
270     }
271 }
272
273 /* Print an error message for invalid use of an incomplete type.
274    VALUE is the expression that was used (or 0 if that isn't known)
275    and TYPE is the type that was invalid.  */
276
277 void
278 incomplete_type_error (value, type)
279      tree value ATTRIBUTE_UNUSED;
280      tree type ATTRIBUTE_UNUSED;
281 {
282   error ("internal error - use of undefined type");
283 }
284
285 void
286 lang_init ()
287 {
288   chill_real_input_filename = input_filename;
289
290   /* the beginning of the file is a new line; check for # */
291   /* With luck, we discover the real source file's name from that
292      and put it in input_filename.  */
293
294   ungetc (check_newline (), finput);
295
296   /* set default grant file */
297   set_default_grant_file ();
298
299   print_error_function = chill_print_error_function;
300 }