// Test for message: dubious operation '%s' on enum [241]
//
// As of February 2021, the option -e is not enabled by default in
// share/mk/sys.mk, therefore this message is neither well-known nor
// well-tested.
/* lint1-extra-flags: -e -X 351 */
/*
* Enums are a possible implementation of bit-sets.
*/
enum color {
RED = 1 << 0,
GREEN = 1 << 1,
BLUE = 1 << 2
};
c = GREEN;
/* expect+1: warning: dubious operation '*=' on enum [241] */
c *= c;
/* expect+1: warning: dubious operation '/=' on enum [241] */
c /= c;
/* expect+1: warning: dubious operation '%=' on enum [241] */
c %= c;
/* expect+1: warning: dubious operation '+=' on enum [241] */
c += c;
/* expect+1: warning: dubious operation '-=' on enum [241] */
c -= c;
/* expect+1: warning: dubious operation '<<=' on enum [241] */
c <<= c;
/* expect+1: warning: dubious operation '>>=' on enum [241] */
c >>= c;
/* expect+1: warning: dubious operation '&=' on enum [241] */
c &= c;
/* expect+1: warning: dubious operation '^=' on enum [241] */
c ^= c;
/* expect+1: warning: dubious operation '|=' on enum [241] */
c |= c;
/* The cast to unsigned is required by GCC at WARNS=6. */
/* expect+1: warning: dubious operation '&=' on enum [241] */
c &= ~(unsigned)GREEN;
}
void
cover_typeok_enum(enum color c, int i)
{
/* expect+2: warning: dubious operation '*' on enum [241] */
/* expect+1: warning: combination of 'enum color' and 'int', op '>' [242] */
if (c * i > 5)
return;
}