c_common_truthvalue_conversion. */
/* For now, convert to: (t_expr != 0) */
t_ret = build2 (NE_EXPR, t_dst_type,
- t_expr, integer_zero_node);
+ t_expr,
+ build_int_cst (TREE_TYPE (t_expr), 0));
goto maybe_fold;
case REAL_TYPE:
+2014-12-19 David Malcolm <dmalcolm@redhat.com>
+
+ * jit.dg/test-expressions.c (make_tests_of_casts): Add tests of
+ casting between "long" and "bool".
+ (verify_casts): Verify these new test cases.
+
2014-12-19 Matthew Fortune <matthew.fortune@imgtec.com>
* gcc.target/mips/pr37362.c: Skip for mips-img-elf.
{
gcc_jit_type *int_type =
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
+ gcc_jit_type *long_type =
+ gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_LONG);
gcc_jit_type *float_type =
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT);
gcc_jit_type *bool_type =
"test_cast_from_int_to_bool"),
"(bool)a");
+ /* bool/long conversions */
+ CHECK_STRING_VALUE (
+ make_test_of_cast (ctxt,
+ bool_type,
+ long_type,
+ "test_cast_from_bool_to_long"),
+ "(long)a");
+ CHECK_STRING_VALUE (
+ make_test_of_cast (ctxt,
+ long_type,
+ bool_type,
+ "test_cast_from_long_to_bool"),
+ "(bool)a");
+
/* array/ptr conversions */
{
gcc_jit_function *test_fn =
CHECK_VALUE (test_cast_from_int_to_bool (1), 1);
}
+ /* bool to long */
+ {
+ typedef long (*fn_type) (bool);
+ fn_type test_cast_from_bool_to_long =
+ (fn_type)gcc_jit_result_get_code (result,
+ "test_cast_from_bool_to_long");
+ CHECK_NON_NULL (test_cast_from_bool_to_long);
+ CHECK_VALUE (test_cast_from_bool_to_long (0), 0);
+ CHECK_VALUE (test_cast_from_bool_to_long (1), 1);
+ }
+
+ /* long to bool */
+ {
+ typedef bool (*fn_type) (long);
+ fn_type test_cast_from_long_to_bool =
+ (fn_type)gcc_jit_result_get_code (result,
+ "test_cast_from_long_to_bool");
+ CHECK_NON_NULL (test_cast_from_long_to_bool);
+ CHECK_VALUE (test_cast_from_long_to_bool (0), 0);
+ CHECK_VALUE (test_cast_from_long_to_bool (1), 1);
+ }
+
/* array to ptr */
{
typedef int (*fn_type) (void);