* src/SDCCast.c (resolveSymbols): added reentrancy check for parameters
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 1 Feb 2008 18:46:38 +0000 (18:46 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 1 Feb 2008 18:46:38 +0000 (18:46 +0000)
  of function pointer
* src/SDCCerr.h,
* src/SDCCerr.c: changed warning W_NONRENT_ARGS to error E_NONRENT_ARGS
* support/regression/tests/absolute.c: added TestStruct TestVar (see also
  bug 1859853)

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5002 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCast.c
src/SDCCerr.c
src/SDCCerr.h
support/regression/tests/absolute.c

index 98dde146796af778f6acce6660fcc535565dcfe5..077819c0ebdb79a21a2e339715e2124cc2590b61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-02-01 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/SDCCast.c (resolveSymbols): added reentrancy check for parameters
+         of function pointer
+       * src/SDCCerr.h,
+       * src/SDCCerr.c: changed warning W_NONRENT_ARGS to error E_NONRENT_ARGS
+       * support/regression/tests/absolute.c: added TestStruct TestVar (see also
+         bug 1859853)
+
 2008-02-01 Raphael Neider <rneider AT web.de>
 
        * device/include/pic/pic16f886.h,
index a2a67a5732373063bb9d9dd9ca3c20956f3f4d9f..97581fee14dd9027cef9b8f717dc3f4eef0d7aae 100644 (file)
@@ -569,7 +569,7 @@ resolveSymbols (ast * tree)
 
       symbol *csym = findSymWithLevel (SymbolTab, tree->opval.val->sym);
 
-      /* if found in the symbol table & they r not the same */
+      /* if found in the symbol table & they are not the same */
       if (csym && tree->opval.val->sym != csym)
         {
           tree->opval.val->sym = csym;
@@ -578,8 +578,8 @@ resolveSymbols (ast * tree)
         }
 
       /* if not found in the symbol table */
-      /* mark it as undefined assume it is */
-      /* an integer in data space         */
+      /* mark it as undefined & assume it */
+      /* is an integer in data space      */
       if (!csym && !tree->opval.val->sym->implicit)
         {
 
@@ -783,15 +783,15 @@ processParms (ast *func,
   else
     functype = func->ftype;
 
-  /* if the function is being called via a pointer &   */
-  /* it has not been defined reentrant then we cannot */
-  /* have parameters                                   */
+  /* if the function is being called via a pointer &  */
+  /* it has not been defined reentrant then we cannot */
+  /* have parameters                                  */
   /* PIC16 port can... */
   if (!TARGET_IS_PIC16)
     {
       if (func->type != EX_VALUE && !IFFUNC_ISREENT (functype) && !options.stackAuto)
         {
-          werror (W_NONRENT_ARGS);
+          werror (E_NONRENT_ARGS);
           fatalError++;
           return 1;
         }
@@ -930,6 +930,18 @@ processParms (ast *func,
   (*actParm)->etype = getSpec ((*actParm)->ftype = copyLinkChain ((*actParm)->ftype));
   SPEC_REGPARM ((*actParm)->etype) = SPEC_REGPARM (defParm->etype);
   SPEC_ARGREG  ((*actParm)->etype) = SPEC_ARGREG (defParm->etype);
+
+  /* if the function is being called via a pointer &  */
+  /* this parameter is not passed in registers        */
+  /* then the function must be defined reentrant      */
+  if (IS_FUNCPTR (func->ftype) && !SPEC_REGPARM ((*actParm)->etype) &&
+      !IFFUNC_ISREENT (functype) && !options.stackAuto)
+    {
+      werror (E_NONRENT_ARGS);
+      fatalError++;
+      return 1;
+    }
+
   (*parmNumber)++;
   return 0;
 }
index 610f95080d95a4ac62f0efcea3035eb7996f96e6..7425bb7e9a16f6c077ebb07f36156e008811e692 100644 (file)
@@ -31,9 +31,9 @@
 
 struct SDCCERRG _SDCCERRG; 
 
-extern char *filename ;
-extern int lineno ;
-extern int fatalError ;
+extern char *filename;
+extern int lineno;
+extern int fatalError;
 
 /* Currently the errIndex field must match the position of the 
  * entry in the array. It is only included in order to make 
@@ -107,7 +107,7 @@ struct
 { E_UNARY_OP, ERROR_LEVEL_ERROR,
    "'unary %c': illegal operand" },
 { E_CONV_ERR, ERROR_LEVEL_ERROR,
-   "convertion error: integral promotion failed" },
+   "conversion error: integral promotion failed" },
 { E_INT_REQD, ERROR_LEVEL_ERROR,
    "type must be INT for bit field definition" },
 { E_BITFLD_SIZE, ERROR_LEVEL_ERROR,
@@ -233,8 +233,8 @@ struct
    "storage class CANNOT be specified for bit variable '%s'" },
 { E_EXTERN_MISMATCH, ERROR_LEVEL_ERROR,
    "extern definition for '%s' mismatches with declaration." },
-{ W_NONRENT_ARGS, ERROR_LEVEL_WARNING,
-   "Functions called via pointers must be 'reentrant' to take arguments" },
+{ E_NONRENT_ARGS, ERROR_LEVEL_ERROR,
+   "Functions called via pointers must be 'reentrant' to take this many arguments" },
 { W_DOUBLE_UNSUPPORTED, ERROR_LEVEL_WARNING,
    "type 'double' not supported assuming 'float'" },
 { W_COMP_RANGE, ERROR_LEVEL_WARNING,
@@ -467,7 +467,7 @@ void setErrorLogLevel (ERROR_LOG_LEVEL level)
 
 /*
 -------------------------------------------------------------------------------
-vwerror - Output a standard eror message with variable number of arguements
+vwerror - Output a standard error message with variable number of arguments
 
 -------------------------------------------------------------------------------
 */
@@ -525,7 +525,7 @@ void vwerror (int errNum, va_list marker)
 }
 /*
 -------------------------------------------------------------------------------
-werror - Output a standard eror message with variable number of arguements
+werror - Output a standard error message with variable number of arguments
 
 -------------------------------------------------------------------------------
 */
@@ -540,7 +540,7 @@ void werror (int errNum, ...)
 
 /*
 -------------------------------------------------------------------------------
-werrorfl - Output a standard eror message with variable number of arguements.
+werrorfl - Output a standard error message with variable number of arguments.
            Use a specified filename and line number instead of the default.
 
 -------------------------------------------------------------------------------
@@ -566,7 +566,7 @@ void werrorfl (char *newFilename, int newLineno, int errNum, ...)
 
 /*
 -------------------------------------------------------------------------------
-fatal - Output a standard eror message with variable number of arguements and
+fatal - Output a standard error message with variable number of arguments and
         call exit()
 -------------------------------------------------------------------------------
 */
index 3bccf1df1a7835186e5fcbc40b7b3ac75bb79331..7b707445e507863b294927acab5856f79af91380 100644 (file)
@@ -107,7 +107,7 @@ SDCCERR - SDCC Standard error handler
 #define E_SFR_ADDR_RANGE               89 /* sfr address out of range */
 #define E_BITVAR_STORAGE               90 /* storage given for 'bit' variable */
 #define E_EXTERN_MISMATCH              91 /* extern declaration mismatches */
-#define W_NONRENT_ARGS                 92 /* fptr non reentrant has args */
+#define E_NONRENT_ARGS                 92 /* fptr non reentrant has args */
 #define W_DOUBLE_UNSUPPORTED           93 /* 'double' not supported yet */
 #define W_COMP_RANGE                   94 /* comparison is always %s due to limited range of data type */
 #define W_FUNC_NO_RETURN               95 /* no return statement found */
index cfc5b140c10a3e6a1915a0a169fe00872eb5e264..e8c3b22970c63e423ddbd77a81bded8dab4ce19b 100644 (file)
@@ -4,6 +4,12 @@
 */
 #include <testfwk.h>
 
+typedef struct
+{
+       int a,b;
+} TestStruct;
+
+{mem} volatile at(0xCABC) TestStruct TestVar = {0,0};
 {mem} at(0xCAB7) char u;
 {mem} at(0xCAB7) char x = 'x';
 {mem} at(0xCAB9) char y = 'y';