This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

proposed testsuite entry. Re: new #pragma pack failure


Zack, with your patch installed, my build gets a lot quieter.  Thanx!

Richard Henderson wrote:
> On Sat, Sep 09, 2000 at 07:36:50PM -0500, Robert Lipe wrote:
> > So while I could make the tests run only where HANDLE_SYSV_PRAGMA is
> > set, they still wouldn't get run on the "mainstream" GCC development
> > hosts, would they?
> 
> Linux and *BSD define HANDLE_SYSV_PRAGMA.

OK.  You talked me into it.  The following testcase will fail with the
current tree and will pass with Zack's patch above installed.  It will
also fail if pragma pack doesn't actually work.  

This is hardly general purpose code, but it should at least share my
pragma pack joys with many of my other IA32 brethren.  We could make it
a _better_ test as long as we're inclined to test IA32 only by testing
against struct sizes that we divinely known to be true instead of
testing only the relative sizes of the structs.


I propose installing this as gcc.dg/pragma-align.c:


/* Prove that HANDLE_SYSTEMV_PRAGMA alignment handling works somewhat. */

/* { dg-do compile { target i?86-*-linux* i?86-*-*bsd* i?86-*-sco3.2v5* } } */

struct {
        char one;
        long two;
} defaultalign;

#pragma pack(4)
struct {
        char one;
        long two;
} sixteen;

#pragma pack(1)
struct {
        char one;
        long two;
} two;

#pragma pack(2)
struct {
        char one;
        long two;
} three;

#pragma pack()
struct {
        char one;
        long two;
} resetalign;

main()
{
        if(sizeof(sixteen) < sizeof(defaultalign)) abort();
        if(sizeof(two) >= sizeof(defaultalign)) abort();
        if(sizeof(three) <= sizeof(two)) abort();
        if(sizeof(resetalign) != sizeof(defaultalign)) abort();
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]