diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-02-21 20:51:23 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-12-29 14:39:38 +0100 |
commit | 0f2eee32cae5b87d1871ebafe766c8b65a5234f8 (patch) | |
tree | cf63dd9d90732d9f623ad5c9d395ed40a11ffc44 | |
parent | 1b896707d95982c7c9cdd5cd0ab4afd80f766a94 (diff) | |
download | sparse-0f2eee32cae5b87d1871ebafe766c8b65a5234f8.tar.gz |
add testcases for dubious enum values
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>
-rw-r--r-- | validation/enum-type-dubious.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/validation/enum-type-dubious.c b/validation/enum-type-dubious.c new file mode 100644 index 00000000..f2cb39fc --- /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 + */ |