1 /* { dg-do compile } */ 2 /* PR/18047 Test that operators have the right precedence. */ 3 /* by bonzini@gnu.org */ 4 5 #define test(lower, higher, a, b, c, d) \ 6 test_(lower, higher, a, b, c, d, __LINE__) 7 8 #define test_(lower, higher, a, b, c, d, line)\ 9 test__(lower, higher, a, b, c, d, line) 10 11 /* The first declaration tests that the parentheses are added correctly 12 by the expression parser. The second tests that the two possible 13 orderings of precedences do give different results. */ 14 #define test__(lower, higher, a, b, c, d, line) \ 15 char test##line[ \ 16 (a higher b lower c higher d) == \ 17 ((a higher b) lower (c higher d)) \ 18 ? 1 : -1]; \ 19 char doublecheck##line[ \ 20 (a higher b lower c higher d) == \ 21 (a higher (b lower c) higher d) \ 22 ? -1 : 1]; 23 24 test (||, &&, 1, 1, 0, 0) 25 test (&&, |, 5, 1, 1, 19) 26 test (|, ^, 1, 2, 2, 1) 27 test (^, &, 1, 3, 2, 6) 28 test (&, ==, 1, 3, 2, 0) 29 test (==, <, 2, 0, 0, 0) 30 test (<, <<, 2, 3, 6, 8) 31 test (<<, +, 2, 3, 4, 5) 32 test (+, *, 2, 6, 9, 13) 33