OSDN Git Service

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