linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Forbes <chrisf@ijw.co.nz>
To: linux-sparse@vger.kernel.org
Cc: Chris Forbes <chrisf@ijw.co.nz>
Subject: [PATCH 1/2] add test case for identical exprs on LHS and RHS of '&&' operator
Date: Wed, 10 Aug 2011 21:07:14 +1200	[thread overview]
Message-ID: <1312967235-23817-2-git-send-email-chrisf@ijw.co.nz> (raw)
In-Reply-To: <1312967235-23817-1-git-send-email-chrisf@ijw.co.nz>

---
 validation/check_identical_exprs_on_and.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
 create mode 100644 validation/check_identical_exprs_on_and.c

diff --git a/validation/check_identical_exprs_on_and.c b/validation/check_identical_exprs_on_and.c
new file mode 100644
index 0000000..712395d
--- /dev/null
+++ b/validation/check_identical_exprs_on_and.c
@@ -0,0 +1,24 @@
+extern void bar(void);
+
+static void foo(void *a, void *b, void *c)
+{
+	if (a && a)	/* should warn */
+		bar();
+
+	if (a && b)	/* should not warn */
+		bar();
+
+	if ((a == b) && (a == b))	/* should warn */
+		bar();
+
+	if ((a == b) && (b == c))	/* should not warn */
+		bar();
+}
+/*
+ * check-name: A warning should be issued for identical expressions on both sides of the '&&' operator.
+ *
+ * check-error-start
+check_identical_exprs_on_and.c:5:15: warning: identical expressions on both sides of '&&'
+check_identical_exprs_on_and.c:11:22: warning: identical expressions on both sides of '&&'
+ * check-error-end
+ */
-- 
1.7.4.1


  reply	other threads:[~2011-08-10  9:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-10  9:07 [RFC PATCH 0/2] check for identical exprs on LHS and RHS of '&&' Chris Forbes
2011-08-10  9:07 ` Chris Forbes [this message]
2011-08-10  9:07 ` [PATCH 2/2] initial work on check for identical exprs on both sides of '&&'; needs more Chris Forbes
2011-08-10 17:44 ` [RFC PATCH 0/2] check for identical exprs on LHS and RHS of '&&' Josh Triplett
2011-08-10 17:46   ` Al Viro
2011-08-12 19:34     ` Dan Carpenter
2011-08-12 19:16 ` Christopher Li

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=1312967235-23817-2-git-send-email-chrisf@ijw.co.nz \
    --to=chrisf@ijw.co.nz \
    --cc=linux-sparse@vger.kernel.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 NNTP newsgroup(s).