Module Name: src
Committed By: rillig
Date: Sat Jul 31 09:14:47 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_115.c msg_115.exp
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_115.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_115.exp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_115.c
diff -u src/tests/usr.bin/xlint/lint1/msg_115.c:1.4 src/tests/usr.bin/xlint/lint1/msg_115.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_115.c:1.4 Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.c Sat Jul 31 09:14:47 2021
@@ -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;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_115.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_115.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_115.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_115.exp:1.3 Sun Jan 17 16:19:54 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.exp Sat Jul 31 09:14:47 2021
@@ -5,3 +5,4 @@ msg_115.c(13): warning: left operand of
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]