1 /* Parse C expressions for CCCP.
2 Copyright (C) 1987, 92, 94, 95, 97, 98, 1999 Free Software Foundation.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2, or (at your option) any
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
19 In other words, you are welcome to use, share and improve this program.
20 You are forbidden to forbid anyone else to use, share and improve
21 what you give them. Help stamp out software-hoarding!
23 Written by Per Bothner 1994. */
25 /* Parse a C expression from text in a string */
31 #ifdef MULTIBYTE_CHARS
35 #ifndef CHAR_TYPE_SIZE
36 #define CHAR_TYPE_SIZE BITS_PER_UNIT
40 #define INT_TYPE_SIZE BITS_PER_WORD
43 #ifndef LONG_TYPE_SIZE
44 #define LONG_TYPE_SIZE BITS_PER_WORD
47 #ifndef WCHAR_TYPE_SIZE
48 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
51 #ifndef MAX_CHAR_TYPE_SIZE
52 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
55 #ifndef MAX_INT_TYPE_SIZE
56 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
59 #ifndef MAX_LONG_TYPE_SIZE
60 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
63 #ifndef MAX_WCHAR_TYPE_SIZE
64 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
67 #define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \
68 ? (~ (~ (HOST_WIDEST_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
69 : ~ (HOST_WIDEST_INT) 0)
71 #define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \
72 ? ~ (~ (HOST_WIDEST_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
73 : ~ (HOST_WIDEST_INT) 0)
75 /* Yield nonzero if adding two numbers with A's and B's signs can yield a
76 number with SUM's sign, where A, B, and SUM are all C integers. */
77 #define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0)
79 static void integer_overflow
PARAMS ((cpp_reader
*));
80 static HOST_WIDEST_INT left_shift
PARAMS ((cpp_reader
*, HOST_WIDEST_INT
, int, unsigned HOST_WIDEST_INT
));
81 static HOST_WIDEST_INT right_shift
PARAMS ((cpp_reader
*, HOST_WIDEST_INT
, int, unsigned HOST_WIDEST_INT
));
96 #define LEFT_OPERAND_REQUIRED 1
97 #define RIGHT_OPERAND_REQUIRED 2
99 /* SKIP_OPERAND is set for '&&' '||' '?' and ':' when the
100 following operand should be short-circuited instead of evaluated. */
101 #define SKIP_OPERAND 8
102 /*#define UNSIGNEDP 16*/
104 #define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)
108 char rprio
; /* Priority of op (relative to it right operand). */
110 char unsignedp
; /* true if value should be treated as unsigned */
111 HOST_WIDEST_INT value
; /* The value logically "right" of op. */
114 /* Parse and convert an integer for #if. Accepts decimal, hex, or octal
115 with or without size suffixes. */
117 static struct operation
118 parse_number (pfile
, start
, end
)
126 unsigned HOST_WIDEST_INT n
= 0, nd
, MAX_over_base
;
129 int digit
, largest_digit
= 0;
136 if (end
- start
>= 3 && (p
[1] == 'x' || p
[1] == 'X'))
148 /* Some buggy compilers (e.g. MPW C) seem to need both casts. */
149 MAX_over_base
= (((unsigned HOST_WIDEST_INT
) -1)
150 / ((unsigned HOST_WIDEST_INT
) base
));
156 if (c
>= '0' && c
<= '9')
158 else if (base
== 16 && c
>= 'a' && c
<= 'f') /* FIXME: assumes ASCII */
159 digit
= c
- 'a' + 10;
160 else if (base
== 16 && c
>= 'A' && c
<= 'F')
161 digit
= c
- 'A' + 10;
164 /* It's a float since it contains a point. */
166 "floating point numbers are not allowed in #if expressions");
171 /* `l' means long, and `u' means unsigned. */
174 if (c
== 'l' || c
== 'L')
176 else if (c
== 'u' || c
== 'U')
180 /* Decrement p here so that the error for an invalid number
181 will be generated below in the case where this is the
182 last character in the buffer. */
190 /* Don't look for any more digits after the suffixes. */
194 if (largest_digit
< digit
)
195 largest_digit
= digit
;
196 nd
= n
* base
+ digit
;
197 overflow
|= MAX_over_base
< n
|| nd
< n
;
203 cpp_error (pfile
, "invalid number in #if expression");
206 else if (spec_long
> (CPP_OPTIONS (pfile
)->c89
? 1 : 2))
208 cpp_error (pfile
, "too many `l' suffixes in integer constant");
211 else if (op
.unsignedp
> 1)
213 cpp_error (pfile
, "too many `u' suffixes in integer constant");
217 if (base
<= largest_digit
)
218 cpp_pedwarn (pfile
, "integer constant contains digits beyond the radix");
221 cpp_pedwarn (pfile
, "integer constant out of range");
223 /* If too big to be signed, consider it unsigned. */
224 else if ((HOST_WIDEST_INT
) n
< 0 && ! op
.unsignedp
)
228 "integer constant is so large that it is unsigned");
241 /* Parse and convert a character constant for #if. Understands backslash
242 escapes (\n, \031) and multibyte characters (if so configured). */
243 static struct operation
244 parse_charconst (pfile
, start
, end
)
250 HOST_WIDEST_INT result
= 0;
253 unsigned int width
= MAX_CHAR_TYPE_SIZE
, mask
= MAX_CHAR_TYPE_MASK
;
257 /* FIXME: Should use reentrant multibyte functions. */
258 #ifdef MULTIBYTE_CHARS
260 (void) mbtowc (NULL_PTR
, NULL_PTR
, 0);
268 width
= MAX_WCHAR_TYPE_SIZE
, mask
= MAX_WCHAR_TYPE_MASK
;
270 max_chars
= MAX_LONG_TYPE_SIZE
/ width
;
272 ++ptr
; /* skip initial quote */
276 #ifndef MULTIBYTE_CHARS
279 ptr
+= mbtowc (&c
, ptr
, end
- ptr
);
281 if (c
== '\'' || c
== '\0')
285 /* Hopefully valid assumption: if mbtowc returns a backslash,
286 we are in initial shift state. No valid escape-sequence
287 character can take us out of initial shift state or begin
288 an unshifted multibyte char, so cpp_parse_escape doesn't
289 need to know about multibyte chars. */
291 c
= cpp_parse_escape (pfile
, (char **) &ptr
, mask
);
292 if (width
< HOST_BITS_PER_INT
293 && (unsigned int) c
>= (unsigned int)(1 << width
))
294 cpp_pedwarn (pfile
, "escape sequence out of range for character");
297 /* Merge character into result; ignore excess chars. */
298 if (++num_chars
<= max_chars
)
300 if (width
< HOST_BITS_PER_INT
)
301 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
309 cpp_error (pfile
, "empty character constant");
314 /* cpp_get_token has already emitted an error if !traditional. */
315 if (! CPP_TRADITIONAL (pfile
))
316 cpp_error (pfile
, "malformatted character constant");
319 else if (num_chars
> max_chars
)
321 cpp_error (pfile
, "character constant too long");
324 else if (num_chars
!= 1 && ! CPP_TRADITIONAL (pfile
))
325 cpp_warning (pfile
, "multi-character character constant");
327 /* If char type is signed, sign-extend the constant. */
328 num_bits
= num_chars
* width
;
330 if (cpp_lookup (pfile
, (U_CHAR
*)"__CHAR_UNSIGNED__",
331 sizeof ("__CHAR_UNSIGNED__")-1, -1)
332 || ((result
>> (num_bits
- 1)) & 1) == 0)
333 op
.value
= result
& ((unsigned HOST_WIDEST_INT
) ~0
334 >> (HOST_BITS_PER_WIDEST_INT
- num_bits
));
336 op
.value
= result
| ~((unsigned HOST_WIDEST_INT
) ~0
337 >> (HOST_BITS_PER_WIDEST_INT
- num_bits
));
339 /* This is always a signed type. */
355 static struct token tokentab2
[] = {
369 /* Read one token. */
371 static struct operation
372 cpp_lex (pfile
, skip_evaluation
)
377 struct token
*toktab
;
378 enum cpp_token token
;
380 U_CHAR
*tok_start
, *tok_end
;
385 old_written
= CPP_WRITTEN (pfile
);
386 cpp_skip_hspace (pfile
);
387 c
= CPP_BUF_PEEK (CPP_BUFFER (pfile
));
391 op
.value
= cpp_read_check_assertion (pfile
);
401 token
= cpp_get_token (pfile
);
402 tok_start
= pfile
->token_buffer
+ old_written
;
403 tok_end
= CPP_PWRITTEN (pfile
);
404 pfile
->limit
= tok_start
;
407 case CPP_EOF
: /* Should not happen ... */
412 if (CPP_BUFFER (pfile
)->fname
!= NULL
)
417 cpp_pop_buffer (pfile
);
423 return parse_number (pfile
, tok_start
, tok_end
);
425 cpp_error (pfile
, "string constants not allowed in #if expressions");
429 return parse_charconst (pfile
, tok_start
, tok_end
);
435 if (strcmp (tok_start
, "defined"))
437 if (CPP_WARN_UNDEF (pfile
) && !skip_evaluation
)
438 cpp_warning (pfile
, "`%.*s' is not defined",
439 (int) (tok_end
- tok_start
), tok_start
);
444 cpp_buffer
*ip
= CPP_BUFFER (pfile
);
447 SKIP_WHITE_SPACE (ip
->cur
);
451 ip
->cur
++; /* Skip over the paren */
452 SKIP_WHITE_SPACE (ip
->cur
);
455 if (!is_idstart
[*ip
->cur
])
457 if (ip
->cur
[0] == 'L' && (ip
->cur
[1] == '\'' || ip
->cur
[1] == '"'))
460 while (is_idchar
[*ip
->cur
])
463 SKIP_WHITE_SPACE (ip
->cur
);
470 if (cpp_lookup (pfile
, tok
, len
, -1))
477 cpp_error (pfile
, "`defined' without an identifier");
481 /* See if it is a special token of length 2. */
482 if (tok_start
+ 2 == tok_end
)
484 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
485 if (tok_start
[0] == toktab
->operator[0]
486 && tok_start
[1] == toktab
->operator[1])
488 if (toktab
->token
== ERROR
)
489 cpp_error (pfile
, "`%s' not allowed in operand of `#if'",
491 op
.op
= toktab
->token
;
502 /* Parse a C escape sequence. STRING_PTR points to a variable
503 containing a pointer to the string to parse. That pointer
504 is updated past the characters we use. The value of the
505 escape sequence is returned.
507 A negative value means the sequence \ newline was seen,
508 which is supposed to be equivalent to nothing at all.
510 If \ is followed by a null character, we return a negative
511 value and leave the string pointer pointing at the null character.
513 If \ is followed by 000, we return 0 and leave the string pointer
514 after the zeros. A value of 0 does not mean end of string. */
517 cpp_parse_escape (pfile
, string_ptr
, result_mask
)
520 HOST_WIDEST_INT result_mask
;
522 register int c
= *(*string_ptr
)++;
531 if (CPP_OPTIONS (pfile
)->pedantic
)
532 cpp_pedwarn (pfile
, "non-ANSI-standard escape sequence, `\\%c'", c
);
537 return TARGET_NEWLINE
;
559 register HOST_WIDEST_INT i
= c
- '0';
560 register int count
= 0;
563 c
= *(*string_ptr
)++;
564 if (c
>= '0' && c
<= '7')
565 i
= (i
<< 3) + c
- '0';
572 if (i
!= (i
& result_mask
))
575 cpp_pedwarn (pfile
, "octal escape sequence out of range");
581 register unsigned HOST_WIDEST_INT i
= 0, overflow
= 0;
582 register int digits_found
= 0, digit
;
585 c
= *(*string_ptr
)++;
586 if (c
>= '0' && c
<= '9')
588 else if (c
>= 'a' && c
<= 'f')
589 digit
= c
- 'a' + 10;
590 else if (c
>= 'A' && c
<= 'F')
591 digit
= c
- 'A' + 10;
597 overflow
|= i
^ (i
<< 4 >> 4);
598 i
= (i
<< 4) + digit
;
602 cpp_error (pfile
, "\\x used with no following hex digits");
603 if (overflow
| (i
!= (i
& result_mask
)))
606 cpp_pedwarn (pfile
, "hex escape sequence out of range");
616 integer_overflow (pfile
)
619 if (CPP_PEDANTIC (pfile
))
620 cpp_pedwarn (pfile
, "integer overflow in preprocessor expression");
623 static HOST_WIDEST_INT
624 left_shift (pfile
, a
, unsignedp
, b
)
628 unsigned HOST_WIDEST_INT b
;
630 if (b
>= HOST_BITS_PER_WIDEST_INT
)
632 if (! unsignedp
&& a
!= 0)
633 integer_overflow (pfile
);
637 return (unsigned HOST_WIDEST_INT
) a
<< b
;
640 HOST_WIDEST_INT l
= a
<< b
;
642 integer_overflow (pfile
);
647 static HOST_WIDEST_INT
648 right_shift (pfile
, a
, unsignedp
, b
)
649 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
652 unsigned HOST_WIDEST_INT b
;
654 if (b
>= HOST_BITS_PER_WIDEST_INT
)
655 return unsignedp
? 0 : a
>> (HOST_BITS_PER_WIDEST_INT
- 1);
657 return (unsigned HOST_WIDEST_INT
) a
>> b
;
662 /* These priorities are all even, so we can handle associatively. */
663 #define PAREN_INNER_PRIO 0
665 #define COND_PRIO (COMMA_PRIO+2)
666 #define OROR_PRIO (COND_PRIO+2)
667 #define ANDAND_PRIO (OROR_PRIO+2)
668 #define OR_PRIO (ANDAND_PRIO+2)
669 #define XOR_PRIO (OR_PRIO+2)
670 #define AND_PRIO (XOR_PRIO+2)
671 #define EQUAL_PRIO (AND_PRIO+2)
672 #define LESS_PRIO (EQUAL_PRIO+2)
673 #define SHIFT_PRIO (LESS_PRIO+2)
674 #define PLUS_PRIO (SHIFT_PRIO+2)
675 #define MUL_PRIO (PLUS_PRIO+2)
676 #define UNARY_PRIO (MUL_PRIO+2)
677 #define PAREN_OUTER_PRIO (UNARY_PRIO+2)
679 #define COMPARE(OP) \
681 top->value = (unsigned1 || unsigned2) \
682 ? (unsigned HOST_WIDEST_INT) v1 OP (unsigned HOST_WIDEST_INT) v2 : (v1 OP v2)
684 /* Parse and evaluate a C expression, reading from PFILE.
685 Returns the value of the expression. */
688 cpp_parse_expr (pfile
)
691 /* The implementation is an operator precedence parser,
692 i.e. a bottom-up parser, using a stack for not-yet-reduced tokens.
694 The stack base is 'stack', and the current stack pointer is 'top'.
695 There is a stack element for each operator (only),
696 and the most recently pushed operator is 'top->op'.
697 An operand (value) is stored in the 'value' field of the stack
698 element of the operator that precedes it.
699 In that case the 'flags' field has the HAVE_VALUE flag set. */
701 #define INIT_STACK_SIZE 20
702 struct operation init_stack
[INIT_STACK_SIZE
];
703 struct operation
*stack
= init_stack
;
704 struct operation
*limit
= stack
+ INIT_STACK_SIZE
;
705 register struct operation
*top
= stack
;
707 int skip_evaluation
= 0;
717 op
= cpp_lex (pfile
, skip_evaluation
);
719 /* See if the token is an operand, in which case go to set_value.
720 If the token is an operator, figure out its left and right
721 priorities, and then goto maybe_reduce. */
728 top
->value
= op
.value
;
729 top
->unsignedp
= op
.unsignedp
;
732 lprio
= 0; goto maybe_reduce
;
734 /* Is this correct if unary ? FIXME */
735 flags
= RIGHT_OPERAND_REQUIRED
;
736 lprio
= PLUS_PRIO
; rprio
= lprio
+ 1; goto maybe_reduce
;
738 flags
= RIGHT_OPERAND_REQUIRED
;
739 rprio
= UNARY_PRIO
; lprio
= rprio
+ 1; goto maybe_reduce
;
740 case '*': case '/': case '%':
741 lprio
= MUL_PRIO
; goto binop
;
742 case '<': case '>': case LEQ
: case GEQ
:
743 lprio
= LESS_PRIO
; goto binop
;
744 case EQUAL
: case NOTEQUAL
:
745 lprio
= EQUAL_PRIO
; goto binop
;
747 lprio
= SHIFT_PRIO
; goto binop
;
748 case '&': lprio
= AND_PRIO
; goto binop
;
749 case '^': lprio
= XOR_PRIO
; goto binop
;
750 case '|': lprio
= OR_PRIO
; goto binop
;
751 case ANDAND
: lprio
= ANDAND_PRIO
; goto binop
;
752 case OROR
: lprio
= OROR_PRIO
; goto binop
;
754 lprio
= COMMA_PRIO
; goto binop
;
756 lprio
= PAREN_OUTER_PRIO
; rprio
= PAREN_INNER_PRIO
;
759 lprio
= PAREN_INNER_PRIO
; rprio
= PAREN_OUTER_PRIO
;
762 lprio
= COND_PRIO
; rprio
= COND_PRIO
;
765 lprio
= COND_PRIO
+ 1; rprio
= COND_PRIO
;
770 flags
= LEFT_OPERAND_REQUIRED
|RIGHT_OPERAND_REQUIRED
;
774 cpp_error (pfile
, "invalid character in #if");
779 /* Push a value onto the stack. */
780 if (top
->flags
& HAVE_VALUE
)
782 cpp_error (pfile
, "syntax error in #if");
785 top
->flags
|= HAVE_VALUE
;
789 /* Push an operator, and check if we can reduce now. */
790 while (top
->rprio
> lprio
)
792 HOST_WIDEST_INT v1
= top
[-1].value
, v2
= top
[0].value
;
793 int unsigned1
= top
[-1].unsignedp
, unsigned2
= top
[0].unsignedp
;
795 if ((top
[1].flags
& LEFT_OPERAND_REQUIRED
)
796 && ! (top
[0].flags
& HAVE_VALUE
))
798 cpp_error (pfile
, "syntax error - missing left operand");
801 if ((top
[1].flags
& RIGHT_OPERAND_REQUIRED
)
802 && ! (top
[1].flags
& HAVE_VALUE
))
804 cpp_error (pfile
, "syntax error - missing right operand");
807 /* top[0].value = (top[1].op)(v1, v2);*/
811 if (!(top
->flags
& HAVE_VALUE
))
814 top
->unsignedp
= unsigned2
;
815 top
->flags
|= HAVE_VALUE
;
819 top
->value
= v1
+ v2
;
820 top
->unsignedp
= unsigned1
|| unsigned2
;
821 if (! top
->unsignedp
&& ! skip_evaluation
822 && ! possible_sum_sign (v1
, v2
, top
->value
))
823 integer_overflow (pfile
);
827 if (!(top
->flags
& HAVE_VALUE
))
830 if (!skip_evaluation
&& (top
->value
& v2
) < 0 && !unsigned2
)
831 integer_overflow (pfile
);
832 top
->unsignedp
= unsigned2
;
833 top
->flags
|= HAVE_VALUE
;
837 top
->value
= v1
- v2
;
838 top
->unsignedp
= unsigned1
|| unsigned2
;
839 if (! top
->unsignedp
&& ! skip_evaluation
840 && ! possible_sum_sign (top
->value
, v2
, v1
))
841 integer_overflow (pfile
);
845 top
->unsignedp
= unsigned1
|| unsigned2
;
847 top
->value
= (unsigned HOST_WIDEST_INT
) v1
* v2
;
848 else if (!skip_evaluation
)
850 top
->value
= v1
* v2
;
852 && (top
->value
/ v1
!= v2
853 || (top
->value
& v1
& v2
) < 0))
854 integer_overflow (pfile
);
862 cpp_error (pfile
, "division by zero in #if");
865 top
->unsignedp
= unsigned1
|| unsigned2
;
867 top
->value
= (unsigned HOST_WIDEST_INT
) v1
/ v2
;
870 top
->value
= v1
/ v2
;
871 if ((top
->value
& v1
& v2
) < 0)
872 integer_overflow (pfile
);
880 cpp_error (pfile
, "division by zero in #if");
883 top
->unsignedp
= unsigned1
|| unsigned2
;
885 top
->value
= (unsigned HOST_WIDEST_INT
) v1
% v2
;
887 top
->value
= v1
% v2
;
890 if (top
->flags
& HAVE_VALUE
)
892 cpp_error (pfile
, "syntax error");
897 top
->flags
|= HAVE_VALUE
;
900 if (top
->flags
& HAVE_VALUE
)
902 cpp_error (pfile
, "syntax error");
906 top
->unsignedp
= unsigned2
;
907 top
->flags
|= HAVE_VALUE
;
909 case '<': COMPARE(<); break;
910 case '>': COMPARE(>); break;
911 case LEQ
: COMPARE(<=); break;
912 case GEQ
: COMPARE(>=); break;
914 top
->value
= (v1
== v2
);
918 top
->value
= (v1
!= v2
);
924 top
->unsignedp
= unsigned1
;
925 if (v2
< 0 && ! unsigned2
)
926 top
->value
= right_shift (pfile
, v1
, unsigned1
, -v2
);
928 top
->value
= left_shift (pfile
, v1
, unsigned1
, v2
);
933 top
->unsignedp
= unsigned1
;
934 if (v2
< 0 && ! unsigned2
)
935 top
->value
= left_shift (pfile
, v1
, unsigned1
, -v2
);
937 top
->value
= right_shift (pfile
, v1
, unsigned1
, v2
);
939 #define LOGICAL(OP) \
940 top->value = v1 OP v2;\
941 top->unsignedp = unsigned1 || unsigned2;
942 case '&': LOGICAL(&); break;
943 case '^': LOGICAL(^); break;
944 case '|': LOGICAL(|); break;
946 top
->value
= v1
&& v2
; top
->unsignedp
= 0;
947 if (!v1
) skip_evaluation
--;
950 top
->value
= v1
|| v2
; top
->unsignedp
= 0;
951 if (v1
) skip_evaluation
--;
954 if (CPP_PEDANTIC (pfile
))
955 cpp_pedwarn (pfile
, "comma operator in operand of `#if'");
957 top
->unsignedp
= unsigned2
;
960 cpp_error (pfile
, "syntax error in #if");
963 if (top
[0].op
!= '?')
966 "syntax error ':' without preceding '?'");
969 else if (! (top
[1].flags
& HAVE_VALUE
)
970 || !(top
[-1].flags
& HAVE_VALUE
)
971 || !(top
[0].flags
& HAVE_VALUE
))
973 cpp_error (pfile
, "bad syntax for ?: operator");
979 if (top
->value
) skip_evaluation
--;
980 top
->value
= top
->value
? v1
: v2
;
981 top
->unsignedp
= unsigned1
|| unsigned2
;
985 if ((top
[1].flags
& HAVE_VALUE
)
986 || ! (top
[0].flags
& HAVE_VALUE
)
988 || (top
[-1].flags
& HAVE_VALUE
))
990 cpp_error (pfile
, "mismatched parentheses in #if");
997 top
->unsignedp
= unsigned1
;
998 top
->flags
|= HAVE_VALUE
;
1003 (top
[1].op
>= ' ' && top
[1].op
<= '~'
1004 ? "unimplemented operator '%c'\n"
1005 : "unimplemented operator '\\%03o'\n"),
1012 cpp_error (pfile
, "internal error in #if expression");
1013 if (stack
!= init_stack
)
1019 /* Check for and handle stack overflow. */
1022 struct operation
*new_stack
;
1023 int old_size
= (char *) limit
- (char *) stack
;
1024 int new_size
= 2 * old_size
;
1025 if (stack
!= init_stack
)
1026 new_stack
= (struct operation
*) xrealloc (stack
, new_size
);
1029 new_stack
= (struct operation
*) xmalloc (new_size
);
1030 bcopy ((char *) stack
, (char *) new_stack
, old_size
);
1033 top
= (struct operation
*) ((char *) new_stack
+ old_size
);
1034 limit
= (struct operation
*) ((char *) new_stack
+ new_size
);
1040 if ((op
.op
== OROR
&& top
[-1].value
)
1041 || (op
.op
== ANDAND
&& !top
[-1].value
)
1042 || (op
.op
== '?' && !top
[-1].value
))
1046 else if (op
.op
== ':')
1048 if (top
[-2].value
) /* Was condition true? */
1055 if (stack
!= init_stack
)
1057 skip_rest_of_line (pfile
);