Powered by Linux
[PATCH 07/18] sparse: add -Wbig-constants — Semantic Matching Tool

[PATCH 07/18] sparse: add -Wbig-constants

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: John Levon <levon@xxxxxxxxxxxxxxxxx>
---
 cgcc         | 2 +-
 expression.c | 3 +++
 lib.c        | 2 ++
 lib.h        | 1 +
 sparse.1     | 7 +++++++
 5 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/cgcc b/cgcc
index b85d508b..04869c11 100755
--- a/cgcc
+++ b/cgcc
@@ -101,7 +101,7 @@ exit 0;
 
 sub check_only_option {
     my ($arg) = @_;
-    return 1 if $arg =~ /^-W(no-?)?(address-space|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|memcpy-max-count|non-ansi-function-declaration|non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$/;
+    return 1 if $arg =~ /^-W(no-?)?(address-space|big-constants|bitwise|cast-to-as|cast-truncate|context|decl|default-bitfield-sign|designated-init|do-while|enum-mismatch|init-cstring|memcpy-max-count|non-ansi-function-declaration|non-pointer-null|old-initializer|one-bit-signed-bitfield|override-init-all|paren-string|ptr-subtraction-blows|return-void|sizeof-bool|sparse-all|sparse-error|transparent-union|typesign|undef|unknown-attribute)$/;
     return 1 if $arg =~ /^-v(no-?)?(entry|dead)$/;
     return 1 if $arg =~ /^-f(dump-linearize|memcpy-max-count)(=\S*)?$/;
     return 0;
diff --git a/expression.c b/expression.c
index 9907e328..097c0a7c 100644
--- a/expression.c
+++ b/expression.c
@@ -318,6 +318,9 @@ static void get_number_value(struct expression *expr, struct token *token)
 			show_token(token));
 	want_unsigned = 1;
 got_it:
+	if (!Wbig_constants)
+		do_warn = 0;
+
 	if (do_warn)
 		warning(expr->pos, "constant %s is so big it is%s%s%s",
 			show_token(token),
diff --git a/lib.c b/lib.c
index e6a3bc4b..8924c2eb 100644
--- a/lib.c
+++ b/lib.c
@@ -223,6 +223,7 @@ static struct token *pre_buffer_end = NULL;
 
 int Waddress = 0;
 int Waddress_space = 1;
+int Wbig_constants = 1;
 int Wbitwise = 1;
 int Wcast_to_as = 0;
 int Wcast_truncate = 1;
@@ -527,6 +528,7 @@ static const struct warning {
 } warnings[] = {
 	{ "address", &Waddress },
 	{ "address-space", &Waddress_space },
+	{ "big-constants", &Wbig_constants },
 	{ "bitwise", &Wbitwise },
 	{ "cast-to-as", &Wcast_to_as },
 	{ "cast-truncate", &Wcast_truncate },
diff --git a/lib.h b/lib.h
index 05579cce..bfb35466 100644
--- a/lib.h
+++ b/lib.h
@@ -114,6 +114,7 @@ extern int preprocess_only;
 
 extern int Waddress;
 extern int Waddress_space;
+extern int Wbig_constants;
 extern int Wbitwise;
 extern int Wcast_to_as;
 extern int Wcast_truncate;
diff --git a/sparse.1 b/sparse.1
index 63bd923e..cc72ad63 100644
--- a/sparse.1
+++ b/sparse.1
@@ -42,6 +42,13 @@ Sparse issues these warnings by default.  To turn them off, use
 \fB\-Wno\-address\-space\fR.
 .
 .TP
+.B \-Wbig-constants
+Warn about large integer constants that are not qualified by a size suffix.
+
+Sparse issues these warnings by default.  To turn them off, use
+\fB\-Wno\-big\-constants\fR.
+.
+.TP
 .B \-Wbitwise
 Warn about unsupported operations or type mismatches with restricted integer
 types.
-- 
2.14.1




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux