linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Zaytsev <alexey.zaytsev@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org, Tommy Thorn <tommy@numba-tu.com>
Subject: [PATCH] Also warn about sizeof(function)
Date: Thu, 25 Dec 2008 23:10:58 +0300	[thread overview]
Message-ID: <20081225200613.15414.96407.stgit@zaytsev.su> (raw)
In-Reply-To: <70318cbf0812251145k1fa1e3bbh58b33a1aadf277cc@mail.gmail.com>

Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
---

> Hi Alexey,
> 
> On Thu, Dec 25, 2008 at 10:36 AM, Alexey Zaytsev
> <alexey.zaytsev@gmail.com> wrote:
>> I added (hopefully the right way) handling of (sizeof(function)) to the
>> patch. function++ was already prohibited.
> 
> Can you send me an incremental patch for the sizeof(function) change?
Sure. Btw, your patches come demaged lately. Could you please use
git-send-email to send them in the future?

> BTW, is it one of the gcc special treatment as well?

It was just mentioned in the same option's description:
http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gcc/pointer-arith.html

 evaluate.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index e23c4eb..1424ce1 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2049,6 +2049,12 @@ static struct symbol *evaluate_sizeof(struct expression *expr)
 		warning(expr->pos, "expression using sizeof(void)");
 		size = bits_in_char;
 	}
+
+	if (is_function(type->ctype.base_type)) {
+		warning(expr->pos, "expression using sizeof on a function");
+		size = bits_in_char;
+	}
+
 	if ((size < 0) || (size & (bits_in_char - 1)))
 		expression_error(expr, "cannot size expression");
 


  reply	other threads:[~2008-12-25 20:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-25  2:09 [PATCH] Warn about explicit usage of sizeof(void) Christopher Li
2008-12-25 17:23 ` Tommy Thorn
2008-12-25 18:36   ` [PATCH] Warn about explicit usage of sizeof(void) and sizeof(function) Alexey Zaytsev
2008-12-25 19:45     ` Christopher Li
2008-12-25 20:10       ` Alexey Zaytsev [this message]
2008-12-26  0:48         ` [PATCH] Also warn about sizeof(function) Christopher Li
2008-12-28 15:14     ` [PATCH] Null ctype should have ptr_ctype as its base type Alexey Zaytsev
2008-12-28 20:52       ` Christopher Li
2008-12-28 21:38         ` Alexey Zaytsev
2008-12-29  7:32           ` Christopher Li
2008-12-29  9:03             ` Alexey Zaytsev
2008-12-25 18:48   ` [PATCH] Warn about explicit usage of sizeof(void) 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=20081225200613.15414.96407.stgit@zaytsev.su \
    --to=alexey.zaytsev@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=tommy@numba-tu.com \
    /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).