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++] Make __java_boolean a true bool (PR 33887)


This makes the fix for PR33887 safer in that __java_boolean is treated
the same as C++ bool.  This is especially important for its special
semantics on increment.

Bootstrap and testing on x86_64-unknown-linux-gnu, ok if that passes?

Thanks,
Richard.

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

	PR c++/33887
	* decl.c (record_builtin_java_type): Make __java_boolean
	a variant of bool.
	* typeck.c (structural_comptypes): Move TYPE_FOR_JAVA check
	after TYPE_MAIN_VARIANT check.

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 131689)
+++ cp/decl.c	(working copy)
@@ -3159,10 +3159,13 @@ record_builtin_java_type (const char* na
   tree type, decl;
   if (size > 0)
     type = make_signed_type (size);
+  else if (size == -1)
+    { /* "__java_boolean".  */
+      type = build_variant_type_copy (boolean_type_node);
+    }
   else if (size > -32)
-    { /* "__java_char" or ""__java_boolean".  */
+    { /* "__java_char".  */
       type = make_unsigned_type (-size);
-      /*if (size == -1)	TREE_SET_CODE (type, BOOLEAN_TYPE);*/
     }
   else
     { /* "__java_float" or ""__java_double".  */
Index: cp/typeck.c
===================================================================
*** cp/typeck.c	(revision 131689)
--- cp/typeck.c	(working copy)
*************** structural_comptypes (tree t1, tree t2, 
*** 962,969 ****
    if (TREE_CODE (t1) != ARRAY_TYPE
        && TYPE_QUALS (t1) != TYPE_QUALS (t2))
      return false;
-   if (TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2))
-     return false;
  
    /* Allow for two different type nodes which have essentially the same
       definition.  Note that we already checked for equality of the type
--- 962,967 ----
*************** structural_comptypes (tree t1, tree t2, 
*** 973,978 ****
--- 971,979 ----
        && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
      return true;
  
+   if (TYPE_FOR_JAVA (t1) != TYPE_FOR_JAVA (t2))
+     return false;
+ 
    /* Compare the types.  Break out if they could be the same.  */
    switch (TREE_CODE (t1))
      {


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