1 /* Parse C expressions for cpplib.
2 Copyright (C) 1987, 1992, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
3 2002 Free Software Foundation.
4 Contributed by Per Bothner, 1994.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program 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 this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
26 /* Yield nonzero if adding two numbers with A's and B's signs can yield a
27 number with SUM's sign, where A, B, and SUM are all C integers. */
28 #define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0)
30 static void integer_overflow
PARAMS ((cpp_reader
*));
31 static HOST_WIDEST_INT left_shift
PARAMS ((cpp_reader
*, HOST_WIDEST_INT
,
33 unsigned HOST_WIDEST_INT
));
34 static HOST_WIDEST_INT right_shift
PARAMS ((cpp_reader
*, HOST_WIDEST_INT
,
36 unsigned HOST_WIDEST_INT
));
37 static struct op parse_number
PARAMS ((cpp_reader
*, const cpp_token
*));
38 static struct op parse_defined
PARAMS ((cpp_reader
*));
39 static struct op eval_token
PARAMS ((cpp_reader
*, const cpp_token
*));
40 static struct op
*reduce
PARAMS ((cpp_reader
*, struct op
*, enum cpp_ttype
));
45 uchar unsignedp
; /* True if value should be treated as unsigned. */
46 HOST_WIDEST_INT value
; /* The value logically "right" of op. */
49 /* Token type abuse. There is no "error" token, but we can't get
50 comments in #if, so we can abuse that token type. Similarly,
51 create unary plus and minus operators. */
52 #define CPP_ERROR CPP_COMMENT
53 #define CPP_UPLUS (CPP_LAST_CPP_OP + 1)
54 #define CPP_UMINUS (CPP_LAST_CPP_OP + 2)
56 /* With -O2, gcc appears to produce nice code, moving the error
57 message load and subsequent jump completely out of the main path. */
58 #define SYNTAX_ERROR(msgid) \
59 do { cpp_error (pfile, DL_ERROR, msgid); goto syntax_error; } while(0)
60 #define SYNTAX_ERROR2(msgid, arg) \
61 do { cpp_error (pfile, DL_ERROR, msgid, arg); goto syntax_error; } while(0)
65 const unsigned char s
[4];
66 const unsigned char u
;
67 const unsigned char l
;
70 static const struct suffix vsuf_1
[] = {
71 { "u", 1, 0 }, { "U", 1, 0 },
72 { "l", 0, 1 }, { "L", 0, 1 }
75 static const struct suffix vsuf_2
[] = {
76 { "ul", 1, 1 }, { "UL", 1, 1 }, { "uL", 1, 1 }, { "Ul", 1, 1 },
77 { "lu", 1, 1 }, { "LU", 1, 1 }, { "Lu", 1, 1 }, { "lU", 1, 1 },
78 { "ll", 0, 2 }, { "LL", 0, 2 }
81 static const struct suffix vsuf_3
[] = {
82 { "ull", 1, 2 }, { "ULL", 1, 2 }, { "uLL", 1, 2 }, { "Ull", 1, 2 },
83 { "llu", 1, 2 }, { "LLU", 1, 2 }, { "LLu", 1, 2 }, { "llU", 1, 2 }
86 /* Parse and convert what is presumably an integer in TOK. Accepts
87 decimal, hex, or octal with or without size suffixes. Returned op
88 is CPP_ERROR on error, otherwise it is a CPP_NUMBER. */
90 parse_number (pfile
, tok
)
95 const uchar
*start
= tok
->val
.str
.text
;
96 const uchar
*end
= start
+ tok
->val
.str
.len
;
97 const uchar
*p
= start
;
99 unsigned HOST_WIDEST_INT n
= 0, nd
, MAX_over_base
;
102 int digit
, largest_digit
= 0;
103 const struct suffix
*sufftab
;
109 if (end
- start
>= 3 && (p
[1] == 'x' || p
[1] == 'X'))
121 /* Some buggy compilers (e.g. MPW C) seem to need both casts. */
122 MAX_over_base
= (((unsigned HOST_WIDEST_INT
) -1)
123 / ((unsigned HOST_WIDEST_INT
) base
));
130 || (base
== 16 && ISXDIGIT (c
)))
131 digit
= hex_value (c
);
135 if (largest_digit
< digit
)
136 largest_digit
= digit
;
137 nd
= n
* base
+ digit
;
138 overflow
|= MAX_over_base
< n
|| nd
< n
;
144 /* Check for a floating point constant. Note that float constants
145 with an exponent or suffix but no decimal point are technically
146 invalid (C99 6.4.4.2) but accepted elsewhere. */
147 if ((c
== '.' || c
== 'F' || c
== 'f')
148 || (base
== 10 && (c
== 'E' || c
== 'e')
149 && p
+1 < end
&& (p
[1] == '+' || p
[1] == '-'))
150 || (base
== 16 && (c
== 'P' || c
== 'p')
151 && p
+1 < end
&& (p
[1] == '+' || p
[1] == '-')))
152 SYNTAX_ERROR ("floating point numbers are not valid in #if");
154 /* Determine the suffix. l means long, and u means unsigned.
155 See the suffix tables, above. */
158 case 1: sufftab
= vsuf_1
; nsuff
= ARRAY_SIZE (vsuf_1
); break;
159 case 2: sufftab
= vsuf_2
; nsuff
= ARRAY_SIZE (vsuf_2
); break;
160 case 3: sufftab
= vsuf_3
; nsuff
= ARRAY_SIZE (vsuf_3
); break;
161 default: goto invalid_suffix
;
164 for (i
= 0; i
< nsuff
; i
++)
165 if (memcmp (p
, sufftab
[i
].s
, end
- p
) == 0)
169 op
.unsignedp
= sufftab
[i
].u
;
171 if (CPP_WTRADITIONAL (pfile
)
173 && ! cpp_sys_macro_p (pfile
))
174 cpp_error (pfile
, DL_WARNING
, "traditional C rejects the `U' suffix");
175 if (sufftab
[i
].l
== 2 && CPP_OPTION (pfile
, pedantic
)
176 && ! CPP_OPTION (pfile
, c99
))
177 cpp_error (pfile
, DL_PEDWARN
,
178 "too many 'l' suffixes in integer constant");
181 if (base
<= largest_digit
)
182 cpp_error (pfile
, DL_PEDWARN
,
183 "integer constant contains digits beyond the radix");
186 cpp_error (pfile
, DL_PEDWARN
, "integer constant out of range");
188 /* If too big to be signed, consider it unsigned. */
189 else if ((HOST_WIDEST_INT
) n
< 0 && ! op
.unsignedp
)
192 cpp_error (pfile
, DL_WARNING
,
193 "integer constant is so large that it is unsigned");
202 cpp_error (pfile
, DL_ERROR
, "invalid suffix '%.*s' on integer constant",
209 /* Handle meeting "defined" in a preprocessor expression. */
211 parse_defined (pfile
)
215 cpp_hashnode
*node
= 0;
216 const cpp_token
*token
;
218 cpp_context
*initial_context
= pfile
->context
;
220 /* Don't expand macros. */
221 pfile
->state
.prevent_expansion
++;
223 token
= cpp_get_token (pfile
);
224 if (token
->type
== CPP_OPEN_PAREN
)
227 token
= cpp_get_token (pfile
);
230 if (token
->type
== CPP_NAME
)
232 node
= token
->val
.node
;
233 if (paren
&& cpp_get_token (pfile
)->type
!= CPP_CLOSE_PAREN
)
235 cpp_error (pfile
, DL_ERROR
, "missing ')' after \"defined\"");
241 cpp_error (pfile
, DL_ERROR
,
242 "operator \"defined\" requires an identifier");
243 if (token
->flags
& NAMED_OP
)
248 op
.type
= token
->type
;
249 cpp_error (pfile
, DL_ERROR
,
250 "(\"%s\" is an alternative token for \"%s\" in C++)",
251 cpp_token_as_text (pfile
, token
),
252 cpp_token_as_text (pfile
, &op
));
260 if (pfile
->context
!= initial_context
)
261 cpp_error (pfile
, DL_WARNING
,
262 "this use of \"defined\" may not be portable");
264 op
.value
= node
->type
== NT_MACRO
;
268 /* A possible controlling macro of the form #if !defined ().
269 _cpp_parse_expr checks there was no other junk on the line. */
270 pfile
->mi_ind_cmacro
= node
;
273 pfile
->state
.prevent_expansion
--;
277 /* Convert a token into a CPP_NUMBER (an interpreted preprocessing
278 number or character constant, or the result of the "defined" or "#"
279 operators), or CPP_ERROR on error. */
281 eval_token (pfile
, token
)
283 const cpp_token
*token
;
294 return parse_number (pfile
, token
);
299 cppchar_t result
= cpp_interpret_charconst (pfile
, token
,
302 /* Sign-extend the result if necessary. */
303 if (!unsignedp
&& (cppchar_signed_t
) result
< 0
304 && sizeof (HOST_WIDEST_INT
) > sizeof (cppchar_t
))
305 op
.value
|= ~(((unsigned HOST_WIDEST_INT
) 1 << BITS_PER_CPPCHAR_T
)
311 if (token
->val
.node
== pfile
->spec_nodes
.n_defined
)
312 return parse_defined (pfile
);
313 else if (CPP_OPTION (pfile
, cplusplus
)
314 && (token
->val
.node
== pfile
->spec_nodes
.n_true
315 || token
->val
.node
== pfile
->spec_nodes
.n_false
))
317 op
.value
= (token
->val
.node
== pfile
->spec_nodes
.n_true
);
319 /* Warn about use of true or false in #if when pedantic
320 and stdbool.h has not been included. */
321 if (CPP_PEDANTIC (pfile
)
322 && ! cpp_defined (pfile
, DSC("__bool_true_false_are_defined")))
323 cpp_error (pfile
, DL_PEDWARN
,
324 "ISO C++ does not permit \"%s\" in #if",
325 NODE_NAME (token
->val
.node
));
330 if (CPP_OPTION (pfile
, warn_undef
) && !pfile
->state
.skip_eval
)
331 cpp_error (pfile
, DL_WARNING
, "\"%s\" is not defined",
332 NODE_NAME (token
->val
.node
));
336 default: /* CPP_HASH */
337 if (_cpp_test_assertion (pfile
, &temp
))
342 op
.unsignedp
= unsignedp
;
346 /* Warn if appropriate on overflow. */
348 integer_overflow (pfile
)
351 if (CPP_PEDANTIC (pfile
))
352 cpp_error (pfile
, DL_PEDWARN
,
353 "integer overflow in preprocessor expression");
356 /* Handle shifting A left by B bits. UNSIGNEDP is non-zero if A is
358 static HOST_WIDEST_INT
359 left_shift (pfile
, a
, unsignedp
, b
)
362 unsigned int unsignedp
;
363 unsigned HOST_WIDEST_INT b
;
365 if (b
>= HOST_BITS_PER_WIDEST_INT
)
367 if (! unsignedp
&& a
!= 0)
368 integer_overflow (pfile
);
372 return (unsigned HOST_WIDEST_INT
) a
<< b
;
375 HOST_WIDEST_INT l
= a
<< b
;
377 integer_overflow (pfile
);
382 /* Handle shifting A right by B bits. UNSIGNEDP is non-zero if A is
384 static HOST_WIDEST_INT
385 right_shift (pfile
, a
, unsignedp
, b
)
386 cpp_reader
*pfile ATTRIBUTE_UNUSED
;
388 unsigned int unsignedp
;
389 unsigned HOST_WIDEST_INT b
;
391 if (b
>= HOST_BITS_PER_WIDEST_INT
)
392 return unsignedp
? 0 : a
>> (HOST_BITS_PER_WIDEST_INT
- 1);
394 return (unsigned HOST_WIDEST_INT
) a
>> b
;
399 /* Operator precedence and flags table.
401 After an operator is returned from the lexer, if it has priority less
402 than the operator on the top of the stack, we reduce the stack by one
403 operator and repeat the test. Since equal priorities do not reduce,
404 this is naturally right-associative.
406 We handle left-associative operators by decrementing the priority of
407 just-lexed operators by one, but retaining the priority of operators
408 already on the stack.
410 The remaining cases are '(' and ')'. We handle '(' by skipping the
411 reduction phase completely. ')' is given lower priority than
412 everything else, including '(', effectively forcing a reduction of the
413 parenthesised expression. If there is a matching '(', the routine
414 reduce() exits immediately. If the normal exit route sees a ')', then
415 there cannot have been a matching '(' and an error message is output.
417 The parser assumes all shifted operators require a left operand unless
418 the flag NO_L_OPERAND is set. These semantics are automatic; any
419 extra semantics need to be handled with operator-specific code. */
422 #define NO_L_OPERAND (1 << 0)
423 #define LEFT_ASSOC (1 << 1)
425 /* Operator to priority map. Must be in the same order as the first
426 N entries of enum cpp_ttype. */
427 static const struct operator
433 /* EQ */ {0, 0}, /* Shouldn't happen. */
434 /* NOT */ {16, NO_L_OPERAND
},
435 /* GREATER */ {12, LEFT_ASSOC
},
436 /* LESS */ {12, LEFT_ASSOC
},
437 /* PLUS */ {14, LEFT_ASSOC
},
438 /* MINUS */ {14, LEFT_ASSOC
},
439 /* MULT */ {15, LEFT_ASSOC
},
440 /* DIV */ {15, LEFT_ASSOC
},
441 /* MOD */ {15, LEFT_ASSOC
},
442 /* AND */ {9, LEFT_ASSOC
},
443 /* OR */ {7, LEFT_ASSOC
},
444 /* XOR */ {8, LEFT_ASSOC
},
445 /* RSHIFT */ {13, LEFT_ASSOC
},
446 /* LSHIFT */ {13, LEFT_ASSOC
},
447 /* MIN */ {10, LEFT_ASSOC
}, /* C++ specific */
448 /* MAX */ {10, LEFT_ASSOC
}, /* extensions */
450 /* COMPL */ {16, NO_L_OPERAND
},
451 /* AND_AND */ {6, LEFT_ASSOC
},
452 /* OR_OR */ {5, LEFT_ASSOC
},
454 /* COLON */ {4, LEFT_ASSOC
},
455 /* COMMA */ {2, LEFT_ASSOC
},
456 /* OPEN_PAREN */ {1, NO_L_OPERAND
},
457 /* CLOSE_PAREN */ {0, 0},
459 /* EQ_EQ */ {11, LEFT_ASSOC
},
460 /* NOT_EQ */ {11, LEFT_ASSOC
},
461 /* GREATER_EQ */ {12, LEFT_ASSOC
},
462 /* LESS_EQ */ {12, LEFT_ASSOC
},
463 /* UPLUS */ {16, NO_L_OPERAND
},
464 /* UMINUS */ {16, NO_L_OPERAND
}
467 #define COMPARE(OP) \
468 top->unsignedp = 0; \
469 top->value = (unsigned1 | unsigned2) \
470 ? (unsigned HOST_WIDEST_INT) v1 OP (unsigned HOST_WIDEST_INT) v2 \
472 #define EQUALITY(OP) \
473 top->value = v1 OP v2; \
475 #define BITWISE(OP) \
476 top->value = v1 OP v2; \
477 top->unsignedp = unsigned1 | unsigned2;
479 top->value = (v1 OP v2) ? v1 : v2; \
480 top->unsignedp = unsigned1 | unsigned2;
482 top->value = OP v2; \
483 top->unsignedp = unsigned2;
484 #define SHIFT(PSH, MSH) \
485 if (pfile->state.skip_eval) \
487 top->unsignedp = unsigned1; \
488 if (v2 < 0 && ! unsigned2) \
489 top->value = MSH (pfile, v1, unsigned1, -v2); \
491 top->value = PSH (pfile, v1, unsigned1, v2);
493 /* Parse and evaluate a C expression, reading from PFILE.
494 Returns the truth value of the expression.
496 The implementation is an operator precedence parser, i.e. a
497 bottom-up parser, using a stack for not-yet-reduced tokens.
499 The stack base is op_stack, and the current stack pointer is 'top'.
500 There is a stack element for each operator (only), and the most
501 recently pushed operator is 'top->op'. An operand (value) is
502 stored in the 'value' field of the stack element of the operator
505 _cpp_parse_expr (pfile
)
508 struct op
*top
= pfile
->op_stack
;
509 const cpp_token
*token
= NULL
, *prev_token
;
510 unsigned int lex_count
;
511 bool saw_leading_not
, want_value
= true;
513 pfile
->state
.skip_eval
= 0;
515 /* Set up detection of #if ! defined(). */
516 pfile
->mi_ind_cmacro
= 0;
517 saw_leading_not
= false;
520 /* Lowest priority operator prevents further reductions. */
528 token
= cpp_get_token (pfile
);
534 /* These tokens convert into values. */
541 SYNTAX_ERROR2 ("missing binary operator before token \"%s\"",
542 cpp_token_as_text (pfile
, token
));
544 op
= eval_token (pfile
, token
);
545 if (op
.op
== CPP_ERROR
)
547 top
->value
= op
.value
;
548 top
->unsignedp
= op
.unsignedp
;
552 saw_leading_not
= lex_count
== 1;
563 if (ISGRAPH (token
->val
.c
))
564 SYNTAX_ERROR2 ("invalid character '%c' in #if", token
->val
.c
);
566 SYNTAX_ERROR2 ("invalid character '\\%03o' in #if", token
->val
.c
);
569 if ((int) op
.op
<= (int) CPP_EQ
|| (int) op
.op
>= (int) CPP_PLUS_EQ
)
570 SYNTAX_ERROR2 ("token \"%s\" is not valid in #if expressions",
571 cpp_token_as_text (pfile
, token
));
575 /* Check we have a value or operator as appropriate. */
576 if (optab
[op
.op
].flags
& NO_L_OPERAND
)
579 SYNTAX_ERROR2 ("missing binary operator before token \"%s\"",
580 cpp_token_as_text (pfile
, token
));
584 /* Ordering here is subtle and intended to favour the
585 missing parenthesis diagnostics over alternatives. */
586 if (op
.op
== CPP_CLOSE_PAREN
)
588 if (top
->op
== CPP_OPEN_PAREN
)
589 SYNTAX_ERROR ("void expression between '(' and ')'");
591 else if (top
->op
== CPP_EOF
)
592 SYNTAX_ERROR ("#if with no expression");
593 if (top
->op
!= CPP_EOF
&& top
->op
!= CPP_OPEN_PAREN
)
594 SYNTAX_ERROR2 ("operator '%s' has no right operand",
595 cpp_token_as_text (pfile
, prev_token
));
598 top
= reduce (pfile
, top
, op
.op
);
602 if (op
.op
== CPP_EOF
)
607 case CPP_CLOSE_PAREN
:
611 pfile
->state
.skip_eval
++;
616 pfile
->state
.skip_eval
++;
619 if (top
->op
!= CPP_QUERY
)
620 SYNTAX_ERROR (" ':' without preceding '?'");
621 if (top
[-1].value
) /* Was '?' condition true? */
622 pfile
->state
.skip_eval
++;
624 pfile
->state
.skip_eval
--;
631 /* Check for and handle stack overflow. */
632 if (++top
== pfile
->op_limit
)
633 top
= _cpp_expand_op_stack (pfile
);
638 /* The controlling macro expression is only valid if we called lex 3
639 times: <!> <defined expression> and <EOF>. push_conditional ()
640 checks that we are at top-of-file. */
641 if (pfile
->mi_ind_cmacro
&& !(saw_leading_not
&& lex_count
== 3))
642 pfile
->mi_ind_cmacro
= 0;
644 if (top
!= pfile
->op_stack
)
646 cpp_error (pfile
, DL_ICE
, "unbalanced stack in #if");
648 return false; /* Return false on syntax error. */
651 return top
->value
!= 0;
654 /* Reduce the operator / value stack if possible, in preparation for
655 pushing operator OP. Returns NULL on error, otherwise the top of
658 reduce (pfile
, top
, op
)
665 if (op
== CPP_OPEN_PAREN
)
668 /* Decrement the priority of left-associative operators to force a
669 reduction with operators of otherwise equal priority. */
670 prio
= optab
[op
].prio
- ((optab
[op
].flags
& LEFT_ASSOC
) != 0);
671 while (prio
< optab
[top
->op
].prio
)
673 HOST_WIDEST_INT v1
, v2
;
674 unsigned int unsigned1
, unsigned2
;
676 unsigned2
= top
->unsignedp
, v2
= top
->value
;
678 unsigned1
= top
->unsignedp
, v1
= top
->value
;
680 /* Now set top->value = (top[1].op)(v1, v2); */
684 cpp_error (pfile
, DL_ICE
, "impossible operator '%u'", top
[1].op
);
687 case CPP_NOT
: UNARY(!); break;
688 case CPP_COMPL
: UNARY(~); break;
689 case CPP_LESS
: COMPARE(<); break;
690 case CPP_GREATER
: COMPARE(>); break;
691 case CPP_LESS_EQ
: COMPARE(<=); break;
692 case CPP_GREATER_EQ
: COMPARE(>=); break;
693 case CPP_EQ_EQ
: EQUALITY(==); break;
694 case CPP_NOT_EQ
: EQUALITY(!=); break;
695 case CPP_AND
: BITWISE(&); break;
696 case CPP_XOR
: BITWISE(^); break;
697 case CPP_OR
: BITWISE(|); break;
698 case CPP_LSHIFT
: SHIFT(left_shift
, right_shift
); break;
699 case CPP_RSHIFT
: SHIFT(right_shift
, left_shift
); break;
700 case CPP_MIN
: MINMAX(<); break;
701 case CPP_MAX
: MINMAX(>); break;
704 /* Can't use UNARY(+) because K+R C did not have unary
705 plus. Can't use UNARY() because some compilers object
706 to the empty argument. */
708 top
->unsignedp
= unsigned2
;
709 if (CPP_WTRADITIONAL (pfile
))
710 cpp_error (pfile
, DL_WARNING
,
711 "traditional C rejects the unary plus operator");
715 if (!pfile
->state
.skip_eval
&& (top
->value
& v2
) < 0 && !unsigned2
)
716 integer_overflow (pfile
);
720 top
->value
= v1
+ v2
;
721 top
->unsignedp
= unsigned1
| unsigned2
;
722 if (! top
->unsignedp
&& ! pfile
->state
.skip_eval
723 && ! possible_sum_sign (v1
, v2
, top
->value
))
724 integer_overflow (pfile
);
727 top
->value
= v1
- v2
;
728 top
->unsignedp
= unsigned1
| unsigned2
;
729 if (! top
->unsignedp
&& ! pfile
->state
.skip_eval
730 && ! possible_sum_sign (top
->value
, v2
, v1
))
731 integer_overflow (pfile
);
734 top
->unsignedp
= unsigned1
| unsigned2
;
736 top
->value
= (unsigned HOST_WIDEST_INT
) v1
* v2
;
737 else if (!pfile
->state
.skip_eval
)
739 top
->value
= v1
* v2
;
740 if (v1
&& (top
->value
/ v1
!= v2
741 || (top
->value
& v1
& v2
) < 0))
742 integer_overflow (pfile
);
747 if (pfile
->state
.skip_eval
)
751 cpp_error (pfile
, DL_ERROR
, "division by zero in #if");
754 top
->unsignedp
= unsigned1
| unsigned2
;
755 if (top
[1].op
== CPP_DIV
)
758 top
->value
= (unsigned HOST_WIDEST_INT
) v1
/ v2
;
761 top
->value
= v1
/ v2
;
762 if ((top
->value
& v1
& v2
) < 0)
763 integer_overflow (pfile
);
769 top
->value
= (unsigned HOST_WIDEST_INT
) v1
% v2
;
771 top
->value
= v1
% v2
;
776 top
->value
= v1
|| v2
;
778 if (v1
) pfile
->state
.skip_eval
--;
781 top
->value
= v1
&& v2
;
783 if (!v1
) pfile
->state
.skip_eval
--;
786 if (CPP_PEDANTIC (pfile
))
787 cpp_error (pfile
, DL_PEDWARN
,
788 "comma operator in operand of #if");
790 top
->unsignedp
= unsigned2
;
793 cpp_error (pfile
, DL_ERROR
, "'?' without following ':'");
797 if (top
->value
) pfile
->state
.skip_eval
--;
798 top
->value
= top
->value
? v1
: v2
;
799 top
->unsignedp
= unsigned1
| unsigned2
;
802 if (op
!= CPP_CLOSE_PAREN
)
804 cpp_error (pfile
, DL_ERROR
, "missing ')' in expression");
808 top
->unsignedp
= unsigned2
;
813 if (op
== CPP_CLOSE_PAREN
)
815 cpp_error (pfile
, DL_ERROR
, "missing '(' in expression");
822 /* Returns the position of the old top of stack after expansion. */
824 _cpp_expand_op_stack (pfile
)
827 size_t old_size
= (size_t) (pfile
->op_limit
- pfile
->op_stack
);
828 size_t new_size
= old_size
* 2 + 20;
830 pfile
->op_stack
= (struct op
*) xrealloc (pfile
->op_stack
,
831 new_size
* sizeof (struct op
));
832 pfile
->op_limit
= pfile
->op_stack
+ new_size
;
834 return pfile
->op_stack
+ old_size
;