Commit e1b7793c by Ian Lance Taylor Committed by Ian Lance Taylor

df-problems.c (df_simulate_one_insn_forwards): Fix braces in switch.

./:	* df-problems.c (df_simulate_one_insn_forwards): Fix braces in
	switch.
	* gcov.c (read_count_file): Add braces around variables declared
	before label.

	* c.opt (Wjump-misses-init): New warning.
	* c-opts.c (c_common_handle_option): Set warn_jump_misses_init for
	-Wall and -Wc++-compat if not already set.
	(c_common_post_options): Clear warn_jump_misses_init if it was not
	set.
	* c-decl.c (struct c_binding): Change type field to a union with
	new label field.  Make it the first field in the struct.  Update
	references to type to use u.type instead.
	(struct c_spot_bindings): Define.
	(struct c_goto_bindings): Define.
	(c_goto_bindings_p): Define, along with VECs.
	(struct c_label_vars): Define.
	(struct c_scope): Add has_label_bindings field.
	(bind_label, set_spot_bindings): New static functions.
	(decl_jump_unsafe, update_spot_bindings): New static functions.
	(update_label_decls): New static function.
	(pop_scope): Call update_label_decls.  Don't call c_end_vm_scope.
	Update binding u.label field to shadowed field.
	(c_binding_start_stmt_expr): New function.
	(c_binding_end_stmt_expr): New function.
	(pushdecl): Don't call c_begin_vm_scope.
	(make_label): Add defining and p_label_vars parameters.  Change
	all callers.
	(lookup_label): Correct test for whether a label has not yet been
	defined.  Call bind_label rather than bind.
	(warn_about_goto): New static function.
	(lookup_label_for_goto): New function.
	(declare_label): Call bind_label rather than bind.
	(check_earlier_gotos): New static function.
	(define_label): Don't give errors about jumping into statement
	expressions or scopes of variably modified types.  Call
	set_spot_bindings and check_earlier_gotos.  Call bind_label
	instead of bind.  Don't set label_context_stack_se or
	label_context_stack_vm.
	(c_get_switch_bindings): New function.
	(c_release_switch_bindings): New function.
	(c_check_switch_jump_warnings): New function.
	(start_function): Don't set label_context_stack_se or
	label_context_stack_vm.
	(finish_function): Likewise.
	* c-typeck.c (label_context_stack_se): Don't define.
	(label_context_stack_vm): Don't define.
	(c_finish_goto_label): Call lookup_label_for_goto rather than
	lookup_label.  Don't give errors about jumping into a statement
	expression or the scope of a variably modified type.  Don't set
	label_context_stack_se or label_context_stack_vm.
	(struct c_switch): Remove blocked_stmt_expr and blocked_vm
	fields.  Add bindings field.
	(c_start_case): Don't set deleted fields.  Set bindings field.
	(do_case): Rework order of tests.  Don't check blocked_stmt_expr
	or blocked_vm.  Call c_check_switch_jump_warnings.
	(c_finish_case): Don't test blocked_stmt_expr field.  Call
	c_release_switch_bindings.
	(c_begin_stmt_expr): Don't increment blocked_stmt_expr in
	c_switch_stack.  Don't walk label_context_stack_se labels.  Don't
	set label_context_stack_se.  Call c_bindings_start_stmt_expr.
	(c_finish_stmt_expr): Don't decrement blocked_stmt_expr in
	c_switch_stack.  Don't walk label_context_stack_se labels.  Don't
	set label_context_stack_se.  Call c_bindings_end_stmt_expr.
	(c_begin_vm_scope, c_end_vm_scope): Don't define.
	* c-tree.h (C_DECL_UNJUMPABLE_STMT_EXPR): Don't define.
	(C_DECL_UNDEFINABLE_STMT_EXPR): Don't define.
	(C_DECL_UNJUMPABLE_VM): Don't define.
	(C_DECL_UNDEFINABLE_VM): Don't define.
	(struct c_label_list): Don't define.
	(struct c_label_context_se): Don't define.
	(struct c_label_context_vm): Don't define.
	(struct c_spot_bindings): Declare.
	(c_bindings_start_stmt_expr): Declare.
	(c_bindings_end_stmt_expr): Declare.
	(lookup_label_for_goto): Declare.
	(c_get_switch_bindings, c_release_switch_bindings): Declare.
	(c_check_switch_jump_warnings): Declare.
	(label_context_stack_se, label_context_stack_vm): Don't declare.
	(c_finish_goto_label): Update declaration.
	(c_begin_vm_scope, c_end_vm_scope): Don't declare.
	* doc/invoke.texi (Option Summary): Mention -Wjump-misses-init.
	(Warning Options): Document -Wjump-misses-init.
cp/:
	* parser.c (cp_parser_direct_declarator): Add braces around
	variables declared before label.
objc/:
	* objc-act.c (objc_start_function): Don't set
	label_context_stack_se or label_context_stack_vm.
testsuite/:
	* gcc.dg/Wjump-misses-init-1.c: New testcase.
	* gcc.dg/Wjump-misses-init-2.c: New testcase.
	* gcc.dg/c99-vla-jump-5.c: Adjust expected error messages.
	Recognize new notes.
	* gcc.dg/stmt-expr-label-2.c: Likewise.
	* gcc.dg/c99-vla-jump-1.c: Recognize new notes.  Fix column
	numbers.
	* gcc.dg/c99-vla-jump-2.c: Recognize new notes.
	* gcc.dg/c99-vla-jump-3.c: Recognize new notes.
	* gcc.dg/c99-vla-jump-4.c: Likewise.
	* gcc.dg/stmt-expr-label-1.c: Likewise.
	* gcc.dg/stmt-expr-label-3.c: Likewise.
	* gcc.dg/vla-8.c: Likewise.  Move error message to different
	line.

From-SVN: r148512
parent dee6f575
2009-06-15 Ian Lance Taylor <iant@google.com>
* df-problems.c (df_simulate_one_insn_forwards): Fix braces in
switch.
* gcov.c (read_count_file): Add braces around variables declared
before label.
* c.opt (Wjump-misses-init): New warning.
* c-opts.c (c_common_handle_option): Set warn_jump_misses_init for
-Wall and -Wc++-compat if not already set.
(c_common_post_options): Clear warn_jump_misses_init if it was not
set.
* c-decl.c (struct c_binding): Change type field to a union with
new label field. Make it the first field in the struct. Update
references to type to use u.type instead.
(struct c_spot_bindings): Define.
(struct c_goto_bindings): Define.
(c_goto_bindings_p): Define, along with VECs.
(struct c_label_vars): Define.
(struct c_scope): Add has_label_bindings field.
(bind_label, set_spot_bindings): New static functions.
(decl_jump_unsafe, update_spot_bindings): New static functions.
(update_label_decls): New static function.
(pop_scope): Call update_label_decls. Don't call c_end_vm_scope.
Update binding u.label field to shadowed field.
(c_binding_start_stmt_expr): New function.
(c_binding_end_stmt_expr): New function.
(pushdecl): Don't call c_begin_vm_scope.
(make_label): Add defining and p_label_vars parameters. Change
all callers.
(lookup_label): Correct test for whether a label has not yet been
defined. Call bind_label rather than bind.
(warn_about_goto): New static function.
(lookup_label_for_goto): New function.
(declare_label): Call bind_label rather than bind.
(check_earlier_gotos): New static function.
(define_label): Don't give errors about jumping into statement
expressions or scopes of variably modified types. Call
set_spot_bindings and check_earlier_gotos. Call bind_label
instead of bind. Don't set label_context_stack_se or
label_context_stack_vm.
(c_get_switch_bindings): New function.
(c_release_switch_bindings): New function.
(c_check_switch_jump_warnings): New function.
(start_function): Don't set label_context_stack_se or
label_context_stack_vm.
(finish_function): Likewise.
* c-typeck.c (label_context_stack_se): Don't define.
(label_context_stack_vm): Don't define.
(c_finish_goto_label): Call lookup_label_for_goto rather than
lookup_label. Don't give errors about jumping into a statement
expression or the scope of a variably modified type. Don't set
label_context_stack_se or label_context_stack_vm.
(struct c_switch): Remove blocked_stmt_expr and blocked_vm
fields. Add bindings field.
(c_start_case): Don't set deleted fields. Set bindings field.
(do_case): Rework order of tests. Don't check blocked_stmt_expr
or blocked_vm. Call c_check_switch_jump_warnings.
(c_finish_case): Don't test blocked_stmt_expr field. Call
c_release_switch_bindings.
(c_begin_stmt_expr): Don't increment blocked_stmt_expr in
c_switch_stack. Don't walk label_context_stack_se labels. Don't
set label_context_stack_se. Call c_bindings_start_stmt_expr.
(c_finish_stmt_expr): Don't decrement blocked_stmt_expr in
c_switch_stack. Don't walk label_context_stack_se labels. Don't
set label_context_stack_se. Call c_bindings_end_stmt_expr.
(c_begin_vm_scope, c_end_vm_scope): Don't define.
* c-tree.h (C_DECL_UNJUMPABLE_STMT_EXPR): Don't define.
(C_DECL_UNDEFINABLE_STMT_EXPR): Don't define.
(C_DECL_UNJUMPABLE_VM): Don't define.
(C_DECL_UNDEFINABLE_VM): Don't define.
(struct c_label_list): Don't define.
(struct c_label_context_se): Don't define.
(struct c_label_context_vm): Don't define.
(struct c_spot_bindings): Declare.
(c_bindings_start_stmt_expr): Declare.
(c_bindings_end_stmt_expr): Declare.
(lookup_label_for_goto): Declare.
(c_get_switch_bindings, c_release_switch_bindings): Declare.
(c_check_switch_jump_warnings): Declare.
(label_context_stack_se, label_context_stack_vm): Don't declare.
(c_finish_goto_label): Update declaration.
(c_begin_vm_scope, c_end_vm_scope): Don't declare.
* doc/invoke.texi (Option Summary): Mention -Wjump-misses-init.
(Warning Options): Document -Wjump-misses-init.
2009-06-15 Jakub Jelinek <jakub@redhat.com>
* tree-object-size.c (addr_object_size): Fix a pasto in the last
......
......@@ -395,6 +395,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
warn_strict_overflow = value;
warn_array_bounds = value;
warn_volatile_register_var = value;
if (warn_jump_misses_init == -1)
warn_jump_misses_init = value;
/* Only warn about unknown pragmas that are not in system
headers. */
......@@ -445,6 +447,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
implies -Wenum-compare. */
if (warn_enum_compare == -1 && value)
warn_enum_compare = value;
/* Because C++ always warns about a goto which misses an
initialization, -Wc++-compat turns on -Wgoto-misses-init. */
if (warn_jump_misses_init == -1 && value)
warn_jump_misses_init = value;
cpp_opts->warn_cxx_operator_names = value;
break;
......@@ -1084,6 +1090,8 @@ c_common_post_options (const char **pfilename)
warn_strict_aliasing = 0;
if (warn_strict_overflow == -1)
warn_strict_overflow = 0;
if (warn_jump_misses_init == -1)
warn_jump_misses_init = 0;
/* -Woverlength-strings is off by default, but is enabled by -pedantic.
It is never enabled in C++, as the minimum limit is not normative
......
......@@ -108,29 +108,6 @@ struct GTY(()) lang_type {
sizeof and typeof it is set for other function decls as well. */
#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. */
#define C_DECL_UNJUMPABLE_STMT_EXPR(EXP) \
DECL_LANG_FLAG_6 (LABEL_DECL_CHECK (EXP))
/* Record whether a label was the subject of a goto from outside the
current level of statement expression nesting and so cannot be
defined right now. */
#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))
/* Record whether a variable has been declared threadprivate by
#pragma omp threadprivate. */
#define C_DECL_THREADPRIVATE_P(DECL) DECL_LANG_FLAG_3 (VAR_DECL_CHECK (DECL))
......@@ -421,45 +398,6 @@ struct GTY(()) language_function {
int warn_about_return_type;
};
/* Save lists of labels used or defined in particular contexts.
Allocated on the parser obstack. */
struct c_label_list
{
/* The label at the head of the list. */
tree label;
/* The rest of the list. */
struct c_label_list *next;
};
/* 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_vm *next;
};
/* Used when parsing an enum. Initialized by start_enum. */
struct c_enum_contents
{
......@@ -491,6 +429,7 @@ extern void c_parse_init (void);
extern void gen_aux_info_record (tree, int, int, int);
/* in c-decl.c */
struct c_spot_bindings;
extern struct obstack parser_obstack;
extern tree c_break_label;
extern tree c_cont_label;
......@@ -498,6 +437,8 @@ extern tree c_cont_label;
extern int global_bindings_p (void);
extern void push_scope (void);
extern tree pop_scope (void);
extern void c_bindings_start_stmt_expr (struct c_spot_bindings *);
extern void c_bindings_end_stmt_expr (struct c_spot_bindings *);
extern void record_inline_static (location_t, tree, tree,
enum c_inline_static_type);
......@@ -513,8 +454,13 @@ extern tree check_for_loop_decls (location_t);
extern void mark_forward_parm_decls (void);
extern void declare_parm_level (void);
extern void undeclared_variable (location_t, tree);
extern tree lookup_label_for_goto (location_t, tree);
extern tree declare_label (tree);
extern tree define_label (location_t, tree);
extern struct c_spot_bindings *c_get_switch_bindings (void);
extern void c_release_switch_bindings (struct c_spot_bindings *);
extern bool c_check_switch_jump_warnings (struct c_spot_bindings *,
location_t, location_t);
extern void c_maybe_initialize_eh (void);
extern void finish_decl (tree, location_t, tree, tree, tree);
extern tree finish_enum (tree, tree, tree);
......@@ -583,8 +529,6 @@ extern int in_sizeof;
extern int in_typeof;
extern struct c_switch *c_switch_stack;
extern struct c_label_context_se *label_context_stack_se;
extern struct c_label_context_vm *label_context_stack_vm;
extern tree c_objc_common_truthvalue_conversion (location_t, tree);
extern tree require_complete_type (tree);
......@@ -643,8 +587,6 @@ extern tree c_finish_return (location_t, tree, tree);
extern tree c_finish_bc_stmt (location_t, tree *, bool);
extern tree c_finish_goto_label (location_t, tree);
extern tree c_finish_goto_ptr (location_t, tree);
extern void c_begin_vm_scope (unsigned int);
extern void c_end_vm_scope (unsigned int);
extern tree c_expr_to_decl (tree, bool *, bool *);
extern tree c_begin_omp_parallel (void);
extern tree c_finish_omp_parallel (location_t, tree, tree);
......
......@@ -284,6 +284,10 @@ Winvalid-pch
C ObjC C++ ObjC++ Warning
Warn about PCH files that are found but not used
Wjump-misses-init
C Objc Var(warn_jump_misses_init) Init(-1) Warning
Warn when a jump misses a variable initialization
Wlogical-op
C ObjC C++ ObjC++ Var(warn_logical_op) Init(0) Warning
Warn when a logical operator is suspiciously always evaluating to true or false
......
2009-06-15 Ian Lance Taylor <iant@google.com>
* parser.c (cp_parser_direct_declarator): Add braces around
variables declared before label.
2009-06-15 Rafael Avila de Espindola <espindola@google.com>
* cp-objcp-common.h (LANG_HOOKS_COMDAT_GROUP): Remove.
......
......@@ -3912,19 +3912,21 @@ df_simulate_one_insn_forwards (basic_block bb, rtx insn, bitmap live)
for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
{
switch (REG_NOTE_KIND (link))
{
case REG_DEAD:
case REG_UNUSED:
{
rtx reg = XEXP (link, 0);
int regno = REGNO (reg);
if (regno < FIRST_PSEUDO_REGISTER)
{
int n = hard_regno_nregs[regno][GET_MODE (reg)];
while (--n >= 0)
bitmap_clear_bit (live, regno + n);
}
else
bitmap_clear_bit (live, regno);
{
rtx reg = XEXP (link, 0);
int regno = REGNO (reg);
if (regno < FIRST_PSEUDO_REGISTER)
{
int n = hard_regno_nregs[regno][GET_MODE (reg)];
while (--n >= 0)
bitmap_clear_bit (live, regno + n);
}
else
bitmap_clear_bit (live, regno);
}
break;
default:
break;
......
......@@ -238,7 +238,7 @@ Objective-C and Objective-C++ Dialects}.
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
-Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
-Wformat-security -Wformat-y2k @gol
-Wframe-larger-than=@var{len} -Wignored-qualifiers @gol
-Wframe-larger-than=@var{len} -Wjump-misses-init -Wignored-qualifiers @gol
-Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol
-Winit-self -Winline @gol
-Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
......@@ -2973,6 +2973,20 @@ requiring a non-null value by the @code{nonnull} function attribute.
@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
can be disabled with the @option{-Wno-nonnull} option.
@item -Wjump-misses-init @r{(C, Objective-C only)}
@opindex Wjump-misses-init
@opindex Wno-jump-misses-init
Warn if a @code{goto} statement or a @code{switch} statement jumps
forward across the initialization of a variable, or jumps backward to a
label after the variable has been initialized. This only warns about
variables which are initialized when they are declared. This warning is
only supported for C and Objective C; in C++ this sort of branch is an
error in any case.
@option{-Wjump-misses-init} is included in @option{-Wall} and
@option{-Wc++-compat}. It can be disabled with the
@option{-Wno-jump-misses-init} option.
@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
@opindex Winit-self
@opindex Wno-init-self
......
......@@ -1065,27 +1065,29 @@ read_count_file (void)
program_count++;
else if (tag == GCOV_TAG_FUNCTION)
{
unsigned ident = gcov_read_unsigned ();
struct function_info *fn_n = functions;
{
unsigned ident = gcov_read_unsigned ();
struct function_info *fn_n = functions;
/* Try to find the function in the list.
To speed up the search, first start from the last function
found. */
for (fn = fn ? fn->next : NULL; ; fn = fn->next)
{
if (fn)
;
else if ((fn = fn_n))
fn_n = NULL;
else
{
fnotice (stderr, "%s:unknown function '%u'\n",
da_file_name, ident);
/* Try to find the function in the list.
To speed up the search, first start from the last function
found. */
for (fn = fn ? fn->next : NULL; ; fn = fn->next)
{
if (fn)
;
else if ((fn = fn_n))
fn_n = NULL;
else
{
fnotice (stderr, "%s:unknown function '%u'\n",
da_file_name, ident);
break;
}
if (fn->ident == ident)
break;
}
if (fn->ident == ident)
break;
}
}
}
if (!fn)
;
......
2009-06-15 Ian Lance Taylor <iant@google.com>
* objc-act.c (objc_start_function): Don't set
label_context_stack_se or label_context_stack_vm.
2009-06-12 Aldy Hernandez <aldyh@redhat.com>
* objc-act.c (finish_var_decl): Pass location to finish_decl.
......
......@@ -8632,19 +8632,6 @@ objc_start_function (tree name, tree type, tree attrs,
cplus_decl_attributes (&fndecl, attrs, 0);
start_preparsed_function (fndecl, attrs, /*flags=*/SF_DEFAULT);
#else
struct c_label_context_se *nstack_se;
struct c_label_context_vm *nstack_vm;
nstack_se = XOBNEW (&parser_obstack, struct c_label_context_se);
nstack_se->labels_def = NULL;
nstack_se->labels_used = NULL;
nstack_se->next = label_context_stack_se;
label_context_stack_se = nstack_se;
nstack_vm = XOBNEW (&parser_obstack, struct c_label_context_vm);
nstack_vm->labels_def = NULL;
nstack_vm->labels_used = NULL;
nstack_vm->scope = 0;
nstack_vm->next = label_context_stack_vm;
label_context_stack_vm = nstack_vm;
current_function_returns_value = 0; /* Assume, until we see it does. */
current_function_returns_null = 0;
......
2009-06-15 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wjump-misses-init-1.c: New testcase.
* gcc.dg/Wjump-misses-init-2.c: New testcase.
* gcc.dg/c99-vla-jump-5.c: Adjust expected error messages.
Recognize new notes.
* gcc.dg/stmt-expr-label-2.c: Likewise.
* gcc.dg/c99-vla-jump-1.c: Recognize new notes. Fix column
numbers.
* gcc.dg/c99-vla-jump-2.c: Recognize new notes.
* gcc.dg/c99-vla-jump-3.c: Recognize new notes.
* gcc.dg/c99-vla-jump-4.c: Likewise.
* gcc.dg/stmt-expr-label-1.c: Likewise.
* gcc.dg/stmt-expr-label-3.c: Likewise.
* gcc.dg/vla-8.c: Likewise. Move error message to different
line.
2009-06-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-math-6.c: Robustify and fix clog cases.
......
/* { dg-do compile } */
/* { dg-options "-Wjump-misses-init" } */
int
f1 (int a)
{
if (a > 0)
{
int i = 7; /* { dg-message "here" } */
lab: /* { dg-message "here" } */
return a;
}
else
{
if (a < 0)
goto lab; /* { dg-warning "jump" } */
return 1;
}
}
int
f2 (int a)
{
if (a > 0)
{
if (a < 0)
goto lab; /* { dg-warning "jump" } */
return 1;
}
else
{
int i = 7; /* { dg-message "here" } */
lab: /* { dg-message "here" } */
return a;
}
}
int
f3 (int a)
{
if (a > 0)
{
static int i = 7;
lab:
return a;
}
else
{
if (a < 0)
goto lab;
return 1;
}
}
int
f4 (int a)
{
if (a > 0)
{
if (a < 0)
goto lab;
return 1;
}
else
{
static int i = 7;
lab:
return a;
}
}
int
f5 (int a)
{
if (a > 0)
{
int b = 1;
if (a < 0)
goto lab;
}
lab:
return a;
}
int
f6 (int a)
{
if (a > 0)
{
lab:
return a;
}
else
{
int b = 1;
goto lab;
}
}
int
f7 (int a)
{
switch (a) /* { dg-message "switch" } */
{
int b = 1; /* { dg-message "here" } */
case 1: /* { dg-warning "jump" } */
return a;
}
}
int
f8 (int a)
{
switch (a) /* { dg-message "switch" } */
{
int b = 1; /* { dg-message "here" } */
case 1: /* { dg-warning "jump" } */
goto lab;
}
lab:
return a;
}
int
f9 (int a)
{
switch (a)
{
case 0:
{
int b = 1;
return b;
}
case 1:
return a;
}
}
int
f10 (int a)
{
switch (a)
{
case 0:
{
int b = 1;
goto lab;
}
case 1:
goto lab;
}
lab:
return a;
}
/* { dg-do compile } */
/* { dg-options "-Wjump-misses-init -std=c99" } */
extern void f1 ();
int
f2 (int a)
{
switch (a) /* { dg-message "switch" } */
{
case 1:
f1 ();
int v2 = 3; /* { dg-message "here" } */
case 2: /* { dg-warning "jump" } */
if (v2 == 7)
f1 ();
}
return 0;
}
int
f3 (int i)
{
if (i)
goto bad; /* { dg-warning "jump" } */
int a = f2 (i); /* { dg-message "here" } */
bad: /* { dg-message "here" } */
return a;
}
int
f4 (int a)
{
switch (a)
{
case 1:
f1 ();
static int v2 = 3;
case 2:
if (v2 == 7)
f1 ();
}
return 0;
}
int
f5 (int i)
{
if (i)
goto bad;
static int a = 6;
bad:
return a;
}
......@@ -15,11 +15,11 @@
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
void fa0 (int n) { goto a; a:{ int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; }
void fa1 (int n) { goto a; { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "41:jump into scope of identifier with variably modified type" } */
void fa2 (int n) { goto a; { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "53:jump into scope of identifier with variably modified type" } */
void fa3 (int n) { goto a; { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "57:jump into scope of identifier with variably modified type" } */
void fa4 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "69:jump into scope of identifier with variably modified type" } */
void fa5 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "73:jump into scope of identifier with variably modified type" } */
void fa1 (int n) { goto a; { int b[n]; a:{ int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */
void fa2 (int n) { goto a; { int b[n]; { int c[n]; a:0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */
void fa3 (int n) { goto a; { int b[n]; { int c[n]; 0;} a:{ int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */
void fa4 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; a:0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */
void fa5 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} a:; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "21:jump into scope of identifier with variably modified type" } */
void fa6 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; a:0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
void fa7 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; a:{ int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; }
void fa8 (int n) { goto a; { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; a:{ int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0; } /* { dg-error "jump into scope of identifier with variably modified type" } */
......@@ -303,3 +303,7 @@ void fa285 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}
void fa286 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; a:; int j[n]; 0; goto a; }
void fa287 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; a:0; goto a; }
void fa288 (int n) { { int b[n]; { int c[n]; 0;} { int d[n]; 0;} ; int e[n]; 0;}; { int f[n]; { int g[n]; 0;}; { int h[n]; 0;}; ; int i[n]; 0;}; ; int j[n]; 0;a: goto a; }
/* Match extra informative notes. */
/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */
/* { dg-message "note: '\[^\n'\]*' declared here" "note: expected" { target *-*-* } 0 } */
......@@ -303,3 +303,7 @@ void fb285 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:g
void fb286 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; a:; int j[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; }
void fb287 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; a:0;p03B:goto p03B; goto a; P03B:goto P03B; }
void fb288 (int n) { P0A:goto P0A;{ int b[n]; P01A:goto P01A;{ int c[n]; P012A:goto P012A;0;} P01B:goto P01B;{ int d[n]; P013A:goto P013A;0;} P01C:goto P01C;; int e[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ int f[n]; P02A:goto P02A;{ int g[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ int h[n]; P025A:goto P025A;0;}; P02C:goto P02C;; int i[n]; P026A:goto P026A;0;}; P0C:goto P0C;; int j[n]; P03A:goto P03A;0;a: goto a; P03B:goto P03B; }
/* Match extra informative notes. */
/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */
/* { dg-message "note: '\[^\n'\]*' declared here" "note: expected" { target *-*-* } 0 } */
......@@ -303,3 +303,7 @@ void fc285 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef
void fc286 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; a:; typedef int (*j)[n]; 0; goto a; }
void fc287 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; a:0; goto a; }
void fc288 (int n) { { typedef int (*b)[n]; { typedef int (*c)[n]; 0;} { typedef int (*d)[n]; 0;} ; typedef int (*e)[n]; 0;}; { typedef int (*f)[n]; { typedef int (*g)[n]; 0;}; { typedef int (*h)[n]; 0;}; ; typedef int (*i)[n]; 0;}; ; typedef int (*j)[n]; 0;a: goto a; }
/* Match extra informative notes. */
/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */
/* { dg-message "note: '\[^\n'\]*' declared here" "note: expected" { target *-*-* } 0 } */
......@@ -303,3 +303,7 @@ void fd285 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typede
void fd286 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; a:; typedef int (*j)[n]; P03A:goto P03A;0;p03B:goto p03B; goto a; P03B:goto P03B; }
void fd287 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; a:0;p03B:goto p03B; goto a; P03B:goto P03B; }
void fd288 (int n) { P0A:goto P0A;{ typedef int (*b)[n]; P01A:goto P01A;{ typedef int (*c)[n]; P012A:goto P012A;0;} P01B:goto P01B;{ typedef int (*d)[n]; P013A:goto P013A;0;} P01C:goto P01C;; typedef int (*e)[n]; P014A:goto P014A;0;}; P0B:goto P0B;{ typedef int (*f)[n]; P02A:goto P02A;{ typedef int (*g)[n]; P024A:goto P024A;0;}; P02B:goto P02B;{ typedef int (*h)[n]; P025A:goto P025A;0;}; P02C:goto P02C;; typedef int (*i)[n]; P026A:goto P026A;0;}; P0C:goto P0C;; typedef int (*j)[n]; P03A:goto P03A;0;a: goto a; P03B:goto P03B; }
/* Match extra informative notes. */
/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */
/* { dg-message "note: '\[^\n'\]*' declared here" "note: expected" { target *-*-* } 0 } */
......@@ -16,8 +16,8 @@ f (int a, int b)
{
switch (a) {
int v[b];
case 2: /* { dg-error "case label in scope of identifier with variably modified type not containing enclosing switch statement" } */
default: /* { dg-error "'default' label in scope of identifier with variably modified type not containing enclosing switch statement" } */
case 2: /* { dg-error "switch jumps into scope of identifier with variably modified type" } */
default: /* { dg-error "switch jumps into scope of identifier with variably modified type" } */
switch (a)
{
case 4:
......@@ -28,3 +28,7 @@ f (int a, int b)
}
}
}
/* Match extra informative notes. */
/* { dg-message "note: switch starts here" "note: expected" { target *-*-* } 0 } */
/* { dg-message "note: '\[^\n'\]*' declared here" "note: expected" { target *-*-* } 0 } */
......@@ -402,3 +402,6 @@ void f194 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); a:0; goto a
void fa194 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); a:0;p0D:goto p0D; goto a; P0D:goto P0D; }
void f195 (void) { ({ ({0;}); ({0;}); 0;}); ({ ({0;}); ({0;}); 0;}); 0;a: goto a; }
void fa195 (void) { P0A:goto P0A;({ P01A:goto P01A;({P012A:goto P012A;0;}); P01B:goto P01B;({P013A:goto P013A;0;}); P01C:goto P01C;0;}); P0B:goto P0B;({ P02A:goto P02A;({P024A:goto P024A;0;}); P02B:goto P02B;({P025A:goto P025A;0;}); P02C:goto P02C;0;}); P0C:goto P0C;0;a: goto a; P0D:goto P0D; }
/* Match extra informative notes. */
/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */
......@@ -8,13 +8,13 @@
void
f (int a)
{
switch (a)
switch (a) /* { dg-message "here" } */
{
case 0:
case 1:
({
case 2: /* { dg-error "case label in statement expression not containing enclosing switch statement" } */
default: /* { dg-error "'default' label in statement expression not containing enclosing switch statement" } */
case 2: /* { dg-error "switch jumps into statement expression" } */
default: /* { dg-error "switch jumps into statement expression" } */
switch (a)
{
case 3:
......
......@@ -6,3 +6,6 @@
/* { dg-options "-O2" } */
void f(void) { 1 ? 1 : ({ a : 1; 1; }); goto a; } /* { dg-error "jump into statement expression" } */
/* Match extra informative notes. */
/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */
......@@ -23,8 +23,12 @@ void foo1(int n) {
}
void foo2(int n) {
goto A;
goto A; /* { dg-error "jump into scope of identifier with variably modified type" } */
int (*(*bar2)(void))[n];
A: /* { dg-error "jump into scope of identifier with variably modified type" } */
A:
;
}
/* Match extra informative notes. */
/* { dg-message "note: label '\[^\n'\]*' defined here" "note: expected" { target *-*-* } 0 } */
/* { dg-message "note: '\[^\n'\]*' declared here" "note: expected" { target *-*-* } 0 } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment