From f4d8234688c60bed83a3549072ac1709d942cdcf Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 13 Apr 2020 14:09:35 -0700 Subject: [PATCH 2/3] Rename 'function' scope as 'label' scope The only thing that was scoped this way were labels. And 'function' scope will soon be a mis-namer. --- parse.c | 4 ++-- scope.c | 14 +++++++------- scope.h | 6 +++--- symbol.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/parse.c b/parse.c index 9d11309e..64aaf07b 100644 --- a/parse.c +++ b/parse.c @@ -2245,7 +2245,7 @@ static struct statement *start_function(struct symbol *sym) struct symbol *ret; struct statement *stmt = alloc_statement(sym->pos, STMT_COMPOUND); - start_function_scope(); + start_label_scope(); ret = alloc_symbol(sym->pos, SYM_NODE); ret->ctype = sym->ctype.base_type->ctype; ret->ctype.modifiers &= ~(MOD_STORAGE | MOD_QUALIFIER | MOD_TLS | MOD_ACCESS | MOD_NOCAST | MOD_NODEREF); @@ -2263,7 +2263,7 @@ static struct statement *start_function(struct symbol *sym) static void end_function(struct symbol *sym) { current_fn = NULL; - end_function_scope(); + end_label_scope(); } /* diff --git a/scope.c b/scope.c index a0de2e0d..8df9a5e0 100644 --- a/scope.c +++ b/scope.c @@ -35,8 +35,8 @@ static struct scope builtin_scope = { .next = &builtin_scope }; -struct scope *block_scope = &builtin_scope, // regular automatic variables etc - *function_scope = &builtin_scope, // labels, arguments etc +struct scope *block_scope = &builtin_scope, // regular variables etc + *label_scope = &builtin_scope, // labels *file_scope = &builtin_scope, // static *global_scope = &builtin_scope; // externally visible @@ -82,7 +82,7 @@ void start_file_scope(void) file_scope = scope; /* top-level stuff defaults to file scope, "extern" etc will choose global scope */ - function_scope = scope; + label_scope = scope; block_scope = scope; } @@ -91,9 +91,9 @@ void start_block_scope(void) start_scope(&block_scope); } -void start_function_scope(void) +void start_label_scope(void) { - start_scope(&function_scope); + start_scope(&label_scope); start_scope(&block_scope); } @@ -136,10 +136,10 @@ void end_block_scope(void) end_scope(&block_scope); } -void end_function_scope(void) +void end_label_scope(void) { end_scope(&block_scope); - end_scope(&function_scope); + end_scope(&label_scope); } int is_outer_scope(struct scope *scope) diff --git a/scope.h b/scope.h index 83741459..e7c5ba05 100644 --- a/scope.h +++ b/scope.h @@ -34,7 +34,7 @@ struct scope { extern struct scope *block_scope, - *function_scope, + *label_scope, *file_scope, *global_scope; @@ -50,8 +50,8 @@ extern void new_file_scope(void); extern void start_block_scope(void); extern void end_block_scope(void); -extern void start_function_scope(void); -extern void end_function_scope(void); +extern void start_label_scope(void); +extern void end_label_scope(void); extern void set_current_scope(struct symbol *); extern void bind_scope(struct symbol *, struct scope *); diff --git a/symbol.c b/symbol.c index c2e6f0b4..c3ded5ef 100644 --- a/symbol.c +++ b/symbol.c @@ -707,7 +707,7 @@ void bind_symbol(struct symbol *sym, struct ident *ident, enum namespace ns) if (ns == NS_MACRO) scope = file_scope; if (ns == NS_LABEL) - scope = function_scope; + scope = label_scope; bind_scope(sym, scope); } -- 2.24.0.158.g3fed155289