Patch for c/13801

Joseph S. Myers jsm@polyomino.org.uk
Tue Aug 3 14:27:00 GMT 2004


On Tue, 3 Aug 2004, I wrote:

> >   struct foo;
> >   function() { struct foo { int a, int b; }; }
> >   struct foo array[5];
> 
> Works fine (i.e. is diagnosed); the struct foo in the inner scope is a
> different type from that in the outer scope.  However I see this isn't
> covered by c99-tag-1.c which I added when fixing tag handling (and finding
> the problem described in DR#251 in the process), so I'll add testcases.

Now added.  c99-tag-2.c shows a regression in 3.4 only, but I don't
propose to look for a fix there.  Both tests pass with mainline on
i686-pc-linux-gnu.  Applied to mainline.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2004-08-03  Joseph S. Myers  <jsm@polyomino.org.uk>

	* gcc.dg/array-7.c, gcc.dg/c99-tag-2.c: New tests.

--- /dev/null	2002-08-26 16:21:36.000000000 +0000
+++ array-7.c	2004-08-03 12:12:07.000000000 +0000
@@ -0,0 +1,14 @@
+/* Test for array of incomplete structure type - Zack Weinberg in
+   <http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00108.html>.  */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct foo;
+
+void
+f (void)
+{
+  struct foo { int a; int b; };
+}
+
+struct foo array[5]; /* { dg-error "storage size" } */
--- /dev/null	2002-08-26 16:21:36.000000000 +0000
+++ c99-tag-2.c	2004-08-03 12:11:09.000000000 +0000
@@ -0,0 +1,16 @@
+/* Test for handling of tags.  A struct defined in an inner scope does
+   not match one declared in an outer scope.  */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+struct s;
+struct t { struct s *p; } x;
+
+void
+f (void)
+{
+  /* This is a different struct s from the outer one.  */
+  struct s { int a; } y;
+  x.p = &y; /* { dg-error "incompatible" } */
+}



More information about the Gcc-patches mailing list