summaryrefslogtreecommitdiff
path: root/gcc/java
diff options
context:
space:
mode:
authorapbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4>1999-07-20 20:56:10 +0000
committerapbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4>1999-07-20 20:56:10 +0000
commitf1bf91b635c19a257b9466b6689183a6c0798633 (patch)
tree5ca1ceb178214a9ef4598a10e5149aadc81751b4 /gcc/java
parent4534ad55b05139272139eeedbdf7c11dff5a0aa6 (diff)
downloadgcc-f1bf91b635c19a257b9466b6689183a6c0798633.tar.gz
Tue Jul 20 13:20:05 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* parse.y (resolve_and_layout): Check methods only once. (resolve_qualified_expression_name): Verify thrown exceptions compatibility. (check_thrown_exceptions): Reject exceptions thrown in initializer. Error message tuned. (This fixes PR #12. Libgcj's java/net must be updated in order to compiles with a patch at this URL: http://sourceware.cygnus.com/ml/java-patches/1999-q3/msg00048.html) git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@28196 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java')
-rw-r--r--gcc/java/ChangeLog8
-rw-r--r--gcc/java/parse.c36
-rw-r--r--gcc/java/parse.y36
3 files changed, 64 insertions, 16 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index d170b3db10d..2e7bb3a715d 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,11 @@
+Tue Jul 20 13:20:05 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
+
+ * parse.y (resolve_and_layout): Check methods only once.
+ (resolve_qualified_expression_name): Verify thrown exceptions
+ compatibility.
+ (check_thrown_exceptions): Reject exceptions thrown in
+ initializer. Error message tuned.
+
1999-07-14 Andrew Haley <aph@cygnus.com>
* expr.c (expand_expr): Do not return the last statement in a
diff --git a/gcc/java/parse.c b/gcc/java/parse.c
index cdb62d71b75..e36ef3f3cc9 100644
--- a/gcc/java/parse.c
+++ b/gcc/java/parse.c
@@ -6922,7 +6922,9 @@ resolve_and_layout (something, cl)
/* Resolve and layout if necessary */
layout_class_methods (TREE_TYPE (decl));
- if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)))
+ /* Check methods, but only once */
+ if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl))
+ && !CLASS_LOADED_P (TREE_TYPE (decl)))
CHECK_METHODS (decl);
if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
safe_layout_class (TREE_TYPE (decl));
@@ -9018,6 +9020,8 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
{
tree qual_wfl = QUAL_WFL (q);
+ tree ret_decl; /* for EH checking */
+ int location; /* for EH checking */
/* 15.10.1 Field Access Using a Primary */
switch (TREE_CODE (qual_wfl))
@@ -9036,14 +9040,21 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
/* And code for the function call */
if (complete_function_arguments (qual_wfl))
return 1;
+
if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
CALL_USING_SUPER (qual_wfl) = 1;
- *where_found =
- patch_method_invocation (qual_wfl, decl, type, &is_static, NULL);
+ location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
+ EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
+ *where_found = patch_method_invocation (qual_wfl, decl, type,
+ &is_static, &ret_decl);
if (*where_found == error_mark_node)
return 1;
*type_found = type = QUAL_DECL_TYPE (*where_found);
+ /* EH check */
+ if (location)
+ check_thrown_exceptions (location, ret_decl);
+
/* If the previous call was static and this one is too,
build a compound expression to hold the two (because in
that case, previous function calls aren't transported as
@@ -14040,11 +14051,20 @@ check_thrown_exceptions (location, decl)
continue;
#endif
EXPR_WFL_LINECOL (wfl_operator) = location;
- parse_error_context
- (wfl_operator, "Exception `%s' must be caught, or it must be "
- "declared in the `throws' clause of `%s'",
- lang_printable_name (TREE_VALUE (throws), 0),
- IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
+ if (DECL_NAME (current_function_decl) == finit_identifier_node)
+ parse_error_context
+ (wfl_operator, "Exception `%s' can't be thrown in initializer",
+ lang_printable_name (TREE_VALUE (throws), 0));
+ else
+ {
+ parse_error_context
+ (wfl_operator, "Exception `%s' must be caught, or it must be "
+ "declared in the `throws' clause of `%s'",
+ lang_printable_name (TREE_VALUE (throws), 0),
+ (DECL_NAME (current_function_decl) == init_identifier_node ?
+ IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
+ IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
+ }
}
}
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 4a4b3245375..be1c788b8de 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -4335,7 +4335,9 @@ resolve_and_layout (something, cl)
/* Resolve and layout if necessary */
layout_class_methods (TREE_TYPE (decl));
- if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)))
+ /* Check methods, but only once */
+ if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl))
+ && !CLASS_LOADED_P (TREE_TYPE (decl)))
CHECK_METHODS (decl);
if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
safe_layout_class (TREE_TYPE (decl));
@@ -6431,6 +6433,8 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
{
tree qual_wfl = QUAL_WFL (q);
+ tree ret_decl; /* for EH checking */
+ int location; /* for EH checking */
/* 15.10.1 Field Access Using a Primary */
switch (TREE_CODE (qual_wfl))
@@ -6449,14 +6453,21 @@ resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
/* And code for the function call */
if (complete_function_arguments (qual_wfl))
return 1;
+
if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
CALL_USING_SUPER (qual_wfl) = 1;
- *where_found =
- patch_method_invocation (qual_wfl, decl, type, &is_static, NULL);
+ location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
+ EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
+ *where_found = patch_method_invocation (qual_wfl, decl, type,
+ &is_static, &ret_decl);
if (*where_found == error_mark_node)
return 1;
*type_found = type = QUAL_DECL_TYPE (*where_found);
+ /* EH check */
+ if (location)
+ check_thrown_exceptions (location, ret_decl);
+
/* If the previous call was static and this one is too,
build a compound expression to hold the two (because in
that case, previous function calls aren't transported as
@@ -11453,11 +11464,20 @@ check_thrown_exceptions (location, decl)
continue;
#endif
EXPR_WFL_LINECOL (wfl_operator) = location;
- parse_error_context
- (wfl_operator, "Exception `%s' must be caught, or it must be "
- "declared in the `throws' clause of `%s'",
- lang_printable_name (TREE_VALUE (throws), 0),
- IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
+ if (DECL_NAME (current_function_decl) == finit_identifier_node)
+ parse_error_context
+ (wfl_operator, "Exception `%s' can't be thrown in initializer",
+ lang_printable_name (TREE_VALUE (throws), 0));
+ else
+ {
+ parse_error_context
+ (wfl_operator, "Exception `%s' must be caught, or it must be "
+ "declared in the `throws' clause of `%s'",
+ lang_printable_name (TREE_VALUE (throws), 0),
+ (DECL_NAME (current_function_decl) == init_identifier_node ?
+ IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
+ IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
+ }
}
}