diff options
author | Joseph Myers <joseph@codesourcery.com> | 2005-04-20 17:41:48 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2005-04-20 17:41:48 +0100 |
commit | 187230a795716fc0d98cb066402fe9d71639996c (patch) | |
tree | e2e44d98a3c2439eda0265c0bce9ef5990fc410d /gcc/c-tree.h | |
parent | 2a9254314b416c9d6e8eccf600a54ed829a48147 (diff) | |
download | gcc-187230a795716fc0d98cb066402fe9d71639996c.zip gcc-187230a795716fc0d98cb066402fe9d71639996c.tar.gz gcc-187230a795716fc0d98cb066402fe9d71639996c.tar.bz2 |
re PR c/12913 (Jumps into variable length array scope not rejected)
PR c/12913
* c-tree.h (struct c_label_list): Update comment.
(struct c_label_context): Rename to struct c_label_context_se.
(label_context_stack): Rename to label_context_stack_se.
(C_DECL_UNJUMPABLE_VM, C_DECL_UNDEFINABLE_VM, struct
c_label_context_vm, label_context_stack_vm, c_begin_vm_scope,
c_end_vm_scope): New.
(C_DECL_DECLARED_BUILTIN, C_DECL_USED): Use FUNCTION_DECL_CHECK.
* c-decl.c (pop_scope): Call c_end_vm_scope.
(pushdecl): Call c_begin_vm_scope for variably modified
declarations.
(define_label): Check for jumping into scope of identifier with
variably modified type. Push label on stack for those defined at
current context of identifiers with variably modified type.
(start_function): Create stack level for context of identifiers
with variably modified type.
(finish_function): Pop stack level for context of identifiers with
variably modified type.
* c-typeck.c (label_context_stack): Rename to
label_context_stack_se.
(label_context_stack_vm, c_begin_vm_scope, c_end_vm_scope): New.
(c_finish_goto_label): Check for jumping into scope of identifier
with variably modified type. Push label on stack for those jumped
to from current context of identifiers with variably modified
type.
(struct c_switch): Add blocked_vm.
(c_start_case): Initialize blocked_vm.
(do_case): Check blocked_vm.
(c_finish_case): Add comment.
(c_begin_stmt_expr, c_finish_stmt_expr): Update for renamed
variable label_context_stack.
objc:
* objc-act.c (objc_start_function): Create stack level for context
of identifiers with variably modified type.
testsuite:
* gcc.dg/c99-vla-jump-1.c, gcc.dg/c99-vla-jump-2.c,
gcc.dg/c99-vla-jump-3.c, gcc.dg/c99-vla-jump-4.c,
gcc.dg/c99-vla-jump-5.c: New tests.
From-SVN: r98464
Diffstat (limited to 'gcc/c-tree.h')
-rw-r--r-- | gcc/c-tree.h | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/gcc/c-tree.h b/gcc/c-tree.h index c6e0ca9..c7cbd13 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -86,7 +86,8 @@ struct lang_type GTY(()) /* For FUNCTION_DECLs, evaluates true if the decl is built-in but has been declared. */ -#define C_DECL_DECLARED_BUILTIN(EXP) DECL_LANG_FLAG_3 (EXP) +#define C_DECL_DECLARED_BUILTIN(EXP) \ + DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (EXP)) /* Record whether a decl was declared register. This is strictly a front-end flag, whereas DECL_REGISTER is used for code generation; @@ -97,7 +98,7 @@ struct lang_type GTY(()) unevaluated operand of sizeof / typeof / alignof. This is only used for functions declared static but not defined, though outside sizeof and typeof it is set for other function decls as well. */ -#define C_DECL_USED(EXP) DECL_LANG_FLAG_5 (EXP) +#define C_DECL_USED(EXP) DECL_LANG_FLAG_5 (FUNCTION_DECL_CHECK (EXP)) /* Record whether a label was defined in a statement expression which has finished and so can no longer be jumped to. */ @@ -110,6 +111,18 @@ struct lang_type GTY(()) #define C_DECL_UNDEFINABLE_STMT_EXPR(EXP) \ DECL_LANG_FLAG_7 (LABEL_DECL_CHECK (EXP)) +/* Record whether a label was defined in the scope of an identifier + with variably modified type which has finished and so can no longer + be jumped to. */ +#define C_DECL_UNJUMPABLE_VM(EXP) \ + DECL_LANG_FLAG_3 (LABEL_DECL_CHECK (EXP)) + +/* Record whether a label was the subject of a goto from outside the + current level of scopes of identifiers with variably modified type + and so cannot be defined right now. */ +#define C_DECL_UNDEFINABLE_VM(EXP) \ + DECL_LANG_FLAG_5 (LABEL_DECL_CHECK (EXP)) + /* Nonzero for a decl which either doesn't exist or isn't a prototype. N.B. Could be simplified if all built-in decls had complete prototypes (but this is presently difficult because some of them need FILE*). */ @@ -354,8 +367,8 @@ struct language_function GTY(()) int extern_inline; }; -/* Save lists of labels used or defined in particular statement - expression contexts. Allocated on the parser obstack. */ +/* Save lists of labels used or defined in particular contexts. + Allocated on the parser obstack. */ struct c_label_list { @@ -365,14 +378,32 @@ struct c_label_list struct c_label_list *next; }; -struct c_label_context +/* Statement expression context. */ + +struct c_label_context_se +{ + /* The labels defined at this level of nesting. */ + struct c_label_list *labels_def; + /* The labels used at this level of nesting. */ + struct c_label_list *labels_used; + /* The next outermost context. */ + struct c_label_context_se *next; +}; + +/* Context of variably modified declarations. */ + +struct c_label_context_vm { /* The labels defined at this level of nesting. */ struct c_label_list *labels_def; /* The labels used at this level of nesting. */ struct c_label_list *labels_used; + /* The scope of this context. Multiple contexts may be at the same + numbered scope, since each variably modified declaration starts a + new context. */ + unsigned scope; /* The next outermost context. */ - struct c_label_context *next; + struct c_label_context_vm *next; }; @@ -477,7 +508,8 @@ extern int in_sizeof; extern int in_typeof; extern struct c_switch *c_switch_stack; -extern struct c_label_context *label_context_stack; +extern struct c_label_context_se *label_context_stack_se; +extern struct c_label_context_vm *label_context_stack_vm; extern tree require_complete_type (tree); extern int same_translation_unit_p (tree, tree); @@ -532,6 +564,8 @@ extern tree c_finish_return (tree); extern tree c_finish_bc_stmt (tree *, bool); extern tree c_finish_goto_label (tree); extern tree c_finish_goto_ptr (tree); +extern void c_begin_vm_scope (unsigned int); +extern void c_end_vm_scope (unsigned int); /* Set to 0 at beginning of a function definition, set to 1 if a return statement that specifies a return value is seen. */ |