From ff7b5335ba987f731d73c81a1e136b5d0b826dce Mon Sep 17 00:00:00 2001 From: maartenbrock Date: Thu, 9 Sep 2004 16:44:26 +0000 Subject: [PATCH] * src/SDCCicode.c (geniCodePostInc, geniCodePreInc, geniCodePostDec, geniCodePreDec): Fixed bug 904237 by generating a warning * src/SDCCerr.h, * src/SDCCerr.c: added warning W_SIZEOF_VOID git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3486 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 7 +++++++ src/SDCCicode.c | 10 ++++++++-- support/Util/SDCCerr.c | 2 ++ support/Util/SDCCerr.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40a90d5d..c8c59d5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-09-08 Maarten Brock + + * src/SDCCicode.c (geniCodePostInc, geniCodePreInc, geniCodePostDec, + geniCodePreDec): Fixed bug 904237 by generating a warning + * src/SDCCerr.h, + * src/SDCCerr.c: added warning W_SIZEOF_VOID + 2004-09-09 Slade Rich * src/pic/device.c : When no max ram set validate full memory range. diff --git a/src/SDCCicode.c b/src/SDCCicode.c index c024091a..01bf6e6c 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2495,6 +2495,8 @@ geniCodePostInc (operand * op) geniCodeAssign (rOp, rv, 0, 0); size = (IS_PTR (rvtype) ? getSize (rvtype->next) : 1); + if (size == 0) + werror(W_SIZEOF_VOID); if (IS_FLOAT (rvtype)) ic = newiCode ('+', rv, operandFromValue (constFloatVal ("1.0"))); else @@ -2530,8 +2532,9 @@ geniCodePreInc (operand * op, bool lvalue) return op; } - size = (IS_PTR (roptype) ? getSize (roptype->next) : 1); + if (size == 0) + werror(W_SIZEOF_VOID); if (IS_FLOAT (roptype)) ic = newiCode ('+', rop, operandFromValue (constFloatVal ("1.0"))); else @@ -2578,6 +2581,8 @@ geniCodePostDec (operand * op) geniCodeAssign (rOp, rv, 0, 0); size = (IS_PTR (rvtype) ? getSize (rvtype->next) : 1); + if (size == 0) + werror(W_SIZEOF_VOID); if (IS_FLOAT (rvtype)) ic = newiCode ('-', rv, operandFromValue (constFloatVal ("1.0"))); else @@ -2613,8 +2618,9 @@ geniCodePreDec (operand * op, bool lvalue) return op; } - size = (IS_PTR (roptype) ? getSize (roptype->next) : 1); + if (size == 0) + werror(W_SIZEOF_VOID); if (IS_FLOAT (roptype)) ic = newiCode ('-', rop, operandFromValue (constFloatVal ("1.0"))); else diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 43391455..cc3e98a4 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -412,6 +412,8 @@ struct "sizeof applied to an incomplete type" }, { E_PREVIOUS_DEF, ERROR_LEVEL_ERROR, "previously defined here" }, +{ W_SIZEOF_VOID, ERROR_LEVEL_WARNING, + "size of void is zero" }, }; /* diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index 7a9fe583..1233f5a8 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -193,6 +193,7 @@ SDCCERR - SDCC Standard error handler #define W_DEPRECATED_PRAGMA 175 /* deprecated pragma */ #define E_SIZEOF_INCOMPLETE_TYPE 176 /* sizeof applied to an incomplete type */ #define E_PREVIOUS_DEF 177 /* previously defined here */ +#define W_SIZEOF_VOID 178 /* size of void is zero */ #define MAX_ERROR_WARNING 256 /* size of disable warnings array */ -- 2.30.2