mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-28 14:24:43 +08:00
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
This commit is contained in:
parent
f94cef0a66
commit
6947512352
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
32
gcc/testsuite/g++.dg/parse/expr3.C
Normal file
32
gcc/testsuite/g++.dg/parse/expr3.C
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user