+2003-12-28 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+ * src/SDCC.y (external_definition, type_specifier2, sfr_reg_bit,
+ sft_attributes, struct_declaration, parameter_declaration,
+ type_name, start_block, declaration_list),
+ * src/SDCC.lex (check_type): support redefinition of typedef names
+
2003-12-22 Frieder Ferlemann <Frieder.Ferlemann@web.de>
* src/mcs51/gen.c (genPlus): added special handling for 256 byte
"==" { count(); return(EQ_OP); }
"!=" { count(); return(NE_OP); }
";" { count(); return(';'); }
-"{" { count(); NestLevel++ ; return('{'); }
+"{" { count(); NestLevel++ ; ignoreTypedefType = 0; return('{'); }
"}" { count(); NestLevel--; return('}'); }
"," { count(); return(','); }
":" { count(); return(':'); }
"=" { count(); return('='); }
-"(" { count(); return('('); }
+"(" { count(); ignoreTypedefType = 0; return('('); }
")" { count(); return(')'); }
"[" { count(); return('['); }
"]" { count(); return(']'); }
static int check_type(void)
{
- /* check if it is in the typedef table */
- if (findSym(TypedefTab, NULL, yytext)) {
+ symbol *sym = findSym(SymbolTab, NULL, yytext);
+
+ /* check if it is in the table as a typedef */
+ if (!ignoreTypedefType && sym && IS_SPEC (sym->etype)
+ && SPEC_TYPEDEF (sym->etype)) {
strncpyz(yylval.yychar, yytext, SDCC_NAME_MAX);
return (TYPE_NAME);
}
/*
* Change by JTV 2001-05-19 to not concantenate strings
- * to support ANSI hex and octal escape sequences in string liteals
+ * to support ANSI hex and octal escape sequences in string literals
*/
static char *stringLiteral(void)
int currBlockno=0 ;
int inCritical= 0 ;
int seqPointNo= 1 ; /* sequence point number */
+int ignoreTypedefType=0;
extern int yylex();
int yyparse(void);
extern int noLineno ;
value *cenum = NULL ; /* current enumeration type chain*/
bool uselessDecl = TRUE;
+#define YYDEBUG 1
+
%}
%expect 6
blockNo=0;
}
| declaration {
+ ignoreTypedefType = 0;
if ($1 && $1->type
&& IS_FUNC($1->type))
{
: type_specifier2
| type_specifier2 AT constant_expr
{
- /* add this to the storage class specifier */
+ /* add this to the storage class specifier */
SPEC_ABSA($1) = 1; /* set the absolute addr flag */
/* now get the abs addr from value */
SPEC_ADDR($1) = (int) floatFromVal(constExprValue($3,TRUE)) ;
: CHAR {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_CHAR ;
+ ignoreTypedefType = 1;
}
| SHORT {
$$=newLink(SPECIFIER);
$$->select.s._short = 1 ;
+ ignoreTypedefType = 1;
}
| INT {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_INT ;
+ ignoreTypedefType = 1;
}
| LONG {
$$=newLink(SPECIFIER);
SPEC_LONG($$) = 1 ;
+ ignoreTypedefType = 1;
}
| SIGNED {
$$=newLink(SPECIFIER);
$$->select.s._signed = 1;
+ ignoreTypedefType = 1;
}
| UNSIGNED {
$$=newLink(SPECIFIER);
SPEC_USIGN($$) = 1 ;
+ ignoreTypedefType = 1;
}
| VOID {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_VOID ;
+ ignoreTypedefType = 1;
}
| CONST {
$$=newLink(SPECIFIER);
| FLOAT {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_FLOAT;
+ ignoreTypedefType = 1;
}
| XDATA {
$$ = newLink (SPECIFIER);
SPEC_SCLS($$) = S_BIT ;
SPEC_BLEN($$) = 1;
SPEC_BSTR($$) = 0;
+ ignoreTypedefType = 1;
}
| struct_or_union_specifier {
uselessDecl = FALSE;
$$ = $1 ;
+ ignoreTypedefType = 1;
}
| enum_specifier {
cenum = NULL ;
uselessDecl = FALSE;
+ ignoreTypedefType = 1;
$$ = $1 ;
}
| TYPE_NAME
sym = findSym(TypedefTab,NULL,$1) ;
$$ = p = copyLinkChain(sym->type);
SPEC_TYPEDEF(getSpec(p)) = 0;
+ ignoreTypedefType = 1;
}
| sfr_reg_bit
;
$$ = newLink(SPECIFIER) ;
SPEC_NOUN($$) = V_SBIT;
SPEC_SCLS($$) = S_SBIT;
+ ignoreTypedefType = 1;
}
| sfr_attributes
;
SPEC_NOUN($$) = V_CHAR;
SPEC_SCLS($$) = S_SFR ;
SPEC_USIGN($$) = 1 ;
+ ignoreTypedefType = 1;
}
| SFR BANKED {
$$ = newLink(SPECIFIER) ;
SPEC_NOUN($$) = V_CHAR;
SPEC_SCLS($$) = S_SFR ;
SPEC_USIGN($$) = 1 ;
+ ignoreTypedefType = 1;
}
;
/* make sure the type is complete and sane */
checkTypeSanity(sym->etype, sym->name);
}
- $$ = $2;
+ ignoreTypedefType = 0;
+ $$ = $2;
}
;
function_declarator2
: declarator2 '(' ')' { addDecl ($1,FUNCTION,NULL) ; }
- | declarator2 '(' { NestLevel++ ; currBlockno++; } parameter_type_list ')'
+ | declarator2 '(' { NestLevel++ ; currBlockno++; }
+ parameter_type_list ')'
{
addDecl ($1,FUNCTION,NULL) ;
;
parameter_list
- : parameter_declaration
+ : parameter_declaration
| parameter_list ',' parameter_declaration
{
$3->next = $1 ;
- $$ = $3 ;
+ $$ = $3 ;
}
;
for (loop=$2;loop;loop->_isparm=1,loop=loop->next);
addSymChain ($2);
$$ = symbolVal($2);
+ ignoreTypedefType = 0;
}
| type_name {
$$ = newValue() ;
$$->type = $1;
$$->etype = getSpec($$->type);
+ ignoreTypedefType = 0;
}
;
type_name
- : type_specifier_list { $$ = $1 ;}
+ : type_specifier_list { $$ = $1; ignoreTypedefType = 0;}
| type_specifier_list abstract_declarator
{
/* go to the end of the list */
p->next = $1 ;
}
$$ = $2 ;
+ ignoreTypedefType = 0;
}
;
}
;
-start_block : '{' { STACK_PUSH(blockNum,currBlockno); currBlockno = ++blockNo ; }
+start_block : '{'
+ {
+ STACK_PUSH(blockNum,currBlockno);
+ currBlockno = ++blockNo ;
+ ignoreTypedefType = 0;
+ }
;
end_block : '}' { currBlockno = STACK_POP(blockNum); }
}
else
$$ = $1 ;
+ ignoreTypedefType = 0;
}
| declaration_list declaration
else
$$ = $2 ;
}
+ ignoreTypedefType = 0;
}
;