OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [cpp/] [if-oppr.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Copyright (C) 2000, 2008 Free Software Foundation, Inc.  */
2
 
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.  */
8
 
9
/* { dg-do preprocess } */
10
 
11
/* Ensure correct functioning of if-then-else.  */
12
#if 1
13
#else
14
#error #else block evaluated for true conditional
15
#endif
16
 
17
#if 0
18
#error #if block evaluated for false conditional
19
#else
20
#endif
21
 
22
/* : strictly higher than ?.  This would give a syntax error otherwise.  */
23
#if 0 ? 0 : 1 ? 1 : 1
24
#endif
25
 
26
/* || strictly higher than ?:. */
27
#if 1 ? 0: 0 || 1
28
#error operator ?: has higher precedence than operator ||
29
#endif
30
 
31
/* && strictly higher than ||.  */
32
#if 1 || 0 && 0
33
#else
34
#error operator || has higher precedence than operator &&
35
#endif
36
 
37
/* | strictly higher than &&.  */
38
#if 0 && 0 | 1
39
#error operator && has higher precedence than operator |
40
#endif
41
 
42
/* ^ strictly higher than |.  */
43
#if 1 | 0 ^ 1
44
#else
45
#error operator | has higher precedence than operator ^
46
#endif
47
 
48
/* & strictly higher than ^.  */
49
#if 1 ^ 0 & 0
50
#else
51
#error operator ^ has higher precedence than operator &
52
#endif
53
 
54
/* == (!=) strictly higher than &.  */
55
#if 0 & 0 == 0
56
#error operator & has higher precedence than operator ==
57
#endif
58
 
59
/* < (>, <=, >=) strictly higher than == (!=).  */
60
 
61
#if 0 == 0 < 0
62
#else
63
#error operator == has higher precedence than operator <
64
#endif
65
 
66
/* << (>>) strictly higher than < (>, <=, >=).  */
67
#if 1 < 1 << 1
68
#else
69
#error operator < has higher precedence than operator <<
70
#endif
71
 
72
/* Binary + (-) strictly higher than << (>>).  */
73
#if 0 << 0 + 1
74
#error operator << has higher precedence than binary +
75
#endif
76
 
77
/* Binary * (/, %) strictly higher than binary + (-).  */
78
#if 1 + 0 * 0
79
#else
80
#error binary + has higher precedence than binary *
81
#endif
82
 
83
/* Unary operators (!, ~, -, +) strictly higher than binary * (/, %).
84
   Equality is hard to detect because of right-associativity.  */
85
#if ~1 * 0
86
#error binary * has higher precedence than operator ~
87
#endif
88
 
89
/* () > Unary.  Unfortunately this requires an additional operator.  */
90
#if -(1 - 1)
91
#error unary - has higher precedence than operator ()
92
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.