summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7dc0e9e)
* support/Util/SDCCerr.c,
* support/Util/SDCCerr.h: added warning W_CMP_SU_CHAR
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3998
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2005-11-29 Bernhard Held <bernhard AT bernhardheld.de>
+
+ * src/SDCCast.c (decorateType): fixed bug 1368489
+ * support/Util/SDCCerr.c,
+ * support/Util/SDCCerr.h: added warning W_CMP_SU_CHAR
+
2005-11-28 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
* device/include/mcs51/at89c51snd1c.h: added file submitted by
2005-11-28 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
* device/include/mcs51/at89c51snd1c.h: added file submitted by
tree->opval.val->type);
return tree;
}
tree->opval.val->type);
return tree;
}
+ /* if one is 'signed char ' and the other one is 'unsigned char' */
+ /* it's necessary to promote to int */
+ if (IS_CHAR (RTYPE (tree)) && IS_CHAR (LTYPE (tree)) &&
+ (IS_UNSIGNED (RTYPE (tree)) != IS_UNSIGNED (LTYPE (tree))))
+ {
+ werror (W_CMP_SU_CHAR);
+ tree->left = addCast (tree->left , RESULT_TYPE_INT, TRUE);
+ tree->right = addCast (tree->right, RESULT_TYPE_INT, TRUE);
+ }
+
LRVAL (tree) = RRVAL (tree) = 1;
TTYPE (tree) = TETYPE (tree) = newCharLink ();
return tree;
LRVAL (tree) = RRVAL (tree) = 1;
TTYPE (tree) = TETYPE (tree) = newCharLink ();
return tree;
"Both banked and callee-saves cannot be used together." },
{ W_INVALID_INT_CONST, ERROR_LEVEL_WARNING,
"integer constant '%s' out of range, truncated to %.0lf." },
"Both banked and callee-saves cannot be used together." },
{ W_INVALID_INT_CONST, ERROR_LEVEL_WARNING,
"integer constant '%s' out of range, truncated to %.0lf." },
+{ W_CMP_SU_CHAR, ERROR_LEVEL_PEDANTIC,
+ "comparison of 'signed char' with 'unsigned char' requires promotion to int" },
#define W_SFR_ABSRANGE 182 /* sfr at address out of range */
#define E_BANKED_WITH_CALLEESAVES 183 /* banked and callee-saves mixed */
#define W_INVALID_INT_CONST 184 /* invalid integer literal string */
#define W_SFR_ABSRANGE 182 /* sfr at address out of range */
#define E_BANKED_WITH_CALLEESAVES 183 /* banked and callee-saves mixed */
#define W_INVALID_INT_CONST 184 /* invalid integer literal string */
+#define W_CMP_SU_CHAR 185 /* comparison of 'signed char' with 'unsigned char' requires promotion to int */
#define MAX_ERROR_WARNING 256 /* size of disable warnings array */
#define MAX_ERROR_WARNING 256 /* size of disable warnings array */
ASSERT(~ (char) 0x80 == (short) 0x007f); ASSERT(~ (char) 0x80 > 0);
ASSERT(~ (unsigned char) 0x80 == (short) 0xff7f); ASSERT(~ (unsigned char) 0x80 < 0);
}
ASSERT(~ (char) 0x80 == (short) 0x007f); ASSERT(~ (char) 0x80 > 0);
ASSERT(~ (unsigned char) 0x80 == (short) 0xff7f); ASSERT(~ (unsigned char) 0x80 < 0);
}
+
+void
+testComp(void)
+{
+ {attrL} signed char c;
+ {attrR} unsigned char uc;
+
+ c = 0x80; /* -128 */
+ uc = 0x80; /* +128 */
+
+ ASSERT(!(c == uc));
+ ASSERT( c != uc );
+ ASSERT( c < uc );
+ ASSERT( c <= uc );
+ ASSERT(!(c > uc));
+ ASSERT(!(c >= uc));
+}