File tree 4 files changed +738
-755
lines changed
4 files changed +738
-755
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ void newio(void);
107
107
void newfile (char * , int );
108
108
Sym * slookup (char * );
109
109
Sym * lookup (void );
110
+ Sym * labellookup (Sym * );
110
111
void settext (LSym * );
111
112
void syminit (Sym * );
112
113
int32 yylex (void );
Original file line number Diff line number Diff line change @@ -41,15 +41,11 @@ prog:
41
41
| prog line
42
42
43
43
line :
44
- LLAB ' :'
45
- {
46
- if ($1 ->value != pc)
47
- yyerror (" redeclaration of %s" , $1 ->name);
48
- $1 ->value = pc;
49
- }
50
- line
51
44
| LNAME ' :'
52
45
{
46
+ $1 = labellookup($1 );
47
+ if ($1 ->type == LLAB && $1 ->value != pc)
48
+ yyerror (" redeclaration of %s" , $1 ->labelname);
53
49
$1 ->type = LLAB;
54
50
$1 ->value = pc;
55
51
}
@@ -435,15 +431,10 @@ rel:
435
431
}
436
432
| LNAME offset
437
433
{
434
+ $1 = labellookup($1 );
438
435
$$ = nullgen;
439
- if (pass == 2 )
440
- yyerror (" undefined label: %s" , $1 ->name);
441
- $$ .type = D_BRANCH;
442
- $$ .offset = $2 ;
443
- }
444
- | LLAB offset
445
- {
446
- $$ = nullgen;
436
+ if (pass == 2 && $1 ->type != LLAB)
437
+ yyerror (" undefined label: %s" , $1 ->labelname);
447
438
$$ .type = D_BRANCH;
448
439
$$ .offset = $1 ->value + $2 ;
449
440
}
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -186,15 +186,15 @@ extern int yydebug;
186
186
typedef union YYSTYPE YYSTYPE ;
187
187
union YYSTYPE
188
188
{
189
- #line 9 "a.y" /* yacc.c:1915 */
189
+ #line 9 "a.y" /* yacc.c:1909 */
190
190
191
191
Sym * sym ;
192
192
vlong lval ;
193
193
double dval ;
194
194
char sval [NSNAME ];
195
195
Addr addr ;
196
196
197
- #line 198 "y.tab.h" /* yacc.c:1915 */
197
+ #line 198 "y.tab.h" /* yacc.c:1909 */
198
198
};
199
199
# define YYSTYPE_IS_TRIVIAL 1
200
200
# define YYSTYPE_IS_DECLARED 1
You can’t perform that action at this time.
0 commit comments