From dfe79cab9b242337d696548f80b2bb9cb190b135 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Sun, 25 Jul 2004 18:08:52 +0000 Subject: [PATCH] pragma-align-2.c: New test. * gcc.dg/pragma-align-2.c: New test. * gcc.dg/pragma-init-fini.c: New test. * gcc.dg/pragma-align.c: Change from compile to run. Run on Solaris targets. From-SVN: r85154 --- gcc/testsuite/ChangeLog | 7 ++++ gcc/testsuite/gcc.dg/pragma-align-2.c | 54 +++++++++++++++++++++++++ gcc/testsuite/gcc.dg/pragma-align.c | 3 +- gcc/testsuite/gcc.dg/pragma-init-fini.c | 50 +++++++++++++++++++++++ 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pragma-align-2.c create mode 100644 gcc/testsuite/gcc.dg/pragma-init-fini.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b0d645b8a3..fca22b74038 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2004-07-25 Daniel Jacobowitz + + * gcc.dg/pragma-align-2.c: New test. + * gcc.dg/pragma-init-fini.c: New test. + * gcc.dg/pragma-align.c: Change from compile to run. Run on Solaris + targets. + 2004-07-25 Joseph S. Myers * gcc.dg/init-string-2.c: New test. diff --git a/gcc/testsuite/gcc.dg/pragma-align-2.c b/gcc/testsuite/gcc.dg/pragma-align-2.c new file mode 100644 index 00000000000..3d5e0da3270 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pragma-align-2.c @@ -0,0 +1,54 @@ +/* { dg-do run { target *-*-solaris2.* } } */ + +void abort (void); + +#pragma align 1(x1) +#pragma align 2(x2) +#pragma align 4(x4) +#pragma align 8(x8,y8,z8) +#pragma align 16(x16) +#pragma align 32(x32) +#pragma align 64(x64) +#pragma align 128(x128) + +#pragma align 8(not_defined) + +#pragma align 9(odd_align) /* { dg-error "invalid alignment" } */ +#pragma align 256(high_align) /* { dg-error "invalid alignment" } */ +#pragma align -1(neg_align) /* { dg-error "malformed" } */ +#pragma align bad_align /* { dg-error "malformed" } */ +#pragma align 1(bad_align /* { dg-error "malformed" } */ + +int x, x1, x2, x4, x8, y8, z8, x16, x32, x64, x128; + +#pragma align 16(x) /* { dg-error "must appear before" } */ + +int +main () +{ + if (__alignof__ (x4) < 4) + abort (); + + if (__alignof__ (x8) < 8) + abort (); + + if (__alignof__ (y8) < 8) + abort (); + + if (__alignof__ (z8) < 8) + abort (); + + if (__alignof__ (x16) < 16) + abort (); + + if (__alignof__ (x32) < 32) + abort (); + + if (__alignof__ (x64) < 64) + abort (); + + if (__alignof__ (x128) < 128) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pragma-align.c b/gcc/testsuite/gcc.dg/pragma-align.c index f5d457e69d5..5341870b6cb 100644 --- a/gcc/testsuite/gcc.dg/pragma-align.c +++ b/gcc/testsuite/gcc.dg/pragma-align.c @@ -1,6 +1,6 @@ /* Prove that HANDLE_SYSTEMV_PRAGMA alignment handling works somewhat. */ -/* { dg-do compile { target i?86-*-linux* i?86-*-*bsd* i?86-*-sco3.2v5* } } */ +/* { dg-do run { target i?86-*-linux* i?86-*-*bsd* i?86-*-sco3.2v5* *-*-solaris2.* } } */ struct { char one; @@ -39,4 +39,3 @@ main() if(sizeof(resetalign) != sizeof(defaultalign)) abort(); return 0; } - diff --git a/gcc/testsuite/gcc.dg/pragma-init-fini.c b/gcc/testsuite/gcc.dg/pragma-init-fini.c new file mode 100644 index 00000000000..8c5c53a25aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/pragma-init-fini.c @@ -0,0 +1,50 @@ +/* Tests for #pragma init and #pragma fini. */ + +/* { dg-do run { target *-*-solaris2.* } } */ + +extern void abort (); + +#pragma init /* { dg-error "malformed" } */ +#pragma init () /* { dg-error "malformed" } */ +#pragma init init_func /* { dg-error "malformed" } */ + +#pragma fini /* { dg-error "malformed" } */ +#pragma fini () /* { dg-error "malformed" } */ +#pragma fini fini_func /* { dg-error "malformed" } */ + +#pragma init (init_func, init_static_func) + +int glob_1, glob_2; + +void init_func (void) +{ + glob_1 = 1; +} + +static void init_static_func (void) +{ + glob_2 = 2; +} + +#pragma fini (fini_func, fini_static_func) + +void fini_func (void) +{ + +} + +static void fini_static_func (void) +{ + +} + +int main() +{ + if (glob_1 != 1) + abort (); + + if (glob_2 != 2) + abort (); + + return 0; +} -- 2.30.2