diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-19 20:18:08 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-19 20:18:08 +0000 |
commit | 92936ecf1a27517ac0b96c5af6a5ae9664faf3f3 (patch) | |
tree | fb27fc4ef85133963af7127518d36e07b5e1d021 /gcc/cppexp.c | |
parent | b86db3ebc22f22aae3f7dddadc90c9b1841ebe1a (diff) | |
download | gcc-92936ecf1a27517ac0b96c5af6a5ae9664faf3f3.tar.gz |
cpplib.h (TTYPE_TABLE): Move CPP_MIN and CPP_MAX into block of operators allowed in #if...
* cpplib.h (TTYPE_TABLE): Move CPP_MIN and CPP_MAX into block
of operators allowed in #if and having an _EQ variant. Add
CPP_MIN_EQ, CPP_MAX_EQ, and CPP_DEFINED.
(cpp_token flags): Add NAMED_OP.
(enum node_type): Add T_OPERATOR.
(struct cpp_hashnode): Add code slot to value union.
* cpphash.h (spec_nodes): Remove n_defined.
* cpplex.c (lex_line): Convert T_OPERATOR nodes to their proper types.
(spell_token, can_paste, maybe_paste_with_next): Handle named operators.
(is_macro_disabled): Tweak error messages.
* cpplib.c (get_define_node): Disallow all named operators as
macro names. Tweak error messages.
(_cpp_init_stacks): Don't set up spec_nodes->n_defined.
* cppinit.c (builtin_array): Add entries for the named operators.
* cppexp.c (lex): Check for CPP_DEFINED token.
(priority table): Add entries for CPP_MIN and CPP_MAX.
(_cpp_parse_expr): Handle CPP_MIN and CPP_MAX.
testsuite:
* gcc.dg/cpp/directiv.c, gcc.dg/cpp/macsyntx.c,
gcc.dg/cpp/undef1.c: Tweak error regexps.
From-SVN: r35137
Diffstat (limited to 'gcc/cppexp.c')
-rw-r--r-- | gcc/cppexp.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/gcc/cppexp.c b/gcc/cppexp.c index deb5ffb2d49..e80f8e882e3 100644 --- a/gcc/cppexp.c +++ b/gcc/cppexp.c @@ -419,10 +419,10 @@ lex (pfile, skip_evaluation) else SYNTAX_ERROR2 ("invalid character '\\%03o' in #if", tok->val.aux); - case CPP_NAME: - if (tok->val.node == pfile->spec_nodes->n_defined) - return parse_defined (pfile); + case CPP_DEFINED: + return parse_defined (pfile); + case CPP_NAME: op.op = CPP_INT; op.unsignedp = 0; op.value = 0; @@ -648,12 +648,13 @@ be handled with operator-specific code. */ #define OR_PRIO (8 << PRIO_SHIFT) #define XOR_PRIO (9 << PRIO_SHIFT) #define AND_PRIO (10 << PRIO_SHIFT) -#define EQUAL_PRIO (11 << PRIO_SHIFT) -#define LESS_PRIO (12 << PRIO_SHIFT) -#define SHIFT_PRIO (13 << PRIO_SHIFT) -#define PLUS_PRIO (14 << PRIO_SHIFT) -#define MUL_PRIO (15 << PRIO_SHIFT) -#define UNARY_PRIO ((16 << PRIO_SHIFT) | RIGHT_ASSOC | NO_L_OPERAND) +#define MINMAX_PRIO (11 << PRIO_SHIFT) +#define EQUAL_PRIO (12 << PRIO_SHIFT) +#define LESS_PRIO (13 << PRIO_SHIFT) +#define SHIFT_PRIO (14 << PRIO_SHIFT) +#define PLUS_PRIO (15 << PRIO_SHIFT) +#define MUL_PRIO (16 << PRIO_SHIFT) +#define UNARY_PRIO ((17 << PRIO_SHIFT) | RIGHT_ASSOC | NO_L_OPERAND) /* Operator to priority map. Must be in the same order as the first N entries of enum cpp_ttype. */ @@ -674,6 +675,8 @@ op_to_prio[] = /* XOR */ XOR_PRIO, /* RSHIFT */ SHIFT_PRIO, /* LSHIFT */ SHIFT_PRIO, + /* MIN */ MINMAX_PRIO, /* C++ specific */ + /* MAX */ MINMAX_PRIO, /* extensions */ /* COMPL */ UNARY_PRIO, /* AND_AND */ ANDAND_PRIO, @@ -700,6 +703,9 @@ op_to_prio[] = #define BITWISE(OP) \ top->value = v1 OP v2; \ top->unsignedp = unsigned1 | unsigned2; +#define MINMAX(OP) \ + top->value = (v1 OP v2) ? v1 : v2; \ + top->unsignedp = unsigned1 | unsigned2; #define UNARY(OP) \ top->value = OP v2; \ top->unsignedp = unsigned2; \ @@ -831,6 +837,8 @@ _cpp_parse_expr (pfile) case CPP_OR: BITWISE(|); break; case CPP_LSHIFT: SHIFT(left_shift, right_shift); break; case CPP_RSHIFT: SHIFT(right_shift, left_shift); break; + case CPP_MIN: MINMAX(<); break; + case CPP_MAX: MINMAX(>); break; case CPP_PLUS: if (!(top->flags & HAVE_VALUE)) |