aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--lib.c3
-rw-r--r--scope.c7
-rw-r--r--scope.h1
3 files changed, 9 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index 3f753f06..525c64f6 100644
--- a/lib.c
+++ b/lib.c
@@ -677,9 +677,8 @@ struct symbol_list * __sparse(char **argv)
*argv++ = next;
} while (next);
- start_file_scope();
+ new_file_scope();
res = sparse_file(filename);
- end_file_scope();
/* Drop the tokens for this file after parsing */
clear_token_alloc();
diff --git a/scope.c b/scope.c
index 6b8b705b..3afab836 100644
--- a/scope.c
+++ b/scope.c
@@ -96,6 +96,13 @@ void end_file_scope(void)
end_scope(&file_scope);
}
+void new_file_scope(void)
+{
+ if (file_scope != &builtin_scope)
+ end_file_scope();
+ start_file_scope();
+}
+
void end_symbol_scope(void)
{
end_scope(&block_scope);
diff --git a/scope.h b/scope.h
index f120821d..ce430c8e 100644
--- a/scope.h
+++ b/scope.h
@@ -28,6 +28,7 @@ static inline int toplevel(struct scope *scope)
extern void start_file_scope(void);
extern void end_file_scope(void);
+extern void new_file_scope(void);
extern void start_symbol_scope(void);
extern void end_symbol_scope(void);