msg_382.c revision 1.1
11.1Srillig/* $NetBSD: msg_382.c,v 1.1 2024/07/10 20:33:38 rillig Exp $ */ 21.1Srillig# 3 "msg_382.c" 31.1Srillig 41.1Srillig// Test for message: constant assignment of type '%s' in operand of '!' always evaluates to '%s' [382] 51.1Srillig 61.1Srillig/* 71.1Srillig * Outside strict bool mode, an assignment can be used as a condition, but 81.1Srillig * that is generally wrong. Especially if a constant is assigned to a 91.1Srillig * variable, the condition always evaluates to that constant value, which 101.1Srillig * indicates a typo, as '==' makes more sense than '=' in a condition. 111.1Srillig */ 121.1Srillig 131.1Srillig/* lint1-extra-flags: -X 351 */ 141.1Srillig 151.1Srilligint 161.1Srillig/* expect+1: warning: parameter 'b' unused in function 'conversions' [231] */ 171.1Srilligconversions(int a, int b) 181.1Srillig{ 191.1Srillig /* expect+1: warning: constant assignment of type 'int' in operand of '!' always evaluates to 'true' [382] */ 201.1Srillig if (!(a = 13)) 211.1Srillig return 1; 221.1Srillig /* expect+1: warning: constant assignment of type 'int' in operand of '!' always evaluates to 'false' [382] */ 231.1Srillig if (!(b = 0)) 241.1Srillig return 2; 251.1Srillig if (!(a = a + 1)) 261.1Srillig return 3; 271.1Srillig return a; 281.1Srillig} 29