diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-02-28 18:54:37 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-01 16:29:22 +0200 |
| commit | 5c9b0ffbced524f4e8bdc586cf32db28a039cc83 (patch) | |
| tree | 43f8c16014e7b93e3a3d11081f8c40fda439fe0e /parse.c | |
| parent | 79d8848e79f0640ffdbcc24ab78eb2bc0bf8d068 (diff) | |
| download | sparse-dev-5c9b0ffbced524f4e8bdc586cf32db28a039cc83.tar.gz | |
fix: warn on typedef redefinition
check_duplicates() verifies that symbols are not redefined and
warns if they are.
However, this function is only called at evaluation-time and
then only for symbols corresponding to objects and functions.
So, typedefs can be redefined without any kind of diagnostic.
Fix this by calling check_duplicates() at parsing time on typedefs.
Note: this is C11's semantic or GCC's C89/C99 in non-pedantic mode.
Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -2888,6 +2888,10 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis if (decl->same_symbol) { decl->definition = decl->same_symbol->definition; decl->op = decl->same_symbol->op; + if (is_typedef) { + // TODO: handle -std=c89 --pedantic + check_duplicates(decl); + } } if (!match_op(token, ',')) |
