summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9711153)
(decorateType): emit W_COMPLEMENT before the problem vanishes behind promotion casts
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3908
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2005-10-25 Bernhard Held <bernhard AT bernhardheld.de>
+
+ * src/SDCCast.c (addCast): added promotion for bit variables
+ (decorateType): emit W_COMPLEMENT before the problem vanishes behind
+ promotion casts
+
2005-10-24 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCicode.c (ast2iCode): reverted to 1.224 because of regression:
2005-10-24 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCicode.c (ast2iCode): reverted to 1.224 because of regression:
/* addCast - adds casts to a type specified by RESULT_TYPE */
/*-----------------------------------------------------------------*/
static ast *
/* addCast - adds casts to a type specified by RESULT_TYPE */
/*-----------------------------------------------------------------*/
static ast *
-addCast (ast *tree, RESULT_TYPE resultType, bool upcast)
+addCast (ast *tree, RESULT_TYPE resultType, bool promote)
{
sym_link *newLink;
bool upCasted = FALSE;
{
sym_link *newLink;
bool upCasted = FALSE;
switch (resultType)
{
case RESULT_TYPE_NONE:
switch (resultType)
{
case RESULT_TYPE_NONE:
- /* char: promote to int */
- if (!upcast ||
+ /* if thing smaller than int must be promoted to int */
+ if (!promote ||
getSize (tree->etype) >= INTSIZE)
getSize (tree->etype) >= INTSIZE)
+ /* promotion not necessary or already an int */
+ return tree;
+ /* char and bits: promote to int */
+ newLink = newIntLink();
+ upCasted = TRUE;
+ break;
+ case RESULT_TYPE_BIT:
+ if (!promote ||
+ /* already an int */
+ bitsForType (tree->etype) >= 16 ||
+ /* bit to bit operation: don't promote, the code generators
+ hopefully know everything about promotion rules */
+ bitsForType (tree->etype) == 1)
return tree;
newLink = newIntLink();
upCasted = TRUE;
return tree;
newLink = newIntLink();
upCasted = TRUE;
}
#endif
/* char: promote to int */
}
#endif
/* char: promote to int */
getSize (tree->etype) >= INTSIZE)
return tree;
newLink = newIntLink();
upCasted = TRUE;
break;
case RESULT_TYPE_OTHER:
getSize (tree->etype) >= INTSIZE)
return tree;
newLink = newIntLink();
upCasted = TRUE;
break;
case RESULT_TYPE_OTHER:
return tree;
/* return type is long, float: promote char to int */
if (getSize (tree->etype) >= INTSIZE)
return tree;
/* return type is long, float: promote char to int */
if (getSize (tree->etype) >= INTSIZE)
TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
return addCast (tree, resultType, TRUE);
}
TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
return addCast (tree, resultType, TRUE);
}
+ if (getSize (tree->left->etype) < INTSIZE)
+ werror(W_COMPLEMENT);
tree->left = addCast (tree->left, resultType, TRUE);
LRVAL (tree) = 1;
COPYTYPE (TTYPE (tree), TETYPE (tree), LTYPE (tree));
tree->left = addCast (tree->left, resultType, TRUE);
LRVAL (tree) = 1;
COPYTYPE (TTYPE (tree), TETYPE (tree), LTYPE (tree));