From 021a4213483a23736906ffd68d004c58e062d086 Mon Sep 17 00:00:00 2001 From: sandeep Date: Sun, 4 Nov 2001 18:25:49 +0000 Subject: [PATCH] Fixed bug-478036 : (struct array passed as argument) Fixed bug when pointers to different structures were allowed to be cast without a warning. SDCC.lex cosmetic git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1497 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCC.lex | 4 ++-- src/SDCCast.c | 11 +++++++++-- src/SDCCsymt.c | 5 +---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/SDCC.lex b/src/SDCC.lex index 9ff54cb7..02876dd0 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -175,7 +175,7 @@ struct options save_options ; 0[xX]{H}+{IS}? { count(); yylval.val = constVal(yytext); return(CONSTANT); } 0{D}+{IS}? { count(); yylval.val = constVal(yytext); return(CONSTANT); } {D}+{IS}? { count(); yylval.val = constVal(yytext); return(CONSTANT); } -'(\\.|[^\\'])+' { count();yylval.val = charVal (yytext); return(CONSTANT); } +'(\\.|[^\\'])+' { count();yylval.val = charVal (yytext); return(CONSTANT); /* ' make syntax highliter happy */} {D}+{E}{FS}? { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } {D}*"."{D}+({E})?{FS}? { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } {D}+"."{D}*({E})?{FS}? { count(); yylval.val = constFloatVal(yytext);return(CONSTANT); } @@ -243,7 +243,7 @@ struct options save_options ; } . { count() ; } %% - + int checkCurrFile ( char *s) { char lineNum[10] ; diff --git a/src/SDCCast.c b/src/SDCCast.c index 18921681..441bedc9 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -760,6 +760,8 @@ processParms (ast * func, actParm->right = pTree; actParm->etype = defParm->etype; actParm->ftype = defParm->type; + actParm->decorated=0; /* force typechecking */ + decorateType (actParm); } /* make a copy and change the regparm type to the defined parm */ @@ -2719,6 +2721,12 @@ decorateType (ast * tree) LRVAL (tree) = 1; } #else + /* 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)) { + werror(W_CAST_STRUCT_PTR,SPEC_STRUCT(RETYPE(tree))->tag,SPEC_STRUCT(LETYPE(tree))->tag); + } /* if the right is a literal replace the tree */ if (IS_LITERAL (RETYPE (tree)) && !IS_PTR (LTYPE (tree))) { tree->type = EX_VALUE; @@ -2733,8 +2741,7 @@ decorateType (ast * tree) TTYPE (tree) = LTYPE (tree); LRVAL (tree) = 1; } -#endif - +#endif TETYPE (tree) = getSpec (TTYPE (tree)); return tree; diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index d19342b5..afedc3e5 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1582,10 +1582,7 @@ aggregateToPointer (value * val) DCL_TYPE (val->type) = PPOINTER; break; case S_FIXED: - if (SPEC_OCLS(val->etype)) { DCL_TYPE(val->type)=PTR_TYPE(SPEC_OCLS(val->etype)); - break; - } if (TARGET_IS_DS390) { @@ -1600,7 +1597,7 @@ aggregateToPointer (value * val) DCL_TYPE (val->type) = FPOINTER; break; } - /* fall through! */ + break; case S_AUTO: case S_DATA: case S_REGISTER: -- 2.30.2