tests/lint: demonstrate wrong error message for initialization
Seen in usr.bin/make/var.c:4022 in C99 mode, where a ModChain variable is initialized and two of the members are const-qualified.
This commit is contained in:
parent
51085f5d8c
commit
fe7cbecd8a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg_115.c,v 1.4 2021/01/31 11:12:07 rillig Exp $ */
|
||||
/* $NetBSD: msg_115.c,v 1.5 2021/07/31 09:14:47 rillig Exp $ */
|
||||
# 3 "msg_115.c"
|
||||
|
||||
// Test for message: %soperand of '%s' must be modifiable lvalue [115]
|
||||
|
@ -15,3 +15,21 @@ example(const int *const_ptr)
|
|||
*const_ptr %= 9; /* expect: 115 */
|
||||
(*const_ptr)++; /* expect: 115 */
|
||||
}
|
||||
|
||||
void
|
||||
initialize_const_struct_member(void)
|
||||
{
|
||||
struct S {
|
||||
int const member;
|
||||
};
|
||||
|
||||
/* FIXME: In an initialization, const members can be assigned. */
|
||||
/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
|
||||
struct S s1 = (struct S) { 12345 };
|
||||
if (s1.member != 0)
|
||||
return;
|
||||
|
||||
struct S s2 = { 12345 };
|
||||
if (s2.member != 0)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,3 +5,4 @@ msg_115.c(13): warning: left operand of '*=' must be modifiable lvalue [115]
|
|||
msg_115.c(14): warning: left operand of '/=' must be modifiable lvalue [115]
|
||||
msg_115.c(15): warning: left operand of '%=' must be modifiable lvalue [115]
|
||||
msg_115.c(16): warning: operand of 'x++' must be modifiable lvalue [115]
|
||||
msg_115.c(28): warning: left operand of '=' must be modifiable lvalue [115]
|
||||
|
|
Loading…
Reference in New Issue