aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-08-02 17:23:23 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-08-02 17:23:23 -0700
commit89f32d3da8d281e826bf33c4c3efa7149654ea23 (patch)
treebf1cec49fa15e87f307dedb4c893b2f7c2f9b550 /scope.c
parentWhen dropping all allocations, clear the freelist too (diff)
downloadsparse-89f32d3da8d281e826bf33c4c3efa7149654ea23.tar.gz
sparse-89f32d3da8d281e826bf33c4c3efa7149654ea23.tar.bz2
sparse-89f32d3da8d281e826bf33c4c3efa7149654ea23.zip
Make macros have file scope
Also, macros are special: they can be removed out of scope with #undef, which makes them slightly more interesting when we exit the scope.
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/scope.c b/scope.c
index 9239bca..5305d03 100644
--- a/scope.c
+++ b/scope.c
@@ -10,6 +10,7 @@
*/
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include "lib.h"
#include "allocate.h"
@@ -64,8 +65,12 @@ static void remove_symbol_scope(struct symbol *sym)
{
struct symbol **ptr = sym->id_list;
- while (*ptr != sym)
+ while (*ptr != sym) {
+ /* Macros can get removed from scope early with #undef! */
+ if (!*ptr)
+ return;
ptr = &(*ptr)->next_id;
+ }
*ptr = sym->next_id;
}
@@ -82,6 +87,11 @@ static void end_scope(struct scope **s)
} END_FOR_EACH_PTR(sym);
}
+void end_file_scope(void)
+{
+ end_scope(&file_scope);
+}
+
void end_symbol_scope(void)
{
end_scope(&block_scope);