Module Name: src
Committed By: rillig
Date: Wed Jun 30 12:26:35 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_155.c msg_155.exp
Log Message:
tests/lint: add test for type name of enum converted to int
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_155.c \
src/tests/usr.bin/xlint/lint1/msg_155.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_155.c
diff -u src/tests/usr.bin/xlint/lint1/msg_155.c:1.7 src/tests/usr.bin/xlint/lint1/msg_155.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_155.c:1.7 Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.c Wed Jun 30 12:26:35 2021
@@ -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 @@ provoke_error_messages(struct incompatib
/* 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);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_155.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_155.exp:1.7 src/tests/usr.bin/xlint/lint1/msg_155.exp:1.8
--- src/tests/usr.bin/xlint/lint1/msg_155.exp:1.7 Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.exp Wed Jun 30 12:26:35 2021
@@ -6,3 +6,7 @@ msg_155.c(38): warning: passing 'struct
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]