From d7d85d58cbc4bbec9ec34fdac39904beaa564020 Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Fri, 1 Feb 2008 18:46:38 +0000 Subject: [PATCH] * 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) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5002 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 9 +++++++++ src/SDCCast.c | 26 +++++++++++++++++++------- src/SDCCerr.c | 20 ++++++++++---------- src/SDCCerr.h | 2 +- support/regression/tests/absolute.c | 6 ++++++ 5 files changed, 45 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98dde146..077819c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-02-01 Maarten Brock + + * 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 * device/include/pic/pic16f886.h, diff --git a/src/SDCCast.c b/src/SDCCast.c index a2a67a57..97581fee 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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 a 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; } diff --git a/src/SDCCerr.c b/src/SDCCerr.c index 610f9508..7425bb7e 100644 --- a/src/SDCCerr.c +++ b/src/SDCCerr.c @@ -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() ------------------------------------------------------------------------------- */ diff --git a/src/SDCCerr.h b/src/SDCCerr.h index 3bccf1df..7b707445 100644 --- a/src/SDCCerr.h +++ b/src/SDCCerr.h @@ -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 */ diff --git a/support/regression/tests/absolute.c b/support/regression/tests/absolute.c index cfc5b140..e8c3b229 100644 --- a/support/regression/tests/absolute.c +++ b/support/regression/tests/absolute.c @@ -4,6 +4,12 @@ */ #include +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'; -- 2.30.2