]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/java/lang.c
Add --extdirs support.
[thirdparty/gcc.git] / gcc / java / lang.c
1 /* Java(TM) language-specific utility routines.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
21
22 Java and all Java-based marks are trademarks or registered trademarks
23 of Sun Microsystems, Inc. in the United States and other countries.
24 The Free Software Foundation is independent of Sun Microsystems, Inc. */
25
26 /* Hacked by Per Bothner <bothner@cygnus.com> February 1996. */
27
28 #include "config.h"
29 #include "system.h"
30 #include "tree.h"
31 #include "input.h"
32 #include "rtl.h"
33 #include "expr.h"
34 #include "java-tree.h"
35 #include "jcf.h"
36 #include "toplev.h"
37 #include "langhooks.h"
38 #include "langhooks-def.h"
39 #include "flags.h"
40 #include "xref.h"
41 #include "ggc.h"
42 #include "diagnostic.h"
43
44 struct string_option
45 {
46 const char *const string;
47 int *const variable;
48 const int on_value;
49 };
50
51 static const char *java_init PARAMS ((const char *));
52 static void java_finish PARAMS ((void));
53 static void java_init_options PARAMS ((void));
54 static int java_decode_option PARAMS ((int, char **));
55 static void put_decl_string PARAMS ((const char *, int));
56 static void put_decl_node PARAMS ((tree));
57 static void java_print_error_function PARAMS ((diagnostic_context *,
58 const char *));
59 static int process_option_with_no PARAMS ((const char *,
60 const struct string_option *,
61 int));
62
63 #ifndef TARGET_OBJECT_SUFFIX
64 # define TARGET_OBJECT_SUFFIX ".o"
65 #endif
66
67 /* Table indexed by tree code giving a string containing a character
68 classifying the tree code. Possibilities are
69 t, d, s, c, r, <, 1 and 2. See java/java-tree.def for details. */
70
71 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
72
73 const char tree_code_type[] = {
74 #include "tree.def"
75 'x',
76 #include "java-tree.def"
77 };
78 #undef DEFTREECODE
79
80 /* Table indexed by tree code giving number of expression
81 operands beyond the fixed part of the node structure.
82 Not used for types or decls. */
83
84 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
85
86 const unsigned char tree_code_length[] = {
87 #include "tree.def"
88 0,
89 #include "java-tree.def"
90 };
91 #undef DEFTREECODE
92
93 /* Names of tree components.
94 Used for printing out the tree and error messages. */
95 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
96
97 const char *const tree_code_name[] = {
98 #include "tree.def"
99 "@@dummy",
100 #include "java-tree.def"
101 };
102 #undef DEFTREECODE
103
104 /* Used to avoid printing error messages with bogus function
105 prototypes. Starts out false. */
106 static bool inhibit_error_function_printing;
107
108 int compiling_from_source;
109
110 char * resource_name;
111
112 int flag_emit_class_files = 0;
113
114 /* Nonzero if input file is a file with a list of filenames to compile. */
115
116 int flag_filelist_file = 0;
117
118 /* When non zero, we emit xref strings. Values of the flag for xref
119 backends are defined in xref_flag_table, xref.c. */
120
121 int flag_emit_xref = 0;
122
123 /* When non zero, -Wall was turned on. */
124 int flag_wall = 0;
125
126 /* When non zero, check for redundant modifier uses. */
127 int flag_redundant = 0;
128
129 /* When non zero, call a library routine to do integer divisions. */
130 int flag_use_divide_subroutine = 1;
131
132 /* When non zero, generate code for the Boehm GC. */
133 int flag_use_boehm_gc = 0;
134
135 /* When non zero, assume the runtime uses a hash table to map an
136 object to its synchronization structure. */
137 int flag_hash_synchronization;
138
139 /* When non zero, assume all native functions are implemented with
140 JNI, not CNI. */
141 int flag_jni = 0;
142
143 /* When non zero, warn when source file is newer than matching class
144 file. */
145 int flag_newer = 1;
146
147 /* When non zero, generate checks for references to NULL. */
148 int flag_check_references = 0;
149
150 /* The encoding of the source file. */
151 const char *current_encoding = NULL;
152
153 /* When non zero, report the now deprecated empty statements. */
154 int flag_extraneous_semicolon;
155
156 /* When non zero, always check for a non gcj generated classes archive. */
157 int flag_force_classes_archive_check;
158
159 /* When zero, don't optimize static class initialization. This flag shouldn't
160 be tested alone, use STATIC_CLASS_INITIALIZATION_OPTIMIZATION_P instead. */
161 int flag_optimize_sci = 1;
162
163 /* When non zero, use offset tables for virtual method calls
164 in order to improve binary compatibility. */
165 int flag_indirect_dispatch = 0;
166
167 /* When zero, don't generate runtime array store checks. */
168 int flag_store_check = 1;
169
170 /* When non zero, print extra version information. */
171 static int version_flag = 0;
172
173 /* Table of language-dependent -f options.
174 STRING is the option name. VARIABLE is the address of the variable.
175 ON_VALUE is the value to store in VARIABLE
176 if `-fSTRING' is seen as an option.
177 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
178
179 static const struct string_option
180 lang_f_options[] =
181 {
182 {"emit-class-file", &flag_emit_class_files, 1},
183 {"emit-class-files", &flag_emit_class_files, 1},
184 {"filelist-file", &flag_filelist_file, 1},
185 {"use-divide-subroutine", &flag_use_divide_subroutine, 1},
186 {"use-boehm-gc", &flag_use_boehm_gc, 1},
187 {"hash-synchronization", &flag_hash_synchronization, 1},
188 {"jni", &flag_jni, 1},
189 {"check-references", &flag_check_references, 1},
190 {"force-classes-archive-check", &flag_force_classes_archive_check, 1},
191 {"optimize-static-class-initialization", &flag_optimize_sci, 1 },
192 {"indirect-dispatch", &flag_indirect_dispatch, 1},
193 {"store-check", &flag_store_check, 1}
194 };
195
196 static const struct string_option
197 lang_W_options[] =
198 {
199 { "redundant-modifiers", &flag_redundant, 1 },
200 { "extraneous-semicolon", &flag_extraneous_semicolon, 1 },
201 { "out-of-date", &flag_newer, 1 }
202 };
203
204 JCF *current_jcf;
205
206 /* Variable controlling how dependency tracking is enabled in
207 java_init. */
208 static int dependency_tracking = 0;
209
210 /* Flag values for DEPENDENCY_TRACKING. */
211 #define DEPEND_SET_FILE 1
212 #define DEPEND_ENABLE 2
213 #define DEPEND_TARGET_SET 4
214 #define DEPEND_FILE_ALREADY_SET 8
215
216 #undef LANG_HOOKS_NAME
217 #define LANG_HOOKS_NAME "GNU Java"
218 #undef LANG_HOOKS_INIT
219 #define LANG_HOOKS_INIT java_init
220 #undef LANG_HOOKS_FINISH
221 #define LANG_HOOKS_FINISH java_finish
222 #undef LANG_HOOKS_INIT_OPTIONS
223 #define LANG_HOOKS_INIT_OPTIONS java_init_options
224 #undef LANG_HOOKS_DECODE_OPTION
225 #define LANG_HOOKS_DECODE_OPTION java_decode_option
226 #undef LANG_HOOKS_SET_YYDEBUG
227 #define LANG_HOOKS_SET_YYDEBUG java_set_yydebug
228 #undef LANG_HOOKS_PARSE_FILE
229 #define LANG_HOOKS_PARSE_FILE java_parse_file
230 #undef LANG_HOOKS_MARK_TREE
231 #define LANG_HOOKS_MARK_TREE java_mark_tree
232 #undef LANG_HOOKS_MARK_ADDRESSABLE
233 #define LANG_HOOKS_MARK_ADDRESSABLE java_mark_addressable
234 #undef LANG_HOOKS_EXPAND_EXPR
235 #define LANG_HOOKS_EXPAND_EXPR java_expand_expr
236 #undef LANG_HOOKS_TRUTHVALUE_CONVERSION
237 #define LANG_HOOKS_TRUTHVALUE_CONVERSION java_truthvalue_conversion
238 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
239 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl
240 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
241 #define LANG_HOOKS_DECL_PRINTABLE_NAME lang_printable_name
242 #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
243 #define LANG_HOOKS_PRINT_ERROR_FUNCTION java_print_error_function
244
245 #undef LANG_HOOKS_TYPE_FOR_MODE
246 #define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode
247 #undef LANG_HOOKS_TYPE_FOR_SIZE
248 #define LANG_HOOKS_TYPE_FOR_SIZE java_type_for_size
249 #undef LANG_HOOKS_SIGNED_TYPE
250 #define LANG_HOOKS_SIGNED_TYPE java_signed_type
251 #undef LANG_HOOKS_UNSIGNED_TYPE
252 #define LANG_HOOKS_UNSIGNED_TYPE java_unsigned_type
253 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
254 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE java_signed_or_unsigned_type
255
256 /* Each front end provides its own. */
257 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
258
259 /* Process an option that can accept a `no-' form.
260 Return 1 if option found, 0 otherwise. */
261 static int
262 process_option_with_no (p, table, table_size)
263 const char *p;
264 const struct string_option *table;
265 int table_size;
266 {
267 int j;
268
269 for (j = 0; j < table_size; j++)
270 {
271 if (!strcmp (p, table[j].string))
272 {
273 *table[j].variable = table[j].on_value;
274 return 1;
275 }
276 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
277 && ! strcmp (p+3, table[j].string))
278 {
279 *table[j].variable = ! table[j].on_value;
280 return 1;
281 }
282 }
283
284 return 0;
285 }
286
287 /*
288 * process java-specific compiler command-line options
289 * return 0, but do not complain if the option is not recognised.
290 */
291 static int
292 java_decode_option (argc, argv)
293 int argc __attribute__ ((__unused__));
294 char **argv;
295 {
296 char *p = argv[0];
297
298 jcf_path_init ();
299
300 if (strcmp (p, "-version") == 0)
301 {
302 version_flag = 1;
303 /* We return 0 so that the caller can process this. */
304 return 0;
305 }
306
307 #define CLARG "-fcompile-resource="
308 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
309 {
310 resource_name = p + sizeof (CLARG) - 1;
311 return 1;
312 }
313 #undef CLARG
314 #define CLARG "-fassume-compiled="
315 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
316 {
317 add_assume_compiled (p + sizeof (CLARG) - 1, 0);
318 return 1;
319 }
320 #undef CLARG
321 #define CLARG "-fno-assume-compiled="
322 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
323 {
324 add_assume_compiled (p + sizeof (CLARG) - 1, 1);
325 return 1;
326 }
327 #undef CLARG
328 #define CLARG "-fassume-compiled"
329 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
330 {
331 add_assume_compiled ("", 0);
332 return 1;
333 }
334 #undef CLARG
335 #define CLARG "-fno-assume-compiled"
336 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
337 {
338 add_assume_compiled ("", 1);
339 return 1;
340 }
341 #undef CLARG
342 #define CLARG "-fCLASSPATH="
343 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
344 {
345 jcf_path_classpath_arg (p + sizeof (CLARG) - 1);
346 return 1;
347 }
348 #undef CLARG
349 #define CLARG "-fclasspath="
350 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
351 {
352 jcf_path_classpath_arg (p + sizeof (CLARG) - 1);
353 return 1;
354 }
355 #undef CLARG
356 #define CLARG "-fbootclasspath="
357 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
358 {
359 jcf_path_bootclasspath_arg (p + sizeof (CLARG) - 1);
360 return 1;
361 }
362 #undef CLARG
363 #define CLARG "-fextdirs="
364 if (strncmp (p, CLARG, sizeof (CLARG) - 1) == 0)
365 {
366 jcf_path_extdirs_arg (p + sizeof (CLARG) - 1);
367 return 1;
368 }
369 #undef CLARG
370 else if (strncmp (p, "-I", 2) == 0)
371 {
372 jcf_path_include_arg (p + 2);
373 return 1;
374 }
375
376 #define ARG "-foutput-class-dir="
377 if (strncmp (p, ARG, sizeof (ARG) - 1) == 0)
378 {
379 jcf_write_base_directory = p + sizeof (ARG) - 1;
380 return 1;
381 }
382 #undef ARG
383 #define ARG "-fencoding="
384 if (strncmp (p, ARG, sizeof (ARG) - 1) == 0)
385 {
386 current_encoding = p + sizeof (ARG) - 1;
387 return 1;
388 }
389 #undef ARG
390
391 if (p[0] == '-' && p[1] == 'f')
392 {
393 /* Some kind of -f option.
394 P's value is the option sans `-f'.
395 Search for it in the table of options. */
396 p += 2;
397 if (process_option_with_no (p, lang_f_options,
398 ARRAY_SIZE (lang_f_options)))
399 return 1;
400 return dump_switch_p (p);
401 }
402
403 if (strcmp (p, "-Wall") == 0)
404 {
405 flag_wall = 1;
406 flag_redundant = 1;
407 flag_extraneous_semicolon = 1;
408 /* When -Wall given, enable -Wunused. We do this because the C
409 compiler does it, and people expect it. */
410 set_Wunused (1);
411 return 1;
412 }
413
414 if (p[0] == '-' && p[1] == 'W')
415 {
416 /* Skip `-W' and see if we accept the option or its `no-' form. */
417 p += 2;
418 return process_option_with_no (p, lang_W_options,
419 ARRAY_SIZE (lang_W_options));
420 }
421
422 if (strcmp (p, "-MD") == 0)
423 {
424 jcf_dependency_init (1);
425 dependency_tracking |= DEPEND_SET_FILE | DEPEND_ENABLE;
426 return 1;
427 }
428 else if (strcmp (p, "-MMD") == 0)
429 {
430 jcf_dependency_init (0);
431 dependency_tracking |= DEPEND_SET_FILE | DEPEND_ENABLE;
432 return 1;
433 }
434 else if (strcmp (p, "-M") == 0)
435 {
436 jcf_dependency_init (1);
437 dependency_tracking |= DEPEND_ENABLE;
438 return 1;
439 }
440 else if (strcmp (p, "-MM") == 0)
441 {
442 jcf_dependency_init (0);
443 dependency_tracking |= DEPEND_ENABLE;
444 return 1;
445 }
446 else if (strcmp (p, "-MP") == 0)
447 {
448 jcf_dependency_print_dummies ();
449 return 1;
450 }
451 else if (strcmp (p, "-MT") == 0)
452 {
453 jcf_dependency_set_target (argv[1]);
454 dependency_tracking |= DEPEND_TARGET_SET;
455 return 2;
456 }
457 else if (strcmp (p, "-MF") == 0)
458 {
459 jcf_dependency_set_dep_file (argv[1]);
460 dependency_tracking |= DEPEND_FILE_ALREADY_SET;
461 return 2;
462 }
463
464 return 0;
465 }
466
467 /* Global open file. */
468 FILE *finput;
469
470 static const char *
471 java_init (filename)
472 const char *filename;
473 {
474 #if 0
475 extern int flag_minimal_debug;
476 flag_minimal_debug = 0;
477 #endif
478
479 /* Open input file. */
480
481 if (filename == 0 || !strcmp (filename, "-"))
482 {
483 finput = stdin;
484 filename = "stdin";
485
486 if (dependency_tracking)
487 error ("can't do dependency tracking with input from stdin");
488 }
489 else
490 {
491 if (dependency_tracking)
492 {
493 char *dot;
494
495 /* If the target is set and the output filename is set, then
496 there's no processing to do here. Otherwise we must
497 compute one or the other. */
498 if (! ((dependency_tracking & DEPEND_TARGET_SET)
499 && (dependency_tracking & DEPEND_FILE_ALREADY_SET)))
500 {
501 dot = strrchr (filename, '.');
502 if (dot == NULL)
503 error ("couldn't determine target name for dependency tracking");
504 else
505 {
506 char *buf = (char *) xmalloc (dot - filename +
507 3 + sizeof (TARGET_OBJECT_SUFFIX));
508 strncpy (buf, filename, dot - filename);
509
510 /* If emitting class files, we might have multiple
511 targets. The class generation code takes care of
512 registering them. Otherwise we compute the
513 target name here. */
514 if ((dependency_tracking & DEPEND_TARGET_SET))
515 ; /* Nothing. */
516 else if (flag_emit_class_files)
517 jcf_dependency_set_target (NULL);
518 else
519 {
520 strcpy (buf + (dot - filename), TARGET_OBJECT_SUFFIX);
521 jcf_dependency_set_target (buf);
522 }
523
524 if ((dependency_tracking & DEPEND_FILE_ALREADY_SET))
525 ; /* Nothing. */
526 else if ((dependency_tracking & DEPEND_SET_FILE))
527 {
528 strcpy (buf + (dot - filename), ".d");
529 jcf_dependency_set_dep_file (buf);
530 }
531 else
532 jcf_dependency_set_dep_file ("-");
533
534 free (buf);
535 }
536 }
537 }
538 }
539
540 jcf_path_init ();
541 jcf_path_seal (version_flag);
542
543 java_init_decl_processing ();
544
545 using_eh_for_cleanups ();
546
547 return filename;
548 }
549
550 static void
551 java_finish ()
552 {
553 jcf_dependency_write ();
554 }
555
556 /* Buffer used by lang_printable_name. */
557 static char *decl_buf = NULL;
558
559 /* Allocated size of decl_buf. */
560 static int decl_buflen = 0;
561
562 /* Length of used part of decl_buf; position for next character. */
563 static int decl_bufpos = 0;
564
565 /* Append the string STR to decl_buf.
566 It length is given by LEN; -1 means the string is nul-terminated. */
567
568 static void
569 put_decl_string (str, len)
570 const char *str;
571 int len;
572 {
573 if (len < 0)
574 len = strlen (str);
575 if (decl_bufpos + len >= decl_buflen)
576 {
577 if (decl_buf == NULL)
578 {
579 decl_buflen = len + 100;
580 decl_buf = (char *) xmalloc (decl_buflen);
581 }
582 else
583 {
584 decl_buflen *= 2;
585 decl_buf = (char *) xrealloc (decl_buf, decl_buflen);
586 }
587 }
588 strcpy (decl_buf + decl_bufpos, str);
589 decl_bufpos += len;
590 }
591
592 /* Append to decl_buf a printable name for NODE. */
593
594 static void
595 put_decl_node (node)
596 tree node;
597 {
598 int was_pointer = 0;
599 if (TREE_CODE (node) == POINTER_TYPE)
600 {
601 node = TREE_TYPE (node);
602 was_pointer = 1;
603 }
604 if (TREE_CODE_CLASS (TREE_CODE (node)) == 'd'
605 && DECL_NAME (node) != NULL_TREE)
606 {
607 if (TREE_CODE (node) == FUNCTION_DECL)
608 {
609 /* We want to print the type the DECL belongs to. We don't do
610 that when we handle constructors. */
611 if (! DECL_CONSTRUCTOR_P (node)
612 && ! DECL_ARTIFICIAL (node) && DECL_CONTEXT (node))
613 {
614 put_decl_node (TYPE_NAME (DECL_CONTEXT (node)));
615 put_decl_string (".", 1);
616 }
617 if (! DECL_CONSTRUCTOR_P (node))
618 put_decl_node (DECL_NAME (node));
619 if (TREE_TYPE (node) != NULL_TREE)
620 {
621 int i = 0;
622 tree args = TYPE_ARG_TYPES (TREE_TYPE (node));
623 if (TREE_CODE (TREE_TYPE (node)) == METHOD_TYPE)
624 args = TREE_CHAIN (args);
625 put_decl_string ("(", 1);
626 for ( ; args != end_params_node; args = TREE_CHAIN (args), i++)
627 {
628 if (i > 0)
629 put_decl_string (",", 1);
630 put_decl_node (TREE_VALUE (args));
631 }
632 put_decl_string (")", 1);
633 }
634 }
635 else
636 put_decl_node (DECL_NAME (node));
637 }
638 else if (TREE_CODE_CLASS (TREE_CODE (node)) == 't'
639 && TYPE_NAME (node) != NULL_TREE)
640 {
641 if (TREE_CODE (node) == RECORD_TYPE && TYPE_ARRAY_P (node))
642 {
643 put_decl_node (TYPE_ARRAY_ELEMENT (node));
644 put_decl_string("[]", 2);
645 }
646 else if (node == promoted_byte_type_node)
647 put_decl_string ("byte", 4);
648 else if (node == promoted_short_type_node)
649 put_decl_string ("short", 5);
650 else if (node == promoted_char_type_node)
651 put_decl_string ("char", 4);
652 else if (node == promoted_boolean_type_node)
653 put_decl_string ("boolean", 7);
654 else if (node == void_type_node && was_pointer)
655 put_decl_string ("null", 4);
656 else
657 put_decl_node (TYPE_NAME (node));
658 }
659 else if (TREE_CODE (node) == IDENTIFIER_NODE)
660 put_decl_string (IDENTIFIER_POINTER (node), IDENTIFIER_LENGTH (node));
661 else
662 put_decl_string ("<unknown>", -1);
663 }
664
665 /* Return a user-friendly name for DECL.
666 The resulting string is only valid until the next call.
667 The value of the hook decl_printable_name is this function,
668 which is also called directly by java_print_error_function. */
669
670 const char *
671 lang_printable_name (decl, v)
672 tree decl;
673 int v __attribute__ ((__unused__));
674 {
675 decl_bufpos = 0;
676 put_decl_node (decl);
677 put_decl_string ("", 1);
678 return decl_buf;
679 }
680
681 /* Does the same thing that lang_printable_name, but add a leading
682 space to the DECL name string -- With Leading Space. */
683
684 const char *
685 lang_printable_name_wls (decl, v)
686 tree decl;
687 int v __attribute__ ((__unused__));
688 {
689 decl_bufpos = 1;
690 put_decl_node (decl);
691 put_decl_string ("", 1);
692 decl_buf [0] = ' ';
693 return decl_buf;
694 }
695
696 /* Print on stderr the current class and method context. This function
697 is the value of the hook print_error_function. */
698
699 static void
700 java_print_error_function (context, file)
701 diagnostic_context *context __attribute__((__unused__));
702 const char *file;
703 {
704 static tree last_error_function_context = NULL_TREE;
705 static tree last_error_function = NULL;
706 static int initialized_p;
707
708 /* Register LAST_ERROR_FUNCTION_CONTEXT and LAST_ERROR_FUNCTION with
709 the garbage collector. */
710 if (!initialized_p)
711 {
712 ggc_add_tree_root (&last_error_function_context, 1);
713 ggc_add_tree_root (&last_error_function, 1);
714 initialized_p = 1;
715 }
716
717 /* Don't print error messages with bogus function prototypes. */
718 if (inhibit_error_function_printing)
719 return;
720
721 if (current_function_decl != NULL
722 && DECL_CONTEXT (current_function_decl) != last_error_function_context)
723 {
724 if (file)
725 fprintf (stderr, "%s: ", file);
726
727 last_error_function_context = DECL_CONTEXT (current_function_decl);
728 fprintf (stderr, "In class `%s':\n",
729 lang_printable_name (last_error_function_context, 0));
730 }
731 if (last_error_function != current_function_decl)
732 {
733 if (file)
734 fprintf (stderr, "%s: ", file);
735
736 if (current_function_decl == NULL)
737 fprintf (stderr, "At top level:\n");
738 else
739 {
740 const char *name = lang_printable_name (current_function_decl, 2);
741 fprintf (stderr, "In %s `%s':\n",
742 (DECL_CONSTRUCTOR_P (current_function_decl) ? "constructor"
743 : "method"),
744 name);
745 }
746
747 last_error_function = current_function_decl;
748 }
749
750 }
751
752 /* Called to install the PRINT_ERROR_FUNCTION hook differently
753 according to LEVEL. LEVEL is 1 during early parsing, when function
754 prototypes aren't fully resolved. java_print_error_function is set
755 so it doesn't print incomplete function prototypes. When LEVEL is
756 2, function prototypes are fully resolved and can be printed when
757 reporting errors. */
758
759 void lang_init_source (level)
760 int level;
761 {
762 inhibit_error_function_printing = (level == 1);
763 }
764
765 static void
766 java_init_options ()
767 {
768 flag_bounds_check = 1;
769 flag_exceptions = 1;
770 flag_non_call_exceptions = 1;
771
772 /* In Java floating point operations never trap. */
773 flag_trapping_math = 0;
774 }