aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorRamsay Jones <ramsay@ramsayjones.plus.com>2018-11-18 23:52:23 +0000
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-11-23 02:45:45 +0100
commitfdf8252f312a40df9aa51c6e30c0d07fa29ebd12 (patch)
treee77718158645c681cd8fc54bd85da457b446aa29 /validation
parentcb777d34218842a12ebc3eac9baba3e6fbbd7e13 (diff)
downloadsparse-dev-fdf8252f312a40df9aa51c6e30c0d07fa29ebd12.tar.gz
constant: add -Wconstant-suffix warning
Currently, when used on the kernel, sparse issues a bunch of warnings like: warning: constant 0x100000000 is so big it is long These warning are issued when there is a discrepancy between the type as indicated by the suffix (or the absence of a suffix) and the real type as selected by the type suffix *and* the value of the constant. Since there is nothing incorrect with this discrepancy, (no bits are lost) these warnings are more annoying than useful. So, make them depending on a new warning flag -Wconstant-suffix and make it off by default. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/constant-suffix-32.c15
-rw-r--r--validation/constant-suffix-64.c15
2 files changed, 30 insertions, 0 deletions
diff --git a/validation/constant-suffix-32.c b/validation/constant-suffix-32.c
new file mode 100644
index 00000000..dc063a07
--- /dev/null
+++ b/validation/constant-suffix-32.c
@@ -0,0 +1,15 @@
+#define BIGU 0xfffff00000000000U
+#define BIGULL 0xfffff00000000000ULL
+
+static unsigned long long a = BIGU;
+static unsigned long long b = BIGULL;
+
+/*
+ * check-name: constant-suffix
+ * check-command: sparse -m32 -Wconstant-suffix $file
+ *
+ * check-error-start
+constant-suffix-32.c:4:31: warning: constant 0xfffff00000000000U is so big it is unsigned long long
+ * check-error-end
+ */
+
diff --git a/validation/constant-suffix-64.c b/validation/constant-suffix-64.c
new file mode 100644
index 00000000..e65706b0
--- /dev/null
+++ b/validation/constant-suffix-64.c
@@ -0,0 +1,15 @@
+#define BIGU 0xfffff00000000000U
+#define BIGUL 0xfffff00000000000UL
+
+static unsigned long a = BIGU;
+static unsigned long b = BIGUL;
+
+/*
+ * check-name: constant-suffix
+ * check-command: sparse -m64 -Wconstant-suffix $file
+ *
+ * check-error-start
+constant-suffix-64.c:4:26: warning: constant 0xfffff00000000000U is so big it is unsigned long
+ * check-error-end
+ */
+