aboutsummaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorAlexandre Petit-Bianco <apbianco@redhat.com>2001-08-27 07:46:57 -0700
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>2001-08-27 07:46:57 -0700
commit7b02957ec0bb9659ac70b26d8af7e3fbdc4120b0 (patch)
tree152fb4a4d6d6ad312e62373637163f94729dcb6c /gcc/java
parent763bb30cbef3217ab6b36688ff8c15ae765c9666 (diff)
downloadgcc-7b02957ec0bb9659ac70b26d8af7e3fbdc4120b0.zip
gcc-7b02957ec0bb9659ac70b26d8af7e3fbdc4120b0.tar.gz
gcc-7b02957ec0bb9659ac70b26d8af7e3fbdc4120b0.tar.bz2
parse.y (check_deprecation): Handle TYPE_DECL in a special case...
2001-08-24 Alexandre Petit-Bianco <apbianco@redhat.com> * parse.y (check_deprecation): Handle TYPE_DECL in a special case, don't report anything but deprecated class when marked so. Handle VAR_DECL. (patch_method_invocation): Check deprecation on methods and types. (patch_binop): code becomes an enum tree_code, added default: to switch to handle that. Detect division by zero, try to fold and return before using a subroutine. (http://gcc.gnu.org/ml/gcc-patches/2001-08/msg01495.html) From-SVN: r45187
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog10
-rw-r--r--gcc/java/parse.y52
2 files changed, 54 insertions, 8 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 831a380..a54af0d 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,13 @@
+2001-08-24 Alexandre Petit-Bianco <apbianco@redhat.com>
+
+ * parse.y (check_deprecation): Handle TYPE_DECL in a special case,
+ don't report anything but deprecated class when marked so. Handle
+ VAR_DECL.
+ (patch_method_invocation): Check deprecation on methods and types.
+ (patch_binop): code becomes an enum tree_code, added default: to
+ switch to handle that. Detect division by zero, try to fold and
+ return before using a subroutine.
+
2001-08-23 Alexandre Petit-Bianco <apbianco@redhat.com>
* jcf-parse.c (yyparse): Set magic to 0, don't issue error for a
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index b6054d4..8a51483 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -9938,18 +9938,23 @@ check_deprecation (wfl, decl)
strcpy (the, "method");
break;
case FIELD_DECL:
+ case VAR_DECL:
strcpy (the, "field");
break;
case TYPE_DECL:
- strcpy (the, "class");
- break;
+ parse_warning_context (wfl, "The class `%s' has been deprecated",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ return;
default:
abort ();
}
- parse_warning_context
- (wfl, "The %s `%s' in class `%s' has been deprecated",
- the, lang_printable_name (decl, 0),
- IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
+ /* Don't issue a message if the context as been deprecated as a
+ whole. */
+ if (! CLASS_DEPRECATED (TYPE_NAME (DECL_CONTEXT (decl))))
+ parse_warning_context
+ (wfl, "The %s `%s' in class `%s' has been deprecated",
+ the, lang_printable_name (decl, 0),
+ IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
}
}
@@ -10308,7 +10313,13 @@ patch_method_invocation (patch, primary, where, from_super,
access, what, klass, fct_name, refklass);
PATCH_METHOD_RETURN_ERROR ();
}
- check_deprecation (wfl, list);
+
+ /* Deprecation check: check whether the method being invoked or the
+ instance-being-created's type are deprecated. */
+ if (TREE_CODE (patch) == NEW_CLASS_EXPR)
+ check_deprecation (wfl, TYPE_NAME (DECL_CONTEXT (list)));
+ else
+ check_deprecation (wfl, list);
/* If invoking a innerclass constructor, there are hidden parameters
to pass */
@@ -13416,7 +13427,7 @@ patch_binop (node, wfl_op1, wfl_op2)
tree op1_type = TREE_TYPE (op1);
tree op2_type = TREE_TYPE (op2);
tree prom_type = NULL_TREE, cn;
- int code = TREE_CODE (node);
+ enum tree_code code = TREE_CODE (node);
/* If 1, tell the routine that we have to return error_mark_node
after checking for the initialization of the RHS */
@@ -13462,10 +13473,33 @@ patch_binop (node, wfl_op1, wfl_op2)
break;
}
prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
+
+ /* Detect integral division by zero */
+ if ((code == RDIV_EXPR || code == TRUNC_MOD_EXPR)
+ && TREE_CODE (prom_type) == INTEGER_TYPE
+ && (op2 == integer_zero_node || op2 == long_zero_node ||
+ (TREE_CODE (op2) == INTEGER_CST &&
+ ! TREE_INT_CST_LOW (op2) && ! TREE_INT_CST_HIGH (op2))))
+ {
+ parse_error_context (wfl_operator, "Arithmetic exception");
+ error_found = 1;
+ }
+
/* Change the division operator if necessary */
if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
TREE_SET_CODE (node, TRUNC_DIV_EXPR);
+ /* Before divisions as is disapear, try to simplify and bail if
+ applicable, otherwise we won't perform even simple simplifications
+ like (1-1)/3. */
+ if (code == RDIV_EXPR && TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
+ {
+ TREE_TYPE (node) = prom_type;
+ node = fold (node);
+ if (TREE_CODE (node) != code)
+ return node;
+ }
+
if (TREE_CODE (prom_type) == INTEGER_TYPE
&& flag_use_divide_subroutine
&& ! flag_emit_class_files
@@ -13753,6 +13787,8 @@ patch_binop (node, wfl_op1, wfl_op2)
}
prom_type = boolean_type_node;
break;
+ default:
+ abort ();
}
if (error_found)