projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* support/regression/tests/bug-477927.c: Added.
[fw/sdcc]
/
src
/
SDCCast.c
diff --git
a/src/SDCCast.c
b/src/SDCCast.c
index aa9927106bcbbb29069f7ba8641f924a1a55cd5f..a87ac07af4d928c7ad8447903cc65d5bb3667c85 100644
(file)
--- a/
src/SDCCast.c
+++ b/
src/SDCCast.c
@@
-259,6
+259,9
@@
copyAst (ast * src)
dest->level = src->level;
dest->funcName = src->funcName;
dest->level = src->level;
dest->funcName = src->funcName;
+ if (src->ftype)
+ dest->etype = getSpec (dest->ftype = copyLinkChain (src->ftype));
+
/* if this is a leaf */
/* if value */
if (src->type == EX_VALUE)
/* if this is a leaf */
/* if value */
if (src->type == EX_VALUE)
@@
-279,9
+282,6
@@
copyAst (ast * src)
/* if this is a node that has special values */
copyAstValues (dest, src);
/* if this is a node that has special values */
copyAstValues (dest, src);
- if (src->ftype)
- dest->etype = getSpec (dest->ftype = copyLinkChain (src->ftype));
-
dest->trueLabel = copySymbol (src->trueLabel);
dest->falseLabel = copySymbol (src->falseLabel);
dest->left = copyAst (src->left);
dest->trueLabel = copySymbol (src->trueLabel);
dest->falseLabel = copySymbol (src->falseLabel);
dest->left = copyAst (src->left);
@@
-605,7
+605,7
@@
processParms (ast * func,
value *defParm,
ast * actParm,
int *parmNumber, // unused, although updated
value *defParm,
ast * actParm,
int *parmNumber, // unused, although updated
- bool rightmost)
// double checked?
+ bool rightmost)
{
/* if none of them exist */
if (!defParm && !actParm)
{
/* if none of them exist */
if (!defParm && !actParm)
@@
-643,6
+643,11
@@
processParms (ast * func,
return 1;
}
return 1;
}
+ if (IS_VOID(actParm->ftype)) {
+ werror (E_VOID_VALUE_USED);
+ return 1;
+ }
+
/* If this is a varargs function... */
if (!defParm && actParm && IFFUNC_HASVARARGS(func->ftype))
{
/* If this is a varargs function... */
if (!defParm && actParm && IFFUNC_HASVARARGS(func->ftype))
{
@@
-692,7
+697,7
@@
processParms (ast * func,
if (newType)
{
/* cast required; change this op to a cast. */
if (newType)
{
/* cast required; change this op to a cast. */
- ast *parmCopy =
resolveSymbols (copyAst (actParm
));
+ ast *parmCopy =
decorateType(resolveSymbols (copyAst (actParm)
));
actParm->type = EX_OP;
actParm->opval.op = CAST;
actParm->type = EX_OP;
actParm->opval.op = CAST;
@@
-729,7
+734,7
@@
processParms (ast * func,
* Therefore, if there are more defined parameters, the caller didn't
* supply enough.
*/
* Therefore, if there are more defined parameters, the caller didn't
* supply enough.
*/
- if (
0 &&
rightmost && defParm->next)
+ if (rightmost && defParm->next)
{
werror (E_TOO_FEW_PARMS);
return 1;
{
werror (E_TOO_FEW_PARMS);
return 1;
@@
-746,7
+751,7
@@
processParms (ast * func,
/* if the parameter is castable then add the cast */
if (compareType (defParm->type, actParm->ftype) < 0)
{
/* if the parameter is castable then add the cast */
if (compareType (defParm->type, actParm->ftype) < 0)
{
- ast *pTree =
resolveSymbols (copyAst (actParm
));
+ ast *pTree =
decorateType(resolveSymbols (copyAst (actParm)
));
/* now change the current one to a cast */
actParm->type = EX_OP;
/* now change the current one to a cast */
actParm->type = EX_OP;
@@
-1027,7
+1032,7
@@
ast * initAggregates (symbol * sym, initList * ival, ast * wid) {
if (!TARGET_IS_MCS51 || !(options.model==MODEL_LARGE)) {
fprintf (stderr, "Can't \"TRY_THE_NEW_INITIALIZER\" unless "
if (!TARGET_IS_MCS51 || !(options.model==MODEL_LARGE)) {
fprintf (stderr, "Can't \"TRY_THE_NEW_INITIALIZER\" unless "
- "with -mmcs51 and --model-large");
+ "with -mmcs51 and --model-large
\n
");
exit(404);
}
exit(404);
}
@@
-2127,7
+2132,7
@@
decorateType (ast * tree)
/* if bit field then error */
if (IS_BITVAR (tree->left->etype))
{
/* if bit field then error */
if (IS_BITVAR (tree->left->etype))
{
- werror (E_ILLEGAL_ADDR, "addr
r
ess of bit variable");
+ werror (E_ILLEGAL_ADDR, "address of bit variable");
goto errorTreeReturn;
}
goto errorTreeReturn;
}
@@
-2143,7
+2148,13
@@
decorateType (ast * tree)
goto errorTreeReturn;
}
goto errorTreeReturn;
}
- if (LRVAL (tree))
+ if (IS_LITERAL(LTYPE(tree)))
+ {
+ werror (E_ILLEGAL_ADDR, "address of literal");
+ goto errorTreeReturn;
+ }
+
+ if (LRVAL (tree))
{
werror (E_LVALUE_REQUIRED, "address of");
goto errorTreeReturn;
{
werror (E_LVALUE_REQUIRED, "address of");
goto errorTreeReturn;
@@
-3082,13
+3093,15
@@
decorateType (ast * tree)
if (processParms (tree->left,
FUNC_ARGS(tree->left->ftype),
if (processParms (tree->left,
FUNC_ARGS(tree->left->ftype),
- tree->right, &parmNumber, TRUE))
+ tree->right, &parmNumber, TRUE)) {
+ //fprintf (stderr, "jwk: error in processParms()\n");
goto errorTreeReturn;
goto errorTreeReturn;
+ }
if (options.stackAuto || IFFUNC_ISREENT (LTYPE (tree)))
{
if (options.stackAuto || IFFUNC_ISREENT (LTYPE (tree)))
{
- //
IF
FUNC_ARGS(tree->left->ftype) =
- //reverseVal (
IF
FUNC_ARGS(tree->left->ftype));
+ //FUNC_ARGS(tree->left->ftype) =
+ //reverseVal (FUNC_ARGS(tree->left->ftype));
reverseParms (tree->right);
}
reverseParms (tree->right);
}
@@
-4160,7
+4173,7
@@
createFunction (symbol * name, ast * body)
body = resolveSymbols (body); /* resolve the symbols */
body = decorateType (body); /* propagateType & do semantic checks */
body = resolveSymbols (body); /* resolve the symbols */
body = decorateType (body); /* propagateType & do semantic checks */
- ex = newAst_VALUE (symbolVal (name));
/* create name
*/
+ ex = newAst_VALUE (symbolVal (name));
/* create name
*/
ex = newNode (FUNCTION, ex, body);
ex->values.args = FUNC_ARGS(name->type);
ex->decorated=1;
ex = newNode (FUNCTION, ex, body);
ex->values.args = FUNC_ARGS(name->type);
ex->decorated=1;
@@
-4254,27
+4267,40
@@
void ast_print (ast * tree, FILE *outfile, int indent)
}
if (tree->opval.op == FUNCTION) {
}
if (tree->opval.op == FUNCTION) {
- fprintf(outfile,"FUNCTION (%p) type (",tree);
+ int arg=0;
+ 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->ftype,outfile);
+ fprintf(outfile,") args (");
+ do {
+ if (arg) {
+ fprintf (outfile, ", ");
+ }
+ printTypeChain (args ? args->type : NULL, outfile);
+ arg++;
+ args= args ? args->next : NULL;
+ } while (args);
fprintf(outfile,")\n");
fprintf(outfile,")\n");
- ast_print(tree->left,outfile,indent
+4
);
- ast_print(tree->right,outfile,indent
+4
);
+ ast_print(tree->left,outfile,indent);
+ ast_print(tree->right,outfile,indent);
return ;
}
if (tree->opval.op == BLOCK) {
symbol *decls = tree->values.sym;
return ;
}
if (tree->opval.op == BLOCK) {
symbol *decls = tree->values.sym;
- INDENT(indent
+4
,outfile);
+ INDENT(indent,outfile);
fprintf(outfile,"{\n");
while (decls) {
INDENT(indent+4,outfile);
fprintf(outfile,"{\n");
while (decls) {
INDENT(indent+4,outfile);
- fprintf(outfile,"DECLARE SYMBOL %s, type(",decls->name);
+ fprintf(outfile,"DECLARE SYMBOL (%s=%p) type (",
+ decls->name, decls);
printTypeChain(decls->type,outfile);
fprintf(outfile,")\n");
decls = decls->next;
}
ast_print(tree->right,outfile,indent+4);
printTypeChain(decls->type,outfile);
fprintf(outfile,")\n");
decls = decls->next;
}
ast_print(tree->right,outfile,indent+4);
- INDENT(indent
+4
,outfile);
+ INDENT(indent,outfile);
fprintf(outfile,"}\n");
return;
}
fprintf(outfile,"}\n");
return;
}
@@
-4307,7
+4333,8
@@
void ast_print (ast * tree, FILE *outfile, int indent)
} else {
fprintf(outfile,"SYMBOL ");
}
} else {
fprintf(outfile,"SYMBOL ");
}
- fprintf(outfile,"(%p) name= %s ",tree,tree->opval.val->sym->name);
+ fprintf(outfile,"(%s=%p)",
+ tree->opval.val->sym->name,tree);
}
if (tree->ftype) {
fprintf(outfile," type (");
}
if (tree->ftype) {
fprintf(outfile," type (");
@@
-4580,7
+4607,9
@@
void ast_print (ast * tree, FILE *outfile, int indent)
/* casting */
/*----------------------------*/
case CAST: /* change the type */
/* casting */
/*----------------------------*/
case CAST: /* change the type */
- fprintf(outfile,"CAST (%p) type (",tree);
+ fprintf(outfile,"CAST (%p) from type (",tree);
+ printTypeChain(tree->right->ftype,outfile);
+ fprintf(outfile,") to type (");
printTypeChain(tree->ftype,outfile);
fprintf(outfile,")\n");
ast_print(tree->right,outfile,indent+4);
printTypeChain(tree->ftype,outfile);
fprintf(outfile,")\n");
ast_print(tree->right,outfile,indent+4);
@@
-4784,10
+4813,9
@@
void ast_print (ast * tree, FILE *outfile, int indent)
ast_print(tree->right,outfile,indent+4);
return;
case PARAM:
ast_print(tree->right,outfile,indent+4);
return;
case PARAM:
- fprintf(outfile,"PARM
");
+ fprintf(outfile,"PARM
S\n
");
ast_print(tree->left,outfile,indent+4);
if (tree->right && !IS_AST_PARAM(tree->right)) {
ast_print(tree->left,outfile,indent+4);
if (tree->right && !IS_AST_PARAM(tree->right)) {
- fprintf(outfile,"PARM ");
ast_print(tree->right,outfile,indent+4);
}
return ;
ast_print(tree->right,outfile,indent+4);
}
return ;
@@
-4877,5
+4905,5
@@
void ast_print (ast * tree, FILE *outfile, int indent)
void PA(ast *t)
{
void PA(ast *t)
{
- ast_print(t,stdout,
1
);
+ ast_print(t,stdout,
0
);
}
}