diff mbox series

[v3,01/16] add testcases for dubious enum values

Message ID 20201231101034.59978-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series support __packed struct | expand

Commit Message

Luc Van Oostenryck Dec. 31, 2020, 10:10 a.m. UTC
sparse accept any type of integral value for enumerators
but address constants are also accepted, which is 'strange'.

Add a testcase for such 'enums'.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/enum-type-dubious.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 validation/enum-type-dubious.c
diff mbox series

Patch

diff --git a/validation/enum-type-dubious.c b/validation/enum-type-dubious.c
new file mode 100644
index 000000000000..f2cb39fcdbff
--- /dev/null
+++ b/validation/enum-type-dubious.c
@@ -0,0 +1,18 @@ 
+enum foobar {
+	FOO = (void*)0,
+	BAR = (void*)1,
+	BAZ = (int*)0,
+	QUX = (int*)123,
+};
+
+/*
+ * check-name: enum-type-dubious
+ * check-known-to-fail
+ *
+ * check-error-start
+validation/enum-type-dubious.c:2:8: error: enumerator value for 'FOO' is not an integer constant
+validation/enum-type-dubious.c:3:8: error: enumerator value for 'BAR' is not an integer constant
+validation/enum-type-dubious.c:4:8: error: enumerator value for 'BAZ' is not an integer constant
+validation/enum-type-dubious.c:5:8: error: enumerator value for 'QUX' is not an integer constant
+ * check-error-end
+ */