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 wrong error mess...



details:   https://anonhg.NetBSD.org/src/rev/1a87350bef0e
branches:  trunk
changeset: 1027712:1a87350bef0e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Dec 17 01:00:50 2021 +0000

description:
lint: demonstrate wrong error message in initialization

History of the new test fragment:

libexec/2021.09.14.19.44.40-plain/lint1
| (14): error: cannot initialize 'struct typedef histogram_entry'
|     from 'pointer to char' [185]
| exit status 1
libexec/2021.04.01.14.20.30-plain/lint1

libexec/2021.03.30.20.23.30-plain/lint1
| (14): error: cannot initialize 'struct typedef histogram_entry'
|     from 'pointer to char' [185]
| (14): error: cannot initialize 'struct typedef histogram_entry'
|     from 'int' [185]
| (15): error: cannot initialize 'struct typedef histogram_entry'
|     from 'pointer to char' [185]
| (15): error: cannot initialize 'struct typedef histogram_entry'
|     from 'int' [185]
| exit status 1
libexec/2021.03.30.14.25.28-plain/lint1

libexec/2021.03.29.21.34.17-plain/lint1
| (15): error: too many struct/union initializers [172]
| exit status 1
libexec/2021.03.28.15.36.37-plain/lint1

libexec/2021.03.28.14.13.18-plain/lint1
| (18): error: too many struct/union initializers [172]
| exit status 1
libexec/2021.03.21.20.44.59-plain/lint1

libexec/2021.03.21.20.30.19-plain/lint1
| (18): too many struct/union initializers [172]
| exit status 1
libexec/2014.11.20.20.49.06-plain/lint1

libexec/2014.11.20.20.48.33-plain/lint1
| exit status 0

diffstat:

 tests/usr.bin/xlint/lint1/init.c   |  20 +++++++++++++++++++-
 tests/usr.bin/xlint/lint1/init.exp |   1 +
 2 files changed, 20 insertions(+), 1 deletions(-)

diffs (37 lines):

diff -r e5e9b848e1cd -r 1a87350bef0e tests/usr.bin/xlint/lint1/init.c
--- a/tests/usr.bin/xlint/lint1/init.c  Fri Dec 17 00:05:24 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/init.c  Fri Dec 17 01:00:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.1 2021/07/10 09:24:27 rillig Exp $  */
+/*     $NetBSD: init.c,v 1.2 2021/12/17 01:00:50 rillig Exp $  */
 # 3 "init.c"
 
 /*
@@ -22,3 +22,21 @@
 struct {
        int member;
 } empty_struct_initializer = {};
+
+
+typedef struct {
+       const char *key;
+       int n;
+} histogram_entry;
+
+/*
+ * The C standards allow omitting braces around the structural levels.  For
+ * human readers, it is usually clearer to include them.
+ *
+ * Seen in external/ibm-public/postfix/dist/src/util/dict.c(624).
+ */
+const histogram_entry hgr[] = {
+       /* expect+1: error: cannot initialize 'struct typedef histogram_entry' from 'pointer to char' [185] */
+       "odd", 5,
+       "even", 5,
+};
diff -r e5e9b848e1cd -r 1a87350bef0e tests/usr.bin/xlint/lint1/init.exp
--- a/tests/usr.bin/xlint/lint1/init.exp        Fri Dec 17 00:05:24 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/init.exp        Fri Dec 17 01:00:50 2021 +0000
@@ -1,1 +1,2 @@
 init.c(16): error: empty array declaration: empty_array_with_initializer [190]
+init.c(40): error: cannot initialize 'struct typedef histogram_entry' from 'pointer to char' [185]



Home | Main Index | Thread Index | Old Index