ex = Safe_alloc ( sizeof (ast));
ex->type = type;
- ex->lineno = (noLineno ? oldLineno : lineno);
- ex->filename = filename;
+ ex->lineno = (noLineno ? oldLineno : lexLineno);
+ ex->filename = lexFilename;
ex->level = NestLevel;
ex->block = currBlockno;
ex->initMode = inInitMode;
if (lcnt && size > lcnt)
{
// Array size was specified, and we have more initializers than needed.
- char *name=sym->opval.val->sym->name;
- int lineno=sym->opval.val->sym->lineDef;
- char *filename=sym->opval.val->sym->fileDef;
-
- werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
+ werrorfl (sym->opval.val->sym->fileDef, sym->opval.val->sym->lineDef,
+ W_EXCESS_INITIALIZERS, "array", sym->opval.val->sym->name);
}
}
else
{
// is this a better way? at least it won't crash
char *name = (IS_AST_SYM_VALUE(sym)) ? AST_SYMBOL(sym)->name : "";
- int lineno = iloop->lineno;
- char *filename = iloop->filename;
- werrorfl (filename, lineno, W_EXCESS_INITIALIZERS, "array", name);
+ werrorfl (iloop->filename, iloop->lineno, W_EXCESS_INITIALIZERS, "array", name);
break;
}
}
/* update lineno for error msg */
- lineno=sym->lineDef;
- setAstLineno (ilist->init.node, lineno);
+ lineno = sym->lineDef;
+ setAstLineno (ilist->init.node, sym->lineDef);
if (IS_AGGREGATE (sym->type)) {
work = initAggregates (sym, sym->ival, NULL);
/*----------------------------*/
/* leaf has been reached */
/*----------------------------*/
- lineno=tree->lineno;
+ lineno = tree->lineno;
/* if this is of type value */
/* just get the type */
if (tree->type == EX_VALUE)
/* if the undefined flag is set then give error message */
if (tree->opval.val->sym->undefined)
{
- werror (E_ID_UNDEF, tree->opval.val->sym->name);
+ werrorfl (tree->filename, tree->lineno, E_ID_UNDEF, tree->opval.val->sym->name);
/* assume int */
TTYPE (tree) = TETYPE (tree) =
tree->opval.val->type = tree->opval.val->sym->type =
/* first check if this is a array or a pointer */
if ((!IS_ARRAY (LTYPE (tree))) && (!IS_PTR (LTYPE (tree))))
{
- werror (E_NEED_ARRAY_PTR, "[]");
+ werrorfl (tree->filename, tree->lineno, E_NEED_ARRAY_PTR, "[]");
goto errorTreeReturn;
}
/* check if the type of the idx */
if (!IS_INTEGRAL (RTYPE (tree)))
{
- werror (E_IDX_NOT_INT);
+ werrorfl (tree->filename, tree->lineno, E_IDX_NOT_INT);
goto errorTreeReturn;
}
/* if the left is an rvalue then error */
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "array access");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, "array access");
goto errorTreeReturn;
}
int arraySize = DCL_ELEM (LTYPE (tree));
if (arraySize && arrayIndex >= arraySize)
{
- werror (W_IDX_OUT_OF_BOUNDS, arrayIndex, arraySize);
+ werrorfl (tree->filename, tree->lineno, W_IDX_OUT_OF_BOUNDS, arrayIndex, arraySize);
}
}
/* if this is not a structure */
if (!IS_STRUCT (LTYPE (tree)))
{
- werror (E_STRUCT_UNION, ".");
+ werrorfl (tree->filename, tree->lineno, E_STRUCT_UNION, ".");
goto errorTreeReturn;
}
TTYPE (tree) = structElemType (LTYPE (tree),
/* if not pointer to a structure */
if (!IS_PTR (LTYPE (tree)) && !IS_ARRAY (LTYPE(tree)))
{
- werror (E_PTR_REQD);
+ werrorfl (tree->filename, tree->lineno, E_PTR_REQD);
goto errorTreeReturn;
}
if (!IS_STRUCT (LTYPE (tree)->next))
{
- werror (E_STRUCT_UNION, "->");
+ werrorfl (tree->filename, tree->lineno, E_STRUCT_UNION, "->");
goto errorTreeReturn;
}
sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
COPYTYPE (TTYPE (tree), TETYPE (tree), ltc);
if (!tree->initMode && IS_CONSTANT(TTYPE(tree)))
- werror (E_CODE_WRITE, tree->opval.op==INC_OP ? "++" : "--");
+ werrorfl (tree->filename, tree->lineno, E_CODE_WRITE, tree->opval.op==INC_OP ? "++" : "--");
if (tree->right)
RLVAL (tree) = 1;
if (!IS_INTEGRAL (LTYPE (tree)) || !IS_INTEGRAL (RTYPE (tree)))
{
- werror (E_BITWISE_OP);
- werror (W_CONTINUE, "left & right types are ");
+ werrorfl (tree->filename, tree->lineno, E_BITWISE_OP);
+ werrorfl (tree->filename, tree->lineno, W_CONTINUE, "left & right types are ");
printTypeChain (LTYPE (tree), stderr);
fprintf (stderr, ",");
printTypeChain (RTYPE (tree), stderr);
/* if bit field then error */
if (IS_BITVAR (tree->left->etype))
{
- werror (E_ILLEGAL_ADDR, "address of bit variable");
+ werrorfl (tree->filename, tree->lineno, E_ILLEGAL_ADDR, "address of bit variable");
goto errorTreeReturn;
}
if (LETYPE(tree) && SPEC_SCLS (tree->left->etype) == S_REGISTER)
{
- werror (E_ILLEGAL_ADDR, "address of register variable");
+ werrorfl (tree->filename, tree->lineno, E_ILLEGAL_ADDR, "address of register variable");
goto errorTreeReturn;
}
if (IS_LITERAL(LTYPE(tree)))
{
- werror (E_ILLEGAL_ADDR, "address of literal");
+ werrorfl (tree->filename, tree->lineno, E_ILLEGAL_ADDR, "address of literal");
goto errorTreeReturn;
}
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "address of");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, "address of");
goto errorTreeReturn;
}
if (!LETYPE (tree))
case '^':
if (!IS_INTEGRAL (LTYPE (tree)) || !IS_INTEGRAL (RTYPE (tree)))
{
- werror (E_BITWISE_OP);
- werror (W_CONTINUE, "left & right types are ");
+ werrorfl (tree->filename, tree->lineno, E_BITWISE_OP);
+ werrorfl (tree->filename, tree->lineno, W_CONTINUE, "left & right types are ");
printTypeChain (LTYPE (tree), stderr);
fprintf (stderr, ",");
printTypeChain (RTYPE (tree), stderr);
case '/':
if (!IS_ARITHMETIC (LTYPE (tree)) || !IS_ARITHMETIC (RTYPE (tree)))
{
- werror (E_INVALID_OP, "divide");
+ werrorfl (tree->filename, tree->lineno, E_INVALID_OP, "divide");
goto errorTreeReturn;
}
/* if they are both literal then */
case '%':
if (!IS_INTEGRAL (LTYPE (tree)) || !IS_INTEGRAL (RTYPE (tree)))
{
- werror (E_BITWISE_OP);
- werror (W_CONTINUE, "left & right types are ");
+ werrorfl (tree->filename, tree->lineno, E_BITWISE_OP);
+ werrorfl (tree->filename, tree->lineno, W_CONTINUE, "left & right types are ");
printTypeChain (LTYPE (tree), stderr);
fprintf (stderr, ",");
printTypeChain (RTYPE (tree), stderr);
{
if (!IS_PTR (LTYPE (tree)) && !IS_ARRAY (LTYPE (tree)))
{
- werror (E_PTR_REQD);
+ werrorfl (tree->filename, tree->lineno, E_PTR_REQD);
goto errorTreeReturn;
}
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "pointer deref");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, "pointer deref");
goto errorTreeReturn;
}
if (IS_ADDRESS_OF_OP(tree->left))
/*----------------------------*/
if (!IS_ARITHMETIC (LTYPE (tree)) || !IS_ARITHMETIC (RTYPE (tree)))
{
- werror (E_INVALID_OP, "multiplication");
+ werrorfl (tree->filename, tree->lineno, E_INVALID_OP, "multiplication");
goto errorTreeReturn;
}
{
if (!IS_ARITHMETIC (LTYPE (tree)))
{
- werror (E_UNARY_OP, '+');
+ werrorfl (tree->filename, tree->lineno, E_UNARY_OP, '+');
goto errorTreeReturn;
}
if ((IS_PTR (LTYPE (tree)) || IS_ARRAY (LTYPE (tree))) &&
(IS_PTR (RTYPE (tree)) || IS_ARRAY (RTYPE (tree))))
{
- werror (E_PTR_PLUS_PTR);
+ werrorfl (tree->filename, tree->lineno, E_PTR_PLUS_PTR);
goto errorTreeReturn;
}
if (!IS_ARITHMETIC (LTYPE (tree)) &&
!IS_PTR (LTYPE (tree)) && !IS_ARRAY (LTYPE (tree)))
{
- werror (E_PLUS_INVALID, "+");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "+");
goto errorTreeReturn;
}
if (!IS_ARITHMETIC (RTYPE (tree)) &&
!IS_PTR (RTYPE (tree)) && !IS_ARRAY (RTYPE (tree)))
{
- werror (E_PLUS_INVALID, "+");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "+");
goto errorTreeReturn;
}
/* if they are both literal then */
if (!IS_ARITHMETIC (LTYPE (tree)))
{
- werror (E_UNARY_OP, tree->opval.op);
+ werrorfl (tree->filename, tree->lineno, E_UNARY_OP, tree->opval.op);
goto errorTreeReturn;
}
IS_ARRAY (LTYPE (tree)) ||
IS_ARITHMETIC (LTYPE (tree))))
{
- werror (E_PLUS_INVALID, "-");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "-");
goto errorTreeReturn;
}
IS_ARRAY (RTYPE (tree)) ||
IS_ARITHMETIC (RTYPE (tree))))
{
- werror (E_PLUS_INVALID, "-");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "-");
goto errorTreeReturn;
}
!(IS_PTR (RTYPE (tree)) || IS_ARRAY (RTYPE (tree)) ||
IS_INTEGRAL (RTYPE (tree))))
{
- werror (E_PLUS_INVALID, "-");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "-");
goto errorTreeReturn;
}
/* can be only integral type */
if (!IS_INTEGRAL (LTYPE (tree)))
{
- werror (E_UNARY_OP, tree->opval.op);
+ werrorfl (tree->filename, tree->lineno, E_UNARY_OP, tree->opval.op);
goto errorTreeReturn;
}
bit -> int -> ~int -> bit
uchar -> int -> ~int -> bit
*/
- werror(W_COMPLEMENT);
+ werrorfl (tree->filename, tree->lineno, W_COMPLEMENT);
/* optimize bit-result, even if we optimize a buggy source */
tree->type = EX_VALUE;
!IS_PTR (LTYPE (tree)) &&
!IS_ARRAY (LTYPE (tree)))
{
- werror (E_UNARY_OP, tree->opval.op);
+ werrorfl (tree->filename, tree->lineno, E_UNARY_OP, tree->opval.op);
goto errorTreeReturn;
}
case RIGHT_OP:
if (!IS_INTEGRAL (LTYPE (tree)) || !IS_INTEGRAL (tree->left->etype))
{
- werror (E_SHIFT_OP_INVALID);
- werror (W_CONTINUE, "left & right types are ");
+ werrorfl (tree->filename, tree->lineno, E_SHIFT_OP_INVALID);
+ werrorfl (tree->filename, tree->lineno, W_CONTINUE, "left & right types are ");
printTypeChain (LTYPE (tree), stderr);
fprintf (stderr, ",");
printTypeChain (RTYPE (tree), stderr);
if (tree->opval.op==LEFT_OP ||
(tree->opval.op==RIGHT_OP && SPEC_USIGN(LETYPE(tree))))
{
- lineno=tree->lineno;
- werror (W_SHIFT_CHANGED,
+ werrorfl (tree->filename, tree->lineno, W_SHIFT_CHANGED,
(tree->opval.op == LEFT_OP ? "left" : "right"));
tree->type = EX_VALUE;
tree->left = tree->right = NULL;
/* cannot cast to an aggregate type */
if (IS_AGGREGATE (LTYPE (tree)))
{
- werror (E_CAST_ILLEGAL);
+ werrorfl (tree->filename, tree->lineno, E_CAST_ILLEGAL);
goto errorTreeReturn;
}
} 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);
+ werrorfl (tree->filename, tree->lineno, W_LITERAL_GENERIC);
TTYPE(tree) = newLink(DECLARATOR);
DCL_TYPE(TTYPE(tree)) = FPOINTER;
TTYPE(tree)->next = rest;
IS_PTR(RTYPE(tree)) && IS_STRUCT(RTYPE(tree)->next) &&
strcmp(SPEC_STRUCT(LETYPE(tree))->tag,SPEC_STRUCT(RETYPE(tree))->tag))
{
- werror(W_CAST_STRUCT_PTR,SPEC_STRUCT(RETYPE(tree))->tag,
+ werrorfl (tree->filename, tree->lineno, W_CAST_STRUCT_PTR,SPEC_STRUCT(RETYPE(tree))->tag,
SPEC_STRUCT(LETYPE(tree))->tag);
}
#endif
!IS_ARRAY (LTYPE (tree)) &&
!IS_INTEGRAL (LTYPE (tree)))
{
- werror (E_COMPARE_OP);
+ werrorfl (tree->filename, tree->lineno, E_COMPARE_OP);
goto errorTreeReturn;
}
!IS_ARRAY (RTYPE (tree)) &&
!IS_INTEGRAL (RTYPE (tree)))
{
- werror (E_COMPARE_OP);
+ werrorfl (tree->filename, tree->lineno, E_COMPARE_OP);
goto errorTreeReturn;
}
/* if they are both literal then */
}
if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
- werror (E_COMPARE_OP);
+ werrorfl (tree->filename, tree->lineno, E_COMPARE_OP);
fprintf (stderr, "comparing type ");
printTypeChain (LTYPE (tree), stderr);
fprintf (stderr, "to type ");
if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
- werror (E_COMPARE_OP);
+ werrorfl (tree->filename, tree->lineno, E_COMPARE_OP);
fprintf (stderr, "comparing type ");
printTypeChain (LTYPE (tree), stderr);
fprintf (stderr, "to type ");
case CCR_ALWAYS_TRUE:
case CCR_ALWAYS_FALSE:
if (!options.lessPedantic)
- werror (W_COMP_RANGE,
+ 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")),
}
else
{
- werror (W_CMP_SU_CHAR);
+ werrorfl (tree->filename, tree->lineno, W_CMP_SU_CHAR);
tree->left = addCast (tree->left , RESULT_TYPE_INT, TRUE);
tree->right = addCast (tree->right, RESULT_TYPE_INT, TRUE);
}
if ((compareType (LTYPE (tree), RTYPE (tree)) == 0) &&
(compareType (RTYPE (tree), LTYPE (tree)) == 0))
{
- werror (E_TYPE_MISMATCH, "conditional operator", " ");
+ werrorfl (tree->filename, tree->lineno, E_TYPE_MISMATCH, "conditional operator", " ");
goto errorTreeReturn;
}
if (!IS_ARITHMETIC (LTYPE (tree)) ||
!IS_ARITHMETIC (RTYPE (tree)))
{
- werror (E_OPS_INTEGRAL);
+ werrorfl (tree->filename, tree->lineno, E_OPS_INTEGRAL);
goto errorTreeReturn;
}
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
- werror (E_CODE_WRITE, tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
+ werrorfl (tree->filename, tree->lineno, E_CODE_WRITE, tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, tree->opval.op==MUL_ASSIGN ? "*=" : "/=");
goto errorTreeReturn;
}
LLVAL (tree) = 1;
if (!IS_INTEGRAL (LTYPE (tree)) ||
!IS_INTEGRAL (RTYPE (tree)))
{
- werror (E_OPS_INTEGRAL);
+ werrorfl (tree->filename, tree->lineno, E_OPS_INTEGRAL);
goto errorTreeReturn;
}
RRVAL (tree) = 1;
TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
- werror (E_CODE_WRITE, "&= or |= or ^= or >>= or <<=");
+ werrorfl (tree->filename, tree->lineno, E_CODE_WRITE, "&= or |= or ^= or >>= or <<=");
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "&= or |= or ^= or >>= or <<=");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, "&= or |= or ^= or >>= or <<=");
goto errorTreeReturn;
}
LLVAL (tree) = 1;
if (!(IS_PTR (LTYPE (tree)) ||
IS_ARITHMETIC (LTYPE (tree))))
{
- werror (E_PLUS_INVALID, "-=");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "-=");
goto errorTreeReturn;
}
if (!(IS_PTR (RTYPE (tree)) ||
IS_ARITHMETIC (RTYPE (tree))))
{
- werror (E_PLUS_INVALID, "-=");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "-=");
goto errorTreeReturn;
}
RRVAL (tree) = 1;
tree->opval.op));
if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
- werror (E_CODE_WRITE, "-=");
+ werrorfl (tree->filename, tree->lineno, E_CODE_WRITE, "-=");
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "-=");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, "-=");
goto errorTreeReturn;
}
LLVAL (tree) = 1;
/* if both pointers then problem */
if (IS_PTR (LTYPE (tree)) && IS_PTR (RTYPE (tree)))
{
- werror (E_PTR_PLUS_PTR);
+ werrorfl (tree->filename, tree->lineno, E_PTR_PLUS_PTR);
goto errorTreeReturn;
}
if (!IS_ARITHMETIC (LTYPE (tree)) && !IS_PTR (LTYPE (tree)))
{
- werror (E_PLUS_INVALID, "+=");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "+=");
goto errorTreeReturn;
}
if (!IS_ARITHMETIC (RTYPE (tree)) && !IS_PTR (RTYPE (tree)))
{
- werror (E_PLUS_INVALID, "+=");
+ werrorfl (tree->filename, tree->lineno, E_PLUS_INVALID, "+=");
goto errorTreeReturn;
}
RRVAL (tree) = 1;
tree->opval.op));
if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
- werror (E_CODE_WRITE, "+=");
+ werrorfl (tree->filename, tree->lineno, E_CODE_WRITE, "+=");
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "+=");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, "+=");
goto errorTreeReturn;
}
/* cannot be an aggregate */
if (IS_AGGREGATE (LTYPE (tree)))
{
- werror (E_AGGR_ASSIGN);
+ werrorfl (tree->filename, tree->lineno, E_AGGR_ASSIGN);
goto errorTreeReturn;
}
/* they should either match or be castable */
if (compareType (LTYPE (tree), RTYPE (tree)) == 0)
{
- werror (E_TYPE_MISMATCH, "assignment", " ");
+ werrorfl (tree->filename, tree->lineno, E_TYPE_MISMATCH, "assignment", " ");
printFromToType(RTYPE(tree),LTYPE(tree));
}
then report error */
if (IS_VOID (LTYPE (tree)))
{
- werror (E_CAST_ZERO);
+ werrorfl (tree->filename, tree->lineno, E_CAST_ZERO);
printFromToType(RTYPE(tree), LTYPE(tree));
}
LLVAL (tree) = 1;
if (!tree->initMode ) {
if (IS_CONSTANT(LTYPE(tree)))
- werror (E_CODE_WRITE, "=");
+ werrorfl (tree->filename, tree->lineno, E_CODE_WRITE, "=");
}
if (LRVAL (tree))
{
- werror (E_LVALUE_REQUIRED, "=");
+ werrorfl (tree->filename, tree->lineno, E_LVALUE_REQUIRED, "=");
goto errorTreeReturn;
}
if (!IS_VOID (currFunc->type->next) && tree->right == NULL)
{
- werror (W_VOID_FUNC, currFunc->name);
+ werrorfl (tree->filename, tree->lineno, W_VOID_FUNC, currFunc->name);
goto errorTreeReturn;
}
tree->left), RESULT_TYPE_NONE);
}
case PARAM:
- werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
+ werrorfl (tree->filename, tree->lineno, E_INTERNAL_ERROR, __FILE__, __LINE__,
"node PARAM shouldn't be processed here");
/* but in processParams() */
return tree;
addSymChain (&name);
allocVariables (name);
}
- name->lastLine = lineno;
+ name->lastLine = lexLineno;
currFunc = name;
/* set the stack pointer */