msg_161.c revision 1.5
1/* $NetBSD: msg_161.c,v 1.5 2021/02/28 03:29:12 rillig Exp $ */ 2# 3 "msg_161.c" 3 4// Test for message: constant in conditional context [161] 5 6/* lint1-extra-flags: -h */ 7 8void 9while_1(void) 10{ 11 while (1) /* expect: 161 */ 12 continue; 13} 14 15void 16while_0(void) 17{ 18 while (0) /* expect: 161 */ 19 continue; 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 */ 28void 29do_while_0(void) 30{ 31 do { 32 33 } while (0); 34} 35 36void 37do_while_1(void) 38{ 39 do { 40 41 } while (1); /* expect: 161 */ 42} 43 44extern void println(const char *); 45 46void 47test_sizeof(void) 48{ 49 /* 50 * XXX: The following conditions should not need CONSTCOND as they 51 * are perfectly legitimate. 52 */ 53 if (sizeof(int) > sizeof(char)) /* expect: 161 */ 54 println("very probable"); 55 if (sizeof(int) < sizeof(char)) /* expect: 161 */ 56 println("impossible"); 57} 58