This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA:] Fix invalid tests (was: Re: Tests gcc.dg/c99-scope-2.c ...)
- To: Geoff Keating <geoffk at geoffk dot org>
- Subject: [RFA:] Fix invalid tests (was: Re: Tests gcc.dg/c99-scope-2.c ...)
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- Date: Mon, 30 Jul 2001 18:29:06 -0400 (EDT)
- cc: <gcc at gcc dot gnu dot org>, <gcc-patches at gcc dot gnu dot org>
On 30 Jul 2001, Geoff Keating wrote:
> A compiler is less useful if
>
> struct { char a[4]; }
>
> does not have size 4, as it makes it hard to implement certain styles
> of file and network I/O.
That kind of code is usually non-portable anyway, so it could be
somewhat solved by attribute packed, but on the other hand
that'd still have problems with a large base of existing code.
> If the tests fail for your port because of this, it's better to submit
> a patch to fix them (make it '<=' and '>=' respectively), unless you'd
> rather change your port to remove the excess padding.
To keep the story short, as I said there was no reason for the
port having the alignment that was making the tests fail, so I'm
changing that. But let's also change the tests for the future.
I thought of changing ints to longs, but rethought that as being
excessive.
This passes, tested with and without the excessive alignment on
the new port. I hope the original intention is not munged. I
think the align-1 test was checking a bug that "contaminated"
the type typedef:d from with the alignment attribute.
Ok to commit?
gcc/testsuite:
* gcc.dg/c99-scope-2.c: Don't generally assume adding more
largest-type elements to a struct makes its size grow.
* gcc.c-torture/execute/align-1.c: Compare size against size of
another struct, not against sizeof int.
Index: c99-scope-2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/gcc.dg/c99-scope-2.c,v
retrieving revision 1.1
diff -p -c -u -p -r1.1 c99-scope-2.c
cvs server: conflicting specifications of output style
--- c99-scope-2.c 2000/11/13 14:08:09 1.1
+++ c99-scope-2.c 2001/07/30 21:04:49
@@ -14,58 +14,58 @@ main (void)
a = sizeof (struct foo);
if (b = sizeof (struct foo { int i0; int i1; }))
c = sizeof (struct foo { int i0; int i1; int i2; });
- if (!(a < b && b < c))
+ if (!(a <= b && b <= c))
abort ();
if ((b = sizeof (struct foo { int i0; int i1; })), 0)
c = sizeof (struct foo { int i0; int i1; int i2; });
else
d = sizeof (struct foo { int i0; int i1; int i2; int i3; });
- if (!(a < b && b < d))
+ if (!(a <= b && b <= d))
abort ();
switch (b = sizeof (struct foo { int i0; int i1; }))
default:
c = sizeof (struct foo { int i0; int i1; int i2; });
- if (!(a < b && b < c))
+ if (!(a <= b && b <= c))
abort ();
do
c = sizeof (struct foo { int i0; int i1; int i2; });
while ((b = sizeof (struct foo { int i0; int i1; })), 0);
- if (!(a < b && b < c))
+ if (!(a <= b && b <= c))
abort ();
d = 1;
while ((b = sizeof (struct foo { int i0; int i1; })), d)
(c = sizeof (struct foo { int i0; int i1; int i2; })), d--;
- if (!(a < b && b < c))
+ if (!(a <= b && b <= c))
abort ();
d = 1;
for ((b = sizeof (struct foo { int i0; int i1; })); d; d--)
c = sizeof (struct foo { int i0; int i1; int i2; });
- if (!(a < b && b < c))
+ if (!(a <= b && b <= c))
abort ();
d = 1;
for ((b = sizeof (struct foo { int i0; int i1; })); d; d--)
c = sizeof (struct foo);
- if (!(a < b && b == c))
+ if (!(a <= b && b == c))
abort ();
d = 1;
for (; (b = sizeof (struct foo { int i0; int i1; })), d; d--)
c = sizeof (struct foo { int i0; int i1; int i2; });
- if (!(a < b && b < c))
+ if (!(a <= b && b <= c))
abort ();
d = 1;
for (; (b = sizeof (struct foo { int i0; int i1; })), d; d--)
c = sizeof (struct foo);
- if (!(a < b && b == c))
+ if (!(a <= b && b == c))
abort ();
d = 1;
for (; d; (b = sizeof (struct foo { int i0; int i1; })), d--)
c = sizeof (struct foo { int i0; int i1; int i2; });
- if (!(a < b && b < c))
+ if (!(a <= b && b <= c))
abort ();
d = 1;
for (; d; (b = sizeof (struct foo { int i0; int i1; })), d--)
c = sizeof (struct foo);
- if (!(a < b && b == c))
+ if (!(a <= b && b == c))
abort ();
exit (0);
}
brgds, H-P