diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2004-10-19 12:40:31 +0000 |
---|---|---|
committer | Paolo Bonzini <bonzini@gcc.gnu.org> | 2004-10-19 12:40:31 +0000 |
commit | 6947512352a71aba76705bb7a04d0ec301461821 (patch) | |
tree | dba19c74a89cbb86dc57f18fa29d12f02e9c3c4b /gcc | |
parent | f94cef0a668dbea993ab630a24fdae73aecb1c5a (diff) | |
download | gcc-6947512352a71aba76705bb7a04d0ec301461821.zip gcc-6947512352a71aba76705bb7a04d0ec301461821.tar.gz gcc-6947512352a71aba76705bb7a04d0ec301461821.tar.bz2 |
re PR c++/18047 (Wrong precedence between equality (==, !=) and < operators)
2004-10-19 Paolo Bonzini <bonzini@gnu.org>
PR c++/18047
* parser.c (enum cp_parser_prec): Give relational expressions
a higher precedence than equality expressions.
2004-10-19 Paolo Bonzini <bonzini@gnu.org>
PR c++/18047
* g++.dg/parse/expr3.C: New test.
From-SVN: r89272
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/expr3.C | 32 |
4 files changed, 45 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fa85757..325fbf3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-10-19 Paolo Bonzini <bonzini@gnu.org> + + PR c++/18047 + * parser.c (enum cp_parser_prec): Give relational expressions + a higher precedence than equality expressions. + 2004-10-15 Nathan Sidwell <nathan@codesourcery.com> * cp-tree.h (UNIQUELY_DERIVED_FROM_P): Adjust lookup_base call. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7673826..6dac467 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1074,8 +1074,8 @@ enum cp_parser_prec PREC_INCLUSIVE_OR_EXPRESSION, PREC_EXCLUSIVE_OR_EXPRESSION, PREC_AND_EXPRESSION, - PREC_RELATIONAL_EXPRESSION, PREC_EQUALITY_EXPRESSION, + PREC_RELATIONAL_EXPRESSION, PREC_SHIFT_EXPRESSION, PREC_ADDITIVE_EXPRESSION, PREC_MULTIPLICATIVE_EXPRESSION, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0254a74..28942058 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2004-10-19 Paolo Bonzini <bonzini@gnu.org> + + PR c++/18047 + + * g++.dg/parse/expr3.C: New test. + 2004-10-18 Eric Botcazou <ebotcazou@libertysurf.fr> * gcc.dg/smod-1.c: New test. diff --git a/gcc/testsuite/g++.dg/parse/expr3.C b/gcc/testsuite/g++.dg/parse/expr3.C new file mode 100644 index 0000000..95d332f --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/expr3.C @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* PR/18047 Test that operators have the right precedence. */ +/* by bonzini@gnu.org */ + +#define test(lower, higher, a, b, c, d) \ + test_(lower, higher, a, b, c, d, __LINE__) + +#define test_(lower, higher, a, b, c, d, line)\ + test__(lower, higher, a, b, c, d, line) + +/* The first declaration tests that the parentheses are added correctly + by the expression parser. The second tests that the two possible + orderings of precedences do give different results. */ +#define test__(lower, higher, a, b, c, d, line) \ + char test##line[ \ + (a higher b lower c higher d) == \ + ((a higher b) lower (c higher d)) \ + ? 1 : -1]; \ + char doublecheck##line[ \ + (a higher b lower c higher d) == \ + (a higher (b lower c) higher d) \ + ? -1 : 1]; + +test (||, &&, 1, 1, 0, 0) +test (&&, |, 5, 1, 1, 19) +test (|, ^, 1, 2, 2, 1) +test (^, &, 1, 3, 2, 6) +test (&, ==, 1, 3, 2, 0) +test (==, <, 2, 0, 0, 0) +test (<, <<, 2, 3, 6, 8) +test (<<, +, 2, 3, 4, 5) +test (+, *, 2, 6, 9, 13) |