This is the mail archive of the gcc-patches@gcc.gnu.org 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][C++] Fix libjava breakage on darwin, PR35035


The following patch un-breaks the java ABI on darwin by not making
jboolean the same as bool, but unconditionally use QImode while still
retaining the fix to make jboolean have boolean semantics.  To
not make changes all over the place in the C++ frontend to support
two distinct boolean types we still link both types via their
main variant and canonical types and thus only retain the difference
during structure layout and at expansion time.  Hopefully at least.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Can anyone confirm this fixes ppc-darwin?

Ok for mainline?

Thanks,
Richard.

2008-01-31  Richard Guenther  <rguenther@suse.de>

	PR libjava/35035
	* decl.c (record_builtin_java_type): Make jboolean QImode,
	but still link it to boolean_type_node.

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 131958)
+++ cp/decl.c	(working copy)
@@ -3161,7 +3161,16 @@ record_builtin_java_type (const char* na
     type = make_signed_type (size);
   else if (size == -1)
     { /* "__java_boolean".  */
-      type = build_variant_type_copy (boolean_type_node);
+      /* Do not use build_variant_type_copy here, as jboolean and
+	 bool may not agree in size as the C++ and Java ABIs may differ.
+	 But we still have to make sure to give jboolean boolean
+	 semantics and properly link it to the single boolean type.  */
+      type = make_unsigned_type (1);
+      TREE_SET_CODE (type, BOOLEAN_TYPE);
+      TYPE_CANONICAL (type) = TYPE_CANONICAL (boolean_type_node);
+      TYPE_NEXT_VARIANT (type) = TYPE_NEXT_VARIANT (boolean_type_node);
+      TYPE_NEXT_VARIANT (boolean_type_node) = type;
+      TYPE_MAIN_VARIANT (type) = boolean_type_node;
     }
   else if (size > -32)
     { /* "__java_char".  */


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