diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-06 17:15:07 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-06 17:15:07 +0000 |
commit | 151e90ccc4ec622c5c4004b25fb90b67171bcc9d (patch) | |
tree | 9b75142790c70534d0c2159f221893eb16ef3402 /libcpp | |
parent | 36fb17058156550631e423817c444f200c235a07 (diff) | |
download | gcc-151e90ccc4ec622c5c4004b25fb90b67171bcc9d.tar.gz |
gcc/testsuite
PR preprocessor/35313, PR preprocessor/36088:
* gcc.dg/cpp/pr35313.c: New file.
* gcc.dg/cpp/if-oppr.c: Remove test for ',' in a conditional
expression.
* gcc.dg/cpp/if-oppr2.c: New file.
libcpp
PR preprocessor/35313, PR preprocessor/36088:
* expr.c (optab) <QUERY, COMMA>: Set precedence to 4.
(reduce) <case CPP_QUERY>: Special case CPP_COMMA and CPP_COLON.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134989 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 6 | ||||
-rw-r--r-- | libcpp/expr.c | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 25fc09dcf77..b86e22e613d 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2008-05-06 Tom Tromey <tromey@redhat.com> + + PR preprocessor/35313, PR preprocessor/36088: + * expr.c (optab) <QUERY, COMMA>: Set precedence to 4. + (reduce) <case CPP_QUERY>: Special case CPP_COMMA and CPP_COLON. + 2008-05-04 David S. Miller <davem@davemloft.net> * configure.ac (sparc*-*-*): Always set need_64bit_hwint to yes. diff --git a/libcpp/expr.c b/libcpp/expr.c index 00149b2422d..af0e2590ee4 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -1,6 +1,6 @@ /* Parse C expressions for cpplib. Copyright (C) 1987, 1992, 1994, 1995, 1997, 1998, 1999, 2000, 2001, - 2002, 2004 Free Software Foundation. + 2002, 2004, 2008 Free Software Foundation. Contributed by Per Bothner, 1994. This program is free software; you can redistribute it and/or modify it @@ -809,9 +809,11 @@ static const struct cpp_operator /* COMPL */ {16, NO_L_OPERAND}, /* AND_AND */ {6, LEFT_ASSOC}, /* OR_OR */ {5, LEFT_ASSOC}, - /* QUERY */ {3, 0}, + /* Note that QUERY, COLON, and COMMA must have the same precedence. + However, there are some special cases for these in reduce(). */ + /* QUERY */ {4, 0}, /* COLON */ {4, LEFT_ASSOC | CHECK_PROMOTION}, - /* COMMA */ {2, LEFT_ASSOC}, + /* COMMA */ {4, LEFT_ASSOC}, /* OPEN_PAREN */ {1, NO_L_OPERAND}, /* CLOSE_PAREN */ {0, 0}, /* EOF */ {0, 0}, @@ -1101,6 +1103,9 @@ reduce (cpp_reader *pfile, struct op *top, enum cpp_ttype op) continue; case CPP_QUERY: + /* COMMA and COLON should not reduce a QUERY operator. */ + if (op == CPP_COMMA || op == CPP_COLON) + return top; cpp_error (pfile, CPP_DL_ERROR, "'?' without following ':'"); return 0; |