summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorapbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4>1999-04-21 13:49:49 +0000
committerapbianco <apbianco@138bc75d-0d04-0410-961f-82ee72b054a4>1999-04-21 13:49:49 +0000
commit53bd31b59a04dd78049c5bbc67c4d26f98c7653f (patch)
tree6a4397f5304c150cbe5d79eab70071c1fe5a446a /gcc
parentbb5daf981dd9bf2a57d8bc80a238f5cf9d2922dd (diff)
downloadgcc-53bd31b59a04dd78049c5bbc67c4d26f98c7653f.tar.gz
Wed Apr 21 11:13:36 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* decl.c (predef_filenames, predef_filenames_size): New globals (init_decl_processing): predef_filenames and predef_filenames_size initialized. * java-tree.h (predef_filenames, predef_filenames_size): Declared extern. * jcf-parse.c (predefined_filename_p): New function. (yyparse): Check that files on the command line are specified only once and issue a warning otherwise. * parse.h (JPRIMITIVE_TYPE_OR_VOID_P): New macro. * parse.y (source_end_java_method): Nullify NOP method bodies, to avoid a gcc warning with -W -Wall turned on. (java_expand_classes): Abort if errors were encountered. (java_complete_lhs): If the cross reference flag is set, wrap field DECL node around a WFL when resolving expression name. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26578 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/java/ChangeLog19
-rw-r--r--gcc/java/decl.c16
-rw-r--r--gcc/java/java-tree.h3
-rw-r--r--gcc/java/jcf-parse.c52
-rw-r--r--gcc/java/parse.c39
-rw-r--r--gcc/java/parse.h3
-rw-r--r--gcc/java/parse.y16
7 files changed, 132 insertions, 16 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 39e4c86f3b8..cac0f2bb53f 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,20 @@
+Wed Apr 21 11:13:36 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
+
+ * decl.c (predef_filenames, predef_filenames_size): New globals
+ (init_decl_processing): predef_filenames and predef_filenames_size
+ initialized.
+ * java-tree.h (predef_filenames, predef_filenames_size): Declared
+ extern.
+ * jcf-parse.c (predefined_filename_p): New function.
+ (yyparse): Check that files on the command line are specified only
+ once and issue a warning otherwise.
+ * parse.h (JPRIMITIVE_TYPE_OR_VOID_P): New macro.
+ * parse.y (source_end_java_method): Nullify NOP method bodies, to
+ avoid a gcc warning with -W -Wall turned on.
+ (java_expand_classes): Abort if errors were encountered.
+ (java_complete_lhs): If the cross reference flag is set, wrap
+ field DECL node around a WFL when resolving expression name.
+
Mon Apr 19 14:44:48 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
* lang.c (lang_decode_option): Fixed returned value when parsing
@@ -6,7 +23,7 @@ Mon Apr 19 14:44:48 1999 Alexandre Petit-Bianco <apbianco@cygnus.com>
flag_emit_xref is set.
(resolve_expression_name): Do not build static field access when
flag_emit_xref is set.
- (resolve_field_access): No special treatement on `length' when
+ (resolve_field_access): No special treatment on `length' when
flag_emit_xref is set. Do not build qualified static field access
when flag_emit_xref is set.
(patch_invoke): Keep the method DECL as operand 0 of the CALL_EXPR
diff --git a/gcc/java/decl.c b/gcc/java/decl.c
index 110945460d1..f248ad2fb40 100644
--- a/gcc/java/decl.c
+++ b/gcc/java/decl.c
@@ -257,6 +257,8 @@ tree string_type_node;
tree throwable_type_node;
tree runtime_exception_type_node;
tree error_exception_type_node;
+tree *predef_filenames;
+int predef_filenames_size;
tree boolean_type_node;
@@ -540,6 +542,9 @@ init_decl_processing ()
float_zero_node = build_real (float_type_node, dconst0);
double_zero_node = build_real (double_type_node, dconst0);
+ /* As your adding items here, please update the code right after
+ this section, so that the filename containing the source code of
+ the pre-defined class gets registered correctly. */
unqualified_object_id_node = get_identifier ("Object");
object_type_node = lookup_class (get_identifier ("java.lang.Object"));
object_ptr_type_node = promote_type (object_type_node);
@@ -551,6 +556,17 @@ init_decl_processing ()
error_exception_type_node =
lookup_class (get_identifier ("java.lang.Error"));
+ /* This section has to be updated as items are added to the previous
+ section. */
+ predef_filenames_size = 6;
+ predef_filenames = (tree *)xmalloc (predef_filenames_size * sizeof (tree));
+ predef_filenames [0] = get_identifier ("java/lang/Class.java");
+ predef_filenames [1] = get_identifier ("java/lang/Error.java");
+ predef_filenames [2] = get_identifier ("java/lang/Object.java");
+ predef_filenames [3] = get_identifier ("java/lang/RuntimeException.java");
+ predef_filenames [4] = get_identifier ("java/lang/String.java");
+ predef_filenames [5] = get_identifier ("java/lang/Throwable.java");
+
methodtable_type = make_node (RECORD_TYPE);
layout_type (methodtable_type);
build_decl (TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h
index 3158621f790..eb318f1f5ef 100644
--- a/gcc/java/java-tree.h
+++ b/gcc/java/java-tree.h
@@ -202,6 +202,9 @@ extern tree throwable_type_node;
extern tree runtime_exception_type_node;
extern tree error_exception_type_node;
+extern tree *predef_filenames;
+extern int predef_filenames_size;
+
extern tree byte_array_type_node;
extern tree short_array_type_node;
extern tree int_array_type_node;
diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index 7b582299f7f..054c239ff72 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -761,6 +761,17 @@ parse_source_file (file)
java_parse_abort_on_error ();
}
+static int
+predefined_filename_p (node)
+ tree node;
+{
+ int i;
+ for (i = 0; i < predef_filenames_size; i++)
+ if (predef_filenames [i] == node)
+ return 1;
+ return 0;
+}
+
int
yyparse ()
{
@@ -780,6 +791,8 @@ yyparse ()
if (list[0])
{
char *value;
+ tree id;
+ int twice = 0;
int len = strlen (list);
/* FIXME: this test is only needed until our .java parser is
@@ -792,9 +805,42 @@ yyparse ()
obstack_grow0 (&temporary_obstack, list, len);
value = obstack_finish (&temporary_obstack);
- node = get_identifier (value);
- IS_A_COMMAND_LINE_FILENAME_P (node) = 1;
- current_file_list = tree_cons (NULL_TREE, node, current_file_list);
+
+ /* Exclude file that we see twice on the command line. For
+ all files except {Class,Error,Object,RuntimeException,String,
+ Throwable}.java we can rely on maybe_get_identifier. For
+ these files, we need to do a linear search of
+ current_file_list. This search happens only for these
+ files, presumably only when we're recompiling libgcj. */
+
+ if ((id = maybe_get_identifier (value)))
+ {
+ if (predefined_filename_p (id))
+ {
+ tree c;
+ for (c = current_file_list; c; c = TREE_CHAIN (c))
+ if (TREE_VALUE (c) == id)
+ twice = 1;
+ }
+ else
+ twice = 1;
+ }
+
+ if (twice)
+ {
+ char *saved_input_filename = input_filename;
+ input_filename = value;
+ warning ("source file seen twice on command line and will be "
+ "compiled only once.");
+ input_filename = saved_input_filename;
+ }
+ else
+ {
+ node = get_identifier (value);
+ IS_A_COMMAND_LINE_FILENAME_P (node) = 1;
+ current_file_list = tree_cons (NULL_TREE, node,
+ current_file_list);
+ }
}
list = next;
}
diff --git a/gcc/java/parse.c b/gcc/java/parse.c
index 1dda0bfd800..f283692fa21 100644
--- a/gcc/java/parse.c
+++ b/gcc/java/parse.c
@@ -2226,7 +2226,7 @@ static const short yycheck[] = { 3,
#define YYPURE 1
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/x1/java/install/share/bison.simple"
+#line 3 "/usr/lib/bison.simple"
/* Skeleton output parser for bison,
Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
@@ -2419,7 +2419,7 @@ __yy_memcpy (char *to, char *from, int count)
#endif
#endif
-#line 196 "/x1/java/install/share/bison.simple"
+#line 196 "/usr/lib/bison.simple"
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
@@ -4678,7 +4678,7 @@ case 493:
break;}
}
/* the action file gets copied in in place of this dollarsign */
-#line 498 "/x1/java/install/share/bison.simple"
+#line 498 "/usr/lib/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
@@ -8087,9 +8087,16 @@ source_end_java_method ()
/* Set EH language codes */
java_set_exception_lang_code ();
+ /* Turn function bodies with only a NOP expr null, so they don't get
+ generated at all and we won't get warnings when using the -W
+ -Wall flags. */
+ if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
+ BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
+
/* Generate function's code */
if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
- && ! flag_emit_class_files)
+ && ! flag_emit_class_files
+ && ! flag_emit_xref)
expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
/* pop out of its parameters */
@@ -8098,7 +8105,7 @@ source_end_java_method ()
BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
/* Generate rtl for function exit. */
- if (! flag_emit_class_files)
+ if (! flag_emit_class_files && ! flag_emit_xref)
{
lineno = DECL_SOURCE_LINE_LAST (fndecl);
/* Emit catch-finally clauses */
@@ -8502,7 +8509,7 @@ java_expand_finals ()
void
java_expand_classes ()
{
- int save_error_count = java_error_count;
+ int save_error_count = 0;
java_parse_abort_on_error ();
if (!(ctxp = ctxp_for_generation))
return;
@@ -8692,7 +8699,7 @@ resolve_expression_name (id, orig)
/* Otherwise build what it takes to access the field */
decl = build_field_ref ((fs ? NULL_TREE : current_this),
current_class, name);
- if (fs && !flag_emit_class_files)
+ if (fs && !flag_emit_class_files && !flag_emit_xref)
decl = build_class_init (current_class, decl);
/* We may be asked to save the real field access node */
if (orig)
@@ -8741,7 +8748,7 @@ resolve_field_access (qual_wfl, field_decl, field_type)
/* Resolve the LENGTH field of an array here */
if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
- && ! flag_emit_class_files)
+ && ! flag_emit_class_files && ! flag_emit_xref)
{
tree length = build_java_array_length_access (where_found);
field_ref =
@@ -8770,7 +8777,8 @@ resolve_field_access (qual_wfl, field_decl, field_type)
type_found, DECL_NAME (decl));
if (field_ref == error_mark_node)
return error_mark_node;
- if (is_static && !static_final_found && !flag_emit_class_files)
+ if (is_static && !static_final_found
+ && !flag_emit_class_files && !flag_emit_xref)
{
field_ref = build_class_init (type_found, field_ref);
/* If the static field was identified by an expression that
@@ -9612,7 +9620,7 @@ patch_invoke (patch, method, args)
TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
- if (flag_emit_class_files)
+ if (flag_emit_class_files || flag_emit_xref)
func = method;
else
{
@@ -9658,7 +9666,7 @@ patch_invoke (patch, method, args)
{
tree class = DECL_CONTEXT (method);
tree c1, saved_new, size, new;
- if (flag_emit_class_files)
+ if (flag_emit_class_files || flag_emit_xref)
{
TREE_TYPE (patch) = build_pointer_type (class);
return patch;
@@ -10523,9 +10531,17 @@ java_complete_lhs (node)
if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
|| TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
{
+ tree wfl = node;
node = resolve_expression_name (node, NULL);
if (node == error_mark_node)
return node;
+ /* Keep line number information somewhere were it doesn't
+ disrupt the completion process. */
+ if (flag_emit_xref)
+ {
+ EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
+ TREE_OPERAND (node, 1) = wfl;
+ }
CAN_COMPLETE_NORMALLY (node) = 1;
}
else
@@ -11255,6 +11271,7 @@ patch_assignment (node, wfl_op1, wfl_op2)
/* 10.10: Array Store Exception runtime check */
if (!flag_emit_class_files
+ && !flag_emit_xref
&& lvalue_from_array
&& JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type))
&& !CLASS_FINAL (TYPE_NAME (GET_SKIP_TYPE (rhs_type))))
diff --git a/gcc/java/parse.h b/gcc/java/parse.h
index 52d9917df87..fb489e00508 100644
--- a/gcc/java/parse.h
+++ b/gcc/java/parse.h
@@ -177,6 +177,9 @@ extern tree stabilize_reference PROTO ((tree));
&& (JNUMERIC_TYPE_P ((TYPE)) \
|| TREE_CODE ((TYPE)) == BOOLEAN_TYPE))
+#define JPRIMITIVE_TYPE_OR_VOID_P(TYPE) \
+ (JPRIMITIVE_TYPE_P (TYPE) || ((TYPE) == void_type_node))
+
#define JBSC_TYPE_P(TYPE) ((TYPE) && (((TYPE) == byte_type_node) \
|| ((TYPE) == short_type_node) \
|| ((TYPE) == char_type_node)))
diff --git a/gcc/java/parse.y b/gcc/java/parse.y
index 8774576ddc3..4652ff2d018 100644
--- a/gcc/java/parse.y
+++ b/gcc/java/parse.y
@@ -5486,6 +5486,12 @@ source_end_java_method ()
/* Set EH language codes */
java_set_exception_lang_code ();
+ /* Turn function bodies with only a NOP expr null, so they don't get
+ generated at all and we won't get warnings when using the -W
+ -Wall flags. */
+ if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
+ BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
+
/* Generate function's code */
if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
&& ! flag_emit_class_files
@@ -5902,7 +5908,7 @@ java_expand_finals ()
void
java_expand_classes ()
{
- int save_error_count = java_error_count;
+ int save_error_count = 0;
java_parse_abort_on_error ();
if (!(ctxp = ctxp_for_generation))
return;
@@ -7924,9 +7930,17 @@ java_complete_lhs (node)
if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
|| TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
{
+ tree wfl = node;
node = resolve_expression_name (node, NULL);
if (node == error_mark_node)
return node;
+ /* Keep line number information somewhere were it doesn't
+ disrupt the completion process. */
+ if (flag_emit_xref)
+ {
+ EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
+ TREE_OPERAND (node, 1) = wfl;
+ }
CAN_COMPLETE_NORMALLY (node) = 1;
}
else