This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][Java] Fix PR38374, type verification errors with the constant pool decl

This fixes the issue that the Java frontend patches the type of the
constant pool decl thereby invalidating all built address-expressions.

The "fix" is to retain the old pointer type as a valid one to access
the new type.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?

This is necessary to keep libjava bootstrapping after enabling
type verification throughout the compilation.


2009-04-15  Richard Guenther  <>

	PR java/38374
	* constants.c (build_constants_constructor): Retain the old
	pointer type as valid TYPE_POINTER_TO after patching the
	type of the constant pool decl.

Index: gcc/java/constants.c
*** gcc/java/constants.c.orig	2009-04-14 17:39:36.000000000 +0200
--- gcc/java/constants.c	2009-04-15 11:57:57.000000000 +0200
*************** build_constants_constructor (void)
*** 557,569 ****
--- 557,578 ----
        tree data_decl, tags_decl, tags_type;
        tree max_index = build_int_cst (sizetype, outgoing_cpool->count - 1);
        tree index_type = build_index_type (max_index);
+       tree tem;
        /* Add dummy 0'th element of constant pool. */
        tags_list = tree_cons (NULL_TREE, get_tag_node (0), tags_list);
        data_list = tree_cons (NULL_TREE, null_pointer_node, data_list);
+       /* Change the type of the decl to have the proper array size.
+          ???  Make sure to transition the old type-pointer-to list to this
+ 	 new type to not invalidate all build address expressions.  */
        data_decl = build_constant_data_ref (false);
+       tem = TYPE_POINTER_TO (TREE_TYPE (data_decl));
+       if (!tem)
+ 	tem = build_pointer_type (TREE_TYPE (data_decl));
+       TYPE_POINTER_TO (TREE_TYPE (data_decl)) = NULL_TREE;
        TREE_TYPE (data_decl) = build_array_type (ptr_type_node, index_type);
+       TYPE_POINTER_TO (TREE_TYPE (data_decl)) = tem;
        DECL_INITIAL (data_decl) = build_constructor_from_list
  				  (TREE_TYPE (data_decl), data_list);
        DECL_SIZE (data_decl) = TYPE_SIZE (TREE_TYPE (data_decl));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]