sft_attributes, struct_declaration, parameter_declaration,
type_name, start_block, declaration_list),
* src/SDCC.lex (check_type): support redefinition of typedef names
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3068
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+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
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(); 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(); NestLevel--; return('}'); }
"," { count(); return(','); }
":" { count(); return(':'); }
"=" { count(); return('='); }
-"(" { count(); return('('); }
+"(" { count(); ignoreTypedefType = 0; return('('); }
")" { count(); return(')'); }
"[" { count(); return('['); }
"]" { count(); return(']'); }
")" { count(); return(')'); }
"[" { count(); return('['); }
"]" { count(); return(']'); }
static int check_type(void)
{
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);
}
strncpyz(yylval.yychar, yytext, SDCC_NAME_MAX);
return (TYPE_NAME);
}
/*
* Change by JTV 2001-05-19 to not concantenate strings
/*
* 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)
*/
static char *stringLiteral(void)
int currBlockno=0 ;
int inCritical= 0 ;
int seqPointNo= 1 ; /* sequence point number */
int currBlockno=0 ;
int inCritical= 0 ;
int seqPointNo= 1 ; /* sequence point number */
+int ignoreTypedefType=0;
extern int yylex();
int yyparse(void);
extern int noLineno ;
extern int yylex();
int yyparse(void);
extern int noLineno ;
value *cenum = NULL ; /* current enumeration type chain*/
bool uselessDecl = TRUE;
value *cenum = NULL ; /* current enumeration type chain*/
bool uselessDecl = TRUE;
blockNo=0;
}
| declaration {
blockNo=0;
}
| declaration {
if ($1 && $1->type
&& IS_FUNC($1->type))
{
if ($1 && $1->type
&& IS_FUNC($1->type))
{
: type_specifier2
| type_specifier2 AT constant_expr
{
: 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)) ;
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 ;
: CHAR {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_CHAR ;
}
| SHORT {
$$=newLink(SPECIFIER);
$$->select.s._short = 1 ;
}
| SHORT {
$$=newLink(SPECIFIER);
$$->select.s._short = 1 ;
}
| INT {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_INT ;
}
| INT {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_INT ;
}
| LONG {
$$=newLink(SPECIFIER);
SPEC_LONG($$) = 1 ;
}
| LONG {
$$=newLink(SPECIFIER);
SPEC_LONG($$) = 1 ;
}
| SIGNED {
$$=newLink(SPECIFIER);
$$->select.s._signed = 1;
}
| SIGNED {
$$=newLink(SPECIFIER);
$$->select.s._signed = 1;
}
| UNSIGNED {
$$=newLink(SPECIFIER);
SPEC_USIGN($$) = 1 ;
}
| UNSIGNED {
$$=newLink(SPECIFIER);
SPEC_USIGN($$) = 1 ;
}
| VOID {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_VOID ;
}
| VOID {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_VOID ;
}
| CONST {
$$=newLink(SPECIFIER);
}
| CONST {
$$=newLink(SPECIFIER);
| FLOAT {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_FLOAT;
| FLOAT {
$$=newLink(SPECIFIER);
SPEC_NOUN($$) = V_FLOAT;
}
| XDATA {
$$ = newLink (SPECIFIER);
}
| XDATA {
$$ = newLink (SPECIFIER);
SPEC_SCLS($$) = S_BIT ;
SPEC_BLEN($$) = 1;
SPEC_BSTR($$) = 0;
SPEC_SCLS($$) = S_BIT ;
SPEC_BLEN($$) = 1;
SPEC_BSTR($$) = 0;
}
| struct_or_union_specifier {
uselessDecl = FALSE;
$$ = $1 ;
}
| struct_or_union_specifier {
uselessDecl = FALSE;
$$ = $1 ;
}
| enum_specifier {
cenum = NULL ;
uselessDecl = FALSE;
}
| enum_specifier {
cenum = NULL ;
uselessDecl = FALSE;
sym = findSym(TypedefTab,NULL,$1) ;
$$ = p = copyLinkChain(sym->type);
SPEC_TYPEDEF(getSpec(p)) = 0;
sym = findSym(TypedefTab,NULL,$1) ;
$$ = p = copyLinkChain(sym->type);
SPEC_TYPEDEF(getSpec(p)) = 0;
$$ = newLink(SPECIFIER) ;
SPEC_NOUN($$) = V_SBIT;
SPEC_SCLS($$) = S_SBIT;
$$ = newLink(SPECIFIER) ;
SPEC_NOUN($$) = V_SBIT;
SPEC_SCLS($$) = S_SBIT;
SPEC_NOUN($$) = V_CHAR;
SPEC_SCLS($$) = S_SFR ;
SPEC_USIGN($$) = 1 ;
SPEC_NOUN($$) = V_CHAR;
SPEC_SCLS($$) = S_SFR ;
SPEC_USIGN($$) = 1 ;
}
| SFR BANKED {
$$ = newLink(SPECIFIER) ;
}
| SFR BANKED {
$$ = newLink(SPECIFIER) ;
SPEC_NOUN($$) = V_CHAR;
SPEC_SCLS($$) = S_SFR ;
SPEC_USIGN($$) = 1 ;
SPEC_NOUN($$) = V_CHAR;
SPEC_SCLS($$) = S_SFR ;
SPEC_USIGN($$) = 1 ;
/* make sure the type is complete and sane */
checkTypeSanity(sym->etype, sym->name);
}
/* make sure the type is complete and sane */
checkTypeSanity(sym->etype, sym->name);
}
+ ignoreTypedefType = 0;
+ $$ = $2;
function_declarator2
: declarator2 '(' ')' { addDecl ($1,FUNCTION,NULL) ; }
function_declarator2
: declarator2 '(' ')' { addDecl ($1,FUNCTION,NULL) ; }
- | declarator2 '(' { NestLevel++ ; currBlockno++; } parameter_type_list ')'
+ | declarator2 '(' { NestLevel++ ; currBlockno++; }
+ parameter_type_list ')'
{
addDecl ($1,FUNCTION,NULL) ;
{
addDecl ($1,FUNCTION,NULL) ;
- : parameter_declaration
+ : parameter_declaration
| parameter_list ',' parameter_declaration
{
$3->next = $1 ;
| parameter_list ',' parameter_declaration
{
$3->next = $1 ;
for (loop=$2;loop;loop->_isparm=1,loop=loop->next);
addSymChain ($2);
$$ = symbolVal($2);
for (loop=$2;loop;loop->_isparm=1,loop=loop->next);
addSymChain ($2);
$$ = symbolVal($2);
}
| type_name {
$$ = newValue() ;
$$->type = $1;
$$->etype = getSpec($$->type);
}
| type_name {
$$ = newValue() ;
$$->type = $1;
$$->etype = getSpec($$->type);
- : type_specifier_list { $$ = $1 ;}
+ : type_specifier_list { $$ = $1; ignoreTypedefType = 0;}
| type_specifier_list abstract_declarator
{
/* go to the end of the list */
| type_specifier_list abstract_declarator
{
/* go to the end of the list */
p->next = $1 ;
}
$$ = $2 ;
p->next = $1 ;
}
$$ = $2 ;
-start_block : '{' { STACK_PUSH(blockNum,currBlockno); currBlockno = ++blockNo ; }
+start_block : '{'
+ {
+ STACK_PUSH(blockNum,currBlockno);
+ currBlockno = ++blockNo ;
+ ignoreTypedefType = 0;
+ }
;
end_block : '}' { currBlockno = STACK_POP(blockNum); }
;
end_block : '}' { currBlockno = STACK_POP(blockNum); }
}
| declaration_list declaration
}
| declaration_list declaration