* 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 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>
* integrate.c (copy_rtx_and_substitute, case CALL): Fix error in last
2001-10-24 Dan Nicolaescu <dann@ics.uci.edu>
* 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>
* cppmain.c: Update comments.
Tue Oct 2 12:46:01 CEST 2001 Bo Thorsen <bo@suse.co.uk>,
- Andreas Jaeger <aj@suse.de>,
- Jan Hubicka <jh@suse.cz>
+ Andreas Jaeger <aj@suse.de>,
+ Jan Hubicka <jh@suse.cz>
* doc/invoke.texi (i386 Options): Document x86-64 options.
(i386 and x86-64 Options): Rename i386 options section.
(try_optimize_cfg): Update call of try_forward_edges.
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.
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>
- Jan Hubicka <jh@suse.cz>
+ Jan Hubicka <jh@suse.cz>
* m68k.md (zero_extend?i?i2 expander): Use gen_lowpart instead
of doing the change by hand.
* aclocal.m4 (AM_ICONV): New macro from Bruno Haible.
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.
(try_optimize_cfg): Do not remove tail recursive labels before sibcall.
2001-07-17 Andreas Schwab <schwab@suse.de>
- * configure.in (assembler eh_frame optimization): Handle big
- endian.
- * configure: Regenerated.
+ * configure.in (assembler eh_frame optimization): Handle big
+ endian.
+ * configure: Regenerated.
Tue Jul 17 23:43:31 CEST 2001 Jan Hubicka <jh@suse.cz>
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
tree_identifier, despite appearances. */
{
struct tree_common common;
struct cpp_hashnode node;
- ENUM_BITFIELD(rid) rid_code: CHAR_BIT;
};
#define wchar_type_node c_global_trees[CTI_WCHAR_TYPE]
/* Nonzero if this is an initializer for a top-level decl. */
static int constructor_top_level;
+/* Nonzero if there were any member designators in this initializer. */
+static int constructor_designated;
+
/* Nesting depth of designator list. */
static int designator_depth;
char erroneous;
char outer;
char incremental;
+ char designated;
};
struct constructor_stack *constructor_stack;
constructor_decl = decl;
constructor_asmspec = asmspec;
constructor_subconstants_deferred = 0;
+ constructor_designated = 0;
constructor_top_level = top_level;
if (decl != 0)
p->range_stack = 0;
p->outer = 0;
p->incremental = constructor_incremental;
+ p->designated = constructor_designated;
p->next = 0;
constructor_stack = p;
constructor_pending_elts = 0;
constructor_type = type;
constructor_incremental = 1;
+ constructor_designated = 0;
designator_depth = 0;
designator_errorneous = 0;
p->implicit = implicit;
p->outer = 0;
p->incremental = constructor_incremental;
+ p->designated = constructor_designated;
p->next = constructor_stack;
p->range_stack = 0;
constructor_stack = p;
constructor_depth = SPELLING_DEPTH ();
constructor_elements = 0;
constructor_incremental = 1;
+ constructor_designated = 0;
constructor_pending_elts = 0;
if (!implicit)
{
|| integer_zerop (DECL_SIZE (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);
warning_init ("missing initializer");
constructor_simple = p->simple;
constructor_erroneous = p->erroneous;
constructor_incremental = p->incremental;
+ constructor_designated = p->designated;
constructor_pending_elts = p->pending_elts;
constructor_depth = p->depth;
if (!p->implicit)
braces. */
while (constructor_stack->implicit)
process_init_element (pop_init_level (1));
+ constructor_designated = 1;
return 0;
}
return 1;
}
+ constructor_designated = 1;
push_init_level (2);
return 0;
}
under the assumption that the zero initializer in user
code appears conditioned on e.g. __STDC__ to avoid
"missing initializer" warnings and relies on default
- initialization to zero in the traditional C case. */
- if (warn_traditional && !in_system_header
+ initialization to zero in the traditional C case.
+ 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))))
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>
* dcigettext.c: Don't use #elif.
# include "../locale/localeinfo.h"
#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 @@ */
#ifdef _LIBC
return;
/* 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 (
#ifdef _LIBC
__builtin_expect (fstat64 (fd, &st) != 0, 0)
#else
__builtin_expect (fstat (fd, &st) != 0, 0)
#endif
- || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)
- || __builtin_expect (size < sizeof (struct mo_file_header), 0))
+ || __builtin_expect (st.st_size > INTTYPE_MAXIMUM (ssize_t), 0)
+ || __builtin_expect (st.st_size < (off_t) sizeof (struct mo_file_header),
+ 0))
{
/* Something went wrong. */
close (fd);
return;
}
+ size = (size_t) st.st_size;
#ifdef HAVE_MMAP
/* 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>
* gcc.c-torture/compile/20011023-1.c: New test.
--- /dev/null
+/* 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" } */