1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
# basic access works (byte) ---------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if raw[0].b == 0xff;
}
EOF
0:0:8=0xFF
# basic access works (short) --------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if raw[0].ns == 0x12;
}
EOF
0:0:16=0x0012
# basic access works (long) ---------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if raw[0].nl == 0x1234;
}
EOF
0:0:32=0x00001234
# reversed order is corrected by earlier stages -------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if 0x8000 == raw[0].ns;
}
EOF
0:0:16=0x8000
# X rel X is refused ----------------------------------------------------------
tcc -xif:err 2>&1 >/dev/null
prio {
class if raw[0].ns > raw[2].ns;
}
EOF
ERROR
can't dump subexpression (iflib_arith.c, "rel const" expected)
# X op X rel C is refused -----------------------------------------------------
tcc -xif:err 2>&1 >/dev/null
prio {
class if raw[0].ns+raw[2].ns != 13;
}
EOF
ERROR
can't dump subexpression (if_ext.c, bad operator)
# X & X rel C is refused ------------------------------------------------------
tcc -xif:err 2>&1 >/dev/null
prio {
class if raw[0].ns & raw[2].ns == 42;
}
EOF
ERROR
can't dump subexpression (if_ext.c, must be "& constant")
# X << X rel C is refused -----------------------------------------------------
tcc -xif:err 2>&1 >/dev/null
prio {
class if raw[0].ns << raw[2].ns == 44;
}
EOF
ERROR
can't dump subexpression (if_ext.c, bad operator)
# X >> X rel C is refused -----------------------------------------------------
tcc -xif:err 2>&1 >/dev/null
prio {
class if raw[0].ns >> raw[2].ns == 33;
}
EOF
ERROR
can't dump subexpression (if_ext.c, bad operator)
# X.ns & 0xf works ------------------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[2].ns & 0xf) == 7;
}
EOF
0:28:4=0x7
# X.b << 1 works (ext) --------------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[0].b << 1) == 0x20;
}
EOF
0:0:8=0x10
# X.b << 1 works (u32) --------------------------------------------------------
tcc 2>&1 | sed '/.*match \\(.*\\) classid.*/s//\\1/p;d'
prio {
class if (raw[0].b << 1) == 0x20; /* old algorithm generated mask 0x7f */
}
EOF
u8 0x10 0xff at 0
# X.b << 30 works (ext) --------------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[0].b << 30) == 0xc0000000;
/* since we're using 128 bit arithmetic, the 32 bit overflow leaves tcc
utterly unimpressed */
}
EOF
0:0:8=0x03
# X.b << 126 works (ext) ------------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[0].b << 126) == c000::;
}
EOF
0:6:2=0x3
# X.nl >> 2 works (ext) -------------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[2].nl >> 2) == 1; /* ext uses bit alignment */
}
EOF
0:16:30=0x00000001
# X.nl >> 2 works (u32) -------------------------------------------------------
tcc | sed '/.*match \\(.*\\) classid.*/s//\\1/p;d'
prio {
class if (raw[4].nl >> 2) == 1;
/* u32 has long alignment, so we have to be careful */
}
EOF
u32 0x4 0xfffffffc at 4
# (X.ns >> 4) << 4 works (ext) ------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[0].ns >> 4) << 4 == 256; /* lower four bits are lost */
}
EOF
0:0:12=0x010
# (X.ns >> 4) << 4 works (u32) ------------------------------------------------
tcc | sed '/.*match \\(.*\\) classid.*/s//\\1/p;d'
prio {
class if (raw[0].ns >> 4) << 4 == 256;
}
EOF
u16 0x100 0xfff0 at 0
# (X.ns << 4) >> 4 works (ext) ------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[0].ns << 4) >> 4 == 256; /* no losses */
}
EOF
0:0:16=0x0100
# (X.ns << 4) >> 4 works (u32) ------------------------------------------------
tcc 2>&1 | sed '/.*match \\(.*\\) classid.*/s//\\1/p;d'
prio {
class if (raw[0].ns << 4) >> 4 == 256; /* no losses */
}
EOF
u16 0x100 0xffff at 0
# X >> N == C without overflow ------------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].nl >> 4 == 0x1000000;
}
EOF
match 0:0:28=0x1000000 action 1
match action 0
# X >> N == C with overflow ---------------------------------------------------
tcc -xif:err 2>&1 | sed '/match/p;/warning/p;d'
prio {
class if raw[0].nl >> 4 == 0x80000000;
}
EOF
warning: left-shift of value in access exceeds 32 bit range
match action 0
# X >> N != C with overflow ---------------------------------------------------
tcc -xif:err 2>&1 | sed '/match/p;/warning/p;d'
prio {
class if raw[0].nl >> 4 != 0x80000000;
}
EOF
warning: left-shift of value in access exceeds 32 bit range
match action 1
# X << N == C without underflow -----------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].nl << 4 == 32;
}
EOF
match 0:0:32=0x00000002 action 1
match action 0
# X << N == C with underflow --------------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].nl << 4 == 33;
}
EOF
match action 0
# X << N != C with underflow --------------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].nl << 4 != 33;
}
EOF
match action 1
# X << N < C with underflow ---------------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].nl << 4 < 33; /* <= 2 */
}
EOF
match 0:0:31=0x00000000 action 1
match 0:0:30=0x00000000 0:31:1=0x0 action 1
match action 0
# X << N <= C with underflow --------------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].b << 4 <= 33; /* <= 2 */
}
EOF
match 0:0:7=0x00 action 1
match 0:0:6=0x00 0:7:1=0x0 action 1
match action 0
# X << N > C with underflow ---------------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].b << 4 > 33; /* > 3 */
}
EOF
match 0:0:6=0x00 action 0
match action 1
# X << N >= C with underflow ---------------------------------------------------
tcc -xif:err 2>&1 | grep match
prio {
class if raw[0].b << 4 >= 33; /* > 2 */
}
EOF
match 0:0:1=0x1 action 1
match 0:1:1=0x1 action 1
match 0:2:1=0x1 action 1
match 0:3:1=0x1 action 1
match 0:4:1=0x1 action 1
match 0:5:1=0x1 action 1
match 0:6:2=0x3 action 1
match action 0
# (X.nl & 0xf0) << 2 works ----------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (raw[0].nl & 0xf0) << 2 == 0x40;
}
EOF
0:24:4=0x1
# (X.nl << 2) & 0xf0 works ----------------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if ((raw[0].nl << 2) & 0xf0) == 0x40;
}
EOF
0:26:4=0x4
# ((X.nl & 0xf0) >> 2) & 0xf0 works -------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (((raw[0].nl & 0xf0) >> 2) & 0xf0) == 0x20;
}
EOF
0:24:2=0x2
# ((X.nl & 0xf0) >> 2) & 0xf0 works -------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if (((raw[0].nl & 0xf0) >> 2) & 0xf0) == 0x20;
}
EOF
0:24:2=0x2
# ((X.nl << 2) & 0xf0) >> 3 works ---------------------------------------------
tcc -xif:err 2>&1 | sed '/^match \\(.*\\) action.*/s//\\1/p;d'
prio {
class if ((raw[0].nl << 2) & 0xf0) >> 3 == 6;
}
EOF
0:26:4=0x3
|