fix for the first part of bug #458099
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 4 Sep 2001 14:33:37 +0000 (14:33 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 4 Sep 2001 14:33:37 +0000 (14:33 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1225 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCmem.c
src/SDCCsymt.c
src/SDCCsymt.h

index 9649469fc0791cb028ecc14e98df01170df9df1b..4692be48e609842c9020b1e5f950311272e2c707 100644 (file)
@@ -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  */
index 4717bf10b60664e0e99ea3d0424ed723a9ac5f44..8f3d8df450bbb681edbb13eba488793b551562ba 100644 (file)
@@ -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
index 41e4ec78b31d1ccec5b7bb04572f567b8daca319..fab6ac5cc3e9702f1cde0a1cd9b61f50c0ad599f 100644 (file)
@@ -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 *);