aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/parse.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-05 20:21:52 +0100
committerChristopher Li <sparse@chrisli.org>2017-03-06 08:56:19 +0800
commitbdeaed12f95822474ebd113a50d2fb8138cc5d9a (patch)
tree4a0296fb9074d7b9c46e97a43b08272d531f5a1f /parse.c
parent44632081a3b54299e8899954efcd7133ef093259 (diff)
downloadsparse-dev-bdeaed12f95822474ebd113a50d2fb8138cc5d9a.tar.gz
move 'extern with initializer' validation after the validate method
Before the call to the method external_decl::validate_decl() there is another validation done which check if the declaration linkage is not external, otherwise an error is issued and the 'extern' is removed from the declaration. While also valid for C99 for-loop initializer, this is less desirable because in this context, 'extern' is invalid anyway and removing it from the declaration make it imposible to issue a diagnostic about it. Fix this by moving the 'extern with initializer' check after the call to validate_decl() method, where it is always pertinent and so allowing process_for_loop_decl() to make its own diagnostic. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/parse.c b/parse.c
index 6ec1bab9..80f0337c 100644
--- a/parse.c
+++ b/parse.c
@@ -2890,16 +2890,17 @@ struct token *external_declaration(struct token *token, struct symbol_list **lis
for (;;) {
if (!is_typedef && match_op(token, '=')) {
- if (decl->ctype.modifiers & MOD_EXTERN) {
- warning(decl->pos, "symbol with external linkage has initializer");
- decl->ctype.modifiers &= ~MOD_EXTERN;
- }
token = initializer(&decl->initializer, token->next);
}
if (!is_typedef) {
if (validate_decl)
validate_decl(decl);
+ if (decl->initializer && decl->ctype.modifiers & MOD_EXTERN) {
+ warning(decl->pos, "symbol with external linkage has initializer");
+ decl->ctype.modifiers &= ~MOD_EXTERN;
+ }
+
if (!(decl->ctype.modifiers & (MOD_EXTERN | MOD_INLINE))) {
add_symbol(list, decl);
fn_local_symbol(decl);