int noLineno = 0;
int noAlloc = 0;
-symbol *currFunc;
+symbol *currFunc=NULL;
static ast *createIval (ast *, sym_link *, initList *, ast *);
static ast *createIvalCharPtr (ast *, sym_link *, ast *);
static ast *optimizeCompare (ast *);
ex = Safe_alloc ( sizeof (ast));
ex->type = type;
- ex->lineno = (noLineno ? oldLineno : yylineno);
+ ex->lineno = (noLineno ? oldLineno : mylineno);
ex->filename = currFname;
ex->level = NestLevel;
ex->block = currBlockno;
return ex;
}
-ast *
-newAst_STMNT (unsigned val)
-{
- ast *ex = newAst_ (EX_STMNT);
- ex->opval.stmnt = val;
- return ex;
-}
-
/*-----------------------------------------------------------------*/
/* newNode - creates a new node */
/*-----------------------------------------------------------------*/
ast *autoInit;
if (action == ALLOCATE)
- {
+ {
*stack += allocVariables (tree->values.sym);
autoInit = gatherAutoInit (tree->values.sym);
-
+
/* if there are auto inits then do them */
if (autoInit)
tree->left = newNode (NULLOP, autoInit, tree->left);
- }
+ }
else /* action is deallocate */
deallocLocal (tree->values.sym);
}
return constExprTree(cexpr->right);
}
if (cexpr->opval.op==CAST) {
- // jwk: cast ignored, maybe we should throw a warning here
+ // cast ignored, maybe we should throw a warning here?
return constExprTree(cexpr->right);
}
if (cexpr->opval.op=='&') {
if (constExprTree(cexpr->left) && constExprTree(cexpr->right)) {
return TRUE;
}
+ return FALSE;
+ case EX_OPERAND:
+ return IS_CONSTANT(operandType(cexpr->opval.oprnd));
}
return FALSE;
-}
+}
/*-----------------------------------------------------------------*/
/* constExprValue - returns the value of a constant expression */
if (IS_AST_OP(tree) &&
(tree->opval.op == CAST || tree->opval.op == '=') &&
(getSize(LTYPE(tree)) > getSize(RTYPE(tree))) &&
- (getSize(RTYPE(tree)) < INTSIZE)) {
+ (getSize(RTYPE(tree)) < (unsigned) INTSIZE)) {
// this is a cast/assign to a bigger type
if (IS_AST_OP(tree->right) &&
IS_INTEGRAL(tree->right->ftype) &&
{
sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
COPYTYPE (TTYPE (tree), TETYPE (tree), ltc);
- if (!tree->initMode && IS_CONSTANT (TTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT(TETYPE(tree)))
werror (E_CODE_WRITE, tree->opval.op==INC_OP ? "++" : "--");
if (tree->right)
return tree;
}
LRVAL (tree) = 1;
- TTYPE (tree) = LTYPE (tree);
+ TETYPE(tree) = getSpec (TTYPE (tree) = LTYPE (tree));
return tree;
}
tree->right = NULL;
TTYPE (tree) = tree->opval.val->type;
tree->values.literalFromCast = 1;
- } else if (IS_GENPTR(LTYPE(tree)) && !IS_PTR(RTYPE(tree)) &&
+ } else if (IS_GENPTR(LTYPE(tree)) && !IS_PTR(RTYPE(tree)) &&
((int)floatFromVal(valFromType(RETYPE(tree)))) !=0 ) /* special case of NULL */ {
sym_link *rest = LTYPE(tree)->next;
- werror(W_LITERAL_GENERIC);
+ werror(W_LITERAL_GENERIC);
TTYPE(tree) = newLink(DECLARATOR);
DCL_TYPE(TTYPE(tree)) = FPOINTER;
TTYPE(tree)->next = rest;
/* if pointer to struct then check names */
if (IS_PTR(LTYPE(tree)) && IS_STRUCT(LTYPE(tree)->next) &&
IS_PTR(RTYPE(tree)) && IS_STRUCT(RTYPE(tree)->next) &&
- strcmp(SPEC_STRUCT(LETYPE(tree))->tag,SPEC_STRUCT(RETYPE(tree))->tag))
+ strcmp(SPEC_STRUCT(LETYPE(tree))->tag,SPEC_STRUCT(RETYPE(tree))->tag))
{
werror(W_CAST_STRUCT_PTR,SPEC_STRUCT(RETYPE(tree))->tag,
SPEC_STRUCT(LETYPE(tree))->tag);
}
/* if unsigned value < 0 then always false */
/* if (unsigned value) > 0 then (unsigned value) */
- if (SPEC_USIGN(LETYPE(tree)) && IS_LITERAL(RTYPE(tree)) &&
+ if (SPEC_USIGN(LETYPE(tree)) && IS_LITERAL(RTYPE(tree)) &&
((int) floatFromVal (valFromType (RETYPE (tree)))) == 0) {
if (tree->opval.op == '<') {
case V_STRUCT:
typeofv = TYPEOF_STRUCT;
break;
+ case V_BITFIELD:
+ typeofv = TYPEOF_BITFIELD;
+ break;
case V_BIT:
typeofv = TYPEOF_BIT;
break;
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
- if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "&= or |= or ^= or >>= or <<=");
if (LRVAL (tree))
computeType (LTYPE (tree),
RTYPE (tree)));
- if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "-=");
if (LRVAL (tree))
computeType (LTYPE (tree),
RTYPE (tree)));
- if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+ if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
werror (E_CODE_WRITE, "+=");
if (LRVAL (tree))
{
werror (E_TYPE_MISMATCH, "assignment", " ");
printFromToType(RTYPE(tree),LTYPE(tree));
- //goto errorTreeReturn;
}
/* if the left side of the tree is of type void
RRVAL (tree) = 1;
LLVAL (tree) = 1;
if (!tree->initMode ) {
- if (IS_CONSTANT (LTYPE (tree)))
+ if ((IS_SPEC(LETYPE(tree)) && IS_CONSTANT (LETYPE (tree))))
werror (E_CODE_WRITE, "=");
}
if (LRVAL (tree))
if ((options.stackAuto || IFFUNC_ISREENT (LTYPE (tree))) &&
!IFFUNC_ISBUILTIN(LTYPE(tree)))
{
- //FUNC_ARGS(tree->left->ftype) =
- //reverseVal (FUNC_ARGS(tree->left->ftype));
reverseParms (tree->right);
}
- TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree)->next);
+ if (IS_CODEPTR(LTYPE(tree))) {
+ TTYPE(tree) = LTYPE(tree)->next->next;
+ } else {
+ TTYPE(tree) = LTYPE(tree)->next;
+ }
+ TETYPE (tree) = getSpec (TTYPE (tree));
return tree;
/*------------------------------------------------------------------*/
if (!IS_VOID (currFunc->type->next) && tree->right == NULL)
{
- werror (E_VOID_FUNC, currFunc->name);
+ werror (W_VOID_FUNC, currFunc->name);
goto errorTreeReturn;
}
ast *ex;
/* if the block has nothing */
- if (!body)
+ if (!body && !decl)
return NULL;
ex = newNode (BLOCK, NULL, body);
ex->values.sym = decl;
-
+
ex->right = ex->right;
ex->level++;
ex->lineno = 0;
addSymChain (name);
allocVariables (name);
}
- name->lastLine = yylineno;
+ name->lastLine = mylineno;
currFunc = name;
/* set the stack pointer */
/* dealloc the block variables */
processBlockVars (body, &stack, DEALLOCATE);
+ outputDebugStackSymbols();
/* deallocate paramaters */
deallocParms (FUNC_ARGS(name->type));
addSet (&operKeyReset, name);
applyToSet (operKeyReset, resetParmKey);
- if (options.debug)
- cdbStructBlock (1, cdbFile);
+ if (options.debug)
+ cdbStructBlock(1);
cleanUpLevel (LabelTab, 0);
cleanUpBlock (StructTab, 1);
value *args=FUNC_ARGS(tree->left->opval.val->type);
fprintf(outfile,"FUNCTION (%s=%p) type (",
tree->left->opval.val->name, tree);
- printTypeChain (tree->ftype,outfile);
+ printTypeChain (tree->left->opval.val->type->next,outfile);
fprintf(outfile,") args (");
do {
if (arg) {
/* just get the type */
if (tree->type == EX_VALUE) {
- if (IS_LITERAL (tree->opval.val->etype)) {
- fprintf(outfile,"CONSTANT (%p) value = %d, 0x%x, %g", tree,
- (int) floatFromVal(tree->opval.val),
- (int) floatFromVal(tree->opval.val),
- floatFromVal(tree->opval.val));
+ if (IS_LITERAL (tree->opval.val->etype)) {
+ fprintf(outfile,"CONSTANT (%p) value = ", tree);
+ if (SPEC_USIGN (tree->opval.val->etype))
+ fprintf(outfile,"%u", (TYPE_UDWORD) floatFromVal(tree->opval.val));
+ else
+ fprintf(outfile,"%d", (TYPE_DWORD) floatFromVal(tree->opval.val));
+ fprintf(outfile,", 0x%x, %g", (TYPE_UDWORD) floatFromVal(tree->opval.val),
+ floatFromVal(tree->opval.val));
} else if (tree->opval.val->sym) {
/* if the undefined flag is set then give error message */
if (tree->opval.val->sym->undefined) {