From b19542d7491682f3c35c4c52660dbe37fd817acd Mon Sep 17 00:00:00 2001 From: johanknol Date: Tue, 4 Sep 2001 14:33:37 +0000 Subject: [PATCH] fix for the first part of bug #458099 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1225 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCmem.c | 4 ++-- src/SDCCsymt.c | 28 +++++++++++++++------------- src/SDCCsymt.h | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/SDCCmem.c b/src/SDCCmem.c index 9649469f..4692be48 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -420,7 +420,7 @@ allocParms (value * val) { /* check the declaration */ - checkDecl (lval->sym); + checkDecl (lval->sym, 0); /* if this a register parm then allocate it as a local variable by adding it @@ -793,7 +793,7 @@ allocVariables (symbol * symChain) csym = sym; /* check the declaration */ - checkDecl (csym); + checkDecl (csym,0); /* if this is a function or a pointer to function */ /* then args processing */ diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 4717bf10..8f3d8df4 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1092,7 +1092,7 @@ compStructSize (int su, structdef * sdef) } } else { - checkDecl (loop); + checkDecl (loop, 1); sum += getSize (loop->type); } @@ -1124,7 +1124,7 @@ compStructSize (int su, structdef * sdef) /* checkSClass - check the storage class specification */ /*------------------------------------------------------------------*/ static void -checkSClass (symbol * sym) +checkSClass (symbol * sym, int isProto) { if (getenv("DEBUG_SANITY")) { fprintf (stderr, "checkSClass: %s \n", sym->name); @@ -1252,15 +1252,17 @@ checkSClass (symbol * sym) SPEC_BSTR (sym->etype) = 0; } - /* variables declared in CODE space must have */ - /* initializers if not an extern */ - if (SPEC_SCLS (sym->etype) == S_CODE && - sym->ival == NULL && - !sym->level && - port->mem.code_ro && - !IS_EXTERN (sym->etype) && - !funcInChain (sym->type)) - werror (E_CODE_NO_INIT, sym->name); + if (!isProto) { + /* variables declared in CODE space must have */ + /* initializers if not an extern */ + if (SPEC_SCLS (sym->etype) == S_CODE && + sym->ival == NULL && + !sym->level && + port->mem.code_ro && + !IS_EXTERN (sym->etype) && + !funcInChain (sym->type)) + werror (E_CODE_NO_INIT, sym->name); + } /* if parameter or local variable then change */ /* the storage class to reflect where the var will go */ @@ -1310,10 +1312,10 @@ changePointer (symbol * sym) /* checkDecl - does semantic validation of a declaration */ /*------------------------------------------------------------------*/ int -checkDecl (symbol * sym) +checkDecl (symbol * sym, int isProto) { - checkSClass (sym); /* check the storage class */ + checkSClass (sym, isProto); /* check the storage class */ changePointer (sym); /* change pointers if required */ /* if this is an array without any dimension diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 41e4ec78..fab6ac5c 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -419,7 +419,7 @@ sym_link *getSpec (sym_link *); char *genSymName (int); int compStructSize (int, structdef *); sym_link *copyLinkChain (sym_link *); -int checkDecl (symbol *); +int checkDecl (symbol *, int); void checkBasic (sym_link *, sym_link *); value *checkPointerIval (sym_link *, value *); value *checkStructIval (symbol *, value *); -- 2.30.2