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]

Re: [PATCH][C++] Make __java_boolean a true bool (PR 33887)


On Tue, 29 Jan 2008, Richard Guenther wrote:

> We do build_c_cast which performs the conversion via build_static_cast_1
> and returns VA_ARG_EXPR <va> != 0 of type boolean_type_node(!), which
> we then try to convert to __java_boolean node again here:
> 
>       /* If the type of RESULT does not match TYPE, perform a
>          const_cast to make it match.  If the static_cast or
>          reinterpret_cast succeeded, we will differ by at most
>          cv-qualification, so the follow-on const_cast is guaranteed
>          to succeed.  */
>       if (!same_type_p (non_reference (type), non_reference 
> (result_type)))
>         {
>           result = build_const_cast_1 (type, result, false, &valid_p);
>           gcc_assert (valid_p);
>         }
> 
> and ICE.

Maybe better fixup build_static_cast_1 like this:

@@ -5004,6 +5003,13 @@ build_static_cast_1 (tree type, tree exp
         the result is an rvalue.  */
       if (TREE_CODE (type) != REFERENCE_TYPE)
        result = rvalue (result);
+
+      /* We can end up converting to the "wrong" boolean type.  Adjust
+        that here by adding an explicit conversion if required.  */
+      if (TREE_CODE (type) == BOOLEAN_TYPE
+         && TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (TREE_TYPE 
(result)))
+       return build_nop (type, result);
+
       return result;
     }
 

?

Richard.


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