linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Eder <hannes@hanneseder.net>
To: Christopher Li <sparse@chrisli.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>, linux-sparse@vger.kernel.org
Subject: [PATCH] test-suite: new preprocessor test case
Date: Thu, 19 Mar 2009 18:56:11 +0100	[thread overview]
Message-ID: <20090319175544.13691.42362.stgit@f10box.hanneseder.net> (raw)

Sparse currently fails on this test.

Signed-off-by: Hannes Eder <hannes@hanneseder.net>
---

I discovered this while hunting down the sparse segfault when checking kernel/cred.c.

When preprocessing the file with gcc, gcc remains silent, but sparse
complains:

include/linux/skbuff.h:381:9: error: expected preprocessor identifier
include/linux/skbuff.h:381:9: error: expected preprocessor identifier
include/linux/skbuff.h:381:9: error: garbage at end: )
include/linux/skbuff.h:381:9: error: expected preprocessor identifier
include/linux/skbuff.h:381:9: error: expected preprocessor identifier
include/linux/skbuff.h:381:9: error: garbage at end: )

this is covered by the test case in a more abstract form.  Sparse
further complains about this, which is not yet covered in a test case:

kernel/cred.c:281:9: error: unmatched #endif in stream
kernel/cred.c:281:9: error: unmatched #endif in stream
kernel/cred.c:281:9: error: unmatched #endif in stream

 validation/preprocessor/preprocessor22.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 validation/preprocessor/preprocessor22.c

diff --git a/validation/preprocessor/preprocessor22.c b/validation/preprocessor/preprocessor22.c
new file mode 100644
index 0000000..838479f
--- /dev/null
+++ b/validation/preprocessor/preprocessor22.c
@@ -0,0 +1,21 @@
+#define CONFIG_FOO 1
+
+#define define_struct(name, fields...) struct fields name;
+
+define_struct(a, {
+#ifdef CONFIG_FOO
+  int b;
+#endif
+});
+/*
+ * check-name: Preprocessor #22
+ * check-description: Sparse gets this wrong, should be fixed
+ * check-command: sparse -E $file
+ * check-known-to-fail
+ *
+ * check-output-start
+
+struct {
+int b; } a;;
+ * check-output-end
+ */


             reply	other threads:[~2009-03-19 17:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-19 17:56 Hannes Eder [this message]
2009-03-19 18:26 ` [PATCH] test-suite: new preprocessor test case Al Viro
2009-03-19 18:51   ` Hannes Eder
2009-03-19 19:07     ` Nasal demons in preprocessor use (Re: [PATCH] test-suite: new preprocessor test case) Al Viro
2009-03-19 19:27       ` Ingo Molnar
2009-03-19 19:39         ` Al Viro
2009-03-19 20:20         ` Vegard Nossum
2009-03-19 22:07           ` Stephen Rothwell
2009-03-20 18:08           ` Ingo Molnar
2009-03-20 19:04             ` Al Viro
2009-03-20 19:14               ` Al Viro
2009-03-20 23:16                 ` Vegard Nossum
2009-03-20 23:44                   ` Al Viro
2009-03-21  8:34                 ` Johannes Berg
2009-03-27  3:13                   ` H. Peter Anvin
2009-03-19 19:24   ` [PATCH] test-suite: new preprocessor test case Derek M Jones

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=20090319175544.13691.42362.stgit@f10box.hanneseder.net \
    --to=hannes@hanneseder.net \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).