Fixed bug-478036 : (struct array passed as argument)
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Nov 2001 18:25:49 +0000 (18:25 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 4 Nov 2001 18:25:49 +0000 (18:25 +0000)
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
src/SDCCast.c
src/SDCCsymt.c

index 9ff54cb70022877e4910ad770eb2305f37d39815..02876dd012436c56680afbb6f16f86cdbc2f6cfd 100644 (file)
@@ -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]                   ;
index 189216815a0652776a06e48bf869ceb537abd859..441bedc9105bed4feccc0f20c93d5192574fbd07 100644 (file)
@@ -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;
index d19342b5faa11f98638a465218c0201b1f863839..afedc3e53ce77719f6e3e7e93bd23e0b8de3c4de 100644 (file)
@@ -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: