if (!sym->type) {
sym->type = copyLinkChain($1);
sym->etype = getSpec(sym->type);
- /* make sure the type is complete and sane */
- checkTypeSanity(sym->etype, sym->name);
}
else
addDecl (sym,0,cloneSpec($1));
+ /* make sure the type is complete and sane */
+ checkTypeSanity(sym->etype, sym->name);
}
$$ = $2;
}
;
struct_declarator
- : declarator
+ : declarator
| ':' constant_expr {
$$ = newSymbol (genSymName(NestLevel),NestLevel) ;
$$->bitVar = (int) floatFromVal(constExprValue($2,TRUE));
$1->hasVargs = IS_VARG($4);
$1->args = reverseVal($4) ;
+
/* nest level was incremented to take care of the parms */
NestLevel-- ;
currBlockno--;
+
+ // if this was a pointer to a function, remove the symbol args
+ // (if any)
+ if (IS_PTR($1->type) && IS_FUNC($1->etype)) {
+ cleanUpLevel(SymbolTab,NestLevel+1);
+ /* fprintf (stderr, "Removed parm symbols of %s in line %d\n",
+ $1->name, yylineno); */
+ }
+
$$ = $1;
}
| declarator2 '(' parameter_identifier_list ')'
{
$$ = $1 ;
$$->next = $2 ;
+ DCL_TYPE($2)=GPOINTER;
}
| unqualified_pointer type_specifier_list pointer
{
type_specifier_list
: type_specifier
- | type_specifier_list type_specifier { $$ = mergeSpec ($1,$2, "type_specifier_list"); }
+ //| type_specifier_list type_specifier { $$ = mergeSpec ($1,$2, "type_specifier_list"); }
+ | type_specifier_list type_specifier {
+ /* if the decl $2 is not a specifier */
+ /* find the spec and replace it */
+ if ( !IS_SPEC($2)) {
+ sym_link *lnk = $2 ;
+ while (lnk && !IS_SPEC(lnk->next))
+ lnk = lnk->next;
+ lnk->next = mergeSpec($1,lnk->next, "type_specifier_list");
+ $$ = $2 ;
+ }
+ else
+ $$ = mergeSpec($1,$2, "type_specifier_list");
+ }
;
parameter_identifier_list
| jump_statement
| INLINEASM ';' {
ast *ex = newNode(INLINEASM,NULL,NULL);
- ex->values.inlineasm = Safe_calloc(1,strlen($1)+1);
+ ex->values.inlineasm = malloc(strlen($1)+1);
strcpy(ex->values.inlineasm,$1);
$$ = ex;
- }
+ }
;
labeled_statement
- : identifier ':' statement { $$ = createLabel($1,$3); }
+// : identifier ':' statement { $$ = createLabel($1,$3); }
+ : identifier ':' { $$ = createLabel($1,NULL); }
| CASE constant_expr ':' statement { $$ = createCase(STACK_PEEK(swStk),$2,$4); }
| DEFAULT ':' statement { $$ = createDefault(STACK_PEEK(swStk),$3); }
;