summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-24 20:10:53 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-24 20:10:53 +0000
commit521369900202afd3918f5859d3da0e351b1e2a06 (patch)
treec0538b67d74f1cd1505eb648f2f17be9f0ccc09c
parent10159af365137961781f9986bf6e66146277e5f7 (diff)
downloadgcc-521369900202afd3918f5859d3da0e351b1e2a06.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46472 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog37
-rw-r--r--gcc/c-common.h3
-rw-r--r--gcc/c-typeck.c24
-rw-r--r--gcc/intl/ChangeLog8
-rw-r--r--gcc/intl/loadmsgcat.c17
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/20011021-1.c43
7 files changed, 120 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 08323772175..773395322b8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,22 @@
+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
@@ -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>
* 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>
@@ -1811,8 +1830,8 @@ Wed Oct 3 12:22:11 EDT 2001 John Wehle (john@feith.com)
* 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.
@@ -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.
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.
@@ -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.
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.
@@ -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.
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.
@@ -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>
- * 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>
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 8d378b82348..d8bb629d4bb 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -177,7 +177,7 @@ enum c_tree_index
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. */
@@ -185,7 +185,6 @@ struct c_common_identifier
{
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]
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 5dac4774f57..aa7e89f7f2a 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4943,6 +4943,9 @@ static const char *constructor_asmspec;
/* 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;
@@ -4980,6 +4983,7 @@ struct constructor_stack
char erroneous;
char outer;
char incremental;
+ char designated;
};
struct constructor_stack *constructor_stack;
@@ -5056,6 +5060,7 @@ start_init (decl, asmspec_tree, top_level)
constructor_decl = decl;
constructor_asmspec = asmspec;
constructor_subconstants_deferred = 0;
+ constructor_designated = 0;
constructor_top_level = top_level;
if (decl != 0)
@@ -5165,6 +5170,7 @@ really_start_incremental_init (type)
p->range_stack = 0;
p->outer = 0;
p->incremental = constructor_incremental;
+ p->designated = constructor_designated;
p->next = 0;
constructor_stack = p;
@@ -5175,6 +5181,7 @@ really_start_incremental_init (type)
constructor_pending_elts = 0;
constructor_type = type;
constructor_incremental = 1;
+ constructor_designated = 0;
designator_depth = 0;
designator_errorneous = 0;
@@ -5276,6 +5283,7 @@ push_init_level (implicit)
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;
@@ -5285,6 +5293,7 @@ push_init_level (implicit)
constructor_depth = SPELLING_DEPTH ();
constructor_elements = 0;
constructor_incremental = 1;
+ constructor_designated = 0;
constructor_pending_elts = 0;
if (!implicit)
{
@@ -5465,7 +5474,9 @@ pop_init_level (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");
@@ -5531,6 +5542,7 @@ pop_init_level (implicit)
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)
@@ -5577,6 +5589,7 @@ set_designator (array)
braces. */
while (constructor_stack->implicit)
process_init_element (pop_init_level (1));
+ constructor_designated = 1;
return 0;
}
@@ -5612,6 +5625,7 @@ set_designator (array)
return 1;
}
+ constructor_designated = 1;
push_init_level (2);
return 0;
}
@@ -6589,8 +6603,12 @@ process_init_element (value)
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");
diff --git a/gcc/intl/ChangeLog b/gcc/intl/ChangeLog
index f298b2e37ef..a677ba5e467 100644
--- a/gcc/intl/ChangeLog
+++ b/gcc/intl/ChangeLog
@@ -1,3 +1,11 @@
+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.
diff --git a/gcc/intl/loadmsgcat.c b/gcc/intl/loadmsgcat.c
index b6b13ff2cad..7055e52fadc 100644
--- a/gcc/intl/loadmsgcat.c
+++ b/gcc/intl/loadmsgcat.c
@@ -78,6 +78,15 @@ char *alloca ();
# 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
@@ -373,19 +382,23 @@ _nl_load_domain (domain_file, domainbinding)
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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 106e21ab979..a4701cfd900 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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.
diff --git a/gcc/testsuite/gcc.dg/20011021-1.c b/gcc/testsuite/gcc.dg/20011021-1.c
new file mode 100644
index 00000000000..821db47c2ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20011021-1.c
@@ -0,0 +1,43 @@
+/* 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" } */