1 /* Subroutines shared by all languages that are variants of C.
2 Copyright (C) 1992 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
30 /* Make bindings for __FUNCTION__ and __PRETTY_FUNCTION__. */
33 declare_function_name ()
36 char *name
, *printable_name
;
38 if (current_function_decl
== NULL
)
41 printable_name
= "top level";
45 char *kind
= "function";
46 if (TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
48 name
= IDENTIFIER_POINTER (DECL_NAME (current_function_decl
));
49 printable_name
= (*decl_printable_name
) (current_function_decl
, &kind
);
52 push_obstacks_nochange ();
53 decl
= build_decl (VAR_DECL
, get_identifier ("__FUNCTION__"),
54 char_array_type_node
);
55 TREE_STATIC (decl
) = 1;
56 TREE_READONLY (decl
) = 1;
57 TREE_NO_UNUSED_WARNING (decl
) = 1;
58 DECL_IGNORED_P (decl
) = 1;
59 init
= build_string (strlen (name
) + 1, name
);
60 TREE_TYPE (init
) = char_array_type_node
;
61 DECL_INITIAL (decl
) = init
;
62 finish_decl (pushdecl (decl
), init
, NULL_TREE
);
64 push_obstacks_nochange ();
65 decl
= build_decl (VAR_DECL
, get_identifier ("__PRETTY_FUNCTION__"),
66 char_array_type_node
);
67 TREE_STATIC (decl
) = 1;
68 TREE_READONLY (decl
) = 1;
69 TREE_NO_UNUSED_WARNING (decl
) = 1;
70 DECL_IGNORED_P (decl
) = 1;
71 init
= build_string (strlen (printable_name
) + 1, printable_name
);
72 TREE_TYPE (init
) = char_array_type_node
;
73 DECL_INITIAL (decl
) = init
;
74 finish_decl (pushdecl (decl
), init
, NULL_TREE
);
77 /* Given a chain of STRING_CST nodes,
78 concatenate them into one STRING_CST
79 and give it a suitable array-of-chars data type. */
82 combine_strings (strings
)
85 register tree value
, t
;
86 register int length
= 1;
89 int wchar_bytes
= TYPE_PRECISION (wchar_type_node
) / BITS_PER_UNIT
;
92 if (TREE_CHAIN (strings
))
94 /* More than one in the chain, so concatenate. */
97 /* Don't include the \0 at the end of each substring,
98 except for the last one.
99 Count wide strings and ordinary strings separately. */
100 for (t
= strings
; t
; t
= TREE_CHAIN (t
))
102 if (TREE_TYPE (t
) == wchar_array_type_node
)
104 wide_length
+= (TREE_STRING_LENGTH (t
) - wchar_bytes
);
108 length
+= (TREE_STRING_LENGTH (t
) - 1);
111 /* If anything is wide, the non-wides will be converted,
112 which makes them take more space. */
114 length
= length
* wchar_bytes
+ wide_length
;
116 p
= savealloc (length
);
118 /* Copy the individual strings into the new combined string.
119 If the combined string is wide, convert the chars to ints
120 for any individual strings that are not wide. */
123 for (t
= strings
; t
; t
= TREE_CHAIN (t
))
125 int len
= (TREE_STRING_LENGTH (t
)
126 - ((TREE_TYPE (t
) == wchar_array_type_node
)
128 if ((TREE_TYPE (t
) == wchar_array_type_node
) == wide_flag
)
130 bcopy (TREE_STRING_POINTER (t
), q
, len
);
136 for (i
= 0; i
< len
; i
++)
137 ((int *) q
)[i
] = TREE_STRING_POINTER (t
)[i
];
138 q
+= len
* wchar_bytes
;
144 for (i
= 0; i
< wchar_bytes
; i
++)
150 value
= make_node (STRING_CST
);
151 TREE_STRING_POINTER (value
) = p
;
152 TREE_STRING_LENGTH (value
) = length
;
153 TREE_CONSTANT (value
) = 1;
158 length
= TREE_STRING_LENGTH (value
);
159 if (TREE_TYPE (value
) == wchar_array_type_node
)
163 /* Compute the number of elements, for the array type. */
164 nchars
= wide_flag
? length
/ wchar_bytes
: length
;
166 /* Create the array type for the string constant.
167 -Wwrite-strings says make the string constant an array of const char
168 so that copying it to a non-const pointer will get a warning. */
169 if (warn_write_strings
170 && (! flag_traditional
&& ! flag_writable_strings
))
173 = build_type_variant (wide_flag
? wchar_type_node
: char_type_node
,
176 = build_array_type (elements
,
177 build_index_type (build_int_2 (nchars
- 1, 0)));
181 = build_array_type (wide_flag
? wchar_type_node
: char_type_node
,
182 build_index_type (build_int_2 (nchars
- 1, 0)));
183 TREE_CONSTANT (value
) = 1;
184 TREE_STATIC (value
) = 1;
188 /* Process the attributes listed in ATTRIBUTES
189 and install them in DECL. */
192 decl_attributes (decl
, attributes
)
193 tree decl
, attributes
;
196 for (a
= attributes
; a
; a
= TREE_CHAIN (a
))
197 if (TREE_VALUE (a
) == get_identifier ("packed"))
199 if (TREE_CODE (decl
) == FIELD_DECL
)
200 DECL_PACKED (decl
) = 1;
202 else if (TREE_VALUE (a
) != 0
203 && TREE_CODE (TREE_VALUE (a
)) == TREE_LIST
204 && TREE_PURPOSE (TREE_VALUE (a
)) == get_identifier ("mode"))
208 = IDENTIFIER_POINTER (TREE_VALUE (TREE_VALUE (a
)));
210 /* Give this decl a type with the specified mode. */
211 for (i
= 0; i
< NUM_MACHINE_MODES
; i
++)
212 if (!strcmp (specified_name
, GET_MODE_NAME (i
)))
215 = type_for_mode (i
, TREE_UNSIGNED (TREE_TYPE (decl
)));
218 TREE_TYPE (decl
) = type
;
219 DECL_SIZE (decl
) = 0;
223 error ("no data type for mode `%s'", specified_name
);
226 if (i
== NUM_MACHINE_MODES
)
227 error ("unknown machine mode `%s'", specified_name
);
229 else if (TREE_VALUE (a
) != 0
230 && TREE_CODE (TREE_VALUE (a
)) == TREE_LIST
231 && TREE_PURPOSE (TREE_VALUE (a
)) == get_identifier ("aligned"))
233 int align
= TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (a
)))
236 if (exact_log2 (align
) == -1)
237 error_with_decl (decl
,
238 "requested alignment of `%s' is not a power of 2");
239 else if (TREE_CODE (decl
) != VAR_DECL
240 && TREE_CODE (decl
) != FIELD_DECL
)
241 error_with_decl (decl
,
242 "alignment specified for `%s'");
244 DECL_ALIGN (decl
) = align
;
246 else if (TREE_VALUE (a
) != 0
247 && TREE_CODE (TREE_VALUE (a
)) == TREE_LIST
248 && TREE_PURPOSE (TREE_VALUE (a
)) == get_identifier ("format"))
250 tree list
= TREE_VALUE (TREE_VALUE (a
));
251 tree format_type
= TREE_PURPOSE (list
);
252 int format_num
= TREE_INT_CST_LOW (TREE_PURPOSE (TREE_VALUE (list
)));
253 int first_arg_num
= TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (list
)));
256 if (TREE_CODE (decl
) != FUNCTION_DECL
)
258 error_with_decl (decl
,
259 "argument format specified for non-function `%s'");
263 if (format_type
== get_identifier ("printf"))
265 else if (format_type
== get_identifier ("scanf"))
269 error_with_decl (decl
, "unrecognized format specifier for `%s'");
273 if (first_arg_num
!= 0 && first_arg_num
<= format_num
)
275 error_with_decl (decl
,
276 "format string arg follows the args to be formatted, for `%s'");
280 record_format_info (DECL_NAME (decl
), is_scan
, format_num
,
286 c_expand_expr_stmt (expr
)
289 /* Do default conversion if safe and possibly important,
290 in case within ({...}). */
291 if ((TREE_CODE (TREE_TYPE (expr
)) == ARRAY_TYPE
&& lvalue_p (expr
))
292 || TREE_CODE (TREE_TYPE (expr
)) == FUNCTION_TYPE
)
293 expr
= default_conversion (expr
);
295 if (TREE_TYPE (expr
) != error_mark_node
296 && TYPE_SIZE (TREE_TYPE (expr
)) == 0
297 && TREE_CODE (TREE_TYPE (expr
)) != ARRAY_TYPE
)
298 error ("expression statement has incomplete type");
300 expand_expr_stmt (expr
);
303 /* Validate the expression after `case' and apply default promotions. */
306 check_case_value (value
)
309 if (value
== NULL_TREE
)
312 /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
313 if (TREE_CODE (value
) == NON_LVALUE_EXPR
)
314 value
= TREE_OPERAND (value
, 0);
316 if (TREE_CODE (value
) != INTEGER_CST
317 && value
!= error_mark_node
)
319 error ("case label does not reduce to an integer constant");
320 value
= error_mark_node
;
323 /* Promote char or short to int. */
324 value
= default_conversion (value
);
329 /* Return an integer type with BITS bits of precision,
330 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
333 type_for_size (bits
, unsignedp
)
337 if (bits
<= TYPE_PRECISION (signed_char_type_node
))
338 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
340 if (bits
<= TYPE_PRECISION (short_integer_type_node
))
341 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
343 if (bits
<= TYPE_PRECISION (integer_type_node
))
344 return unsignedp
? unsigned_type_node
: integer_type_node
;
346 if (bits
<= TYPE_PRECISION (long_integer_type_node
))
347 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
349 if (bits
<= TYPE_PRECISION (long_long_integer_type_node
))
350 return (unsignedp
? long_long_unsigned_type_node
351 : long_long_integer_type_node
);
356 /* Return a data type that has machine mode MODE.
357 If the mode is an integer,
358 then UNSIGNEDP selects between signed and unsigned types. */
361 type_for_mode (mode
, unsignedp
)
362 enum machine_mode mode
;
365 if (mode
== TYPE_MODE (signed_char_type_node
))
366 return unsignedp
? unsigned_char_type_node
: signed_char_type_node
;
368 if (mode
== TYPE_MODE (short_integer_type_node
))
369 return unsignedp
? short_unsigned_type_node
: short_integer_type_node
;
371 if (mode
== TYPE_MODE (integer_type_node
))
372 return unsignedp
? unsigned_type_node
: integer_type_node
;
374 if (mode
== TYPE_MODE (long_integer_type_node
))
375 return unsignedp
? long_unsigned_type_node
: long_integer_type_node
;
377 if (mode
== TYPE_MODE (long_long_integer_type_node
))
378 return unsignedp
? long_long_unsigned_type_node
: long_long_integer_type_node
;
380 if (mode
== TYPE_MODE (float_type_node
))
381 return float_type_node
;
383 if (mode
== TYPE_MODE (double_type_node
))
384 return double_type_node
;
386 if (mode
== TYPE_MODE (long_double_type_node
))
387 return long_double_type_node
;
389 if (mode
== TYPE_MODE (build_pointer_type (char_type_node
)))
390 return build_pointer_type (char_type_node
);
392 if (mode
== TYPE_MODE (build_pointer_type (integer_type_node
)))
393 return build_pointer_type (integer_type_node
);
398 /* Print an error message for invalid operands to arith operation CODE.
399 NOP_EXPR is used as a special case (see truthvalue_conversion). */
402 binary_op_error (code
)
405 register char *opname
;
409 error ("invalid truth-value expression");
419 opname
= "max"; break;
421 opname
= "min"; break;
423 opname
= "=="; break;
425 opname
= "!="; break;
427 opname
= "<="; break;
429 opname
= ">="; break;
435 opname
= "<<"; break;
437 opname
= ">>"; break;
448 case TRUTH_ANDIF_EXPR
:
449 opname
= "&&"; break;
450 case TRUTH_ORIF_EXPR
:
451 opname
= "||"; break;
456 opname
= "rotate"; break;
458 error ("invalid operands to binary %s", opname
);
461 /* Subroutine of build_binary_op, used for comparison operations.
462 See if the operands have both been converted from subword integer types
463 and, if so, perhaps change them both back to their original type.
465 The arguments of this function are all pointers to local variables
466 of build_binary_op: OP0_PTR is &OP0, OP1_PTR is &OP1,
467 RESTYPE_PTR is &RESULT_TYPE and RESCODE_PTR is &RESULTCODE.
469 If this function returns nonzero, it means that the comparison has
470 a constant value. What this function returns is an expression for
474 shorten_compare (op0_ptr
, op1_ptr
, restype_ptr
, rescode_ptr
)
475 tree
*op0_ptr
, *op1_ptr
;
477 enum tree_code
*rescode_ptr
;
482 int unsignedp0
, unsignedp1
;
484 tree primop0
, primop1
;
485 enum tree_code code
= *rescode_ptr
;
487 /* Throw away any conversions to wider types
488 already present in the operands. */
490 primop0
= get_narrower (op0
, &unsignedp0
);
491 primop1
= get_narrower (op1
, &unsignedp1
);
493 /* Handle the case that OP0 does not *contain* a conversion
494 but it *requires* conversion to FINAL_TYPE. */
496 if (op0
== primop0
&& TREE_TYPE (op0
) != *restype_ptr
)
497 unsignedp0
= TREE_UNSIGNED (TREE_TYPE (op0
));
498 if (op1
== primop1
&& TREE_TYPE (op1
) != *restype_ptr
)
499 unsignedp1
= TREE_UNSIGNED (TREE_TYPE (op1
));
501 /* If one of the operands must be floated, we cannot optimize. */
502 real1
= TREE_CODE (TREE_TYPE (primop0
)) == REAL_TYPE
;
503 real2
= TREE_CODE (TREE_TYPE (primop1
)) == REAL_TYPE
;
505 /* If first arg is constant, swap the args (changing operation
506 so value is preserved), for canonicalization. */
508 if (TREE_CONSTANT (primop0
))
510 register tree tem
= primop0
;
511 register int temi
= unsignedp0
;
519 unsignedp0
= unsignedp1
;
543 /* If comparing an integer against a constant more bits wide,
544 maybe we can deduce a value of 1 or 0 independent of the data.
545 Or else truncate the constant now
546 rather than extend the variable at run time.
548 This is only interesting if the constant is the wider arg.
549 Also, it is not safe if the constant is unsigned and the
550 variable arg is signed, since in this case the variable
551 would be sign-extended and then regarded as unsigned.
552 Our technique fails in this case because the lowest/highest
553 possible unsigned results don't follow naturally from the
554 lowest/highest possible values of the variable operand.
555 For just EQ_EXPR and NE_EXPR there is another technique that
556 could be used: see if the constant can be faithfully represented
557 in the other operand's type, by truncating it and reextending it
558 and see if that preserves the constant's value. */
561 && TREE_CODE (primop1
) == INTEGER_CST
562 && TYPE_PRECISION (TREE_TYPE (primop0
)) < TYPE_PRECISION (*restype_ptr
))
564 int min_gt
, max_gt
, min_lt
, max_lt
;
566 /* 1 if comparison is nominally unsigned. */
567 int unsignedp
= TREE_UNSIGNED (*restype_ptr
);
570 type
= signed_or_unsigned_type (unsignedp0
, TREE_TYPE (primop0
));
572 maxval
= TYPE_MAX_VALUE (type
);
573 minval
= TYPE_MIN_VALUE (type
);
575 if (unsignedp
&& !unsignedp0
)
576 *restype_ptr
= signed_type (*restype_ptr
);
578 if (TREE_TYPE (primop1
) != *restype_ptr
)
579 primop1
= convert (*restype_ptr
, primop1
);
580 if (type
!= *restype_ptr
)
582 minval
= convert (*restype_ptr
, minval
);
583 maxval
= convert (*restype_ptr
, maxval
);
586 if (unsignedp
&& unsignedp0
)
588 min_gt
= INT_CST_LT_UNSIGNED (primop1
, minval
);
589 max_gt
= INT_CST_LT_UNSIGNED (primop1
, maxval
);
590 min_lt
= INT_CST_LT_UNSIGNED (minval
, primop1
);
591 max_lt
= INT_CST_LT_UNSIGNED (maxval
, primop1
);
595 min_gt
= INT_CST_LT (primop1
, minval
);
596 max_gt
= INT_CST_LT (primop1
, maxval
);
597 min_lt
= INT_CST_LT (minval
, primop1
);
598 max_lt
= INT_CST_LT (maxval
, primop1
);
602 /* This used to be a switch, but Genix compiler can't handle that. */
605 if (max_lt
|| min_gt
)
606 val
= integer_one_node
;
608 else if (code
== EQ_EXPR
)
610 if (max_lt
|| min_gt
)
611 val
= integer_zero_node
;
613 else if (code
== LT_EXPR
)
616 val
= integer_one_node
;
618 val
= integer_zero_node
;
620 else if (code
== GT_EXPR
)
623 val
= integer_one_node
;
625 val
= integer_zero_node
;
627 else if (code
== LE_EXPR
)
630 val
= integer_one_node
;
632 val
= integer_zero_node
;
634 else if (code
== GE_EXPR
)
637 val
= integer_one_node
;
639 val
= integer_zero_node
;
642 /* If primop0 was sign-extended and unsigned comparison specd,
643 we did a signed comparison above using the signed type bounds.
644 But the comparison we output must be unsigned.
646 Also, for inequalities, VAL is no good; but if the signed
647 comparison had *any* fixed result, it follows that the
648 unsigned comparison just tests the sign in reverse
649 (positive values are LE, negative ones GE).
650 So we can generate an unsigned comparison
651 against an extreme value of the signed type. */
653 if (unsignedp
&& !unsignedp0
)
660 primop1
= TYPE_MIN_VALUE (type
);
666 primop1
= TYPE_MAX_VALUE (type
);
670 type
= unsigned_type (type
);
673 if (!max_gt
&& !unsignedp0
)
675 /* This is the case of (char)x >?< 0x80, which people used to use
676 expecting old C compilers to change the 0x80 into -0x80. */
677 if (val
== integer_zero_node
)
678 warning ("comparison is always 0 due to limited range of data type");
679 if (val
== integer_one_node
)
680 warning ("comparison is always 1 due to limited range of data type");
683 if (!min_lt
&& unsignedp0
)
685 /* This is the case of (unsigned char)x >?< -1 or < 0. */
686 if (val
== integer_zero_node
)
687 warning ("comparison is always 0 due to limited range of data type");
688 if (val
== integer_one_node
)
689 warning ("comparison is always 1 due to limited range of data type");
694 /* Don't forget to evaluate PRIMOP0 if it has side effects. */
695 if (TREE_SIDE_EFFECTS (primop0
))
696 return build (COMPOUND_EXPR
, TREE_TYPE (val
), primop0
, val
);
700 /* Value is not predetermined, but do the comparison
701 in the type of the operand that is not constant.
702 TYPE is already properly set. */
704 else if (real1
&& real2
705 && TYPE_PRECISION (TREE_TYPE (primop0
)) == TYPE_PRECISION (TREE_TYPE (primop1
)))
706 type
= TREE_TYPE (primop0
);
708 /* If args' natural types are both narrower than nominal type
709 and both extend in the same manner, compare them
710 in the type of the wider arg.
711 Otherwise must actually extend both to the nominal
712 common type lest different ways of extending
714 (eg, (short)-1 == (unsigned short)-1 should be 0.) */
716 else if (unsignedp0
== unsignedp1
&& real1
== real2
717 && TYPE_PRECISION (TREE_TYPE (primop0
)) < TYPE_PRECISION (*restype_ptr
)
718 && TYPE_PRECISION (TREE_TYPE (primop1
)) < TYPE_PRECISION (*restype_ptr
))
720 type
= common_type (TREE_TYPE (primop0
), TREE_TYPE (primop1
));
721 type
= signed_or_unsigned_type (unsignedp0
722 || TREE_UNSIGNED (*restype_ptr
),
724 /* Make sure shorter operand is extended the right way
725 to match the longer operand. */
726 primop0
= convert (signed_or_unsigned_type (unsignedp0
, TREE_TYPE (primop0
)),
728 primop1
= convert (signed_or_unsigned_type (unsignedp1
, TREE_TYPE (primop1
)),
733 /* Here we must do the comparison on the nominal type
734 using the args exactly as we received them. */
739 if (!real1
&& !real2
&& integer_zerop (primop1
)
740 && TREE_UNSIGNED (TREE_TYPE (primop0
)))
747 warning ("unsigned value >= 0 is always 1");
748 value
= integer_one_node
;
753 warning ("unsigned value < 0 is always 0");
754 value
= integer_zero_node
;
759 /* Don't forget to evaluate PRIMOP0 if it has side effects. */
760 if (TREE_SIDE_EFFECTS (primop0
))
761 return build (COMPOUND_EXPR
, TREE_TYPE (value
),
768 *op0_ptr
= convert (type
, primop0
);
769 *op1_ptr
= convert (type
, primop1
);
771 *restype_ptr
= integer_type_node
;
776 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
777 or validate its data type for an `if' or `while' statement or ?..: exp.
779 This preparation consists of taking the ordinary
780 representation of an expression expr and producing a valid tree
781 boolean expression describing whether expr is nonzero. We could
782 simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
783 but we optimize comparisons, &&, ||, and !.
785 The resulting type should always be `integer_type_node'. */
788 truthvalue_conversion (expr
)
791 register enum tree_code code
;
793 switch (TREE_CODE (expr
))
795 /* It is simpler and generates better code to have only TRUTH_*_EXPR
796 or comparison expressions as truth values at this level. */
799 /* A one-bit unsigned bit-field is already acceptable. */
800 if (1 == TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (expr
, 1)))
801 && TREE_UNSIGNED (TREE_OPERAND (expr
, 1)))
807 /* It is simpler and generates better code to have only TRUTH_*_EXPR
808 or comparison expressions as truth values at this level. */
810 if (integer_zerop (TREE_OPERAND (expr
, 1)))
811 return build_unary_op (TRUTH_NOT_EXPR
, TREE_OPERAND (expr
, 0), 0);
813 case NE_EXPR
: case LE_EXPR
: case GE_EXPR
: case LT_EXPR
: case GT_EXPR
:
814 case TRUTH_ANDIF_EXPR
:
815 case TRUTH_ORIF_EXPR
:
822 return integer_zerop (expr
) ? integer_zero_node
: integer_one_node
;
825 return real_zerop (expr
) ? integer_zero_node
: integer_one_node
;
828 if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr
, 0)))
829 return build (COMPOUND_EXPR
, integer_type_node
,
830 TREE_OPERAND (expr
, 0), integer_one_node
);
832 return integer_one_node
;
838 /* These don't change whether an object is non-zero or zero. */
839 return truthvalue_conversion (TREE_OPERAND (expr
, 0));
843 /* These don't change whether an object is zero or non-zero, but
844 we can't ignore them if their second arg has side-effects. */
845 if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr
, 1)))
846 return build (COMPOUND_EXPR
, integer_type_node
, TREE_OPERAND (expr
, 1),
847 truthvalue_conversion (TREE_OPERAND (expr
, 0)));
849 return truthvalue_conversion (TREE_OPERAND (expr
, 0));
852 /* Distribute the conversion into the arms of a COND_EXPR. */
853 return fold (build (COND_EXPR
, integer_type_node
, TREE_OPERAND (expr
, 0),
854 truthvalue_conversion (TREE_OPERAND (expr
, 1)),
855 truthvalue_conversion (TREE_OPERAND (expr
, 2))));
858 /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
859 since that affects how `default_conversion' will behave. */
860 if (TREE_CODE (TREE_TYPE (expr
)) == REFERENCE_TYPE
861 || TREE_CODE (TREE_TYPE (TREE_OPERAND (expr
, 0))) == REFERENCE_TYPE
)
863 /* fall through... */
865 /* If this is widening the argument, we can ignore it. */
866 if (TYPE_PRECISION (TREE_TYPE (expr
))
867 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr
, 0))))
868 return truthvalue_conversion (TREE_OPERAND (expr
, 0));
873 /* These can be changed into a comparison of the two objects. */
874 if (TREE_TYPE (TREE_OPERAND (expr
, 0))
875 == TREE_TYPE (TREE_OPERAND (expr
, 1)))
876 return build_binary_op (NE_EXPR
, TREE_OPERAND (expr
, 0),
877 TREE_OPERAND (expr
, 1), 1);
878 return build_binary_op (NE_EXPR
, TREE_OPERAND (expr
, 0),
879 fold (build1 (NOP_EXPR
,
880 TREE_TYPE (TREE_OPERAND (expr
, 0)),
881 TREE_OPERAND (expr
, 1))), 1);
884 return build_binary_op (NE_EXPR
, expr
, integer_zero_node
, 1);
887 /* Read the rest of a #-directive from input stream FINPUT.
888 In normal use, the directive name and the white space after it
889 have already been read, so they won't be included in the result.
890 We allow for the fact that the directive line may contain
891 a newline embedded within a character or string literal which forms
892 a part of the directive.
894 The value is a string in a reusable buffer. It remains valid
895 only until the next time this function is called. */
898 get_directive_line (finput
)
899 register FILE *finput
;
901 static char *directive_buffer
= NULL
;
902 static unsigned buffer_length
= 0;
904 register char *buffer_limit
;
905 register int looking_for
= 0;
906 register int char_escaped
= 0;
908 if (buffer_length
== 0)
910 directive_buffer
= (char *)xmalloc (128);
914 buffer_limit
= &directive_buffer
[buffer_length
];
916 for (p
= directive_buffer
; ; )
920 /* Make buffer bigger if it is full. */
921 if (p
>= buffer_limit
)
923 register unsigned bytes_used
= (p
- directive_buffer
);
927 = (char *)xrealloc (directive_buffer
, buffer_length
);
928 p
= &directive_buffer
[bytes_used
];
929 buffer_limit
= &directive_buffer
[buffer_length
];
934 /* Discard initial whitespace. */
935 if ((c
== ' ' || c
== '\t') && p
== directive_buffer
)
938 /* Detect the end of the directive. */
939 if (c
== '\n' && looking_for
== 0)
948 return directive_buffer
;
950 /* Handle string and character constant syntax. */
953 if (looking_for
== c
&& !char_escaped
)
954 looking_for
= 0; /* Found terminator... stop looking. */
957 if (c
== '\'' || c
== '"')
958 looking_for
= c
; /* Don't stop buffering until we see another
959 another one of these (or an EOF). */
961 /* Handle backslash. */
962 char_escaped
= (c
== '\\' && ! char_escaped
);