Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 lint: demonstrate bug in assignmen...
details: https://anonhg.NetBSD.org/src/rev/e81eb2b638a6
branches: trunk
changeset: 1019866:e81eb2b638a6
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Mar 22 15:05:00 2021 +0000
description:
lint: demonstrate bug in assignment of compound literal
Seen in external/mpl/bind/dist/lib/dns/rbtdb.c, update_rrsetstats.
diffstat:
tests/usr.bin/xlint/lint1/msg_171.c | 20 +++++++++++++++++++-
tests/usr.bin/xlint/lint1/msg_171.exp | 1 +
2 files changed, 20 insertions(+), 1 deletions(-)
diffs (39 lines):
diff -r b41899b654a4 -r e81eb2b638a6 tests/usr.bin/xlint/lint1/msg_171.c
--- a/tests/usr.bin/xlint/lint1/msg_171.c Mon Mar 22 14:11:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_171.c Mon Mar 22 15:05:00 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_171.c,v 1.2 2021/01/24 16:12:45 rillig Exp $ */
+/* $NetBSD: msg_171.c,v 1.3 2021/03/22 15:05:00 rillig Exp $ */
# 3 "msg_171.c"
// Test for message: assignment type mismatch (%s != %s) [171]
@@ -17,3 +17,21 @@
vp = *s; /* expect: 171 */
*s = vp; /* expect: 171 */
}
+
+/*
+ * C99 6.5.2.5 says that a compound literal evaluates to an unnamed object
+ * with automatic storage duration, like any normal named object. It is an
+ * lvalue, which means that it is possible to take the address of the object.
+ * Seen in external/mpl/bind/dist/lib/dns/rbtdb.c, update_rrsetstats.
+ */
+void
+pointer_to_compound_literal(void)
+{
+ struct point {
+ int x;
+ int y;
+ };
+ struct point *p = &(struct point){
+ 12, 5,
+ }; /* expect: 171 *//*FIXME*/
+}
diff -r b41899b654a4 -r e81eb2b638a6 tests/usr.bin/xlint/lint1/msg_171.exp
--- a/tests/usr.bin/xlint/lint1/msg_171.exp Mon Mar 22 14:11:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_171.exp Mon Mar 22 15:05:00 2021 +0000
@@ -2,3 +2,4 @@
msg_171.c(15): error: assignment type mismatch (struct != int) [171]
msg_171.c(17): error: assignment type mismatch (pointer != struct) [171]
msg_171.c(18): error: assignment type mismatch (struct != pointer) [171]
+msg_171.c(36): error: assignment type mismatch (struct != pointer) [171]
Home |
Main Index |
Thread Index |
Old Index