| 1 |
// empty.iso is used because there is an iso that converts sizeof(E) to |
| 2 |
// sizeof E, which causes a double match in an expression, and thus a |
| 3 |
// double modification |
| 4 |
|
| 5 |
@ rule1 using "empty.iso" @ |
| 6 |
expression E; |
| 7 |
@@ |
| 8 |
|
| 9 |
- (sizeof(E)/sizeof(*E)) |
| 10 |
+ ARRAY_SIZE(E) |
| 11 |
|
| 12 |
@ rule2 using "empty.iso" @ |
| 13 |
expression E; |
| 14 |
@@ |
| 15 |
|
| 16 |
- sizeof(E)/sizeof(*E) |
| 17 |
+ ARRAY_SIZE(E) |
| 18 |
|
| 19 |
@ rule3 using "empty.iso" @ |
| 20 |
expression E, E1; |
| 21 |
@@ |
| 22 |
|
| 23 |
- (sizeof(E)/sizeof(E[E1])) |
| 24 |
+ ARRAY_SIZE(E) |
| 25 |
|
| 26 |
@ rule4 using "empty.iso" @ |
| 27 |
expression E, E1; |
| 28 |
@@ |
| 29 |
|
| 30 |
- sizeof(E)/sizeof(E[E1]) |
| 31 |
+ ARRAY_SIZE(E) |
| 32 |
|
| 33 |
@ rule5 using "empty.iso" @ |
| 34 |
type T; |
| 35 |
T[] E; |
| 36 |
@@ |
| 37 |
|
| 38 |
- (sizeof(E)/sizeof(T)) |
| 39 |
+ ARRAY_SIZE(E) |
| 40 |
|
| 41 |
@ rule6 using "empty.iso" @ |
| 42 |
type T; |
| 43 |
T[] E; |
| 44 |
@@ |
| 45 |
|
| 46 |
- sizeof(E)/sizeof(T) |
| 47 |
+ ARRAY_SIZE(E) |
| 48 |
|
| 49 |
// --------------------------------------------------------------------------- |
| 50 |
// some of the above rules with more parentheses |
| 51 |
// this can't be done with an isomorphism, as described above |
| 52 |
|
| 53 |
@ rule1p using "empty.iso" @ |
| 54 |
expression E; |
| 55 |
@@ |
| 56 |
|
| 57 |
- (sizeof(E)/sizeof(*(E))) |
| 58 |
+ ARRAY_SIZE(E) |
| 59 |
|
| 60 |
@ rule2p using "empty.iso" @ |
| 61 |
expression E; |
| 62 |
@@ |
| 63 |
|
| 64 |
- sizeof(E)/sizeof(*(E)) |
| 65 |
+ ARRAY_SIZE(E) |
| 66 |
|
| 67 |
@ rule3p using "empty.iso" @ |
| 68 |
expression E, E1; |
| 69 |
@@ |
| 70 |
|
| 71 |
- (sizeof(E)/sizeof((E)[E1])) |
| 72 |
+ ARRAY_SIZE(E) |
| 73 |
|
| 74 |
@ rule4p using "empty.iso" @ |
| 75 |
expression E, E1; |
| 76 |
@@ |
| 77 |
|
| 78 |
- sizeof(E)/sizeof((E)[E1]) |
| 79 |
+ ARRAY_SIZE(E) |
| 80 |
|
| 81 |
// --------------------------------------------------------------------------- |
| 82 |
@@ expression E; @@ |
| 83 |
|
| 84 |
- NUM_ELEMENTS(E) |
| 85 |
+ ARRAY_SIZE(E) |
| 86 |
|
| 87 |
@ rule53 @ |
| 88 |
identifier NUM, x; |
| 89 |
@@ |
| 90 |
|
| 91 |
- #define NUM(x) ARRAY_SIZE(x) |
| 92 |
|
| 93 |
@@ |
| 94 |
expression E; |
| 95 |
identifier rule53.NUM; |
| 96 |
@@ |
| 97 |
|
| 98 |
- NUM(E) |
| 99 |
+ ARRAY_SIZE(E) |
| 100 |
|
| 101 |
@@ |
| 102 |
expression E; |
| 103 |
@@ |
| 104 |
|
| 105 |
- ((int)ARRAY_SIZE(E)) |
| 106 |
+ ARRAY_SIZE(E) |