diff options
author | Alexandre Petit-Bianco <apbianco@cygnus.com> | 1999-05-13 14:33:37 +0000 |
---|---|---|
committer | Alexandre Petit-Bianco <apbianco@gcc.gnu.org> | 1999-05-13 07:33:37 -0700 |
commit | ce6e914727336e47ee2d336d13b1fc787342215d (patch) | |
tree | 8b33779181f3c705df69fddd4b380a96ae56cb2b /gcc/java/parse.y | |
parent | 19ba816140b04fd28edfb4d25c5618f4fdec89bc (diff) | |
download | gcc-ce6e914727336e47ee2d336d13b1fc787342215d.zip gcc-ce6e914727336e47ee2d336d13b1fc787342215d.tar.gz gcc-ce6e914727336e47ee2d336d13b1fc787342215d.tar.bz2 |
check-init.c (check_init): Removed code accepting to see things falling through default:, when doing xrefs.
Thu May 13 13:23:38 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* check-init.c (check_init): Removed code accepting to see things
falling through default:, when doing xrefs.
* java-tree.h (do_not_fold): New global variable, declared.
* parse.y (do_not_fold): New global variable, defined.
(java_complete_expand_method): Set `do_not_fold' to the value of
`flag_emit_xref'. When doing xrefs: copy the thrown exceptions,
and reinstall them after them have been purged; do not check for
initializations; do not issue missing return errors.
(java_complete_lhs): Do not attempt to patch INSTANCEOF_EXPR nodes
when doing xrefs.
(patch_binop): Skip the fold part when doing xrefs.
(build_string_concatenation): Skip the concatenation part when
doing xrefs.
(patch_synchronized_statement): Do not generate a try-finally when
doing xrefs.
(patch_throw_statement): When doing xrefs, do not call BUILD_THROW
and keep the location where the throw was seen.
* typeck.c (convert): When `do_not_fold' is set, do not attempt
any treatment on the converted node an simply return a NOP_EXPR of
the targeted type.
* xref.c (xref_get_data): New function, defined.
* xref.h (xref_get_data): New function, declared.
(XREF_GET_DATA): Use xref_get_data.
From-SVN: r26926
Diffstat (limited to 'gcc/java/parse.y')
-rw-r--r-- | gcc/java/parse.y | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/gcc/java/parse.y b/gcc/java/parse.y index ac1876c..dbf7fe4 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -247,6 +247,8 @@ static void static_ref_err PROTO ((tree, tree, tree)); int java_error_count; /* Number of warning found so far. */ int java_warning_count; +/* Tell when not to fold, when doing xrefs */ +int do_not_fold; /* The current parser context */ struct parser_ctxt *ctxp; @@ -5706,6 +5708,8 @@ void java_complete_expand_methods () { tree current; + + do_not_fold = flag_emit_xref; for (current = ctxp->class_list; current; current = TREE_CHAIN (current)) { @@ -5819,6 +5823,7 @@ java_complete_expand_method (mdecl) { tree fbody = DECL_FUNCTION_BODY (mdecl); tree block_body = BLOCK_EXPR_BODY (fbody); + tree exception_copy; expand_start_java_method (mdecl); build_result_decl (mdecl); @@ -5826,7 +5831,12 @@ java_complete_expand_method (mdecl) = (!METHOD_STATIC (mdecl) ? BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE); - /* Purge the `throws' list of unchecked exceptions */ + /* Purge the `throws' list of unchecked exceptions. If we're + doing xref, save a copy of the list and re-install it + later. */ + if (flag_emit_xref) + exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl)); + purge_unchecked_exceptions (mdecl); /* Install exceptions thrown with `throws' */ @@ -5835,13 +5845,15 @@ java_complete_expand_method (mdecl) if (block_body != NULL_TREE) { block_body = java_complete_tree (block_body); - check_for_initialization (block_body); + if (!flag_emit_xref) + check_for_initialization (block_body); ctxp->explicit_constructor_p = 0; } BLOCK_EXPR_BODY (fbody) = block_body; if ((block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body)) - && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE) + && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE + && !flag_emit_xref) missing_return_error (current_function_decl); complete_start_java_method (mdecl); @@ -5860,6 +5872,9 @@ java_complete_expand_method (mdecl) POP_EXCEPTIONS(); if (currently_caught_type_list) fatal ("Exception list non empty - java_complete_expand_method"); + + if (flag_emit_xref) + DECL_FUNCTION_THROWS (mdecl) = exception_copy; } } @@ -7871,7 +7886,7 @@ java_complete_lhs (node) /* First, the case expression must be constant */ cn = fold (cn); - if (!TREE_CONSTANT (cn)) + if (!TREE_CONSTANT (cn) && !flag_emit_xref) { EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node); parse_error_context (node, "Constant expression required"); @@ -8229,6 +8244,11 @@ java_complete_lhs (node) case INSTANCEOF_EXPR: wfl_op1 = TREE_OPERAND (node, 0); COMPLETE_CHECK_OP_0 (node); + if (flag_emit_xref) + { + TREE_TYPE (node) = boolean_type_node; + return node; + } return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1)); case UNARY_PLUS_EXPR: @@ -9508,6 +9528,9 @@ patch_binop (node, wfl_op1, wfl_op2) TREE_TYPE (node) = prom_type; TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2); + if (flag_emit_xref) + return node; + /* fold does not respect side-effect order as required for Java but not C. * Also, it sometimes create SAVE_EXPRs which are bad when emitting * bytecode. @@ -9635,6 +9658,9 @@ build_string_concatenation (op1, op2) { tree result; int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2); + + if (flag_emit_xref) + return build (PLUS_EXPR, string_type_node, op1, op2); /* Try to do some static optimization */ if ((result = string_constant_concatenation (op1, op2))) @@ -11121,6 +11147,14 @@ patch_synchronized_statement (node, wfl_op1) return error_mark_node; } + if (flag_emit_xref) + { + TREE_OPERAND (node, 0) = expr; + TREE_OPERAND (node, 1) = java_complete_tree (block); + CAN_COMPLETE_NORMALLY (node) = 1; + return node; + } + /* Generate a try-finally for the synchronized statement, except that the handler that catches all throw exception calls _Jv_MonitorExit and then rethrow the exception. @@ -11234,8 +11268,12 @@ patch_throw_statement (node, wfl_op1) return error_mark_node; } - if (! flag_emit_class_files) + if (! flag_emit_class_files && ! flag_emit_xref) BUILD_THROW (node, expr); + + /* If doing xrefs, keep the location where the `throw' was seen. */ + if (flag_emit_xref) + EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1); return node; } |