diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-19 12:40:31 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-19 12:40:31 +0000 |
commit | 22dc256c52591745d8c4cff821982d42e72280bb (patch) | |
tree | dba19c74a89cbb86dc57f18fa29d12f02e9c3c4b /gcc | |
parent | 1b95b63bd5561679213e12a896cfb4cac8d9cc72 (diff) | |
download | gcc-22dc256c52591745d8c4cff821982d42e72280bb.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89272 138bc75d-0d04-0410-961f-82ee72b054a4
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 fa85757b919..325fbf3db0f 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 76738262e7c..6dac467f977 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 0254a749d12..289420580b2 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 00000000000..95d332f41b0 --- /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) |