smatch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Levon <levon@movementarian.org>
Subject: [PATCH 07/18] sparse: add -Wbig-constants
Date: Thu, 22 Nov 2018 18:48:24 +0000	[thread overview]
Message-ID: <E1gQCRW-00067u-Sx@movementarian.org> (raw)

Signed-off-by: John Levon <levon@movementarian.org>
---
 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

                 reply	other threads:[~2018-11-24  1:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1gQCRW-00067u-Sx@movementarian.org \
    --to=levon@movementarian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).