aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-05-09 01:12:40 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-10-05 03:29:19 +0200
commitacc13744b394d8de81709b8f61ebcfba81a270d3 (patch)
tree3b464e05e666f0392e3e35003956e4fd676f5468 /validation
parent604a148a73af94bd271bbfb0d36dbe77e42bbc4f (diff)
downloadsparse-dev-acc13744b394d8de81709b8f61ebcfba81a270d3.tar.gz
enum: use the smallest type that fit
The C standard requires that the type of enum constants is 'int' and let the enum base/compatible type be implementation defined. For this base type, instead of 'int', GCC uses the smallest type that can represent all the values of the enum (int, unsigned int, long, ...) Sparse has the same logic as GCC but if all the initializers have the same type, this type is used instead. This is a sensible choice but often gives differents result than GCC. To stay more compatible with GCC, always use the same logic and thus only keep the common type as base type for restricted types. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/enum-base-type.c1
-rw-r--r--validation/enum-bounds.c1
-rw-r--r--validation/enum-min-size.c1
3 files changed, 0 insertions, 3 deletions
diff --git a/validation/enum-base-type.c b/validation/enum-base-type.c
index e430290b..cae801b1 100644
--- a/validation/enum-base-type.c
+++ b/validation/enum-base-type.c
@@ -26,5 +26,4 @@ _Static_assert(sizeof(enum p) == sizeof(int), "UL");
/*
* check-name: enum-base-type
* check-command: sparse -m64 $file
- * check-known-to-fail
*/
diff --git a/validation/enum-bounds.c b/validation/enum-bounds.c
index 604e0f33..64ecd8bb 100644
--- a/validation/enum-bounds.c
+++ b/validation/enum-bounds.c
@@ -21,5 +21,4 @@ _Static_assert([typeof(IMM2)] == [long], "");
/*
* check-name: enum-bounds
* check-command: sparse -m64 $file
- * check-known-to-fail
*/
diff --git a/validation/enum-min-size.c b/validation/enum-min-size.c
index 264a3154..e8bd9fb1 100644
--- a/validation/enum-min-size.c
+++ b/validation/enum-min-size.c
@@ -26,5 +26,4 @@ _Static_assert(sizeof(enum n) == sizeof(int), "llong");
/*
* check-name: enum-min-size
- * check-known-to-fail
*/