8sa1-gcc/gcc/testsuite/gcc.dg/20011021-1.c
Zack Weinberg b621a4ddc7 c-common.h (struct c_common_identifier): Remove rid_code field.
* c-common.h (struct c_common_identifier): Remove rid_code field.
	(C_RID_CODE): Use ->node.rid_code instead of ->rid_code.

	* c-typeck.c (constructor_designated): New local flag.
	(struct constructor_stack): Add "designated" field to match.
	(start_init): Clear it.
	(really_start_incremental_init, push_init_level): Push and
	clear it.
	(pop_init_level): Pop it.
	(set_designator): Set it.

	(pop_init_level): Suppress "missing initializer" warnings if
	constructor_designated is true.
	(process_init_element): Suppress warning about union
	initialization under traditional C, if constructor_designated
	is true.

	* intl/loadmsgcat.c (INTTYPE_SIGNED, INTTYPE_MINIMUM,
	INTTYPE_MAXIMUM): Clone from system.h.
	(_nl_load_domain): Use them when testing for overflow of size_t.
	Cast result of sizeof to off_t to compare to st_size value.
	Move side effects out of conditional for comprehensibility.

	* testsuite/gcc.dg/20011021-1.c: New test.

From-SVN: r46472
2001-10-24 20:10:53 +00:00

44 lines
896 B
C

/* Test for various initializer warnings being suppressed by use of
designated initializers. */
/* { dg-do compile } */
/* { dg-options "-std=c99 -W -Wall -Wtraditional" } */
struct t
{
int a;
int b;
int c;
};
union u
{
int n;
float i;
};
struct multilevel
{
int x;
struct t t;
union u u;
union u v;
char *f;
};
struct t T0 = { 1 }; /* { dg-warning "(missing|near) init" } */
struct t T1 = { .a = 1 }; /* { dg-bogus "(missing|near) init" } */
union u U0 = { 1 }; /* { dg-warning "initialization of union" } */
union u U1 = { .i = 1 }; /* { dg-bogus "initialization of union" } */
struct multilevel M =
{
12,
{ .b = 3 }, /* { dg-bogus "(missing|near) init" } */
{ 4 }, /* { dg-warning "initialization of union" } */
{ .n = 9 }, /* { dg-bogus "initialization of union" } */
/* "string here" */
}; /* { dg-warning "(missing|near) init" } */