[PATCH] Also warn about sizeof(function)

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

 



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

> Hi Alexey,
> 
> On Thu, Dec 25, 2008 at 10:36 AM, Alexey Zaytsev
> <alexey.zaytsev@xxxxxxxxx> 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");
 

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux