newAst_ (unsigned type)
{
ast *ex;
- static int oldLineno = 0;
ex = Safe_alloc ( sizeof (ast));
ex->type = type;
- ex->lineno = (noLineno ? oldLineno : lexLineno);
+ ex->lineno = (noLineno ? 0 : lexLineno);
ex->filename = lexFilename;
ex->level = NestLevel;
ex->block = currBlockno;
dest = Safe_alloc ( sizeof (ast));
dest->type = src->type;
+ dest->filename = src->filename;
dest->lineno = src->lineno;
dest->level = src->level;
dest->funcName = src->funcName;
tempvar1 = replaceAstWithTemporary(&(target->left));
if (hasSEFcalls(target->right))
tempvar2 = replaceAstWithTemporary(&(target->right));
+ } else if ((target->opval.op == INC_OP) || (target->opval.op == DEC_OP)) {
+ /* illegal pre/post-increment/decrement */
+ werrorfl (target->filename, target->lineno, E_LVALUE_REQUIRED, "=");
} else {
/* we would have to handle '.', but it is not generated any more */
wassertl(target->opval.op != '.', "obsolete opcode in tree");
symbol *csym = findSymWithLevel (SymbolTab, tree->opval.val->sym);
- /* if found in the symbol table & they r not the same */
+ /* if found in the symbol table & they are not the same */
if (csym && tree->opval.val->sym != csym)
{
tree->opval.val->sym = csym;
}
/* if not found in the symbol table */
- /* mark it as undefined assume it is */
- /* an integer in data space */
+ /* mark it as undefined & assume it */
+ /* is an integer in data space */
if (!csym && !tree->opval.val->sym->implicit)
{
return tree;
}
-/*-----------------------------------------------------------------*/
-/* setAstLineno - walks a ast tree & sets the line number */
-/*-----------------------------------------------------------------*/
-int setAstLineno (ast * tree, int lineno)
+/*------------------------------------------------------------------------*/
+/* setAstFileLine - walks a ast tree & sets the file name and line number */
+/*------------------------------------------------------------------------*/
+int setAstFileLine (ast * tree, char *filename, int lineno)
{
if (!tree)
return 0;
+ tree->filename = filename;
tree->lineno = lineno;
- setAstLineno (tree->left, lineno);
- setAstLineno (tree->right, lineno);
+ setAstFileLine (tree->left, filename, lineno);
+ setAstFileLine (tree->right, filename, lineno);
return 0;
}
else
functype = func->ftype;
- /* if the function is being called via a pointer & */
- /* it has not been defined a reentrant then we cannot */
- /* have parameters */
+ /* if the function is being called via a pointer & */
+ /* it has not been defined reentrant then we cannot */
+ /* have parameters */
/* PIC16 port can... */
if (!TARGET_IS_PIC16)
{
if (func->type != EX_VALUE && !IFFUNC_ISREENT (functype) && !options.stackAuto)
{
- werror (W_NONRENT_ARGS);
+ werror (E_NONRENT_ARGS);
fatalError++;
return 1;
}
ast *newType = NULL;
sym_link *ftype;
- if (IS_CAST_OP (*actParm)
- || (IS_AST_LIT_VALUE (*actParm) && (*actParm)->values.literalFromCast))
+ /* don't perform integer promotion of explicitly typecasted variable arguments
+ * if sdcc extensions are enabled */
+ if (options.std_sdcc &&
+ (IS_CAST_OP (*actParm) ||
+ (IS_AST_SYM_VALUE (*actParm) && AST_VALUES (*actParm, removedCast)) ||
+ (IS_AST_LIT_VALUE (*actParm) && AST_VALUES (*actParm, literalFromCast))))
{
/* Parameter was explicitly typecast; don't touch it. */
return 0;
/* cast required; change this op to a cast. */
(*actParm)->decorated = 0;
*actParm = newNode (CAST, newType, *actParm);
+ (*actParm)->filename = (*actParm)->right->filename;
(*actParm)->lineno = (*actParm)->right->lineno;
decorateType (*actParm, RESULT_TYPE_NONE);
(*actParm)->etype = getSpec ((*actParm)->ftype = copyLinkChain ((*actParm)->ftype));
SPEC_REGPARM ((*actParm)->etype) = SPEC_REGPARM (defParm->etype);
SPEC_ARGREG ((*actParm)->etype) = SPEC_ARGREG (defParm->etype);
+
+ /* if the function is being called via a pointer & */
+ /* this parameter is not passed in registers */
+ /* then the function must be defined reentrant */
+ if (IS_FUNCPTR (func->ftype) && !SPEC_REGPARM ((*actParm)->etype) &&
+ !IFFUNC_ISREENT (functype) && !options.stackAuto)
+ {
+ werror (E_NONRENT_ARGS);
+ fatalError++;
+ return 1;
+ }
+
(*parmNumber)++;
return 0;
}
}
- if (iloop) {
- werrorfl (sym->opval.val->sym->fileDef, sym->opval.val->sym->lineDef,
- W_EXCESS_INITIALIZERS, "struct",
- sym->opval.val->sym->name);
+ if (iloop)
+ {
+ if (IS_AST_VALUE (sym))
+ werrorfl (sym->opval.val->sym->fileDef, sym->opval.val->sym->lineDef,
+ W_EXCESS_INITIALIZERS, "struct",
+ sym->opval.val->sym->name);
+ else
+ werrorfl (sym->filename, sym->lineno, E_INIT_COUNT);
}
return rast;
&& IS_ARRAY (iexpr->ftype)))
return newNode ('=', sym, iexpr);
- /* left side is an array so we have to assign each */
- /* element */
+ /* left side is an array so we have to assign each element */
if ((IS_LITERAL (iexpr->etype) ||
SPEC_SCLS (iexpr->etype) == S_CODE)
&& IS_ARRAY (iexpr->ftype))
/*-----------------------------------------------------------------*/
/* gatherAutoInit - creates assignment expressions for initial */
-/* values */
+/* values */
/*-----------------------------------------------------------------*/
static ast *
gatherAutoInit (symbol * autoChain)
list2expr (sym->ival));
}
- setAstLineno (work, sym->lineDef);
+ setAstFileLine (work, sym->fileDef, sym->lineDef);
sym->ival = NULL;
if (staticAutos)
}
/* update lineno for error msg */
+ filename = sym->fileDef;
lineno = sym->lineDef;
- setAstLineno (ilist->init.node, sym->lineDef);
+ setAstFileLine (ilist->init.node, sym->fileDef, sym->lineDef);
if (IS_AGGREGATE (sym->type)) {
work = initAggregates (sym, sym->ival, NULL);
}
// just to be sure
- setAstLineno (work, sym->lineDef);
+ setAstFileLine (work, sym->fileDef, sym->lineDef);
sym->ival = NULL;
if (init)
unsigned int size;
// have we heard this before?
- for (sp=statsg->syms; sp; sp=sp->next) {
- sym=sp->item;
- size = getSize (sym->type);
- if (sym->isstrlit && size == getSize (val->type) &&
- !memcmp(SPEC_CVAL(sym->etype).v_char, SPEC_CVAL(val->etype).v_char, size)) {
- // yes, this is old news. Don't publish it again.
- sym->isstrlit++; // but raise the usage count
- return symbolVal(sym);
+ for (sp = statsg->syms; sp; sp = sp->next)
+ {
+ sym = sp->item;
+ size = getSize (sym->type);
+ if (sym->isstrlit && size == getSize (val->type) &&
+ !memcmp (SPEC_CVAL (sym->etype).v_char, SPEC_CVAL (val->etype).v_char, size))
+ {
+ // yes, this is old news. Don't publish it again.
+ sym->isstrlit++; // but raise the usage count
+ return symbolVal (sym);
+ }
}
- }
SNPRINTF (name, sizeof(name), "_str_%d", charLbl++);
sym = newSymbol (name, 0); /* make it @ level 0 */
cexpr->opval.op == CAST &&
IS_LITERAL (cexpr->right->ftype))
{
- return valCastLiteral (cexpr->ftype,
- floatFromVal (cexpr->right->opval.val));
+ return valCastLiteral (cexpr->ftype,
+ floatFromVal (cexpr->right->opval.val));
}
if (IS_AST_VALUE (cexpr))
{
- return cexpr->opval.val;
+ return cexpr->opval.val;
}
if (check)
{
return cexpr->opval.val;
}
- return NULL;
+ return NULL;
}
/*-----------------------------------------------------------------*/
return isLabelInAst (label, tree->right) &&
isLabelInAst (label, tree->left);
-
}
/*-----------------------------------------------------------------*/
{
*end = newNode ('+', condExpr->left->right,
- newAst_VALUE (constVal ("1")));
+ newAst_VALUE (constCharVal (1)));
break;
}
return FALSE;
if (IS_AST_SYM_VALUE (loopExpr->left) &&
isSymbolEqual (*sym, AST_SYMBOL (loopExpr->left)) &&
IS_AST_LIT_VALUE (loopExpr->right) &&
- (int) AST_LIT_VALUE (loopExpr->right) != 1)
+ AST_ULONG_VALUE (loopExpr->right) != 1)
return TRUE;
}
}
body->type = EX_OP;
body->opval.op = '-';
body->left = newAst_VALUE (symbolVal (sym));
- body->right = newAst_VALUE (constVal ("1"));
+ body->right = newAst_VALUE (constCharVal (1));
}
end));
replLoopSym (loop->left, sym);
- setAstLineno (rloop, init->lineno);
+ setAstFileLine (rloop, init->filename, init->lineno);
rloop = newNode (NULLOP,
newNode ('=',
newNode (NULLOP,
newNode (SUB_ASSIGN,
newAst_VALUE (symbolVal (sym)),
- newAst_VALUE (constVal ("1"))),
+ newAst_VALUE (constCharVal (1))),
rloop))));
rloop->lineno=init->lineno;
}
tree->decorated = 0;
tree = newNode (CAST, newAst_LINK (newLink), tree);
+ tree->filename = tree->right->filename;
tree->lineno = tree->right->lineno;
/* keep unsigned type during cast to smaller type,
but not when promoting from char to int */
case AND_OP:
case OR_OP:
case '!':
- return resultType;
case '=':
case '?':
case ':':
case '|':
case '^':
case '~':
+ case LEFT_OP:
+ case LABEL:
+ return resultType;
case '*':
case '+':
case '-':
- case LABEL:
+ if ((IS_AST_VALUE (tree->left) && !IS_INTEGRAL (tree->left->opval.val->etype)) ||
+ (IS_AST_VALUE (tree->right) && !IS_INTEGRAL (tree->right->opval.val->etype)))
+ return RESULT_TYPE_NONE;
return resultType;
case '&':
if (!tree->right)
/*----------------------------*/
/* leaf has been reached */
/*----------------------------*/
+ filename = tree->filename;
lineno = tree->lineno;
/* if this is of type value */
/* just get the type */
upon tree->opval.op, if resultType can be propagated */
resultTypeProp = resultTypePropagate (tree, resultType);
- if (tree->opval.op == '?')
+ if ((tree->opval.op == '?') && (resultTypeProp != RESULT_TYPE_BIT))
dtl = decorateType (tree->left, RESULT_TYPE_IFX);
else
dtl = decorateType (tree->left, resultTypeProp);
litTree->right = newNode ('*',
litTree->right,
copyAst (tree->right));
+ litTree->right->filename = tree->filename;
litTree->right->lineno = tree->lineno;
- tree->right->opval.val = constVal ("1");
+ tree->right->opval.val = constCharVal (1);
decorateType (parent, resultType);
}
else
}
LRVAL (tree) = RRVAL (tree) = 1;
- tree->left = addCast (tree->left, resultType, FALSE);
- tree->right = addCast (tree->right, resultType, FALSE);
+ tree->left = addCast (tree->left, resultTypeProp, FALSE);
+ tree->right = addCast (tree->right, resultTypeProp, FALSE);
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
RTYPE (tree),
if (IS_LITERAL (RTYPE (tree)) && IS_LITERAL (LTYPE (tree)))
{
tree->type = EX_VALUE;
- tree->left = addCast (tree->left, resultType, TRUE);
- tree->right = addCast (tree->right, resultType, TRUE);
+ tree->left = addCast (tree->left, resultTypeProp, TRUE);
+ tree->right = addCast (tree->right, resultTypeProp, TRUE);
tree->opval.val = valPlus (valFromType (LETYPE (tree)),
valFromType (RETYPE (tree)));
tree->right = tree->left = NULL;
LTYPE (tree));
else
{
- tree->left = addCast (tree->left, resultType, TRUE);
- tree->right = addCast (tree->right, resultType, TRUE);
+ tree->left = addCast (tree->left, resultTypeProp, TRUE);
+ tree->right = addCast (tree->right, resultTypeProp, TRUE);
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
RTYPE (tree),
TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
return tree;
}
- tree->left = addCast (tree->left, resultType, TRUE);
+ tree->left = addCast (tree->left, resultTypeProp, TRUE);
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
NULL,
if (IS_LITERAL (RTYPE (tree)) && IS_LITERAL (LTYPE (tree)))
{
tree->type = EX_VALUE;
- tree->left = addCast (tree->left, resultType, TRUE);
- tree->right = addCast (tree->right, resultType, TRUE);
+ tree->left = addCast (tree->left, resultTypeProp, TRUE);
+ tree->right = addCast (tree->right, resultTypeProp, TRUE);
tree->opval.val = valMinus (valFromType (LETYPE (tree)),
valFromType (RETYPE (tree)));
tree->right = tree->left = NULL;
{
tree->type = EX_VALUE;
tree->left = tree->right = NULL;
- tree->opval.val = constVal ("0");
+ tree->opval.val = constCharVal (0);
TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
return tree;
}
LTYPE (tree));
else
{
- tree->left = addCast (tree->left, resultType, TRUE);
- tree->right = addCast (tree->right, resultType, TRUE);
+ tree->left = addCast (tree->left, resultTypeProp, TRUE);
+ tree->right = addCast (tree->right, resultTypeProp, TRUE);
TETYPE (tree) = getSpec (TTYPE (tree) =
computeType (LTYPE (tree),
tree->opval.val = valComplement (valFromType (LETYPE (tree)));
tree->left = NULL;
TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
- return addCast (tree, resultType, TRUE);
+ return addCast (tree, resultTypeProp, TRUE);
}
if (resultType == RESULT_TYPE_BIT &&
/* optimize bit-result, even if we optimize a buggy source */
tree->type = EX_VALUE;
- tree->opval.val = constVal ("1");
+ tree->opval.val = constCharVal (1);
}
else
- tree->left = addCast (tree->left, resultType, TRUE);
+ tree->left = addCast (tree->left, resultTypeProp, TRUE);
LRVAL (tree) = 1;
COPYTYPE (TTYPE (tree), TETYPE (tree), LTYPE (tree));
return tree;
{
if ((resultType == RESULT_TYPE_IFX) || (resultType == RESULT_TYPE_BIT))
{
- /* remove double '!!X' by 'X' */
+ /* replace double '!!X' by 'X' */
return tree->left->left;
}
/* remove double '!!X' by 'X ? 1 : 0' */
tree->opval.op = '?';
tree->left = tree->left->left;
tree->right = newNode (':',
- newAst_VALUE (constVal ("1")),
- newAst_VALUE (constVal ("0")));
+ newAst_VALUE (constCharVal (1)),
+ newAst_VALUE (constCharVal (0)));
+ tree->right->filename = tree->filename;
tree->right->lineno = tree->lineno;
tree->decorated = 0;
return decorateType (tree, resultType);
/* make smaller type only if it's a LEFT_OP */
if (tree->opval.op == LEFT_OP)
- tree->left = addCast (tree->left, resultType, TRUE);
+ tree->left = addCast (tree->left, resultTypeProp, TRUE);
/* if they are both literal then */
/* rewrite the tree */
(tree->opval.op == LEFT_OP ? "left" : "right"));
tree->type = EX_VALUE;
tree->left = tree->right = NULL;
- tree->opval.val = constVal ("0");
+ tree->opval.val = constCharVal (0);
TETYPE (tree) = TTYPE (tree) = tree->opval.val->type;
return tree;
}
changePointer(LTYPE(tree));
checkTypeSanity(LETYPE(tree), "(cast)");
- /* if 'from' and 'to' are the same remove the superfluous cast, */
- /* this helps other optimizations */
+
+ /* if 'from' and 'to' are the same remove the superfluous cast,
+ * this helps other optimizations */
if (compareTypeExact (LTYPE(tree), RTYPE(tree), -1) == 1)
{
+ /* mark that the explicit cast has been removed,
+ * for proper processing (no integer promotion) of explicitly typecasted variable arguments */
+ tree->right->values.removedCast = 1;
return tree->right;
}
allocGlobal (sym);
newTree->left = newAst_VALUE(symbolVal(sym));
+ newTree->left->filename = tree->filename;
newTree->left->lineno = tree->lineno;
LTYPE (newTree) = sym->type;
LETYPE (newTree) = sym->etype;
if (!options.lessPedantic)
werrorfl (tree->filename, tree->lineno, W_COMP_RANGE,
ccr_result == CCR_ALWAYS_TRUE ? "true" : "false");
- return decorateType (newAst_VALUE (constVal (
- ccr_result == CCR_ALWAYS_TRUE ? "1" : "0")),
- resultType);
+ return decorateType (newAst_VALUE (constCharVal ((unsigned char)(ccr_result == CCR_ALWAYS_TRUE))), resultType);
case CCR_OK:
default:
break;
/* (unsigned value) ? 1 : 0 */
tree->opval.op = '?';
tree->right = newNode (':',
- newAst_VALUE (constVal ("1")),
+ newAst_VALUE (constCharVal (1)),
tree->right); /* val 0 */
+ tree->right->filename = tree->filename;
tree->right->lineno = tree->lineno;
+ tree->right->left->filename = tree->filename;
tree->right->left->lineno = tree->lineno;
tree->decorated = 0;
return decorateType (tree, resultType);
tree->opval.op = transformedOp;
tree->decorated = 0;
tree = newNode ('!', tree, NULL);
+ tree->filename = tree->left->filename;
tree->lineno = tree->left->lineno;
return decorateType (tree, resultType);
}
/* the type is value of the colon operator (on the right) */
assert (IS_COLON_OP (tree->right));
- if (IS_AST_LIT_VALUE (tree->right->left) && IS_AST_LIT_VALUE (tree->right->right))
+ /* If already known then replace the tree : optimizer will do it
+ but faster to do it here. If done before decorating tree->right
+ this can save generating unused const strings. */
+ if (IS_LITERAL (LTYPE (tree)))
+ {
+ if (((int) ulFromVal (valFromType (LETYPE (tree)))) != 0)
+ return decorateType (tree->right->left, resultTypeProp);
+ else
+ return decorateType (tree->right->right, resultTypeProp);
+ }
+
+ tree->right = decorateType (tree->right, resultTypeProp);
+
+ if (IS_AST_LIT_VALUE (tree->right->left) && IS_AST_LIT_VALUE (tree->right->right) &&
+ ((resultType == RESULT_TYPE_IFX) || (resultType == RESULT_TYPE_BIT)))
{
- double valTrue = AST_LIT_VALUE (tree->right->left);
- double valFalse = AST_LIT_VALUE (tree->right->right);
+ double valTrue = AST_FLOAT_VALUE (tree->right->left);
+ double valFalse = AST_FLOAT_VALUE (tree->right->right);
- if ((valTrue == 1) && (valFalse == 0) &&
- ((resultType == RESULT_TYPE_IFX) || (resultType == RESULT_TYPE_BIT)))
+ if ((valTrue != 0) && (valFalse == 0))
{
/* assign cond to result */
+ tree->left->decorated = 0;
return decorateType (tree->left, resultTypeProp);
}
- else if ((valTrue == 0) && (valFalse == 1))
+ else if ((valTrue == 0) && (valFalse != 0))
{
/* assign !cond to result */
tree->opval.op = '!';
tree->right = NULL;
return decorateType (tree, resultTypeProp);
}
+ else
+ {
+ /* they have the same boolean value, make them equal */
+ tree->right->left = tree->right->right;
+ }
}
/* if they are equal then replace the tree */
- if (!astHasVolatile (tree->right) &&
- isAstEqual (tree->right->left, tree->right->right))
+ if (isAstEqual (tree->right->left, tree->right->right))
{
- return decorateType (tree->right->left, resultTypeProp);
+ return tree->right->left;
}
- /* if already known then replace the tree : optimizer will do it
- but faster to do it here */
- if (IS_LITERAL (LTYPE (tree)))
- {
- if (((int) ulFromVal (valFromType (LETYPE (tree)))) != 0)
- return decorateType (tree->right->left, resultTypeProp);
- else
- return decorateType (tree->right->right, resultTypeProp);
- }
- else
- {
- tree->right = decorateType (tree->right, resultTypeProp);
- TTYPE (tree) = RTYPE (tree);
- TETYPE (tree) = getSpec (TTYPE (tree));
- }
+ TTYPE (tree) = RTYPE (tree);
+ TETYPE (tree) = getSpec (TTYPE (tree));
return tree;
case ':':
ex->values.sym = decl;
ex->level++;
+ ex->filename = NULL;
ex->lineno = 0;
return ex;
}
label->islbl = 1;
label->key = labelKey++;
rValue = newNode (LABEL, newAst_VALUE (symbolVal (label)), stmnt);
+ rValue->filename = NULL;
rValue->lineno = 0;
return rValue;
(int) ulFromVal (caseVal->opval.val));
rexpr = createLabel (newSymbol (caseLbl, 0), stmnt);
+ rexpr->filename = 0;
rexpr->lineno = 0;
return rexpr;
}
/* put the continue label */
condExpr = backPatchLabels (condExpr, trueLabel, falseLabel);
condExpr = createLabel (continueLabel, condExpr);
+ condExpr->filename = NULL;
condExpr->lineno = 0;
/* put the body label in front of the body */
whileBody = createLabel (trueLabel, whileBody);
+ whileBody->filename = NULL;
whileBody->lineno = 0;
/* put a jump to continue at the end of the body */
/* and put break label at the end of the body */
if (!IS_AST_LIT_VALUE (tree->right))
return -1;
- return powof2 ((TYPE_TARGET_ULONG)AST_LIT_VALUE (tree->right));
+ return powof2 (AST_ULONG_VALUE (tree->right));
}
/*-----------------------------------------------------------------*/
ast *
optimizeGetHbit (ast * tree, RESULT_TYPE resultType)
{
- int i, j;
+ unsigned int i, j;
ast * expr;
expr = isShiftRightLitVal_BitAndLitVal(tree);
if (expr)
{
- if ((AST_LIT_VALUE (tree->right) != 1) ||
- ((i = (int) AST_LIT_VALUE (tree->left->right)) !=
+ if ((AST_ULONG_VALUE (tree->right) != 1) ||
+ ((i = AST_ULONG_VALUE (tree->left->right)) !=
(j = (getSize (TTYPE (expr)) * 8 - 1))))
expr = NULL;
}
expr = isShiftRightLitVal_BitAndLitVal(tree);
if (expr)
{
- if (AST_LIT_VALUE (tree->right) != 1)
+ if (AST_ULONG_VALUE (tree->right) != 1)
expr = NULL;
count = tree->left->right;
}
expr = isShiftRightLitVal_BitAndLitVal(tree);
if (expr)
{
- i = (unsigned int) AST_LIT_VALUE (tree->left->right);
+ i = AST_ULONG_VALUE (tree->left->right);
count = tree->left->right;
- if (AST_LIT_VALUE (tree->right) != 0xFF)
+ if (AST_ULONG_VALUE (tree->right) != 0xFF)
expr = NULL;
}
if (!expr && resultType == RESULT_TYPE_CHAR)
/* if this is a right shift over a multiple of 8 */
if (IS_RIGHT_OP (tree) && IS_AST_LIT_VALUE (tree->right))
{
- i = (unsigned int) AST_LIT_VALUE (tree->right);
+ i = AST_ULONG_VALUE (tree->right);
count = tree->right;
expr = tree->left;
}
expr = isShiftRightLitVal_BitAndLitVal(tree);
if (expr)
{
- i = (unsigned int) AST_LIT_VALUE (tree->left->right);
+ i = AST_ULONG_VALUE (tree->left->right);
count = tree->left->right;
- if (AST_LIT_VALUE (tree->right) != 0xFFFF)
+ if (AST_ULONG_VALUE (tree->right) != 0xFFFF)
expr = NULL;
}
if (!expr && resultType == RESULT_TYPE_INT)
/* if this is a right shift over a multiple of 8 */
if (IS_RIGHT_OP (tree) && IS_AST_LIT_VALUE (tree->right))
{
- i = (unsigned int) AST_LIT_VALUE (tree->right);
+ i = AST_ULONG_VALUE (tree->right);
count = tree->right;
expr = tree->left;
}
root->right->left))
goto tryNext0;
- if (AST_LIT_VALUE (root->left->right) != 1)
+ if (AST_ULONG_VALUE (root->left->right) != 1)
goto tryNext0;
- if (AST_LIT_VALUE (root->right->right) !=
+ if (AST_ULONG_VALUE (root->right->right) !=
(getSize (TTYPE (root->left->left)) * 8 - 1))
goto tryNext0;
root->right->left))
goto tryNext1;
- if (AST_LIT_VALUE (root->right->right) != 1)
+ if (AST_ULONG_VALUE (root->right->right) != 1)
goto tryNext1;
- if (AST_LIT_VALUE (root->left->right) !=
+ if (AST_ULONG_VALUE (root->left->right) !=
(getSize (TTYPE (root->left->left)) * 8 - 1))
goto tryNext1;
root->right->left))
goto tryNext2;
- if (AST_LIT_VALUE (root->left->right) != 1)
+ if (AST_ULONG_VALUE (root->left->right) != 1)
goto tryNext2;
- if (AST_LIT_VALUE (root->right->right) !=
+ if (AST_ULONG_VALUE (root->right->right) !=
(getSize (TTYPE (root->left->left)) * 8 - 1))
goto tryNext2;
root->right->left))
return root;
- if (AST_LIT_VALUE (root->right->right) != 1)
+ if (AST_ULONG_VALUE (root->right->right) != 1)
return root;
- if (AST_LIT_VALUE (root->left->right) !=
+ if (AST_ULONG_VALUE (root->left->right) !=
(getSize (TTYPE (root->left->left)) * 8 - 1))
return root;
root->right->left))
return root;
- if (AST_LIT_VALUE (root->left->right) !=
+ if (AST_ULONG_VALUE (root->left->right) !=
(getSize (TTYPE (root->left->left)) * 4))
return root;
- if (AST_LIT_VALUE (root->right->right) !=
+ if (AST_ULONG_VALUE (root->right->right) !=
(getSize (TTYPE (root->left->left)) * 4))
return root;
case '>':
case '<':
case NE_OP:
- optExpr = newAst_VALUE (constVal ("0"));
+ optExpr = newAst_VALUE (constCharVal (0));
break;
case GE_OP:
case LE_OP:
case EQ_OP:
- optExpr = newAst_VALUE (constVal ("1"));
+ optExpr = newAst_VALUE (constCharVal (1));
break;
}
fixupInlineLabel (symbol * sym)
{
char name[SDCC_NAME_MAX + 1];
-
+
SNPRINTF(name, sizeof(name), "%s_%d", sym->name, inlineState.count);
strcpy (sym->name, name);
}
static void
copyAstLoc (ast * dest, ast * src)
{
- dest->lineno = src->lineno;
dest->filename = src->filename;
+ dest->lineno = src->lineno;
dest->level = src->level;
dest->block = src->block;
dest->seqPoint = src->seqPoint;
-
+
}
while (args)
{
symbol * temparg;
- ast * passedarg;
ast * assigntree;
- symbol * parm = copySymbol (args->sym);
+ symbol * parm;
+ ast * passedarg = inlineFindParm (tree->right, argIndex);
+
+ if (!passedarg)
+ {
+ werror(E_TOO_FEW_PARMS);
+ break;
+ }
temparg = inlineTempVar (args->sym->type, tree->level+1);
inlineAddDecl (temparg, inlinetree, FALSE);
- passedarg = inlineFindParm (tree->right, argIndex);
assigntree = newNode ('=',
newAst_VALUE (symbolVal (temparg)),
passedarg);
assigntree,
inlinetree->right);
+ parm = copySymbol (args->sym);
inlineAddDecl (parm, inlinetree2, FALSE);
parm->_isparm = 0;