1 /* Copyright (C) 2000, 2008 Free Software Foundation, Inc. */
3 /* Test the full range of preprocessor operator precedence. Each
4 operator is tested with one of immediately higher precedence to
5 verify it is of strictly lower precedence. To avoid complications,
6 each test uses just those two operators. Occasionally this assumes
7 correct operation of if-then-else, so the first tests verify this. */
9 /* { dg-do preprocess } */
11 /* Ensure correct functioning of if-then-else. */
14 #error #else block evaluated for true conditional
18 #error #if block evaluated for false conditional
22 /* : strictly higher than ?. This would give a syntax error otherwise. */
26 /* || strictly higher than ?:. */
28 #error operator ?: has higher precedence than operator ||
31 /* && strictly higher than ||. */
34 #error operator || has higher precedence than operator &&
37 /* | strictly higher than &&. */
39 #error operator && has higher precedence than operator |
42 /* ^ strictly higher than |. */
45 #error operator | has higher precedence than operator ^
48 /* & strictly higher than ^. */
51 #error operator ^ has higher precedence than operator &
54 /* == (!=) strictly higher than &. */
56 #error operator & has higher precedence than operator ==
59 /* < (>, <=, >=) strictly higher than == (!=). */
63 #error operator == has higher precedence than operator <
66 /* << (>>) strictly higher than < (>, <=, >=). */
69 #error operator < has higher precedence than operator <<
72 /* Binary + (-) strictly higher than << (>>). */
74 #error operator << has higher precedence than binary +
77 /* Binary * (/, %) strictly higher than binary + (-). */
80 #error binary + has higher precedence than binary *
83 /* Unary operators (!, ~, -, +) strictly higher than binary * (/, %).
84 Equality is hard to detect because of right-associativity. */
86 #error binary * has higher precedence than operator ~
89 /* () > Unary. Unfortunately this requires an additional operator. */
91 #error unary - has higher precedence than operator ()