@@ -158,9 +158,9 @@ struct, union, enum names should not overlap with each other.
158158int conflict_identifier_register_lut [6 ][6 ] = {
159159 {1 , 1 , 0 , 0 , 0 , 1 }, // variable
160160 {1 , 1 , 0 , 0 , 0 , 1 }, // enumerator
161- {0 , 0 , 1 , 1 , 1 , 0 }, // struct
162- {0 , 0 , 1 , 1 , 1 , 0 }, // union
163- {0 , 0 , 1 , 1 , 1 , 0 }, // enum
161+ {0 , 0 , 0 , 1 , 1 , 0 }, // struct
162+ {0 , 0 , 1 , 0 , 1 , 0 }, // union
163+ {0 , 0 , 1 , 1 , 0 , 0 }, // enum
164164 {1 , 1 , 0 , 0 , 0 , 1 }, // typedef
165165};
166166
@@ -271,7 +271,15 @@ void check_identifier_in_table(char* name, enum IdentifierType using_type, struc
271271 printf ("Warning: (Line %d) Identifier %s is not registered as %s\n" , yylineno , name , description );
272272 for (int i = 0 ; i < IDENT_TYPE_COUNT ; i ++ ) {
273273 if (info -> flags & (1 << i )) {
274- pdebug (" - Identifier %s is registered as %s at line %d\n" , name , identifier_type_str [i ], info -> lineno [i ]);
274+ printf (" - Identifier %s is registered as %s at line %d\n" , name , identifier_type_str [i ], info -> lineno [i ]);
275+ if (using_type == IDENT_TYPE_TYPEDEF &&
276+ (i == IDENT_TYPE_STRUCT || i == IDENT_TYPE_UNION ||
277+ i == IDENT_TYPE_ENUM )) {
278+ // e.g. Got `Foo foo` but `Foo` is registered as struct.
279+ // Suggest to use `struct Foo foo` instead.
280+ printf (" - Maybe you want to use %s %s instead of %s\n" ,
281+ identifier_type_str [i ], name , name );
282+ }
275283 }
276284 }
277285 }
0 commit comments