* support/Util/SDCCerr.c,
* src/SDCCast.c (decorateType, sizeofOp): complain when sizeof is used
with an incomplete type (fixed bug #883734)
* src/SDCCicode.c (geniCodeCast): fixed bug #890510
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3173
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2004-02-07 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * support/Util/SDCCerr.h,
+ * support/Util/SDCCerr.c,
+ * src/SDCCast.c (decorateType, sizeofOp): complain when sizeof is used
+ with an incomplete type (fixed bug #883734)
+ * src/SDCCicode.c (geniCodeCast): fixed bug #890510
+
2004-02-07 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
* src/pic16/gen.c (genCmpEq, shiftRLong): fixed declarations
/*----------------------------*/
case SIZEOF: /* evaluate wihout code generation */
/* change the type to a integer */
+ {
+ int size = getSize (tree->right->ftype);
+ SNPRINTF(buffer, sizeof(buffer), "%d", size);
+ if (!size && !IS_VOID(tree->right->ftype))
+ werrorfl (tree->filename, tree->lineno, E_SIZEOF_INCOMPLETE_TYPE);
+ }
tree->type = EX_VALUE;
- SNPRINTF(buffer, sizeof(buffer), "%d", (getSize (tree->right->ftype)));
tree->opval.val = constVal (buffer);
tree->right = tree->left = NULL;
TETYPE (tree) = getSpec (TTYPE (tree) =
sizeofOp (sym_link * type)
{
char buff[10];
+ int size;
/* make sure the type is complete and sane */
checkTypeSanity(type, "(sizeof)");
/* get the size and convert it to character */
- SNPRINTF (buff, sizeof(buff), "%d", getSize (type));
+ SNPRINTF (buff, sizeof(buff), "%d", size = getSize (type));
+ if (!size && !IS_VOID(type))
+ werror (E_SIZEOF_INCOMPLETE_TYPE);
/* now convert into value */
return constVal (buff);
return op;
}
+ if (IS_ITEMP (op) && IS_ARRAY (OP_SYMBOL (op)->type))
+ {
+ geniCodeArray2Ptr (op);
+ op->isaddr = 0;
+ }
+
/* if the operand is already the desired type then do nothing */
if (compareType (type, optype) == 1)
return op;
"enumeration constant not an integer" },
{ W_DEPRECATED_PRAGMA, ERROR_LEVEL_WARNING,
"pragma %s is deprecated, please see documentation for details" },
+{ E_SIZEOF_INCOMPLETE_TYPE, ERROR_LEVEL_ERROR,
+ "sizeof applied to an incomplete type" },
};
/*
#define E_BAD_TAG 173 /* '%s' is not a %s tag */
#define E_ENUM_NON_INTEGER 174 /* enumeration constant not an integer */
#define W_DEPRECATED_PRAGMA 175 /* deprecated pragma */
+#define E_SIZEOF_INCOMPLETE_TYPE 176 /* sizeof applied to an incomplete type */
/** Describes the maximum error level that will be logged. Any level
* includes all of the levels listed after it.