1 /* Language parser definitions for the GNU compiler for the Java(TM) language.
2 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
3 Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
5 This file is part of GNU CC.
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)
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.
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.
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. */
31 /* Extern global variable declarations */
32 extern int java_error_count;
33 extern struct obstack temporary_obstack;
34 extern struct obstack permanent_obstack;
35 extern int quiet_flag;
38 /* Function extern to java/ */
39 extern int int_fits_type_p PROTO ((tree, tree));
40 extern tree stabilize_reference PROTO ((tree));
43 /* Macros for verbose debug info */
44 #ifdef VERBOSE_SKELETON
45 #define RULE( rule ) printf ( "jv_yacc:%d: rule %s\n", lineno, rule )
50 #ifdef SOURCE_FRONTEND_DEBUG
51 #undef SOURCE_FRONTEND_DEBUG
52 #define SOURCE_FRONTEND_DEBUG(X) \
53 {if (!quiet_flag) {printf ("* "); printf X; putchar ('\n');} }
55 #define SOURCE_FRONTEND_DEBUG(X)
58 /* Macro for error recovering */
61 { if (!quiet_flag) {printf ("** Recovered\n");} }
62 #define DRECOVERED(s) \
63 { if (!quiet_flag) {printf ("** Recovered (%s)\n", #s);}}
69 #define DRECOVER(s) {yyerrok; DRECOVERED(s)}
70 #define RECOVER {yyerrok; RECOVERED}
72 #define YYERROR_NOW ctxp->java_error_flag = 1
73 #define YYNOT_TWICE if (ctxp->prevent_ese != lineno)
75 /* Accepted modifiers */
76 #define CLASS_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT|ACC_FINAL
77 #define FIELD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_FINAL| \
78 ACC_STATIC|ACC_TRANSIENT|ACC_VOLATILE
79 #define METHOD_MODIFIERS ACC_PUBLIC|ACC_PROTECTED|ACC_PRIVATE|ACC_ABSTRACT| \
80 ACC_STATIC|ACC_FINAL|ACC_SYNCHRONIZED|ACC_NATIVE
81 #define INTERFACE_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
82 #define INTERFACE_METHOD_MODIFIERS ACC_PUBLIC|ACC_ABSTRACT
83 #define INTERFACE_FIELD_MODIFIERS ACC_PUBLIC|ACC_STATIC|ACC_FINAL
85 /* Getting a modifier WFL */
86 #define MODIFIER_WFL(M) (ctxp->modifier_ctx [(M) - PUBLIC_TK])
88 /* Check on modifiers */
89 #define THIS_MODIFIER_ONLY(f, m, v, count, l) \
92 tree node = ctxp->modifier_ctx [v]; \
94 && ((EXPR_WFL_COLNO (node) > EXPR_WFL_COLNO (l)) \
95 || (EXPR_WFL_LINENO (node) > EXPR_WFL_LINENO (l)))) \
102 #define ABSTRACT_CHECK(flag, v, cl, s) \
104 parse_error_context (cl, s " method can't be abstract");
107 #define exit_java_complete_class() \
113 #define CLASS_OR_INTERFACE(decl, s1, s2) \
115 ((get_access_flags_from_decl (TYPE_NAME (TREE_TYPE (decl))) \
117 s2 : s1) : ((s1 [0]=='S'|| s1 [0]=='s') ? \
118 (s1 [0]=='S' ? "Supertype" : "supertype") : \
119 (s1 [0] > 'A' ? "Type" : "type")))
121 /* Pedantic warning on obsolete modifiers. Note: when cl is NULL,
122 flags was set artificially, such as for a interface method */
123 #define OBSOLETE_MODIFIER_WARNING(cl, flags, modifier, format, arg) \
125 if ((cl) && ((flags) & (modifier))) \
126 parse_warning_context (cl, \
127 "Discouraged redundant use of `%s' modifier " \
128 "in declaration of " format, \
129 java_accstring_lookup (modifier), arg); \
132 /* Quickly build a temporary pointer on hypothetical type NAME. */
133 #define BUILD_PTR_FROM_NAME(ptr, name) \
135 ptr = build (POINTER_TYPE, NULL_TREE); \
136 TYPE_NAME (ptr) = name; \
139 #define INCOMPLETE_TYPE_P(NODE) \
140 ((TREE_CODE (NODE) == TREE_LIST) \
141 && (TREE_CODE (TREE_PURPOSE (NODE)) == POINTER_TYPE) \
142 && (TREE_TYPE (TREE_PURPOSE (NODE)) == NULL_TREE))
144 /* Set the EMIT_LINE_NOTE flag of a EXPR_WLF to 1 if debug information
145 are requested. Works in the context of a parser rule. */
146 #define JAVA_MAYBE_GENERATE_DEBUG_INFO(node) \
147 (debug_info_level != DINFO_LEVEL_NONE ? \
148 EXPR_WFL_EMIT_LINE_NOTE (node) = 1, node : node)
150 /* Types classification, according to the JLS, section 4.2 */
151 #define JFLOAT_TYPE_P(TYPE) (TYPE && TREE_CODE ((TYPE)) == REAL_TYPE)
152 #define JINTEGRAL_TYPE_P(TYPE) ((TYPE) \
153 && (TREE_CODE ((TYPE)) == INTEGER_TYPE \
154 || TREE_CODE ((TYPE)) == CHAR_TYPE))
155 #define JNUMERIC_TYPE_P(TYPE) ((TYPE) \
156 && (JFLOAT_TYPE_P ((TYPE)) \
157 || JINTEGRAL_TYPE_P ((TYPE))))
158 #define JPRIMITIVE_TYPE_P(TYPE) ((TYPE) \
159 && (JNUMERIC_TYPE_P ((TYPE)) \
160 || TREE_CODE ((TYPE)) == BOOLEAN_TYPE))
162 /* Not defined in the LRM */
163 #define JSTRING_TYPE_P(TYPE) ((TYPE) \
164 && ((TYPE) == string_type_node || \
165 (TREE_CODE (TYPE) == POINTER_TYPE && \
166 TREE_TYPE (TYPE) == string_type_node)))
167 #define JSTRING_P(NODE) ((NODE) \
168 && (TREE_CODE (NODE) == STRING_CST \
169 || IS_CRAFTED_STRING_BUFFER_P (NODE) \
170 || JSTRING_TYPE_P (TREE_TYPE (NODE))))
172 #define JREFERENCE_TYPE_P(TYPE) ((TYPE) \
173 && (TREE_CODE (TYPE) == RECORD_TYPE \
174 || (TREE_CODE (TYPE) == POINTER_TYPE \
175 && TREE_CODE (TREE_TYPE (TYPE)) == \
178 /* Other predicate */
179 #define DECL_P(NODE) (NODE && (TREE_CODE (NODE) == PARM_DECL \
180 || TREE_CODE (NODE) == VAR_DECL \
181 || TREE_CODE (NODE) == FIELD_DECL))
183 #define TYPE_INTERFACE_P(TYPE) \
184 (CLASS_P (TYPE) && CLASS_INTERFACE (TYPE_NAME (TYPE)))
186 #define TYPE_CLASS_P(TYPE) (CLASS_P (TYPE) \
187 && !CLASS_INTERFACE (TYPE_NAME (TYPE)) \
188 && !TYPE_ARRAY_P (TYPE))
190 /* Standard error messages */
191 #define ERROR_CANT_CONVERT_TO_BOOLEAN(OPERATOR, NODE, TYPE) \
192 parse_error_context \
193 ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to " \
194 "boolean", operator_string ((NODE)), lang_printable_name ((TYPE),0))
196 #define ERROR_CANT_CONVERT_TO_NUMERIC(OPERATOR, NODE, TYPE) \
197 parse_error_context \
198 ((OPERATOR), "Incompatible type for `%s'. Can't convert `%s' to " \
199 "numeric type", operator_string ((NODE)), lang_printable_name ((TYPE), 0))
201 #define ERROR_CAST_NEEDED_TO_INTEGRAL(OPERATOR, NODE, TYPE) \
202 parse_error_context \
203 ((OPERATOR), (JPRIMITIVE_TYPE_P (TYPE) ? \
204 "Incompatible type for `%s'. Explicit cast needed to convert " \
205 "`%s' to integral" : "Incompatible type for `%s'. Can't convert " \
206 "`%s' to integral"), operator_string ((NODE)), \
207 lang_printable_name ((TYPE), 0))
209 #define ERROR_VARIABLE_NOT_INITIALIZED(WFL, V) \
210 parse_error_context \
211 ((WFL), "Variable `%s' may not have been initialized", \
212 IDENTIFIER_POINTER (V))
214 /* Definition for loop handling. This is Java's own definition of a
215 loop body. See parse.y for documentation. It's valid once you hold
216 a loop's body (LOOP_EXPR_BODY) */
218 /* The loop main block is the one hold the condition and the loop body */
219 #define LOOP_EXPR_BODY_MAIN_BLOCK(NODE) TREE_OPERAND (NODE, 0)
220 /* And then there is the loop update block */
221 #define LOOP_EXPR_BODY_UPDATE_BLOCK(NODE) TREE_OPERAND (NODE, 1)
223 /* Inside the loop main block, there is the loop condition and the
224 loop body. They may be reversed if the loop being described is a
225 do-while loop. NOTE: if you use a WFL around the EXIT_EXPR so you
226 can issue debug info for it, the EXIT_EXPR will be one operand
228 #define LOOP_EXPR_BODY_CONDITION_EXPR(NODE, R) \
229 TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 1 : 0))
231 /* Here is the labeled block the loop real body is encapsulated in */
232 #define LOOP_EXPR_BODY_LABELED_BODY(NODE, R) \
233 TREE_OPERAND (LOOP_EXPR_BODY_MAIN_BLOCK (NODE), (R ? 0 : 1))
234 /* And here is the loop's real body */
235 #define LOOP_EXPR_BODY_BODY_EXPR(NODE, R) \
236 LABELED_BLOCK_BODY (LOOP_EXPR_BODY_LABELED_BODY(NODE, R))
238 /* Does a loop have a label ? */
239 #define LOOP_HAS_LABEL_P(LOOP) \
240 (ctxp->current_labeled_block \
241 && LABELED_BLOCK_BODY (ctxp->current_labeled_block) == (LOOP))
243 /* Same operation than the one performed above, but considering the
244 previous labeled block */
245 #define LOOP_HAS_LABEL_SKIP_P(LOOP) \
246 (ctxp->current_labeled_block \
247 && TREE_CHAIN (ctxp->current_labeled_block) \
248 && LABELED_BLOCK_BODY (TREE_CHAIN (ctxp->current_labeled_block)) == (LOOP))
250 #define PUSH_LABELED_BLOCK(B) \
252 TREE_CHAIN (B) = ctxp->current_labeled_block; \
253 ctxp->current_labeled_block = (B); \
255 #define POP_LABELED_BLOCK() \
256 ctxp->current_labeled_block = TREE_CHAIN (ctxp->current_labeled_block)
258 #define PUSH_LOOP(L) \
260 TREE_CHAIN (L) = ctxp->current_loop; \
261 ctxp->current_loop = (L); \
263 #define POP_LOOP() ctxp->current_loop = TREE_CHAIN (ctxp->current_loop)
265 #define PUSH_EXCEPTIONS(E) \
266 currently_caught_type_list = \
267 tree_cons (NULL_TREE, (E), currently_caught_type_list);
269 #define POP_EXCEPTIONS() \
270 currently_caught_type_list = TREE_CHAIN (currently_caught_type_list)
272 /* Check that we're inside a try block */
273 #define IN_TRY_BLOCK_P() \
274 (currently_caught_type_list \
275 && ((TREE_VALUE (currently_caught_type_list) != \
276 DECL_FUNCTION_THROWS (current_function_decl)) \
277 || TREE_CHAIN (currently_caught_type_list)))
279 /* Check that we have exceptions in E */
280 #define EXCEPTIONS_P(E) ((E) ? TREE_VALUE (E) : NULL_TREE)
283 /* Invocation modes, as returned by invocation_mode (). */
292 /* We need the resolution stuff only if we compile jc1 */
295 /* Unresolved type identifiers handling. When we process the source
296 code, we blindly accept an unknown type identifier and try to
297 resolve it later. When an unknown type identifier is encountered
298 and used, we record in a struct jdep element what the incomplete
299 type is and what it should patch. Later, java_complete_class will
300 process all classes known to have unresolved type
301 dependencies. Within each of these classes, this routine will
302 process unresolved type dependencies (JDEP_TO_RESOLVE), patch what
303 needs to be patched in the dependent tree node (JDEP_GET_PATCH,
304 JDEP_APPLY_PATCH) and perform other actions dictated by the context
305 of the patch (JDEP_KIND). The ideas are: we patch only what needs
306 to be patched, and with java_complete_class called at the right
307 time, we will start processing incomplete function bodies tree
308 nodes with everything external to function's bodies already
309 completed, it makes things much simpler. */
312 JDEP_NO_PATCH, /* Must be first */
313 JDEP_SUPER, /* Patch the type of one type
314 supertype. Requires some check
316 JDEP_FIELD, /* Patch the type of a class field */
318 /* JDEP_{METHOD,METHOD_RETURN,METHOD_END} to be kept in order */
319 JDEP_METHOD, /* Mark the beginning of the patching
320 of a method declaration, including
322 JDEP_METHOD_RETURN, /* Mark the beginning of the patching
323 of a method declaration. Arguments
324 aren't patched, only the returned
326 JDEP_METHOD_END, /* Mark the end of the patching of a
327 method declaration. It indicates
328 that it's time to compute and
329 install a new signature */
331 JDEP_INTERFACE, /* Patch the type of a Class/interface
333 JDEP_VARIABLE, /* Patch the type of a variable declaration */
334 JDEP_PARM, /* Patch the type of a parm declaration */
335 JDEP_TYPE, /* Patch a random tree node type,
336 without the need for any specific
338 JDEP_EXCEPTION, /* Patch exceptions specified by `throws' */
341 typedef struct _jdep {
342 #ifdef ONLY_INT_FIELDS
343 int kind : 8; /* Type of patch */
345 enum jdep_code kind : 8;
348 int flag0 : 1; /* Some flags */
349 tree decl; /* Tied decl/or WFL */
350 tree solv; /* What to solve */
351 tree wfl; /* Where thing to resolve where found */
352 tree misc; /* Miscellaneous info (optional). */
353 tree *patch; /* Address of a location to patch */
354 struct _jdep *next; /* Linked list */
358 #define JDEP_DECL(J) ((J)->decl)
359 #define JDEP_DECL_WFL(J) ((J)->decl)
360 #define JDEP_KIND(J) ((J)->kind)
361 #define JDEP_SOLV(J) ((J)->solv)
362 #define JDEP_WFL(J) ((J)->wfl)
363 #define JDEP_MISC(J) ((J)->misc)
364 #define JDEP_CLASS(J) ((J)->class)
365 #define JDEP_APPLY_PATCH(J,P) (*(J)->patch = (P))
366 #define JDEP_GET_PATCH(J) ((J)->patch)
367 #define JDEP_CHAIN(J) ((J)->next)
368 #define JDEP_TO_RESOLVE(J) (TREE_PURPOSE ((J)->solv))
369 #define JDEP_RESOLVED_DECL(J) ((J)->solv ? TREE_PURPOSE ((J)->solv):NULL_TREE)
370 #define JDEP_RESOLVED(J, D) \
372 TREE_PURPOSE ((J)->solv) = D; \
373 TREE_VALUE ((J)->solv) = (J)->solv; \
375 #define JDEP_RESOLVED_P(J) (!(J)->solv || \
376 TREE_VALUE ((J)->solv) == (J)->solv)
378 typedef struct _jdeplist {
381 struct _jdeplist *next;
383 static jdeplist *reverse_jdep_list ();
385 #endif /* JC1_LITE */
387 #define CLASSD_FIRST(CD) ((CD)->first)
388 #define CLASSD_LAST(CD) ((CD)->last)
389 #define CLASSD_CHAIN(CD) ((CD)->next)
391 #define JDEP_INSERT(L,J) \
394 (L)->last = (L)->first = (J); \
397 JDEP_CHAIN ((L)->last) = (J); \
402 /* if TYPE can't be resolved, obtain something suitable for its
403 resolution (TYPE is saved in SAVE before being changed). and set
404 CHAIN to 1. Otherwise, type is set to something usable. CHAIN is
405 usually used to determine that a new DEP must be installed on TYPE. */
406 #define SET_TYPE_FOR_RESOLUTION(TYPE, SAVE, CHAIN) \
408 tree returned_type; \
410 if (unresolved_type_p (type, &returned_type)) \
413 (TYPE) = returned_type; \
417 (TYPE) = obtain_incomplete_type (TYPE); \
423 /* Insert a DECL in the current block */
424 #define BLOCK_CHAIN_DECL(NODE) \
426 TREE_CHAIN ((NODE)) = \
427 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)); \
428 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) = (NODE); \
431 #define BLOCK_EXPR_DECLS(NODE) BLOCK_VARS(NODE)
432 #define BLOCK_EXPR_BODY(NODE) BLOCK_SUBBLOCKS(NODE)
433 #define BLOCK_EXPR_ORIGIN(NODE) BLOCK_ABSTRACT_ORIGIN(NODE)
435 /* Merge an other line to the source line number of a decl. Used to
436 remember function's end. */
437 #define DECL_SOURCE_LINE_MERGE(DECL,NO) DECL_SOURCE_LINE(DECL) |= (NO << 16)
439 /* Retrieve those two info separately. */
440 #define DECL_SOURCE_LINE_FIRST(DECL) (DECL_SOURCE_LINE(DECL) & 0x0000ffff)
441 #define DECL_SOURCE_LINE_LAST(DECL) (DECL_SOURCE_LINE(DECL) >> 16)
443 /* Build a WFL for expression nodes */
444 #define BUILD_EXPR_WFL(NODE, WFL) \
445 build_expr_wfl ((NODE), input_filename, EXPR_WFL_LINENO ((WFL)), \
446 EXPR_WFL_COLNO ((WFL)))
448 #define EXPR_WFL_QUALIFICATION(WFL) TREE_OPERAND ((WFL), 1)
449 #define QUAL_WFL(NODE) TREE_PURPOSE (NODE)
450 #define QUAL_RESOLUTION(NODE) TREE_VALUE (NODE)
451 #define QUAL_DECL_TYPE(NODE) \
452 (TREE_CODE (TREE_TYPE (NODE)) == POINTER_TYPE ? \
453 TREE_TYPE (TREE_TYPE (NODE)) : TREE_TYPE (NODE))
455 /* Handy macros for the walk operation */
456 #define COMPLETE_CHECK_OP(NODE, N) \
458 TREE_OPERAND ((NODE), (N)) = \
459 java_complete_tree (TREE_OPERAND ((NODE), (N))); \
460 if (TREE_OPERAND ((NODE), (N)) == error_mark_node) \
461 return error_mark_node; \
463 #define COMPLETE_CHECK_OP_0(NODE) COMPLETE_CHECK_OP(NODE, 0)
464 #define COMPLETE_CHECK_OP_1(NODE) COMPLETE_CHECK_OP(NODE, 1)
466 /* Building invocations: append(ARG) and StringBuffer(ARG) */
467 #define BUILD_APPEND(ARG) \
468 build_method_invocation (wfl_append, \
469 (ARG ? build_tree_list (NULL, (ARG)): NULL_TREE))
470 #define BUILD_STRING_BUFFER(ARG) \
471 build_new_invocation (wfl_string_buffer, \
472 (ARG ? build_tree_list (NULL, (ARG)) : NULL_TREE))
474 /* For exception handling, build diverse function calls */
475 #define BUILD_MONITOR_ENTER(WHERE, ARG) \
477 (WHERE) = build (CALL_EXPR, int_type_node, \
478 build_address_of (soft_monitorenter_node), \
479 build_tree_list (NULL_TREE, (ARG))); \
480 TREE_SIDE_EFFECTS (WHERE) = 1; \
483 #define BUILD_MONITOR_EXIT(WHERE, ARG) \
485 (WHERE) = build (CALL_EXPR, int_type_node, \
486 build_address_of (soft_monitorexit_node), \
487 build_tree_list (NULL_TREE, (ARG))); \
488 TREE_SIDE_EFFECTS (WHERE) = 1; \
491 #define BUILD_ASSIGN_EXCEPTION_INFO(WHERE, TO) \
493 (WHERE) = build (MODIFY_EXPR, void_type_node, (TO), \
494 soft_exceptioninfo_call_node); \
495 TREE_SIDE_EFFECTS (WHERE) = 1; \
498 #define BUILD_THROW(WHERE, WHAT) \
500 (WHERE) = build (CALL_EXPR, void_type_node, \
501 build_address_of (throw_node), \
502 build_tree_list (NULL_TREE, (WHAT)), NULL_TREE); \
503 TREE_SIDE_EFFECTS ((WHERE)) = 1; \
506 /* Set wfl_operator for the most accurate error location */
507 #define SET_WFL_OPERATOR(WHICH, NODE, WFL) \
508 EXPR_WFL_LINECOL (WHICH) = \
509 (TREE_CODE (WFL) == EXPR_WITH_FILE_LOCATION ? \
510 EXPR_WFL_LINECOL (WFL) : EXPR_WFL_LINECOL (NODE))
512 #define PATCH_METHOD_RETURN_ERROR() \
515 *ret_decl = NULL_TREE; \
516 return error_mark_node; \
519 /* Parser context data structure. */
522 char *filename; /* Current filename */
523 FILE *finput; /* Current file input stream */
524 struct parser_ctxt *next;
526 struct java_line *p_line, *c_line; /* Previous and current line */
527 java_lc elc; /* Error's line column info */
528 unicode_t unget_utf8_value; /* An unget utf8 value */
529 int ccb_indent; /* Keep track of {} indent, lexer */
530 int first_ccb_indent1; /* First { at ident level 1 */
531 int last_ccb_indent1; /* Last } at ident level 1 */
532 int parser_ccb_indent; /* Keep track of {} indent, parser */
533 int osb_number; /* Keep track of ['s */
534 int minus_seen; /* Integral literal overflow */
535 int lineno; /* Current lineno */
536 int java_error_flag; /* Report error when true */
538 /* This section is defined only if we compile jc1 */
540 tree modifier_ctx [11]; /* WFL of modifiers */
541 tree current_class; /* Current class */
542 tree current_function_decl; /* Current function decl, save/restore */
544 JCF *current_jcf; /* CU jcf */
546 int prevent_ese; /* Prevent expression statement error */
547 int class_err; /* Flag to report certain errors */
549 int formal_parameter_number; /* Number of parameters found */
550 int interface_number; /* # itfs declared to extend an itf def */
552 tree package; /* Defined package ID */
554 tree incomplete_class; /* List of non-complete classes */
555 tree current_parsed_class; /* Class currently parsed */
556 tree class_list; /* List of classes in a CU */
557 jdeplist *classd_list; /* Classe dependencies in a CU */
559 tree non_static_initialized; /* List of non static initialized fields */
560 tree static_initialized; /* List of static non final initialized */
562 tree import_list; /* List of import */
563 tree import_demand_list; /* List of import on demand */
565 tree current_loop; /* List of the currently nested loops */
566 tree current_labeled_block; /* List of currently nested
569 int pending_block; /* Pending block to close */
570 #endif /* JC1_LITE */
573 /* Functions declarations */
575 static char *java_accstring_lookup PROTO ((int));
576 static void parse_error PROTO ((char *));
577 static void classitf_redefinition_error PROTO ((char *,tree, tree, tree));
578 static void variable_redefinition_error PROTO ((tree, tree, tree, int));
579 static void check_modifiers PROTO ((char *, int, int));
580 static tree create_class PROTO ((int, tree, tree, tree));
581 static tree create_interface PROTO ((int, tree, tree));
582 static tree find_field PROTO ((tree, tree));
583 static tree lookup_field_wrapper PROTO ((tree, tree));
584 static int duplicate_declaration_error_p PROTO ((tree, tree, tree));
585 static void register_fields PROTO ((int, tree, tree));
586 static tree parser_qualified_classname PROTO ((tree));
587 static int parser_check_super PROTO ((tree, tree, tree));
588 static int parser_check_super_interface PROTO ((tree, tree, tree));
589 static void check_modifiers_consistency PROTO ((int));
590 static tree lookup_cl PROTO ((tree));
591 static tree lookup_java_method2 PROTO ((tree, tree, int));
592 static tree method_header PROTO ((int, tree, tree, tree));
593 static tree method_declarator PROTO ((tree, tree));
594 static void parse_error_context VPROTO ((tree cl, char *msg, ...));
595 static void parse_warning_context VPROTO ((tree cl, char *msg, ...));
596 static tree parse_jdk1_1_error PROTO ((char *));
597 static void complete_class_report_errors PROTO ((jdep *));
598 static int process_imports PROTO ((void));
599 static void read_import_dir PROTO ((tree));
600 static int find_in_imports_on_demand PROTO ((tree));
601 static int find_in_imports PROTO ((tree));
602 static int check_pkg_class_access PROTO ((tree, tree));
603 static tree resolve_class PROTO ((tree, tree, tree));
604 static tree do_resolve_class PROTO ((tree, tree, tree));
605 static void declare_local_variables PROTO ((int, tree, tree));
606 static void source_start_java_method PROTO ((tree));
607 static void source_end_java_method PROTO ((void));
608 static void expand_start_java_method PROTO ((tree));
609 static tree find_name_in_single_imports PROTO ((tree));
610 static void check_abstract_method_header PROTO ((tree));
611 static tree lookup_java_interface_method2 PROTO ((tree, tree));
612 static tree resolve_expression_name PROTO ((tree));
613 static tree maybe_create_class_interface_decl PROTO ((tree, tree, tree));
614 static int check_class_interface_creation PROTO ((int, int, tree, tree, tree, tree));
615 static tree patch_method_invocation_stmt PROTO ((tree, tree, tree, int *, tree *));
616 static int breakdown_qualified PROTO ((tree *, tree *, tree));
617 static tree resolve_and_layout PROTO ((tree, tree));
618 static tree resolve_no_layout PROTO ((tree, tree));
619 static int invocation_mode PROTO ((tree, int));
620 static tree find_applicable_accessible_methods_list PROTO ((tree, tree, tree));
621 static tree find_most_specific_methods_list PROTO ((tree));
622 static int argument_types_convertible PROTO ((tree, tree));
623 static tree patch_invoke PROTO ((tree, tree, tree));
624 static tree lookup_method_invoke PROTO ((int, tree, tree, tree, tree));
625 static tree register_incomplete_type PROTO ((int, tree, tree, tree));
626 static tree obtain_incomplete_type PROTO ((tree));
627 static tree java_complete_tree PROTO ((tree));
628 static void java_complete_expand_method PROTO ((tree));
629 static int unresolved_type_p PROTO ((tree, tree *));
630 static void create_jdep_list PROTO ((struct parser_ctxt *));
631 static tree build_expr_block PROTO ((tree, tree));
632 static tree enter_block PROTO ((void));
633 static tree enter_a_block PROTO ((tree));
634 static tree exit_block PROTO ((void));
635 static tree lookup_name_in_blocks PROTO ((tree));
636 static void maybe_absorb_scoping_blocks PROTO ((void));
637 static tree build_method_invocation PROTO ((tree, tree));
638 static tree build_new_invocation PROTO ((tree, tree));
639 static tree build_assignment PROTO ((int, int, tree, tree));
640 static tree build_binop PROTO ((enum tree_code, int, tree, tree));
641 static tree patch_assignment PROTO ((tree, tree, tree ));
642 static tree patch_binop PROTO ((tree, tree, tree));
643 static tree build_unaryop PROTO ((int, int, tree));
644 static tree build_incdec PROTO ((int, int, tree, int));
645 static tree patch_unaryop PROTO ((tree, tree));
646 static tree build_cast PROTO ((int, tree, tree));
647 static tree patch_cast PROTO ((tree, tree));
648 static int valid_ref_assignconv_cast_p PROTO ((tree, tree, int));
649 static int valid_builtin_assignconv_identity_widening_p PROTO ((tree, tree));
650 static int valid_cast_to_p PROTO ((tree, tree));
651 static int valid_method_invocation_conversion_p PROTO ((tree, tree));
652 static tree try_builtin_assignconv PROTO ((tree, tree, tree));
653 static tree try_reference_assignconv PROTO ((tree, tree));
654 static tree build_unresolved_array_type PROTO ((tree));
655 static tree build_array_from_name PROTO ((tree, tree, tree, tree *));
656 static tree build_array_ref PROTO ((int, tree, tree));
657 static tree patch_array_ref PROTO ((tree, tree, tree));
658 static tree make_qualified_name PROTO ((tree, tree, int));
659 static tree merge_qualified_name PROTO ((tree, tree));
660 static tree make_qualified_primary PROTO ((tree, tree, int));
661 static int resolve_qualified_expression_name PROTO ((tree, tree *, tree *, tree *));
662 static void qualify_ambiguous_name PROTO ((tree));
663 static void maybe_generate_clinit PROTO ((void));
664 static tree resolve_field_access PROTO ((tree, tree *, tree *));
665 static tree build_newarray_node PROTO ((tree, tree, int));
666 static tree patch_newarray PROTO ((tree));
667 static tree resolve_type_during_patch PROTO ((tree));
668 static int not_initialized_as_it_should_p PROTO ((tree));
669 static tree build_this PROTO ((int));
670 static tree build_return PROTO ((int, tree));
671 static tree patch_return PROTO ((tree));
672 static tree maybe_access_field PROTO ((tree, tree, tree));
673 static int complete_function_arguments PROTO ((tree));
674 static int check_for_static_method_reference PROTO ((tree, tree, tree, tree, tree));
675 static int not_accessible_p PROTO ((tree, tree, int));
676 static int class_in_current_package PROTO ((tree));
677 static tree build_if_else_statement PROTO ((int, tree, tree, tree));
678 static tree patch_if_else_statement PROTO ((tree));
679 static tree add_stmt_to_compound PROTO ((tree, tree, tree));
680 static tree add_stmt_to_block PROTO ((tree, tree, tree));
681 static tree patch_exit_expr PROTO ((tree));
682 static tree build_labeled_block PROTO ((int, tree));
683 static tree generate_labeled_block PROTO (());
684 static tree complete_labeled_statement PROTO ((tree, tree));
685 static tree build_bc_statement PROTO ((int, int, tree));
686 static tree patch_bc_statement PROTO ((tree));
687 static tree patch_loop_statement PROTO ((tree));
688 static tree build_new_loop PROTO ((tree));
689 static tree build_loop_body PROTO ((int, tree, int));
690 static tree complete_loop_body PROTO ((int, tree, tree, int));
691 static tree build_debugable_stmt PROTO ((int, tree));
692 static tree complete_for_loop PROTO ((int, tree, tree, tree));
693 static tree patch_switch_statement PROTO ((tree));
694 static tree string_constant_concatenation PROTO ((tree, tree));
695 static tree build_string_concatenation PROTO ((tree, tree));
696 static tree patch_string_cst PROTO ((tree));
697 static tree patch_string PROTO ((tree));
698 static tree build_jump_to_finally PROTO ((tree, tree, tree, tree));
699 static tree build_try_statement PROTO ((int, tree, tree, tree));
700 static tree patch_try_statement PROTO ((tree));
701 static tree patch_synchronized_statement PROTO ((tree, tree));
702 static tree patch_throw_statement PROTO ((tree, tree));
703 static void check_thrown_exceptions PROTO ((int, tree));
704 static int check_thrown_exceptions_do PROTO ((tree));
705 static void purge_unchecked_exceptions PROTO ((tree));
706 static void check_throws_clauses PROTO ((tree, tree, tree));
708 void safe_layout_class PROTO ((tree));
709 void java_complete_class PROTO ((void));
710 void java_check_circular_reference PROTO ((void));
711 void java_check_final PROTO ((void));
712 void java_check_methods PROTO ((void));
713 void java_layout_classes PROTO ((void));
714 tree java_method_add_stmt PROTO ((tree, tree));
715 char *java_get_line_col PROTO ((char *, int, int));
716 void java_expand_switch PROTO ((tree));
717 tree java_get_catch_block PROTO ((tree, int));
718 #endif /* JC1_LITE */
720 /* Always in use, no matter what you compile */
722 void java_push_parser_context PROTO ((void));
723 void java_pop_parser_context PROTO ((int));
724 void java_init_lex PROTO ((void));
725 int yyparse PROTO ((void));
727 void yyerror PROTO ((char *));