This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[rfc] fix c/21502
- From: Richard Henderson <rth at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 10 May 2005 15:53:14 -0700
- Subject: [rfc] fix c/21502
- References: <20050510192805.GA20480@redhat.com> <Pine.LNX.4.61.0505101954360.15600@digraph.polyomino.org.uk> <20050510214427.GA20680@redhat.com> <Pine.LNX.4.61.0505102232060.15600@digraph.polyomino.org.uk>
On Tue, May 10, 2005 at 10:33:36PM +0000, Joseph S. Myers wrote:
> Yes (as a quality-of-implementation matter, not a standard requirement).
> It does in 3.4. It ought to do so immediately after my patch for bug
> 21342 as well but I don't have a build tree with that patch around.
Hum, yes. The following update seems to do what you want. It
doesn't do your number 2 test; I have no idea what you'd want
for that.
Seem ok? Or good enough at least? This is fixing a bootstrap
failure after all...
r~
* c-decl.c (finish_decl): After complete_array_type on an external
decl, store the composite back into the binding.
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.630.6.10
diff -u -p -d -r1.630.6.10 c-decl.c
--- c-decl.c 10 May 2005 12:41:06 -0000 1.630.6.10
+++ c-decl.c 10 May 2005 22:49:35 -0000
@@ -3285,11 +3285,13 @@ finish_decl (tree decl, tree init, tree
/* Get the completed type made by complete_array_type. */
type = TREE_TYPE (decl);
- if (failure == 1)
- error ("%Jinitializer fails to determine size of %qD", decl, decl);
-
- else if (failure == 2)
+ switch (failure)
{
+ case 1:
+ error ("%Jinitializer fails to determine size of %qD", decl, decl);
+ break;
+
+ case 2:
if (do_default)
error ("%Jarray size missing in %qD", decl, decl);
/* If a `static' var's size isn't known,
@@ -3300,9 +3302,33 @@ finish_decl (tree decl, tree init, tree
and it will get allocated. */
else if (!pedantic && TREE_STATIC (decl) && !TREE_PUBLIC (decl))
DECL_EXTERNAL (decl) = 1;
+ break;
+
+ case 3:
+ error ("%Jzero or negative size array %qD", decl, decl);
+ break;
+
+ case 0:
+ /* For global variables, update the copy of the type that
+ exists in the binding. */
+ if (TREE_PUBLIC (decl))
+ {
+ struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl));
+ while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
+ b_ext = b_ext->shadowed;
+ if (b_ext)
+ {
+ if (b_ext->type)
+ b_ext->type = composite_type (b_ext->type, type);
+ else
+ b_ext->type = type;
+ }
+ }
+ break;
+
+ default:
+ gcc_unreachable ();
}
- else if (failure == 3)
- error ("%Jzero or negative size array %qD", decl, decl);
if (DECL_INITIAL (decl))
TREE_TYPE (DECL_INITIAL (decl)) = type;