#include "common.h"
#include "newalloc.h"
+#include "math.h"
/*-----------------------------------------------------------------*/
/* global variables */
symbol *returnLabel; /* function return label */
symbol *entryLabel; /* function entry label */
-#if defined(__BORLANDC__) || defined(_MSC_VER)
-#define LONG_LONG __int64
-#else
-#define LONG_LONG long long
-#endif
-
/*-----------------------------------------------------------------*/
/* forward definition of some functions */
operand *geniCodeDivision (operand *, operand *);
*/
void checkConstantRange(sym_link *ltype, value *val, char *msg, int pedantic) {
- LONG_LONG max = (LONG_LONG) 1 << bitsForType(ltype);
+ double max;
char message[132]="";
int warnings=0;
int negative=0;
- long v=SPEC_CVAL(val->type).v_long;
+ long v;
+
+ max = pow ((double)2.0, (double)bitsForType(ltype));
+
+ if (SPEC_LONG(val->type)) {
+ if (SPEC_USIGN(val->type)) {
+ v=SPEC_CVAL(val->type).v_ulong;
+ } else {
+ v=SPEC_CVAL(val->type).v_long;
+ }
+ } else {
+ if (SPEC_USIGN(val->type)) {
+ v=SPEC_CVAL(val->type).v_uint;
+ } else {
+ v=SPEC_CVAL(val->type).v_int;
+ }
+ }
+
#if 0
// this could be a good idea
/* if casting to/from pointers, do some checking */
if (IS_PTR(type)) { // to a pointer
- if (!IS_PTR(optype) && !IS_FUNC(optype)) { // from a non pointer
+ if (!IS_PTR(optype) && !IS_FUNC(optype) && !IS_AGGREGATE(optype)) { // from a non pointer
if (IS_INTEGRAL(optype)) {
// maybe this is NULL, than it's ok.
if (!(IS_LITERAL(optype) && (SPEC_CVAL(optype).v_ulong ==0))) {