Commit b621a4dd by Zack Weinberg

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
parent 72403582
2001-10-24 Zack Weinberg <zack@codesourcery.com>
* 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.
Wed Oct 24 15:35:38 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> Wed Oct 24 15:35:38 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* integrate.c (copy_rtx_and_substitute, case CALL): Fix error in last * integrate.c (copy_rtx_and_substitute, case CALL): Fix error in last
...@@ -10,7 +29,7 @@ Wed Oct 24 13:26:12 2001 Jeffrey A Law (law@cygnus.com) ...@@ -10,7 +29,7 @@ Wed Oct 24 13:26:12 2001 Jeffrey A Law (law@cygnus.com)
2001-10-24 Dan Nicolaescu <dann@ics.uci.edu> 2001-10-24 Dan Nicolaescu <dann@ics.uci.edu>
* ssa-ccp.c (ssa_ccp_substitute_constants): Don't do anything if * ssa-ccp.c (ssa_ccp_substitute_constants): Don't do anything if
the node was already a set to a constant. the node was already a set to a constant.
Wed Oct 24 12:41:19 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> Wed Oct 24 12:41:19 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
...@@ -1811,8 +1830,8 @@ Wed Oct 3 12:22:11 EDT 2001 John Wehle (john@feith.com) ...@@ -1811,8 +1830,8 @@ Wed Oct 3 12:22:11 EDT 2001 John Wehle (john@feith.com)
* cppmain.c: Update comments. * cppmain.c: Update comments.
Tue Oct 2 12:46:01 CEST 2001 Bo Thorsen <bo@suse.co.uk>, Tue Oct 2 12:46:01 CEST 2001 Bo Thorsen <bo@suse.co.uk>,
Andreas Jaeger <aj@suse.de>, Andreas Jaeger <aj@suse.de>,
Jan Hubicka <jh@suse.cz> Jan Hubicka <jh@suse.cz>
* doc/invoke.texi (i386 Options): Document x86-64 options. * doc/invoke.texi (i386 Options): Document x86-64 options.
(i386 and x86-64 Options): Rename i386 options section. (i386 and x86-64 Options): Rename i386 options section.
...@@ -8410,7 +8429,7 @@ Sun Jul 29 18:59:13 CEST 2001 Jan Hubicka <jh@suse.cz> ...@@ -8410,7 +8429,7 @@ Sun Jul 29 18:59:13 CEST 2001 Jan Hubicka <jh@suse.cz>
(try_optimize_cfg): Update call of try_forward_edges. (try_optimize_cfg): Update call of try_forward_edges.
Sun Jul 29 18:59:56 CEST 2001 Roman Zippel <zippel@linux-m68k.org> Sun Jul 29 18:59:56 CEST 2001 Roman Zippel <zippel@linux-m68k.org>
Jan Hubicka <jh@suse.cz> Jan Hubicka <jh@suse.cz>
* (validate_replace_rtx_1): Fix simplification of MINUS. * (validate_replace_rtx_1): Fix simplification of MINUS.
...@@ -9145,7 +9164,7 @@ Sun Jul 22 21:31:04 CEST 2001 Jan Hubicka <jh@suse.cz> ...@@ -9145,7 +9164,7 @@ Sun Jul 22 21:31:04 CEST 2001 Jan Hubicka <jh@suse.cz>
insns to delete in the presence of cc0 in a jump insn. insns to delete in the presence of cc0 in a jump insn.
Fri Jul 20 22:14:49 CEST 2001 Roman Zippel <zippel@linux-m68k.org> Fri Jul 20 22:14:49 CEST 2001 Roman Zippel <zippel@linux-m68k.org>
Jan Hubicka <jh@suse.cz> Jan Hubicka <jh@suse.cz>
* m68k.md (zero_extend?i?i2 expander): Use gen_lowpart instead * m68k.md (zero_extend?i?i2 expander): Use gen_lowpart instead
of doing the change by hand. of doing the change by hand.
...@@ -9428,7 +9447,7 @@ Wed Jul 18 20:47:36 CEST 2001 Jan Hubicka <jh@suse.cz> ...@@ -9428,7 +9447,7 @@ Wed Jul 18 20:47:36 CEST 2001 Jan Hubicka <jh@suse.cz>
* aclocal.m4 (AM_ICONV): New macro from Bruno Haible. * aclocal.m4 (AM_ICONV): New macro from Bruno Haible.
Wed Jul 18 18:46:30 CEST 2001 Richard Henderson <rth@cygnus.com> Wed Jul 18 18:46:30 CEST 2001 Richard Henderson <rth@cygnus.com>
Jan Hubicka <jh@suse.cz> Jan Hubicka <jh@suse.cz>
* flow.c (redirect_edge_and_branch): Bail out on complex edges. * flow.c (redirect_edge_and_branch): Bail out on complex edges.
(try_optimize_cfg): Do not remove tail recursive labels before sibcall. (try_optimize_cfg): Do not remove tail recursive labels before sibcall.
...@@ -9485,9 +9504,9 @@ Wed Jul 18 12:05:29 2001 Nicola Pero <n.pero@mi.flashnet.it> ...@@ -9485,9 +9504,9 @@ Wed Jul 18 12:05:29 2001 Nicola Pero <n.pero@mi.flashnet.it>
2001-07-17 Andreas Schwab <schwab@suse.de> 2001-07-17 Andreas Schwab <schwab@suse.de>
* configure.in (assembler eh_frame optimization): Handle big * configure.in (assembler eh_frame optimization): Handle big
endian. endian.
* configure: Regenerated. * configure: Regenerated.
Tue Jul 17 23:43:31 CEST 2001 Jan Hubicka <jh@suse.cz> Tue Jul 17 23:43:31 CEST 2001 Jan Hubicka <jh@suse.cz>
......
...@@ -177,7 +177,7 @@ enum c_tree_index ...@@ -177,7 +177,7 @@ enum c_tree_index
CTI_MAX CTI_MAX
}; };
#define C_RID_CODE(id) (((struct c_common_identifier *) (id))->rid_code) #define C_RID_CODE(id) (((struct c_common_identifier *) (id))->node.rid_code)
/* Identifier part common to the C front ends. Inherits from /* Identifier part common to the C front ends. Inherits from
tree_identifier, despite appearances. */ tree_identifier, despite appearances. */
...@@ -185,7 +185,6 @@ struct c_common_identifier ...@@ -185,7 +185,6 @@ struct c_common_identifier
{ {
struct tree_common common; struct tree_common common;
struct cpp_hashnode node; struct cpp_hashnode node;
ENUM_BITFIELD(rid) rid_code: CHAR_BIT;
}; };
#define wchar_type_node c_global_trees[CTI_WCHAR_TYPE] #define wchar_type_node c_global_trees[CTI_WCHAR_TYPE]
......
...@@ -4943,6 +4943,9 @@ static const char *constructor_asmspec; ...@@ -4943,6 +4943,9 @@ static const char *constructor_asmspec;
/* Nonzero if this is an initializer for a top-level decl. */ /* Nonzero if this is an initializer for a top-level decl. */
static int constructor_top_level; static int constructor_top_level;
/* Nonzero if there were any member designators in this initializer. */
static int constructor_designated;
/* Nesting depth of designator list. */ /* Nesting depth of designator list. */
static int designator_depth; static int designator_depth;
...@@ -4980,6 +4983,7 @@ struct constructor_stack ...@@ -4980,6 +4983,7 @@ struct constructor_stack
char erroneous; char erroneous;
char outer; char outer;
char incremental; char incremental;
char designated;
}; };
struct constructor_stack *constructor_stack; struct constructor_stack *constructor_stack;
...@@ -5056,6 +5060,7 @@ start_init (decl, asmspec_tree, top_level) ...@@ -5056,6 +5060,7 @@ start_init (decl, asmspec_tree, top_level)
constructor_decl = decl; constructor_decl = decl;
constructor_asmspec = asmspec; constructor_asmspec = asmspec;
constructor_subconstants_deferred = 0; constructor_subconstants_deferred = 0;
constructor_designated = 0;
constructor_top_level = top_level; constructor_top_level = top_level;
if (decl != 0) if (decl != 0)
...@@ -5165,6 +5170,7 @@ really_start_incremental_init (type) ...@@ -5165,6 +5170,7 @@ really_start_incremental_init (type)
p->range_stack = 0; p->range_stack = 0;
p->outer = 0; p->outer = 0;
p->incremental = constructor_incremental; p->incremental = constructor_incremental;
p->designated = constructor_designated;
p->next = 0; p->next = 0;
constructor_stack = p; constructor_stack = p;
...@@ -5175,6 +5181,7 @@ really_start_incremental_init (type) ...@@ -5175,6 +5181,7 @@ really_start_incremental_init (type)
constructor_pending_elts = 0; constructor_pending_elts = 0;
constructor_type = type; constructor_type = type;
constructor_incremental = 1; constructor_incremental = 1;
constructor_designated = 0;
designator_depth = 0; designator_depth = 0;
designator_errorneous = 0; designator_errorneous = 0;
...@@ -5276,6 +5283,7 @@ push_init_level (implicit) ...@@ -5276,6 +5283,7 @@ push_init_level (implicit)
p->implicit = implicit; p->implicit = implicit;
p->outer = 0; p->outer = 0;
p->incremental = constructor_incremental; p->incremental = constructor_incremental;
p->designated = constructor_designated;
p->next = constructor_stack; p->next = constructor_stack;
p->range_stack = 0; p->range_stack = 0;
constructor_stack = p; constructor_stack = p;
...@@ -5285,6 +5293,7 @@ push_init_level (implicit) ...@@ -5285,6 +5293,7 @@ push_init_level (implicit)
constructor_depth = SPELLING_DEPTH (); constructor_depth = SPELLING_DEPTH ();
constructor_elements = 0; constructor_elements = 0;
constructor_incremental = 1; constructor_incremental = 1;
constructor_designated = 0;
constructor_pending_elts = 0; constructor_pending_elts = 0;
if (!implicit) if (!implicit)
{ {
...@@ -5465,7 +5474,9 @@ pop_init_level (implicit) ...@@ -5465,7 +5474,9 @@ pop_init_level (implicit)
|| integer_zerop (DECL_SIZE (constructor_unfilled_fields)))) || integer_zerop (DECL_SIZE (constructor_unfilled_fields))))
constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields); constructor_unfilled_fields = TREE_CHAIN (constructor_unfilled_fields);
if (constructor_unfilled_fields) /* Do not warn if this level of the initializer uses member
designators; it is likely to be deliberate. */
if (constructor_unfilled_fields && !constructor_designated)
{ {
push_member_name (constructor_unfilled_fields); push_member_name (constructor_unfilled_fields);
warning_init ("missing initializer"); warning_init ("missing initializer");
...@@ -5531,6 +5542,7 @@ pop_init_level (implicit) ...@@ -5531,6 +5542,7 @@ pop_init_level (implicit)
constructor_simple = p->simple; constructor_simple = p->simple;
constructor_erroneous = p->erroneous; constructor_erroneous = p->erroneous;
constructor_incremental = p->incremental; constructor_incremental = p->incremental;
constructor_designated = p->designated;
constructor_pending_elts = p->pending_elts; constructor_pending_elts = p->pending_elts;
constructor_depth = p->depth; constructor_depth = p->depth;
if (!p->implicit) if (!p->implicit)
...@@ -5577,6 +5589,7 @@ set_designator (array) ...@@ -5577,6 +5589,7 @@ set_designator (array)
braces. */ braces. */
while (constructor_stack->implicit) while (constructor_stack->implicit)
process_init_element (pop_init_level (1)); process_init_element (pop_init_level (1));
constructor_designated = 1;
return 0; return 0;
} }
...@@ -5612,6 +5625,7 @@ set_designator (array) ...@@ -5612,6 +5625,7 @@ set_designator (array)
return 1; return 1;
} }
constructor_designated = 1;
push_init_level (2); push_init_level (2);
return 0; return 0;
} }
...@@ -6589,8 +6603,12 @@ process_init_element (value) ...@@ -6589,8 +6603,12 @@ process_init_element (value)
under the assumption that the zero initializer in user under the assumption that the zero initializer in user
code appears conditioned on e.g. __STDC__ to avoid code appears conditioned on e.g. __STDC__ to avoid
"missing initializer" warnings and relies on default "missing initializer" warnings and relies on default
initialization to zero in the traditional C case. */ initialization to zero in the traditional C case.
if (warn_traditional && !in_system_header We also skip the warning if the initializer is designated,
again on the assumption that this must be conditional on
__STDC__ anyway (and we've already complained about the
member-designator already). */
if (warn_traditional && !in_system_header && !constructor_designated
&& !(value && (integer_zerop (value) || real_zerop (value)))) && !(value && (integer_zerop (value) || real_zerop (value))))
warning ("traditional C rejects initialization of unions"); warning ("traditional C rejects initialization of unions");
......
2001-10-24 Zack Weinberg <zack@codesourcery.com>
* 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.
2001-10-21 Zack Weinberg <zack@codesourcery.com> 2001-10-21 Zack Weinberg <zack@codesourcery.com>
* dcigettext.c: Don't use #elif. * dcigettext.c: Don't use #elif.
......
...@@ -78,6 +78,15 @@ char *alloca (); ...@@ -78,6 +78,15 @@ char *alloca ();
# include "../locale/localeinfo.h" # include "../locale/localeinfo.h"
#endif #endif
/* GCC LOCAL: These macros are used below. */
/* The extra casts work around common compiler bugs. */
#define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
#define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
/* @@ end of prolog @@ */ /* @@ end of prolog @@ */
#ifdef _LIBC #ifdef _LIBC
...@@ -373,19 +382,23 @@ _nl_load_domain (domain_file, domainbinding) ...@@ -373,19 +382,23 @@ _nl_load_domain (domain_file, domainbinding)
return; return;
/* We must know about the size of the file. */ /* We must know about the size of the file. */
/* GCC_LOCAL: Use INTTYPE_MAXIMUM for overflow check, cast sizeof to
off_t, move set of size below if. */
if ( if (
#ifdef _LIBC #ifdef _LIBC
__builtin_expect (fstat64 (fd, &st) != 0, 0) __builtin_expect (fstat64 (fd, &st) != 0, 0)
#else #else
__builtin_expect (fstat (fd, &st) != 0, 0) __builtin_expect (fstat (fd, &st) != 0, 0)
#endif #endif
|| __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0) || __builtin_expect (st.st_size > INTTYPE_MAXIMUM (ssize_t), 0)
|| __builtin_expect (size < sizeof (struct mo_file_header), 0)) || __builtin_expect (st.st_size < (off_t) sizeof (struct mo_file_header),
0))
{ {
/* Something went wrong. */ /* Something went wrong. */
close (fd); close (fd);
return; return;
} }
size = (size_t) st.st_size;
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
/* Now we are ready to load the file. If mmap() is available we try /* Now we are ready to load the file. If mmap() is available we try
......
2001-10-24 Zack Weinberg <zack@codesourcery.com>
* gcc.dg/20011021-1.c: New test.
2001-10-24 Jakub Jelinek <jakub@redhat.com> 2001-10-24 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/compile/20011023-1.c: New test. * gcc.c-torture/compile/20011023-1.c: New test.
......
/* 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" } */
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