;
opt_stag
- : stag
- | { /* synthesize a name add to structtable */
- $$ = newStruct(genSymName(NestLevel)) ;
- $$->level = NestLevel ;
- addSym (StructTab, $$, $$->tag,$$->level,currBlockno) ;
- }
- ;
+: stag
+| { /* synthesize a name add to structtable */
+ $$ = newStruct(genSymName(NestLevel)) ;
+ $$->level = NestLevel ;
+ addSym (StructTab, $$, $$->tag,$$->level,currBlockno, 0);
+};
stag
- : identifier { /* add name to structure table */
- $$ = findSymWithBlock (StructTab,$1,currBlockno);
- if (! $$ ) {
- $$ = newStruct($1->name) ;
- $$->level = NestLevel ;
- addSym (StructTab, $$, $$->tag,$$->level,currBlockno) ;
- }
- }
- ;
+: identifier { /* add name to structure table */
+ $$ = findSymWithBlock (StructTab,$1,currBlockno);
+ if (! $$ ) {
+ $$ = newStruct($1->name) ;
+ $$->level = NestLevel ;
+ addSym (StructTab, $$, $$->tag,$$->level,currBlockno,0);
+ }
+};
+
struct_declaration_list
: struct_declaration
(csym && csym->level == $2->level))
werror(E_DUPLICATE_TYPEDEF,csym->name);
- addSym ( enumTab,$2,$2->name,$2->level,$2->block);
+ addSym ( enumTab,$2,$2->name,$2->level,$2->block, 0);
addSymChain ($4);
allocVariables (reverseSyms($4));
$$ = copyLinkChain(cenum->type);
if (!defParm && !actParm)
return 0;
+ if (defParm) {
+ if (getenv("DEBUG_SANITY")) {
+ fprintf (stderr, "addSym: %s ", defParm->name);
+ }
+ /* make sure the type is complete and sane */
+ checkTypeSanity(defParm->etype, defParm->name);
+ }
+
/* if the function is being called via a pointer & */
/* it has not been defined a reentrant then we cannot */
/* have parameters */
/* insert the symbol into the symbol table */
/* with level = 0 & name = rname */
newSym = copySymbol (sym);
- addSym (SymbolTab, newSym, newSym->name, 0, 0);
+ addSym (SymbolTab, newSym, newSym->name, 0, 0, 1);
/* now lift the code to main */
if (IS_AGGREGATE (sym->type))
if ((csym = findSym (LabelTab, NULL, name)))
werror (E_DUPLICATE_LABEL, label->name);
else
- addSym (LabelTab, label, name, label->level, 0);
+ addSym (LabelTab, label, name, label->level, 0, 0);
label->islbl = 1;
label->key = labelKey++;
itmplbl->isitmp = 1;
itmplbl->islbl = 1;
itmplbl->key = labelKey++;
- addSym (LabelTab, itmplbl, itmplbl->name, 0, 0);
+ addSym (LabelTab, itmplbl, itmplbl->name, 0, 0, 0);
return itmplbl;
}
itmplbl->isitmp = 1;
itmplbl->islbl = 1;
itmplbl->key = labelKey++;
- addSym (LabelTab, itmplbl, itmplbl->name, 0, 0);
+ addSym (LabelTab, itmplbl, itmplbl->name, 0, 0, 0);
return itmplbl;
}
strcpy (lval->sym->rname, buffer);
strcpy (lval->name, strcpy (lval->sym->name, lval->sym->rname));
addSym (SymbolTab, lval->sym, lval->sym->name,
- lval->sym->level, lval->sym->block);
+ lval->sym->level, lval->sym->block, 1);
lval->sym->_isparm = 1;
addSet (&operKeyReset, lval->sym);
}
if (csym && csym->level == sym->level)
werror (E_DUPLICATE_TYPEDEF, sym->name);
- addSym (TypedefTab, sym, sym->name, sym->level, sym->block);
+ addSym (TypedefTab, sym, sym->name, sym->level, sym->block, 0);
continue; /* go to the next one */
}
/* make sure it already exist */
void *sym,
char *sname,
int level,
- int block)
+ int block,
+ int checkType)
{
int i; /* index into the hash Table */
bucket *bp; /* temp bucket * */
- if (getenv("DEBUG_SANITY")) {
- fprintf (stderr, "addSym: %s ", sname);
- }
- /* Make sure sym is a symbol and not a structdef */
- if (StructTab!=stab) {
+ if (checkType) {
+ if (getenv("DEBUG_SANITY")) {
+ fprintf (stderr, "addSym: %s ", sname);
+ }
/* make sure the type is complete and sane */
checkTypeSanity(((symbol *)sym)->etype, ((symbol *)sym)->name);
}
noun=nounName(etype);
if (getenv("DEBUG_SANITY")) {
- fprintf (stderr, "checking sanity for %s\n", name);
+ fprintf (stderr, "checking sanity for %s %x\n", name, (int)etype);
}
if ((SPEC_NOUN(etype)==V_CHAR ||
/* delete current entry */
deleteSym (SymbolTab, csym, csym->name);
/* add new entry */
- addSym (SymbolTab, sym, sym->name, sym->level, sym->block);
+ addSym (SymbolTab, sym, sym->name, sym->level, sym->block, 1);
}
else /* not extern */
werror (E_DUPLICATE, sym->name);
werror (W_EXTERN_MISMATCH, csym->name);
}
}
- addSym (SymbolTab, sym, sym->name, sym->level, sym->block);
+ addSym (SymbolTab, sym, sym->name, sym->level, sym->block, 1);
}
}
{
symbol *csym;
value *exargs, *acargs;
+ value *checkValue;
int argCnt = 0;
if (getenv("DEBUG_SANITY")) {
exargs && acargs;
exargs = exargs->next, acargs = acargs->next, argCnt++)
{
- value *checkValue;
+ if (getenv("DEBUG_SANITY")) {
+ fprintf (stderr, "checkFunction: %s ", exargs->name);
+ }
+ /* make sure the type is complete and sane */
+ checkTypeSanity(exargs->etype, exargs->name);
+
/* If the actual argument is an array, any prototype
* will have modified it to a pointer. Duplicate that
* change here.
/* replace with this defition */
sym->cdef = csym->cdef;
deleteSym (SymbolTab, csym, csym->name);
- addSym (SymbolTab, sym, sym->name, sym->level, sym->block);
+ addSym (SymbolTab, sym, sym->name, sym->level, sym->block, 1);
if (IS_EXTERN (csym->etype) && !
IS_EXTERN (sym->etype))
{
void cdbStructBlock (int, FILE *);
void initHashT ();
bucket *newBucket ();
-void addSym (bucket **, void *, char *, int, int);
+void addSym (bucket **, void *, char *, int, int, int checkType);
void deleteSym (bucket **, void *, char *);
void *findSym (bucket **, void *, const char *);
void *findSymWithLevel (bucket **, struct symbol *);