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 tests/lint: explain wrong type mis...



details:   https://anonhg.NetBSD.org/src/rev/4ac9e3b1f956
branches:  trunk
changeset: 960603:4ac9e3b1f956
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Mar 22 16:51:24 2021 +0000

description:
tests/lint: explain wrong type mismatch in compound literal

When a pointer to a compound literal is used as an initializer, lint
reports a wrong type mismatch.  The details of what happens are now
documented, which allows this problem to be fixed properly.

diffstat:

 tests/usr.bin/xlint/lint1/msg_171.c |  18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diffs (30 lines):

diff -r a16ca7c9277d -r 4ac9e3b1f956 tests/usr.bin/xlint/lint1/msg_171.c
--- a/tests/usr.bin/xlint/lint1/msg_171.c       Mon Mar 22 15:29:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_171.c       Mon Mar 22 16:51:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_171.c,v 1.4 2021/03/22 15:29:43 rillig Exp $       */
+/*     $NetBSD: msg_171.c,v 1.5 2021/03/22 16:51:24 rillig Exp $       */
 # 3 "msg_171.c"
 
 // Test for message: cannot assign to '%s' from '%s' [171]
@@ -34,4 +34,20 @@
        struct point *p = &(struct point){
            12, 5,
        };                      /* expect: 171 *//*FIXME*/
+       /*
+        * FIXME: The type mismatch in the above line occurs because lint
+        * wrongly assumes that there is only ever a single initialization
+        * going on, which takes place in initstk.
+        *
+        * In the debug log, this is marked by the two calls to initstack_init
+        * that are happily intermixed with 'begin initialization' and 'end
+        * initialization'.  This was not planned for, and it worked well
+        * before C99, since compound literals are a new feature from C99.
+        *
+        * The proper fix, as for so many similar problems is to not use
+        * global variables for things that have a limited lifetime, but
+        * instead let the grammar determine the lifetime and scope of these
+        * objects, which makes them only accessible when they can actually be
+        * used.
+        */
 }



Home | Main Index | Thread Index | Old Index