Commit b295aee2 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/36489 (Warning "initialized field overwritten" wrongly triggers with…

re PR c/36489 (Warning "initialized field overwritten" wrongly triggers with multidimensional arrays)

	PR c/36489
	* c-typeck.c (add_pending_init): Add IMPLICIT argument.  Only
	warn about overwriting initializer with side-effects or
	-Woverride-init if !IMPLICIT.
	(output_init_element): Likewise.  Pass IMPLICIT down to
	add_pending_init.
	(process_init_element): Add IMPLICIT argument.  Pass it down
	to output_init_element.
	(push_init_element, pop_init_level, set_designator): Adjust
	process_init_element callers.
	(set_nonincremental_init, set_nonincremental_init_from_string):
	Adjust add_pending_init callers.
	(output_pending_init_elements): Adjust output_init_element callers.
	* c-tree.h (process_init_element): Adjust prototype.
	* c-parser.c (c_parser_initelt, c_parser_initval): Adjust
	process_init_element callers.

	* gcc.dg/pr36489.c: New test.

From-SVN: r142998
parent 91a96b33
2009-01-01 Jakub Jelinek <jakub@redhat.com>
PR c/36489
* c-typeck.c (add_pending_init): Add IMPLICIT argument. Only
warn about overwriting initializer with side-effects or
-Woverride-init if !IMPLICIT.
(output_init_element): Likewise. Pass IMPLICIT down to
add_pending_init.
(process_init_element): Add IMPLICIT argument. Pass it down
to output_init_element.
(push_init_element, pop_init_level, set_designator): Adjust
process_init_element callers.
(set_nonincremental_init, set_nonincremental_init_from_string):
Adjust add_pending_init callers.
(output_pending_init_elements): Adjust output_init_element callers.
* c-tree.h (process_init_element): Adjust prototype.
* c-parser.c (c_parser_initelt, c_parser_initval): Adjust
process_init_element callers.
2008-12-31 Uros Bizjak <ubizjak@gmail.com>
* sched-deps.c (sched_analyze_2) [UNSPEC_VOLATILE]: Flush pending
/* Parser for C and Objective-C.
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
Free Software Foundation, Inc.
Parser actions based on the old Bison parser; structure somewhat
......@@ -3090,7 +3090,7 @@ c_parser_initelt (c_parser *parser)
init.original_code = ERROR_MARK;
c_parser_error (parser, "expected identifier");
c_parser_skip_until_found (parser, CPP_COMMA, NULL);
process_init_element (init);
process_init_element (init, false);
return;
}
}
......@@ -3213,7 +3213,7 @@ c_parser_initelt (c_parser *parser)
init.original_code = ERROR_MARK;
c_parser_error (parser, "expected %<=%>");
c_parser_skip_until_found (parser, CPP_COMMA, NULL);
process_init_element (init);
process_init_element (init, false);
return;
}
}
......@@ -3243,7 +3243,7 @@ c_parser_initval (c_parser *parser, struct c_expr *after)
&& TREE_CODE (init.value) != COMPOUND_LITERAL_EXPR)
init = default_function_array_conversion (init);
}
process_init_element (init);
process_init_element (init, false);
}
/* Parse a compound statement (possibly a function body) (C90 6.6.2,
......
/* Definitions for C parsing and type checking.
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009
Free Software Foundation, Inc.
This file is part of GCC.
......@@ -575,7 +576,7 @@ extern void push_init_level (int);
extern struct c_expr pop_init_level (int);
extern void set_init_index (tree, tree);
extern void set_init_label (tree);
extern void process_init_element (struct c_expr);
extern void process_init_element (struct c_expr, bool);
extern tree build_compound_literal (tree, tree);
extern tree c_start_case (tree);
extern void c_finish_case (tree);
......
2009-01-01 Jakub Jelinek <jakub@redhat.com>
PR c/36489
* gcc.dg/pr36489.c: New test.
2008-12-31 Daniel Franke <franke.daniel@gmail.com>
* gfortran.dg/mapping_2.f90: Fixed testcase.
......
/* PR c/36489 */
/* { dg-do compile } */
/* { dg-options "-Woverride-init" } */
struct A { int a; int b[3]; };
union B { int a; int b[3]; };
int t1[10][10]
= { [1][2] = 11, [1][3] = 12 };
int t2[10][10]
= { [1][2] = 11, [1] = { [3] = 12 } }; /* { dg-warning "initializ" } */
int t3[10][10]
= { [1][2] = 11, [1][2] = 12 }; /* { dg-warning "initializ" } */
struct A t4[2]
= { [0].b[0] = 1, [0].b[1] = 2, [0].b[2] = 3 };
struct A t5[2]
= { [0].b[0] = 1, [0].b[1] = 2, [0].b = { 3 } }; /* { dg-warning "initializ" } */
union B t6
= { .b[0] = 1, .b[1] = 2, .b[2] = 3 };
union B t7
= { .b[0] = 1, .b[1] = 2, .b = { 2 } }; /* { dg-warning "initializ" } */
union B t8
= { .b[0] = 1, .b[1] = 2, .b[1] = 3 }; /* { dg-warning "initializ" } */
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