1 /* $NetBSD: msg_161.c,v 1.7 2021/03/21 15:44:57 rillig Exp $ */ 2 # 3 "msg_161.c" 3 4 // Test for message: constant in conditional context [161] 5 6 /* lint1-extra-flags: -h */ 7 8 void 9 while_1(void) 10 { 11 while (1) /* expect: 161 */ 12 continue; 13 } 14 15 void 16 while_0(void) 17 { 18 while (0) /* expect: 161 */ 19 continue; /* expect: statement not reached */ 20 } 21 22 /* 23 * The pattern 'do { } while (0)' is a common technique to define a 24 * preprocessor macro that behaves like a single statement. There is 25 * nothing unusual or surprising about the constant condition. 26 * Before tree.c 1.202 from 2021-01-31, lint warned about it. 27 */ 28 void 29 do_while_0(void) 30 { 31 do { 32 33 } while (0); 34 } 35 36 void 37 do_while_1(void) 38 { 39 do { 40 41 } while (1); /* expect: 161 */ 42 } 43 44 extern void println(const char *); 45 46 /* 47 * Since 2021-02-28, lint no longer warns about constant controlling 48 * expressions involving sizeof since these are completely legitimate. 49 */ 50 void 51 test_sizeof(void) 52 { 53 if (sizeof(int) > sizeof(char)) 54 println("very probable"); 55 if (sizeof(int) < sizeof(char)) 56 println("impossible"); 57 } 58