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: add test for type name...



details:   https://anonhg.NetBSD.org/src/rev/8248871447b0
branches:  trunk
changeset: 1022034:8248871447b0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jun 30 12:26:35 2021 +0000

description:
tests/lint: add test for type name of enum converted to int

diffstat:

 tests/usr.bin/xlint/lint1/msg_155.c   |  32 +++++++++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_155.exp |   4 ++++
 2 files changed, 35 insertions(+), 1 deletions(-)

diffs (54 lines):

diff -r ff820e7dd597 -r 8248871447b0 tests/usr.bin/xlint/lint1/msg_155.c
--- a/tests/usr.bin/xlint/lint1/msg_155.c       Wed Jun 30 11:29:29 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.c       Wed Jun 30 12:26:35 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_155.c,v 1.7 2021/06/28 11:27:00 rillig Exp $       */
+/*     $NetBSD: msg_155.c,v 1.8 2021/06/30 12:26:35 rillig Exp $       */
 # 3 "msg_155.c"
 
 // Test for message: passing '%s' to incompatible '%s', arg #%d [155]
@@ -46,3 +46,33 @@
        /* expect+1: 'pointer to const pointer to function(unsigned int, ...) returning int' */
        c99_6_7_6_example_h(arg);
 }
+
+extern void sink(struct incompatible);
+
+/*
+ * The function type_name has a special case for an enum type that has been
+ * implicitly converted to an int.  Such a type is still output as the enum
+ * type.
+ *
+ * XXX: The expressions 'day + 0' and '0 + day' should result in the same
+ *  type.
+ */
+void
+type_name_of_enum(void)
+{
+       enum Day {
+               MONDAY
+       } day = MONDAY;
+
+       /* expect+1: passing 'enum Day' */
+       sink(day);
+
+       /* expect+1: passing 'enum Day' */
+       sink(day + 0);
+
+       /* expect+1: passing 'int' */
+       sink(0 + day);
+
+       /* expect+1: passing 'int' */
+       sink(0);
+}
diff -r ff820e7dd597 -r 8248871447b0 tests/usr.bin/xlint/lint1/msg_155.exp
--- a/tests/usr.bin/xlint/lint1/msg_155.exp     Wed Jun 30 11:29:29 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_155.exp     Wed Jun 30 12:26:35 2021 +0000
@@ -6,3 +6,7 @@
 msg_155.c(41): error: function implicitly declared to return int [215]
 msg_155.c(44): warning: passing 'struct incompatible' to incompatible 'pointer to function(void) returning int', arg #1 [155]
 msg_155.c(47): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]
+msg_155.c(68): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(71): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(74): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(77): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]



Home | Main Index | Thread Index | Old Index