aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scope.c
diff options
authorChristopher Li <sparse@chrisli.org>2014-08-02 10:56:59 -0700
committerChristopher Li <sparse@chrisli.org>2014-08-02 10:56:59 -0700
commit7abd8a76b4e07ad60b5262e4c7858e638467fab8 (patch)
tree125c872e01e31fcd0a5f90e8cd2f9512016000bf /scope.c
parent748b856ed3e7b63faed20ed6f64dfb12371e3cf3 (diff)
downloadsparse-dev-7abd8a76b4e07ad60b5262e4c7858e638467fab8.tar.gz
Make same_symbol list share the same scope
Consider the following case, extern inline declare after extern declare of the same function. extern int g(int); extern __inline__ int g(int x) { return x; } Sparse will give the first function global scope and the second one file scope. Also the first one will get the function body from the second one. That cause the failure of the validation/extern-inlien.c This change rebind the scope of the same_symbol chain to the new scope. It will pass the extern-inline.c test case. Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/scope.c b/scope.c
index b415ace9..cbf2fcf5 100644
--- a/scope.c
+++ b/scope.c
@@ -46,6 +46,20 @@ void bind_scope(struct symbol *sym, struct scope *scope)
add_symbol(&scope->symbols, sym);
}
+
+void rebind_scope(struct symbol *sym, struct scope *new)
+{
+ struct scope *old = sym->scope;
+
+ if (old == new)
+ return;
+
+ if (old)
+ delete_ptr_list_entry((struct ptr_list**) &old->symbols, sym, 1);
+
+ bind_scope(sym, new);
+}
+
static void start_scope(struct scope **s)
{
struct scope *scope = __alloc_scope(0);