This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to move boolean_type_node to tree.h
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 24 Jul 2003 16:40:44 -0400
- Subject: PATCH to move boolean_type_node to tree.h
Some work I'm doing on the tree-ssa branch requires a BOOLEAN_TYPE type to
prevent invert_truthvalue from aborting periodically. There doesn't seem
to be any reason not to have boolean_type_node in language-independent
code, so I moved it there.
The only complication is that code shared between the C and C++ frontend
has been using boolean_type_node to refer to the type that comparison ops
have, which is 'int' in C and 'bool' in C++. I've renamed that to
truthvalue_type_node instead, so now the C frontend can use
boolean_type_node instead of c_bool_type_node to refer to _Bool.
Booted and tested x86_64-unknown-linux-gnu, applied to trunk.
2003-07-24 Jason Merrill <jason@redhat.com>
* tree.h (boolean_type_node): Move from C/C++/Java frontends.
(boolean_true_node, boolean_false_node): Likewise.
(enum tree_index): Add TI_BOOLEAN_{TYPE,FALSE,TRUE}.
* tree.c (build_common_tree_nodes): Init boolean_type_node.
(build_common_tree_nodes_2): Init boolean_{true,false}_node.
* stor-layout.c (set_sizetype): Handle an early BOOLEAN_TYPE.
* c-common.h (truthvalue_type_node): Renamed from boolean_type_node.
(truthvalue_true_node): Renamed from boolean_true_node.
(truthvalue_false_node): Renamed from boolean_false_node.
* c-decl.c: Just set truthvalue_* to integer_*.
* c-*.[ch]: s/boolean/truthvalue/. s/c_bool/boolean/.
* cp/decl.c: Just set truthvalue_* to boolean_*.
* java/java-tree.h: Move boolean_type_node et al to the back end.
*** ./cp/decl.c.~1~ Thu Jul 24 10:22:21 2003
--- ./cp/decl.c Thu Jul 24 15:21:05 2003
*************** cxx_init_decl_processing (void)
*** 6260,6275 ****
integer_three_node = build_int_2 (3, 0);
TREE_TYPE (integer_three_node) = integer_type_node;
- boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
- TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
- TYPE_MAX_VALUE (boolean_type_node) = build_int_2 (1, 0);
- TREE_TYPE (TYPE_MAX_VALUE (boolean_type_node)) = boolean_type_node;
- TYPE_PRECISION (boolean_type_node) = 1;
record_builtin_type (RID_BOOL, "bool", boolean_type_node);
! boolean_false_node = build_int_2 (0, 0);
! TREE_TYPE (boolean_false_node) = boolean_type_node;
! boolean_true_node = build_int_2 (1, 0);
! TREE_TYPE (boolean_true_node) = boolean_type_node;
empty_except_spec = build_tree_list (NULL_TREE, NULL_TREE);
--- 6260,6269 ----
integer_three_node = build_int_2 (3, 0);
TREE_TYPE (integer_three_node) = integer_type_node;
record_builtin_type (RID_BOOL, "bool", boolean_type_node);
! truthvalue_type_node = boolean_type_node;
! truthvalue_false_node = boolean_false_node;
! truthvalue_true_node = boolean_true_node;
empty_except_spec = build_tree_list (NULL_TREE, NULL_TREE);
*** ./java/java-tree.h.~1~ Mon Jul 21 15:13:40 2003
--- ./java/java-tree.h Thu Jul 24 15:12:14 2003
*************** enum java_tree_index
*** 287,294 ****
JTI_DECIMAL_INT_MAX_NODE,
JTI_DECIMAL_LONG_MAX_NODE,
- JTI_BOOLEAN_TYPE_NODE,
-
JTI_OBJECT_TYPE_NODE,
JTI_UNQUALIFIED_OBJECT_ID_NODE,
JTI_OBJECT_PTR_TYPE_NODE,
--- 287,292 ----
*************** enum java_tree_index
*** 338,346 ****
JTI_RETURN_ADDRESS_TYPE_NODE,
- JTI_BOOLEAN_TRUE_NODE,
- JTI_BOOLEAN_FALSE_NODE,
-
JTI_LONG_ZERO_NODE,
JTI_FLOAT_ZERO_NODE,
JTI_DOUBLE_ZERO_NODE,
--- 336,341 ----
*************** extern GTY(()) tree java_global_trees[JT
*** 457,465 ****
#define decimal_long_max \
java_global_trees[JTI_DECIMAL_LONG_MAX_NODE]
- #define boolean_type_node \
- java_global_trees[JTI_BOOLEAN_TYPE_NODE]
-
#define object_type_node \
java_global_trees[JTI_OBJECT_TYPE_NODE]
#define unqualified_object_id_node \
--- 452,457 ----
*************** extern GTY(()) tree java_global_trees[JT
*** 556,567 ****
#define return_address_type_node \
java_global_trees[JTI_RETURN_ADDRESS_TYPE_NODE]
- /* Nodes for boolean constants TRUE and FALSE. */
- #define boolean_true_node \
- java_global_trees[JTI_BOOLEAN_TRUE_NODE]
- #define boolean_false_node \
- java_global_trees[JTI_BOOLEAN_FALSE_NODE]
-
/* Integer constants not declared in tree.h. */
#define long_zero_node \
java_global_trees[JTI_LONG_ZERO_NODE]
--- 548,553 ----
*** ./c-common.c.~1~ Thu Jul 24 10:53:11 2003
--- ./c-common.c Thu Jul 24 14:13:26 2003
*************** cpp_reader *parse_in; /* Declared in c-
*** 100,108 ****
tree long_unsigned_type_node;
tree long_long_unsigned_type_node;
! tree boolean_type_node;
! tree boolean_false_node;
! tree boolean_true_node;
tree ptrdiff_type_node;
--- 100,108 ----
tree long_unsigned_type_node;
tree long_long_unsigned_type_node;
! tree truthvalue_type_node;
! tree truthvalue_false_node;
! tree truthvalue_true_node;
tree ptrdiff_type_node;
*************** shorten_compare (tree *op0_ptr, tree *op
*** 2258,2297 ****
if (code == NE_EXPR)
{
if (max_lt || min_gt)
! val = boolean_true_node;
}
else if (code == EQ_EXPR)
{
if (max_lt || min_gt)
! val = boolean_false_node;
}
else if (code == LT_EXPR)
{
if (max_lt)
! val = boolean_true_node;
if (!min_lt)
! val = boolean_false_node;
}
else if (code == GT_EXPR)
{
if (min_gt)
! val = boolean_true_node;
if (!max_gt)
! val = boolean_false_node;
}
else if (code == LE_EXPR)
{
if (!max_gt)
! val = boolean_true_node;
if (min_gt)
! val = boolean_false_node;
}
else if (code == GE_EXPR)
{
if (!min_lt)
! val = boolean_true_node;
if (max_lt)
! val = boolean_false_node;
}
/* If primop0 was sign-extended and unsigned comparison specd,
--- 2258,2297 ----
if (code == NE_EXPR)
{
if (max_lt || min_gt)
! val = truthvalue_true_node;
}
else if (code == EQ_EXPR)
{
if (max_lt || min_gt)
! val = truthvalue_false_node;
}
else if (code == LT_EXPR)
{
if (max_lt)
! val = truthvalue_true_node;
if (!min_lt)
! val = truthvalue_false_node;
}
else if (code == GT_EXPR)
{
if (min_gt)
! val = truthvalue_true_node;
if (!max_gt)
! val = truthvalue_false_node;
}
else if (code == LE_EXPR)
{
if (!max_gt)
! val = truthvalue_true_node;
if (min_gt)
! val = truthvalue_false_node;
}
else if (code == GE_EXPR)
{
if (!min_lt)
! val = truthvalue_true_node;
if (max_lt)
! val = truthvalue_false_node;
}
/* If primop0 was sign-extended and unsigned comparison specd,
*************** shorten_compare (tree *op0_ptr, tree *op
*** 2330,2338 ****
if (TREE_CODE (primop0) != INTEGER_CST)
{
! if (val == boolean_false_node)
warning ("comparison is always false due to limited range of data type");
! if (val == boolean_true_node)
warning ("comparison is always true due to limited range of data type");
}
--- 2330,2338 ----
if (TREE_CODE (primop0) != INTEGER_CST)
{
! if (val == truthvalue_false_node)
warning ("comparison is always false due to limited range of data type");
! if (val == truthvalue_true_node)
warning ("comparison is always true due to limited range of data type");
}
*************** shorten_compare (tree *op0_ptr, tree *op
*** 2404,2410 ****
&& ! TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
warning ("comparison of unsigned expression >= 0 is always true");
! value = boolean_true_node;
break;
case LT_EXPR:
--- 2404,2410 ----
&& ! TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
warning ("comparison of unsigned expression >= 0 is always true");
! value = truthvalue_true_node;
break;
case LT_EXPR:
*************** shorten_compare (tree *op0_ptr, tree *op
*** 2413,2419 ****
&& ! TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
warning ("comparison of unsigned expression < 0 is always false");
! value = boolean_false_node;
break;
default:
--- 2413,2419 ----
&& ! TREE_OVERFLOW (convert (c_common_signed_type (type),
primop0))))
warning ("comparison of unsigned expression < 0 is always false");
! value = truthvalue_false_node;
break;
default:
*************** shorten_compare (tree *op0_ptr, tree *op
*** 2434,2440 ****
*op0_ptr = convert (type, primop0);
*op1_ptr = convert (type, primop1);
! *restype_ptr = boolean_type_node;
return 0;
}
--- 2434,2440 ----
*op0_ptr = convert (type, primop0);
*op1_ptr = convert (type, primop1);
! *restype_ptr = truthvalue_type_node;
return 0;
}
*************** pointer_int_sum (enum tree_code resultco
*** 2544,2553 ****
This preparation consists of taking the ordinary
representation of an expression expr and producing a valid tree
boolean expression describing whether expr is nonzero. We could
! simply always do build_binary_op (NE_EXPR, expr, boolean_false_node, 1),
but we optimize comparisons, &&, ||, and !.
! The resulting type should always be `boolean_type_node'. */
tree
c_common_truthvalue_conversion (tree expr)
--- 2544,2553 ----
This preparation consists of taking the ordinary
representation of an expression expr and producing a valid tree
boolean expression describing whether expr is nonzero. We could
! simply always do build_binary_op (NE_EXPR, expr, truthvalue_false_node, 1),
but we optimize comparisons, &&, ||, and !.
! The resulting type should always be `truthvalue_type_node'. */
tree
c_common_truthvalue_conversion (tree expr)
*************** c_common_truthvalue_conversion (tree exp
*** 2562,2576 ****
{
case RECORD_TYPE:
error ("struct type value used where scalar is required");
! return boolean_false_node;
case UNION_TYPE:
error ("union type value used where scalar is required");
! return boolean_false_node;
case ARRAY_TYPE:
error ("array type value used where scalar is required");
! return boolean_false_node;
default:
break;
--- 2562,2576 ----
{
case RECORD_TYPE:
error ("struct type value used where scalar is required");
! return truthvalue_false_node;
case UNION_TYPE:
error ("union type value used where scalar is required");
! return truthvalue_false_node;
case ARRAY_TYPE:
error ("array type value used where scalar is required");
! return truthvalue_false_node;
default:
break;
*************** c_common_truthvalue_conversion (tree exp
*** 2587,2603 ****
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
case TRUTH_NOT_EXPR:
! TREE_TYPE (expr) = boolean_type_node;
return expr;
case ERROR_MARK:
return expr;
case INTEGER_CST:
! return integer_zerop (expr) ? boolean_false_node : boolean_true_node;
case REAL_CST:
! return real_zerop (expr) ? boolean_false_node : boolean_true_node;
case ADDR_EXPR:
/* If we are taking the address of an external decl, it might be zero
--- 2587,2603 ----
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
case TRUTH_NOT_EXPR:
! TREE_TYPE (expr) = truthvalue_type_node;
return expr;
case ERROR_MARK:
return expr;
case INTEGER_CST:
! return integer_zerop (expr) ? truthvalue_false_node : truthvalue_true_node;
case REAL_CST:
! return real_zerop (expr) ? truthvalue_false_node : truthvalue_true_node;
case ADDR_EXPR:
/* If we are taking the address of an external decl, it might be zero
*************** c_common_truthvalue_conversion (tree exp
*** 2607,2616 ****
break;
if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0)))
! return build (COMPOUND_EXPR, boolean_type_node,
! TREE_OPERAND (expr, 0), boolean_true_node);
else
! return boolean_true_node;
case COMPLEX_EXPR:
return build_binary_op ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
--- 2607,2616 ----
break;
if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0)))
! return build (COMPOUND_EXPR, truthvalue_type_node,
! TREE_OPERAND (expr, 0), truthvalue_true_node);
else
! return truthvalue_true_node;
case COMPLEX_EXPR:
return build_binary_op ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
*************** c_common_truthvalue_conversion (tree exp
*** 2632,2645 ****
/* These don't change whether an object is zero or nonzero, but
we can't ignore them if their second arg has side-effects. */
if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
! return build (COMPOUND_EXPR, boolean_type_node, TREE_OPERAND (expr, 1),
c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)));
else
return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
! return fold (build (COND_EXPR, boolean_type_node, TREE_OPERAND (expr, 0),
c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
c_common_truthvalue_conversion (TREE_OPERAND (expr, 2))));
--- 2632,2645 ----
/* These don't change whether an object is zero or nonzero, but
we can't ignore them if their second arg has side-effects. */
if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
! return build (COMPOUND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 1),
c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)));
else
return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
! return fold (build (COND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 0),
c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
c_common_truthvalue_conversion (TREE_OPERAND (expr, 2))));
*************** c_common_truthvalue_conversion (tree exp
*** 2683,2691 ****
case BIT_AND_EXPR:
if (integer_onep (TREE_OPERAND (expr, 1))
! && TREE_TYPE (expr) != boolean_type_node)
/* Using convert here would cause infinite recursion. */
! return build1 (NOP_EXPR, boolean_type_node, expr);
break;
case MODIFY_EXPR:
--- 2683,2691 ----
case BIT_AND_EXPR:
if (integer_onep (TREE_OPERAND (expr, 1))
! && TREE_TYPE (expr) != truthvalue_type_node)
/* Using convert here would cause infinite recursion. */
! return build1 (NOP_EXPR, truthvalue_type_node, expr);
break;
case MODIFY_EXPR:
*************** tree
*** 4418,4424 ****
boolean_increment (enum tree_code code, tree arg)
{
tree val;
! tree true_res = (c_dialect_cxx () ? boolean_true_node : c_bool_true_node);
arg = stabilize_reference (arg);
switch (code)
--- 4418,4424 ----
boolean_increment (enum tree_code code, tree arg)
{
tree val;
! tree true_res = boolean_true_node;
arg = stabilize_reference (arg);
switch (code)
*** ./c-common.h.~1~ Thu Jul 24 10:53:11 2003
--- ./c-common.h Thu Jul 24 14:13:26 2003
*************** enum c_tree_index
*** 146,158 ****
CTI_CONST_STRING_TYPE,
/* Type for boolean expressions (bool in C++, int in C). */
! CTI_BOOLEAN_TYPE,
! CTI_BOOLEAN_TRUE,
! CTI_BOOLEAN_FALSE,
! /* C99's _Bool type. */
! CTI_C_BOOL_TYPE,
! CTI_C_BOOL_TRUE,
! CTI_C_BOOL_FALSE,
CTI_DEFAULT_FUNCTION_TYPE,
CTI_G77_INTEGER_TYPE,
--- 146,155 ----
CTI_CONST_STRING_TYPE,
/* Type for boolean expressions (bool in C++, int in C). */
! CTI_TRUTHVALUE_TYPE,
! CTI_TRUTHVALUE_TRUE,
! CTI_TRUTHVALUE_FALSE,
!
CTI_DEFAULT_FUNCTION_TYPE,
CTI_G77_INTEGER_TYPE,
*************** struct c_common_identifier GTY(())
*** 192,204 ****
#define widest_integer_literal_type_node c_global_trees[CTI_WIDEST_INT_LIT_TYPE]
#define widest_unsigned_literal_type_node c_global_trees[CTI_WIDEST_UINT_LIT_TYPE]
! #define boolean_type_node c_global_trees[CTI_BOOLEAN_TYPE]
! #define boolean_true_node c_global_trees[CTI_BOOLEAN_TRUE]
! #define boolean_false_node c_global_trees[CTI_BOOLEAN_FALSE]
!
! #define c_bool_type_node c_global_trees[CTI_C_BOOL_TYPE]
! #define c_bool_true_node c_global_trees[CTI_C_BOOL_TRUE]
! #define c_bool_false_node c_global_trees[CTI_C_BOOL_FALSE]
#define char_array_type_node c_global_trees[CTI_CHAR_ARRAY_TYPE]
#define wchar_array_type_node c_global_trees[CTI_WCHAR_ARRAY_TYPE]
--- 189,197 ----
#define widest_integer_literal_type_node c_global_trees[CTI_WIDEST_INT_LIT_TYPE]
#define widest_unsigned_literal_type_node c_global_trees[CTI_WIDEST_UINT_LIT_TYPE]
! #define truthvalue_type_node c_global_trees[CTI_TRUTHVALUE_TYPE]
! #define truthvalue_true_node c_global_trees[CTI_TRUTHVALUE_TRUE]
! #define truthvalue_false_node c_global_trees[CTI_TRUTHVALUE_FALSE]
#define char_array_type_node c_global_trees[CTI_CHAR_ARRAY_TYPE]
#define wchar_array_type_node c_global_trees[CTI_WCHAR_ARRAY_TYPE]
*** ./c-decl.c.~1~ Thu Jul 24 10:53:11 2003
--- ./c-decl.c Thu Jul 24 14:13:26 2003
*************** c_init_decl_processing (void)
*** 2289,2309 ****
c_common_nodes_and_builtins ();
! boolean_type_node = integer_type_node;
! boolean_true_node = integer_one_node;
! boolean_false_node = integer_zero_node;
!
! c_bool_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
! TREE_SET_CODE (c_bool_type_node, BOOLEAN_TYPE);
! TYPE_MAX_VALUE (c_bool_type_node) = build_int_2 (1, 0);
! TREE_TYPE (TYPE_MAX_VALUE (c_bool_type_node)) = c_bool_type_node;
! TYPE_PRECISION (c_bool_type_node) = 1;
pushdecl (build_decl (TYPE_DECL, get_identifier ("_Bool"),
! c_bool_type_node));
! c_bool_false_node = build_int_2 (0, 0);
! TREE_TYPE (c_bool_false_node) = c_bool_type_node;
! c_bool_true_node = build_int_2 (1, 0);
! TREE_TYPE (c_bool_true_node) = c_bool_type_node;
endlink = void_list_node;
ptr_ftype_void = build_function_type (ptr_type_node, endlink);
--- 2289,2302 ----
c_common_nodes_and_builtins ();
! /* In C, comparisons and TRUTH_* expressions have type int. */
! truthvalue_type_node = integer_type_node;
! truthvalue_true_node = integer_one_node;
! truthvalue_false_node = integer_zero_node;
!
! /* Even in C99, which has a real boolean type. */
pushdecl (build_decl (TYPE_DECL, get_identifier ("_Bool"),
! boolean_type_node));
endlink = void_list_node;
ptr_ftype_void = build_function_type (ptr_type_node, endlink);
*************** finish_struct (tree t, tree fieldlist, t
*** 5031,5037 ****
if (DECL_INITIAL (x) && pedantic
&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) != integer_type_node
&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) != unsigned_type_node
! && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != c_bool_type_node
/* Accept an enum that's equivalent to int or unsigned int. */
&& !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
&& (TYPE_PRECISION (TREE_TYPE (x))
--- 5024,5030 ----
if (DECL_INITIAL (x) && pedantic
&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) != integer_type_node
&& TYPE_MAIN_VARIANT (TREE_TYPE (x)) != unsigned_type_node
! && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != boolean_type_node
/* Accept an enum that's equivalent to int or unsigned int. */
&& !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
&& (TYPE_PRECISION (TREE_TYPE (x))
*************** finish_struct (tree t, tree fieldlist, t
*** 5044,5050 ****
if (DECL_INITIAL (x))
{
int max_width
! = (TYPE_MAIN_VARIANT (TREE_TYPE (x)) == c_bool_type_node
? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x)));
if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0)
--- 5037,5043 ----
if (DECL_INITIAL (x))
{
int max_width
! = (TYPE_MAIN_VARIANT (TREE_TYPE (x)) == boolean_type_node
? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x)));
if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0)
*** ./c-parse.in.~1~ Thu Jul 24 10:53:11 2003
--- ./c-parse.in Thu Jul 24 14:13:26 2003
*************** expr_no_commas:
*** 578,603 ****
| expr_no_commas ANDAND
{ $1 = c_common_truthvalue_conversion
(default_conversion ($1));
! skip_evaluation += $1 == boolean_false_node; }
expr_no_commas
! { skip_evaluation -= $1 == boolean_false_node;
$$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
| expr_no_commas OROR
{ $1 = c_common_truthvalue_conversion
(default_conversion ($1));
! skip_evaluation += $1 == boolean_true_node; }
expr_no_commas
! { skip_evaluation -= $1 == boolean_true_node;
$$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
| expr_no_commas '?'
{ $1 = c_common_truthvalue_conversion
(default_conversion ($1));
! skip_evaluation += $1 == boolean_false_node; }
expr ':'
! { skip_evaluation += (($1 == boolean_true_node)
! - ($1 == boolean_false_node)); }
expr_no_commas
! { skip_evaluation -= $1 == boolean_true_node;
$$ = build_conditional_expr ($1, $4, $7); }
| expr_no_commas '?'
{ if (pedantic)
--- 578,603 ----
| expr_no_commas ANDAND
{ $1 = c_common_truthvalue_conversion
(default_conversion ($1));
! skip_evaluation += $1 == truthvalue_false_node; }
expr_no_commas
! { skip_evaluation -= $1 == truthvalue_false_node;
$$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
| expr_no_commas OROR
{ $1 = c_common_truthvalue_conversion
(default_conversion ($1));
! skip_evaluation += $1 == truthvalue_true_node; }
expr_no_commas
! { skip_evaluation -= $1 == truthvalue_true_node;
$$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
| expr_no_commas '?'
{ $1 = c_common_truthvalue_conversion
(default_conversion ($1));
! skip_evaluation += $1 == truthvalue_false_node; }
expr ':'
! { skip_evaluation += (($1 == truthvalue_true_node)
! - ($1 == truthvalue_false_node)); }
expr_no_commas
! { skip_evaluation -= $1 == truthvalue_true_node;
$$ = build_conditional_expr ($1, $4, $7); }
| expr_no_commas '?'
{ if (pedantic)
*************** expr_no_commas:
*** 606,614 ****
$<ttype>2 = save_expr ($1);
$1 = c_common_truthvalue_conversion
(default_conversion ($<ttype>2));
! skip_evaluation += $1 == boolean_true_node; }
':' expr_no_commas
! { skip_evaluation -= $1 == boolean_true_node;
$$ = build_conditional_expr ($1, $<ttype>2, $5); }
| expr_no_commas '=' expr_no_commas
{ char class;
--- 606,614 ----
$<ttype>2 = save_expr ($1);
$1 = c_common_truthvalue_conversion
(default_conversion ($<ttype>2));
! skip_evaluation += $1 == truthvalue_true_node; }
':' expr_no_commas
! { skip_evaluation -= $1 == truthvalue_true_node;
$$ = build_conditional_expr ($1, $<ttype>2, $5); }
| expr_no_commas '=' expr_no_commas
{ char class;
*** ./c-semantics.c.~1~ Thu Jul 24 10:53:11 2003
--- ./c-semantics.c Thu Jul 24 14:13:26 2003
*************** genrtl_switch_stmt (tree t)
*** 668,674 ****
if (cond == error_mark_node)
/* The code is in error, but we don't want expand_end_case to
crash. */
! cond = boolean_false_node;
emit_line_note (input_location);
expand_start_case (1, cond, TREE_TYPE (cond), "switch statement");
--- 668,674 ----
if (cond == error_mark_node)
/* The code is in error, but we don't want expand_end_case to
crash. */
! cond = truthvalue_false_node;
emit_line_note (input_location);
expand_start_case (1, cond, TREE_TYPE (cond), "switch statement");
*** ./tree.c.~1~ Thu Jul 24 10:53:11 2003
--- ./tree.c Thu Jul 24 14:13:26 2003
*************** build_common_tree_nodes (int signed_char
*** 4754,4759 ****
--- 4754,4769 ----
long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
+ /* Define a boolean type. This type only represents boolean values but
+ may be larger than char depending on the value of BOOL_TYPE_SIZE.
+ Front ends which want to override this size (i.e. Java) can redefine
+ boolean_type_node before calling build_common_tree_nodes_2. */
+ boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
+ TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
+ TYPE_MAX_VALUE (boolean_type_node) = build_int_2 (1, 0);
+ TREE_TYPE (TYPE_MAX_VALUE (boolean_type_node)) = boolean_type_node;
+ TYPE_PRECISION (boolean_type_node) = 1;
+
intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
intHI_type_node = make_signed_type (GET_MODE_BITSIZE (HImode));
intSI_type_node = make_signed_type (GET_MODE_BITSIZE (SImode));
*************** build_common_tree_nodes_2 (int short_dou
*** 4784,4789 ****
--- 4794,4802 ----
bitsize_one_node = bitsize_int (1);
bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
+ boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
+ boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
+
void_type_node = make_node (VOID_TYPE);
layout_type (void_type_node);
*** ./tree.h.~1~ Thu Jul 24 10:53:11 2003
--- ./tree.h Thu Jul 24 14:13:26 2003
*************** enum tree_index
*** 1779,1784 ****
--- 1779,1787 ----
TI_BITSIZE_ONE,
TI_BITSIZE_UNIT,
+ TI_BOOLEAN_FALSE,
+ TI_BOOLEAN_TRUE,
+
TI_COMPLEX_INTEGER_TYPE,
TI_COMPLEX_FLOAT_TYPE,
TI_COMPLEX_DOUBLE_TYPE,
*************** enum tree_index
*** 1794,1799 ****
--- 1797,1803 ----
TI_SIZE_TYPE,
TI_PTRDIFF_TYPE,
TI_VA_LIST_TYPE,
+ TI_BOOLEAN_TYPE,
TI_VOID_LIST_NODE,
*************** extern GTY(()) tree global_trees[TI_MAX]
*** 1880,1885 ****
--- 1884,1893 ----
#define ptrdiff_type_node global_trees[TI_PTRDIFF_TYPE]
#define va_list_type_node global_trees[TI_VA_LIST_TYPE]
+ #define boolean_type_node global_trees[TI_BOOLEAN_TYPE]
+ #define boolean_false_node global_trees[TI_BOOLEAN_FALSE]
+ #define boolean_true_node global_trees[TI_BOOLEAN_TRUE]
+
/* The node that should be placed at the end of a parameter list to
indicate that the function does not take a variable number of
arguments. The TREE_VALUE will be void_type_node and there will be
*** ./stor-layout.c.~1~ Mon Jul 21 15:12:46 2003
--- ./stor-layout.c Thu Jul 24 14:13:26 2003
*************** set_sizetype (tree type)
*** 1941,1947 ****
for the sizes in them. */
for (t = early_type_list; t != 0; t = TREE_CHAIN (t))
{
! if (TREE_CODE (TREE_VALUE (t)) != INTEGER_TYPE)
abort ();
TREE_TYPE (TYPE_SIZE (TREE_VALUE (t))) = bitsizetype;
--- 1941,1948 ----
for the sizes in them. */
for (t = early_type_list; t != 0; t = TREE_CHAIN (t))
{
! if (TREE_CODE (TREE_VALUE (t)) != INTEGER_TYPE
! && TREE_CODE (TREE_VALUE (t)) != BOOLEAN_TYPE)
abort ();
TREE_TYPE (TYPE_SIZE (TREE_VALUE (t))) = bitsizetype;