summaryrefslogtreecommitdiff
path: root/usr/src/tools/smatch/src/validation/enum-bounds.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/tools/smatch/src/validation/enum-bounds.c')
-rw-r--r--usr/src/tools/smatch/src/validation/enum-bounds.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/usr/src/tools/smatch/src/validation/enum-bounds.c b/usr/src/tools/smatch/src/validation/enum-bounds.c
new file mode 100644
index 0000000000..49f7a1ed81
--- /dev/null
+++ b/usr/src/tools/smatch/src/validation/enum-bounds.c
@@ -0,0 +1,25 @@
+enum bound_int_max {
+ IMAX = __INT_MAX__,
+};
+_Static_assert([typeof(IMAX)] == [int], "");
+
+enum bound_int_maxp1 {
+ IMP1 = __INT_MAX__ + 1L,
+};
+_Static_assert([typeof(IMP1)] == [unsigned int], "");
+
+enum bound_int_maxm1 {
+ IMM1 = -__INT_MAX__ - 1L,
+};
+_Static_assert([typeof(IMM1)] == [int], "");
+
+enum bound_int_maxm2 {
+ IMM2 = -__INT_MAX__ - 2L,
+};
+_Static_assert([typeof(IMM2)] == [long], "");
+
+/*
+ * check-name: enum-bounds
+ * check-command: sparse -m64 $file
+ * check-assert: sizeof(long) == 8
+ */