@@ -221,6 +221,94 @@ void test_hexadecimal_constants() {
221
221
0x8000000000000000LLu ; // COMPLIANT - unsigned, but uses the suffix correctly
222
222
}
223
223
224
+ void test_octal_constants () {
225
+ 00 ; // COMPLIANT - uses signed int
226
+ 017777777777 ; // COMPLIANT - max value held by signed int
227
+ 020000000000 ; // NON_COMPLIANT - larger than max signed int, so will be
228
+ // unsigned int
229
+ 040000000000 ; // COMPLIANT - larger than unsigned int, but smaller than long
230
+ // int
231
+ 0777777777777777777777 ; // COMPLIANT - max long int
232
+ 01000000000000000000000 ; // NON_COMPLIANT - larger than long int, so will be
233
+ // unsigned long int
234
+ 00U ; // COMPLIANT - unsigned, but uses the suffix correctly
235
+ 017777777777U ; // COMPLIANT - unsigned, but uses the suffix correctly
236
+ 020000000000U ; // COMPLIANT - unsigned, but uses the suffix correctly
237
+ 040000000000U ; // COMPLIANT - unsigned, but uses the suffix correctly
238
+ 0777777777777777777777U ; // COMPLIANT - unsigned, but uses the suffix
239
+ // correctly
240
+ 01000000000000000000000U ; // COMPLIANT - unsigned, but uses the suffix
241
+ // correctly
242
+
243
+ // Use of the `l` suffix
244
+ 00l ; // COMPLIANT - uses signed long
245
+ 017777777777l ; // COMPLIANT - uses signed long
246
+ 020000000000l ; // COMPLIANT - uses signed long
247
+ 040000000000l ; // COMPLIANT - uses signed long
248
+ 0777777777777777777777l ; // COMPLIANT - max long int
249
+ 01000000000000000000000l ; // NON_COMPLIANT - larger than long int, so will be
250
+ // unsigned long int
251
+ 00Ul ; // COMPLIANT - unsigned, but uses the suffix correctly
252
+ 017777777777Ul ; // COMPLIANT - unsigned, but uses the suffix correctly
253
+ 020000000000Ul ; // COMPLIANT - unsigned, but uses the suffix correctly
254
+ 040000000000Ul ; // COMPLIANT - unsigned, but uses the suffix correctly
255
+ 0777777777777777777777Ul ; // COMPLIANT - unsigned, but uses the suffix
256
+ // correctly
257
+ 01000000000000000000000Ul ; // COMPLIANT - unsigned, but uses the suffix
258
+ // correctly
259
+
260
+ // Use of the `L` suffix
261
+ 00L ; // COMPLIANT - uses signed long
262
+ 017777777777L ; // COMPLIANT - uses signed long
263
+ 020000000000L ; // COMPLIANT - uses signed long
264
+ 040000000000L ; // COMPLIANT - uses signed long
265
+ 0777777777777777777777L ; // COMPLIANT - COMPLIANT - uses signed long
266
+ 01000000000000000000000L ; // NON_COMPLIANT - larger than long int, so will be
267
+ // unsigned long int
268
+ 00UL ; // COMPLIANT - unsigned, but uses the suffix correctly
269
+ 017777777777UL ; // COMPLIANT - unsigned, but uses the suffix correctly
270
+ 020000000000UL ; // COMPLIANT - unsigned, but uses the suffix correctly
271
+ 040000000000UL ; // COMPLIANT - unsigned, but uses the suffix correctly
272
+ 0777777777777777777777UL ; // COMPLIANT - unsigned, but uses the suffix
273
+ // correctly
274
+ 01000000000000000000000UL ; // COMPLIANT - unsigned, but uses the suffix
275
+ // correctly
276
+
277
+ // Use of the `ll` suffix
278
+ 00ll ; // COMPLIANT - uses signed long long
279
+ 017777777777ll ; // COMPLIANT - uses signed long long
280
+ 020000000000ll ; // COMPLIANT - uses signed long long
281
+ 040000000000ll ; // COMPLIANT - uses signed long long
282
+ 0777777777777777777777ll ; // COMPLIANT - max long int
283
+ 01000000000000000000000ll ; // NON_COMPLIANT - larger than long int, so will be
284
+ // unsigned long int
285
+ 00Ull ; // COMPLIANT - unsigned, but uses the suffix correctly
286
+ 017777777777Ull ; // COMPLIANT - unsigned, but uses the suffix correctly
287
+ 020000000000Ull ; // COMPLIANT - unsigned, but uses the suffix correctly
288
+ 040000000000Ull ; // COMPLIANT - unsigned, but uses the suffix correctly
289
+ 0777777777777777777777Ull ; // COMPLIANT - unsigned, but uses the suffix
290
+ // correctly
291
+ 01000000000000000000000Ull ; // COMPLIANT - unsigned, but uses the suffix
292
+ // correctly
293
+
294
+ // Use of the `LL` suffix
295
+ 00LL ; // COMPLIANT - uses signed long long
296
+ 017777777777LL ; // COMPLIANT - uses signed long long
297
+ 020000000000LL ; // COMPLIANT - uses signed long long
298
+ 040000000000LL ; // COMPLIANT - uses signed long long
299
+ 0777777777777777777777LL ; // COMPLIANT - max long int
300
+ 01000000000000000000000LL ; // NON_COMPLIANT - larger than long int, so will be
301
+ // unsigned long int
302
+ 00ULL ; // COMPLIANT - unsigned, but uses the suffix correctly
303
+ 017777777777ULL ; // COMPLIANT - unsigned, but uses the suffix correctly
304
+ 020000000000ULL ; // COMPLIANT - unsigned, but uses the suffix correctly
305
+ 040000000000ULL ; // COMPLIANT - unsigned, but uses the suffix correctly
306
+ 0777777777777777777777ULL ; // COMPLIANT - unsigned, but uses the suffix
307
+ // correctly
308
+ 01000000000000000000000ULL ; // COMPLIANT - unsigned, but uses the suffix
309
+ // correctly
310
+ }
311
+
224
312
#define COMPLIANT_VAL 0x80000000U
225
313
#define NON_COMPLIANT_VAL 0x80000000
226
314
0 commit comments