File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,18 @@ static list_t formal_type_list(list_t params, int pos)
7575
7676static void trans_funcs_decl (ast_decl_t decl )
7777{
78- list_t p ;
78+ list_t p , q ;
79+
80+ /* Check for function redefinitions. */
81+ for (p = decl -> u .funcs ; p && p -> next ; p = p -> next )
82+ for (q = p -> next ; q ; q = q -> next )
83+ {
84+ ast_func_t func = q -> data ;
85+ if (((ast_func_t ) p -> data )-> name == func -> name )
86+ em_error (func -> pos ,
87+ "function '%s' redefined" ,
88+ sym_name (func -> name ));
89+ }
7990
8091 /* Enter function prototypes into symbol table. */
8192 for (p = decl -> u .funcs ; p ; p = p -> next )
@@ -121,7 +132,16 @@ static void trans_funcs_decl(ast_decl_t decl)
121132
122133static void trans_types_decl (ast_decl_t decl )
123134{
124- list_t p ;
135+ list_t p , q ;
136+
137+ /* Check for type redefinitions. */
138+ for (p = decl -> u .types ; p && p -> next ; p = p -> next )
139+ for (q = p -> next ; q ; q = q -> next )
140+ {
141+ ast_nametype_t nt = q -> data ;
142+ if (((ast_nametype_t ) p -> data )-> name == nt -> name )
143+ em_error (decl -> pos , "type '%s' redefined" , sym_name (nt -> name ));
144+ }
125145
126146 /* Enter type placeholder into symbol table. */
127147 for (p = decl -> u .types ; p ; p = p -> next )
You can’t perform that action at this time.
0 commit comments