--- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-1_main.c Mon May 5 12:12:29 2003 @@ -0,0 +1,12 @@ +/* Test structure passing by value, using a test from gcc.dg. + Each struct that is passed contains an array of unsigned char. */ + +extern void struct_by_value_1_x (void); +extern void exit (int); + +int +main () +{ + struct_by_value_1_x (); + exit (0); +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-1_x.c Fri May 2 15:58:31 2003 @@ -0,0 +1,63 @@ +#define T(N) \ +struct S##N { unsigned char i[N]; }; \ +struct S##N g1s##N, g2s##N, g3s##N; \ + \ +extern void init##N (struct S##N *p, int i); \ +extern void checkg##N (void); \ +extern void test##N (struct S##N s1, \ + struct S##N s2, struct S##N s3); \ + \ +void \ +check##N (struct S##N x, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + if (x.i[j] != i + j) abort (); \ +} \ + \ +void \ +test2_##N (struct S##N s1, struct S##N s2) \ +{ \ + test##N (s1, g2s##N, s2); \ +} \ + \ +void \ +testit##N (void) \ +{ \ + init##N (&g1s##N, 64); \ + init##N (&g2s##N, 128); \ + init##N (&g3s##N, 192); \ + checkg##N (); \ + test##N (g1s##N, g2s##N, g3s##N); \ + test2_##N (g1s##N, g3s##N); \ +} + +extern void abort (void); + +T(0) T(1) T(2) T(3) T(4) T(5) T(6) T(7) +T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) +T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23) +T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) +T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39) +T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) +T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) +T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63) + +#undef T + +void +struct_by_value_1_x () +{ +#define T(N) testit##N (); + +T(0) T(1) T(2) T(3) T(4) T(5) T(6) T(7) +T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) +T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23) +T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) +T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39) +T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) +T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) +T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63) + +#undef T +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-1_y.c Fri May 2 15:58:31 2003 @@ -0,0 +1,40 @@ +#define T(N) \ +struct S##N { unsigned char i[N]; }; \ +extern struct S##N g1s##N, g2s##N, g3s##N; \ + \ +extern void check##N (struct S##N x, int i); \ +extern void test2_##N (struct S##N s1, struct S##N s2); \ + \ +void \ +init##N (struct S##N *p, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + p->i[j] = i + j; \ +} \ + \ +void \ +checkg##N (void) \ +{ \ + check##N (g1s##N, 64); \ + check##N (g2s##N, 128); \ + check##N (g3s##N, 192); \ +} \ + \ +void \ +test##N (struct S##N s1, struct S##N s2, \ + struct S##N s3) \ +{ \ + check##N (s1, 64); \ + check##N (s2, 128); \ + check##N (s3, 192); \ +} + +T(0) T(1) T(2) T(3) T(4) T(5) T(6) T(7) +T(8) T(9) T(10) T(11) T(12) T(13) T(14) T(15) +T(16) T(17) T(18) T(19) T(20) T(21) T(22) T(23) +T(24) T(25) T(26) T(27) T(28) T(29) T(30) T(31) +T(32) T(33) T(34) T(35) T(36) T(37) T(38) T(39) +T(40) T(41) T(42) T(43) T(44) T(45) T(46) T(47) +T(48) T(49) T(50) T(51) T(52) T(53) T(54) T(55) +T(56) T(57) T(58) T(59) T(60) T(61) T(62) T(63) --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-2_main.c Fri May 2 15:58:31 2003 @@ -0,0 +1,13 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. + This test is based on one contributed by Alan Modra. */ + +extern void struct_by_value_2_x (void); +extern void exit (int); + +int +main () +{ + struct_by_value_2_x (); + exit (0); +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-2_x.c Fri May 2 15:58:31 2003 @@ -0,0 +1,221 @@ +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +#define T(N, NAME, TYPE) \ +struct S##NAME##N { TYPE i[N]; }; \ +struct S##NAME##N g1s##NAME##N, g2s##NAME##N; \ +struct S##NAME##N g3s##NAME##N, g4s##NAME##N; \ +struct S##NAME##N g5s##NAME##N, g6s##NAME##N; \ +struct S##NAME##N g7s##NAME##N, g8s##NAME##N; \ +struct S##NAME##N g9s##NAME##N, g10s##NAME##N; \ +struct S##NAME##N g11s##NAME##N, g12s##NAME##N; \ +struct S##NAME##N g13s##NAME##N, g14s##NAME##N; \ +struct S##NAME##N g15s##NAME##N, g16s##NAME##N; \ + \ +extern void init##NAME##N (struct S##NAME##N *p, int i); \ +extern void checkg##NAME##N (void); \ +extern void \ +test##NAME##N (struct S##NAME##N s1, struct S##NAME##N s2, \ + struct S##NAME##N s3, struct S##NAME##N s4, \ + struct S##NAME##N s5, struct S##NAME##N s6, \ + struct S##NAME##N s7, struct S##NAME##N s8, \ + struct S##NAME##N s9, struct S##NAME##N s10, \ + struct S##NAME##N s11, struct S##NAME##N s12, \ + struct S##NAME##N s13, struct S##NAME##N s14, \ + struct S##NAME##N s15, struct S##NAME##N s16); \ +extern void testva##NAME##N (int n, ...); \ +extern void \ +test2_##NAME##N (struct S##NAME##N s1, struct S##NAME##N s2, \ + struct S##NAME##N s3, struct S##NAME##N s4, \ + struct S##NAME##N s5, struct S##NAME##N s6, \ + struct S##NAME##N s7, struct S##NAME##N s8); \ + \ +void \ +check##NAME##N (struct S##NAME##N *p, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + if (p->i[j] != (TYPE) (i + j)) \ + { \ + DEBUG_NL; \ + abort (); \ + } \ +} \ + \ +void \ +test2_##NAME##N (struct S##NAME##N s1, struct S##NAME##N s2, \ + struct S##NAME##N s3, struct S##NAME##N s4, \ + struct S##NAME##N s5, struct S##NAME##N s6, \ + struct S##NAME##N s7, struct S##NAME##N s8) \ +{ \ + test##NAME##N (s1, g2s##NAME##N, s2, g4s##NAME##N, \ + s3, g6s##NAME##N, s4, g8s##NAME##N, \ + s5, g10s##NAME##N, s6, g12s##NAME##N, \ + s7, g14s##NAME##N, s8, g16s##NAME##N); \ +} \ + \ +void \ +testit##NAME##N (void) \ +{ \ + DEBUG_FPUTS (#NAME "[" #N "]"); \ + init##NAME##N ( &g1s##NAME##N, 1*16); \ + init##NAME##N ( &g2s##NAME##N, 2*16); \ + init##NAME##N ( &g3s##NAME##N, 3*16); \ + init##NAME##N ( &g4s##NAME##N, 4*16); \ + init##NAME##N ( &g5s##NAME##N, 5*16); \ + init##NAME##N ( &g6s##NAME##N, 6*16); \ + init##NAME##N ( &g7s##NAME##N, 7*16); \ + init##NAME##N ( &g8s##NAME##N, 8*16); \ + init##NAME##N ( &g9s##NAME##N, 9*16); \ + init##NAME##N (&g10s##NAME##N, 10*16); \ + init##NAME##N (&g11s##NAME##N, 11*16); \ + init##NAME##N (&g12s##NAME##N, 12*16); \ + init##NAME##N (&g13s##NAME##N, 13*16); \ + init##NAME##N (&g14s##NAME##N, 14*16); \ + init##NAME##N (&g15s##NAME##N, 15*16); \ + init##NAME##N (&g16s##NAME##N, 16*16); \ + checkg##NAME##N (); \ + DEBUG_FPUTS (" test"); \ + test##NAME##N (g1s##NAME##N, g2s##NAME##N, \ + g3s##NAME##N, g4s##NAME##N, \ + g5s##NAME##N, g6s##NAME##N, \ + g7s##NAME##N, g8s##NAME##N, \ + g9s##NAME##N, g10s##NAME##N, \ + g11s##NAME##N, g12s##NAME##N, \ + g13s##NAME##N, g14s##NAME##N, \ + g15s##NAME##N, g16s##NAME##N); \ + DEBUG_FPUTS (" testva"); \ + testva##NAME##N (16, \ + g1s##NAME##N, g2s##NAME##N, \ + g3s##NAME##N, g4s##NAME##N, \ + g5s##NAME##N, g6s##NAME##N, \ + g7s##NAME##N, g8s##NAME##N, \ + g9s##NAME##N, g10s##NAME##N, \ + g11s##NAME##N, g12s##NAME##N, \ + g13s##NAME##N, g14s##NAME##N, \ + g15s##NAME##N, g16s##NAME##N); \ + DEBUG_FPUTS (" test2"); \ + test2_##NAME##N (g1s##NAME##N, g3s##NAME##N, \ + g5s##NAME##N, g7s##NAME##N, \ + g9s##NAME##N, g11s##NAME##N, \ + g13s##NAME##N, g15s##NAME##N); \ + DEBUG_NL; \ +} + +extern void abort (void); + +T(0, uc, unsigned char) +T(1, uc, unsigned char) +T(2, uc, unsigned char) +T(3, uc, unsigned char) +T(4, uc, unsigned char) +T(5, uc, unsigned char) +T(6, uc, unsigned char) +T(7, uc, unsigned char) +T(8, uc, unsigned char) +T(9, uc, unsigned char) +T(10, uc, unsigned char) +T(11, uc, unsigned char) +T(12, uc, unsigned char) +T(13, uc, unsigned char) +T(14, uc, unsigned char) +T(15, uc, unsigned char) +T(0, us, unsigned short) +T(1, us, unsigned short) +T(2, us, unsigned short) +T(3, us, unsigned short) +T(4, us, unsigned short) +T(5, us, unsigned short) +T(6, us, unsigned short) +T(7, us, unsigned short) +T(8, us, unsigned short) +T(9, us, unsigned short) +T(10, us, unsigned short) +T(11, us, unsigned short) +T(12, us, unsigned short) +T(13, us, unsigned short) +T(14, us, unsigned short) +T(15, us, unsigned short) +T(0, ui, unsigned int) +T(1, ui, unsigned int) +T(2, ui, unsigned int) +T(3, ui, unsigned int) +T(4, ui, unsigned int) +T(5, ui, unsigned int) +T(6, ui, unsigned int) +T(7, ui, unsigned int) +T(8, ui, unsigned int) +T(9, ui, unsigned int) +T(10, ui, unsigned int) +T(11, ui, unsigned int) +T(12, ui, unsigned int) +T(13, ui, unsigned int) +T(14, ui, unsigned int) +T(15, ui, unsigned int) + +#undef T + +void +struct_by_value_2_x () +{ +#define T(N, NAME, TYPE) testit##NAME##N (); + +T(0, uc, unsigned char) +T(1, uc, unsigned char) +T(2, uc, unsigned char) +T(3, uc, unsigned char) +T(4, uc, unsigned char) +T(5, uc, unsigned char) +T(6, uc, unsigned char) +T(7, uc, unsigned char) +T(8, uc, unsigned char) +T(9, uc, unsigned char) +T(10, uc, unsigned char) +T(11, uc, unsigned char) +T(12, uc, unsigned char) +T(13, uc, unsigned char) +T(14, uc, unsigned char) +T(15, uc, unsigned char) +T(0, us, unsigned short) +T(1, us, unsigned short) +T(2, us, unsigned short) +T(3, us, unsigned short) +T(4, us, unsigned short) +T(5, us, unsigned short) +T(6, us, unsigned short) +T(7, us, unsigned short) +T(8, us, unsigned short) +T(9, us, unsigned short) +T(10, us, unsigned short) +T(11, us, unsigned short) +T(12, us, unsigned short) +T(13, us, unsigned short) +T(14, us, unsigned short) +T(15, us, unsigned short) +T(0, ui, unsigned int) +T(1, ui, unsigned int) +T(2, ui, unsigned int) +T(3, ui, unsigned int) +T(4, ui, unsigned int) +T(5, ui, unsigned int) +T(6, ui, unsigned int) +T(7, ui, unsigned int) +T(8, ui, unsigned int) +T(9, ui, unsigned int) +T(10, ui, unsigned int) +T(11, ui, unsigned int) +T(12, ui, unsigned int) +T(13, ui, unsigned int) +T(14, ui, unsigned int) +T(15, ui, unsigned int) + +#undef T +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-2_y.c Fri May 2 15:58:31 2003 @@ -0,0 +1,178 @@ +#include + +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +/* Turn off checking for variable arguments with -DSKIPVA. */ +#ifdef SKIPVA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(N, NAME, TYPE) \ +struct S##NAME##N { TYPE i[N]; }; \ + \ +extern struct S##NAME##N g1s##NAME##N, g2s##NAME##N; \ +extern struct S##NAME##N g3s##NAME##N, g4s##NAME##N; \ +extern struct S##NAME##N g5s##NAME##N, g6s##NAME##N; \ +extern struct S##NAME##N g7s##NAME##N, g8s##NAME##N; \ +extern struct S##NAME##N g9s##NAME##N, g10s##NAME##N; \ +extern struct S##NAME##N g11s##NAME##N, g12s##NAME##N; \ +extern struct S##NAME##N g13s##NAME##N, g14s##NAME##N; \ +extern struct S##NAME##N g15s##NAME##N, g16s##NAME##N; \ + \ +extern void check##NAME##N (struct S##NAME##N *p, int i); \ +extern void \ +test2_##NAME##N (struct S##NAME##N s1, struct S##NAME##N s2, \ + struct S##NAME##N s3, struct S##NAME##N s4, \ + struct S##NAME##N s5, struct S##NAME##N s6, \ + struct S##NAME##N s7, struct S##NAME##N s8); \ + \ +void \ +init##NAME##N (struct S##NAME##N *p, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + p->i[j] = i + j; \ +} \ + \ +void \ +checkg##NAME##N (void) \ +{ \ + check##NAME##N ( &g1s##NAME##N, 1*16); \ + check##NAME##N ( &g2s##NAME##N, 2*16); \ + check##NAME##N ( &g3s##NAME##N, 3*16); \ + check##NAME##N ( &g4s##NAME##N, 4*16); \ + check##NAME##N ( &g5s##NAME##N, 5*16); \ + check##NAME##N ( &g6s##NAME##N, 6*16); \ + check##NAME##N ( &g7s##NAME##N, 7*16); \ + check##NAME##N ( &g8s##NAME##N, 8*16); \ + check##NAME##N ( &g9s##NAME##N, 9*16); \ + check##NAME##N (&g10s##NAME##N, 10*16); \ + check##NAME##N (&g11s##NAME##N, 11*16); \ + check##NAME##N (&g12s##NAME##N, 12*16); \ + check##NAME##N (&g13s##NAME##N, 13*16); \ + check##NAME##N (&g14s##NAME##N, 14*16); \ + check##NAME##N (&g15s##NAME##N, 15*16); \ + check##NAME##N (&g16s##NAME##N, 16*16); \ +} \ + \ +void \ +test##NAME##N (struct S##NAME##N s1, struct S##NAME##N s2, \ + struct S##NAME##N s3, struct S##NAME##N s4, \ + struct S##NAME##N s5, struct S##NAME##N s6, \ + struct S##NAME##N s7, struct S##NAME##N s8, \ + struct S##NAME##N s9, struct S##NAME##N s10, \ + struct S##NAME##N s11, struct S##NAME##N s12, \ + struct S##NAME##N s13, struct S##NAME##N s14, \ + struct S##NAME##N s15, struct S##NAME##N s16) \ +{ \ + DEBUG_DOT; \ + check##NAME##N (&s1, 1*16); \ + DEBUG_DOT; \ + check##NAME##N (&s2, 2*16); \ + DEBUG_DOT; \ + check##NAME##N (&s3, 3*16); \ + DEBUG_DOT; \ + check##NAME##N (&s4, 4*16); \ + DEBUG_DOT; \ + check##NAME##N (&s5, 5*16); \ + DEBUG_DOT; \ + check##NAME##N (&s6, 6*16); \ + DEBUG_DOT; \ + check##NAME##N (&s7, 7*16); \ + DEBUG_DOT; \ + check##NAME##N (&s8, 8*16); \ + DEBUG_DOT; \ + check##NAME##N (&s9, 9*16); \ + DEBUG_DOT; \ + check##NAME##N (&s10, 10*16); \ + DEBUG_DOT; \ + check##NAME##N (&s11, 11*16); \ + DEBUG_DOT; \ + check##NAME##N (&s12, 12*16); \ + DEBUG_DOT; \ + check##NAME##N (&s13, 13*16); \ + DEBUG_DOT; \ + check##NAME##N (&s14, 14*16); \ + DEBUG_DOT; \ + check##NAME##N (&s15, 15*16); \ + DEBUG_DOT; \ + check##NAME##N (&s16, 16*16); \ +} \ + \ +void \ +testva##NAME##N (int n, ...) \ +{ \ + int i; \ + va_list ap; \ + if (test_va) \ + { \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + { \ + struct S##NAME##N t = va_arg (ap, struct S##NAME##N); \ + DEBUG_DOT; \ + check##NAME##N (&t, (i+1)*16); \ + } \ + va_end (ap); \ + } \ +} + +T(0, uc, unsigned char) +T(1, uc, unsigned char) +T(2, uc, unsigned char) +T(3, uc, unsigned char) +T(4, uc, unsigned char) +T(5, uc, unsigned char) +T(6, uc, unsigned char) +T(7, uc, unsigned char) +T(8, uc, unsigned char) +T(9, uc, unsigned char) +T(10, uc, unsigned char) +T(11, uc, unsigned char) +T(12, uc, unsigned char) +T(13, uc, unsigned char) +T(14, uc, unsigned char) +T(15, uc, unsigned char) +T(0, us, unsigned short) +T(1, us, unsigned short) +T(2, us, unsigned short) +T(3, us, unsigned short) +T(4, us, unsigned short) +T(5, us, unsigned short) +T(6, us, unsigned short) +T(7, us, unsigned short) +T(8, us, unsigned short) +T(9, us, unsigned short) +T(10, us, unsigned short) +T(11, us, unsigned short) +T(12, us, unsigned short) +T(13, us, unsigned short) +T(14, us, unsigned short) +T(15, us, unsigned short) +T(0, ui, unsigned int) +T(1, ui, unsigned int) +T(2, ui, unsigned int) +T(3, ui, unsigned int) +T(4, ui, unsigned int) +T(5, ui, unsigned int) +T(6, ui, unsigned int) +T(7, ui, unsigned int) +T(8, ui, unsigned int) +T(9, ui, unsigned int) +T(10, ui, unsigned int) +T(11, ui, unsigned int) +T(12, ui, unsigned int) +T(13, ui, unsigned int) +T(14, ui, unsigned int) +T(15, ui, unsigned int) --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-3_main.c Fri May 2 15:58:31 2003 @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. All struct members are scalar + integral types, and the structs are "small": 1, 2, 4, 8, and 12 + bytes for LP64. */ + +extern void struct_by_value_3_x (void); +extern void exit (int); + +int +main () +{ + struct_by_value_3_x (); + exit (0); +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-3_x.c Fri May 2 15:58:31 2003 @@ -0,0 +1,212 @@ +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +#define T(TYPE) \ +TYPE g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE; \ +TYPE g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE; \ +TYPE g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE; \ +TYPE g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE; \ + \ +extern void init##TYPE (TYPE *p, int i); \ +extern void checkg##TYPE (void); \ +extern void \ +test##TYPE (TYPE s1, TYPE s2, TYPE s3, TYPE s4, \ + TYPE s5, TYPE s6, TYPE s7, TYPE s8, \ + TYPE s9, TYPE s10, TYPE s11, TYPE s12, \ + TYPE s13, TYPE s14, TYPE s15, TYPE s16); \ +extern void testva##TYPE (int n, ...); \ + \ +void \ +test2_##TYPE (TYPE s1, TYPE s2, TYPE s3, TYPE s4, \ + TYPE s5, TYPE s6, TYPE s7, TYPE s8) \ +{ \ + test##TYPE (s1, g2s##TYPE, s2, g4s##TYPE, \ + s3, g6s##TYPE, s4, g8s##TYPE, \ + s5, g10s##TYPE, s6, g12s##TYPE, \ + s7, g14s##TYPE, s8, g16s##TYPE); \ +} \ + \ +void \ +testit##TYPE (void) \ +{ \ + DEBUG_FPUTS (#TYPE); \ + init##TYPE ( &g1s##TYPE, 1); \ + init##TYPE ( &g2s##TYPE, 2); \ + init##TYPE ( &g3s##TYPE, 3); \ + init##TYPE ( &g4s##TYPE, 4); \ + init##TYPE ( &g5s##TYPE, 5); \ + init##TYPE ( &g6s##TYPE, 6); \ + init##TYPE ( &g7s##TYPE, 7); \ + init##TYPE ( &g8s##TYPE, 8); \ + init##TYPE ( &g9s##TYPE, 9); \ + init##TYPE (&g10s##TYPE, 10); \ + init##TYPE (&g11s##TYPE, 11); \ + init##TYPE (&g12s##TYPE, 12); \ + init##TYPE (&g13s##TYPE, 13); \ + init##TYPE (&g14s##TYPE, 14); \ + init##TYPE (&g15s##TYPE, 15); \ + init##TYPE (&g16s##TYPE, 16); \ + checkg##TYPE (); \ + DEBUG_FPUTS (" test"); \ + test##TYPE (g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE); \ + DEBUG_FPUTS (" testva"); \ + testva##TYPE (1, \ + g1s##TYPE); \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + testva##TYPE (11, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE); \ + testva##TYPE (12, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE); \ + testva##TYPE (13, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE); \ + testva##TYPE (14, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE); \ + testva##TYPE (15, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE, g15s##TYPE); \ + testva##TYPE (16, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE); \ + DEBUG_FPUTS (" test2"); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +typedef struct { char c; } Sc; +typedef struct { short s; } Ss; +typedef struct { int i; } Si; +typedef struct { short s; char c; } Ssc; +typedef struct { char c; short s; } Scs; +typedef struct { int i; char c; } Sic; +typedef struct { char c; int i; } Sci; +typedef struct { short s; int i; } Ssi; +typedef struct { int i; short s; } Sis; +typedef struct { char c; short s; int i; } Scsi; +typedef struct { char c; int i; short s; } Scis; +typedef struct { short s; char c; int i; } Ssci; +typedef struct { short s; int i; char c; } Ssic; +typedef struct { int i; short s; char c; } Sisc; +typedef struct { int i; char c; short s; } Sics; + +extern void abort (void); + +void checkSc (Sc x, int i) { if (x.c != (char)i) { DEBUG_NL; abort (); } } +void checkSs (Ss x, int i) { if (x.s != i) { DEBUG_NL; abort (); } } +void checkSi (Si x, int i) { if (x.i != i) { DEBUG_NL; abort (); } } +void checkSsc (Ssc x, int i) +{ if (x.s != i || x.c != (char)i+1) { DEBUG_NL; abort (); } } +void checkScs (Scs x, int i) +{ if (x.c != (char)i || x.s != i+1) { DEBUG_NL; abort (); } } +void checkSsi (Ssi x, int i) +{ if (x.s != i || x.i != i+1) { DEBUG_NL; abort (); } } +void checkSis (Sis x, int i) +{ if (x.i != i || x.s != i+1) { DEBUG_NL; abort (); } } +void checkSic (Sic x, int i) +{ if (x.i != i || x.c != (char)i+1) { DEBUG_NL; abort (); } } +void checkSci (Sci x, int i) +{ if (x.c != (char)i || x.i != i+1) { DEBUG_NL; abort (); } } +void checkScsi (Scsi x, int i) +{ if (x.c != (char)i || x.s != i+1 || x.i != i+2) { DEBUG_NL; abort (); } } +void checkScis (Scis x, int i) +{ if (x.c != (char)i || x.i != i+1 || x.s != i+2) { DEBUG_NL; abort (); } } +void checkSsci (Ssci x, int i) +{ if (x.s != i || x.c != (char)i+1 || x.i != i+2) { DEBUG_NL; abort (); } } +void checkSsic (Ssic x, int i) +{ if (x.s != i || x.i != i+1 || x.c != (char)i+2) { DEBUG_NL; abort (); } } +void checkSisc (Sisc x, int i) +{ if (x.i != i || x.s != i+1 || x.c != (char)i+2) { DEBUG_NL; abort (); } } +void checkSics (Sics x, int i) +{ if (x.i != i || x.c != (char)i+1 || x.s != i+2) { DEBUG_NL; abort (); } } + +T(Sc) +T(Ss) +T(Si) +T(Scs) +T(Ssc) +T(Sic) +T(Sci) +T(Ssi) +T(Sis) +T(Scsi) +T(Scis) +T(Ssci) +T(Ssic) +T(Sisc) +T(Sics) + +#undef T + +void +struct_by_value_3_x () +{ +#define T(TYPE) testit##TYPE (); + +T(Sc) +T(Ss) +T(Si) +T(Scs) +T(Ssc) +T(Sic) +T(Sci) +T(Ssi) +T(Sis) +T(Scsi) +T(Scis) +T(Ssci) +T(Ssic) +T(Sisc) +T(Sics) + +#undef T +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-3_y.c Fri May 2 15:58:31 2003 @@ -0,0 +1,168 @@ +#include + +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +/* Turn off checking for variable arguments with -DSKIPVA. */ +#ifdef SKIPVA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +typedef struct { char c; } Sc; +typedef struct { short s; } Ss; +typedef struct { int i; } Si; +typedef struct { short s; char c; } Ssc; +typedef struct { char c; short s; } Scs; +typedef struct { int i; char c; } Sic; +typedef struct { char c; int i; } Sci; +typedef struct { short s; int i; } Ssi; +typedef struct { int i; short s; } Sis; +typedef struct { char c; short s; int i; } Scsi; +typedef struct { char c; int i; short s; } Scis; +typedef struct { short s; char c; int i; } Ssci; +typedef struct { short s; int i; char c; } Ssic; +typedef struct { int i; short s; char c; } Sisc; +typedef struct { int i; char c; short s; } Sics; + +extern void checkSc (Sc x, int i); +extern void checkSs (Ss x, int i); +extern void checkSi (Si x, int i); +extern void checkSsc (Ssc x, int i); +extern void checkScs (Scs x, int i); +extern void checkSsi (Ssi x, int i); +extern void checkSis (Sis x, int i); +extern void checkSic (Sic x, int i); +extern void checkSci (Sci x, int i); +extern void checkScsi (Scsi x, int i); +extern void checkScis (Scis x, int i); +extern void checkSsci (Ssci x, int i); +extern void checkSsic (Ssic x, int i); +extern void checkSisc (Sisc x, int i); +extern void checkSics (Sics x, int i); + +void initSc (Sc *p, int i) { p->c = (char)i; } +void initSs (Ss *p, int i) { p->s = i; } +void initSi (Si *p, int i) { p->i = i; } +void initSsc (Ssc *p, int i) { p->s = i; p->c = (char)i+1; } +void initScs (Scs *p, int i) { p->c = (char)i; p->s = i+1; } +void initSsi (Ssi *p, int i) { p->s = i; p->i = i+1; } +void initSis (Sis *p, int i) { p->i = i; p->s = i+1; } +void initSic (Sic *p, int i) { p->i = i; p->c = (char)i+1; } +void initSci (Sci *p, int i) { p->c = (char)i; p->i = i+1; } +void initScsi (Scsi *p, int i) { p->c = (char)i; p->s = i+1; p->i = i+2; } +void initScis (Scis *p, int i) { p->c = (char)i; p->i = i+1; p->s = i+2; } +void initSsci (Ssci *p, int i) { p->s = i; p->c = (char)i+1; p->i = i+2; } +void initSsic (Ssic *p, int i) { p->s = i; p->i = i+1; p->c = (char)i+2; } +void initSisc (Sisc *p, int i) { p->i = i; p->s = i+1; p->c = (char)i+2; } +void initSics (Sics *p, int i) { p->i = i; p->c = (char)i+1; p->s = i+2; } + +#define T(TYPE) \ +extern TYPE g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE; \ +extern TYPE g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE; \ +extern TYPE g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE; \ +extern TYPE g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE; \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE ( g1s##TYPE, 1); \ + check##TYPE ( g2s##TYPE, 2); \ + check##TYPE ( g3s##TYPE, 3); \ + check##TYPE ( g4s##TYPE, 4); \ + check##TYPE ( g5s##TYPE, 5); \ + check##TYPE ( g6s##TYPE, 6); \ + check##TYPE ( g7s##TYPE, 7); \ + check##TYPE ( g8s##TYPE, 8); \ + check##TYPE ( g9s##TYPE, 9); \ + check##TYPE ( g10s##TYPE, 10); \ + check##TYPE ( g11s##TYPE, 11); \ + check##TYPE ( g12s##TYPE, 12); \ + check##TYPE ( g13s##TYPE, 13); \ + check##TYPE ( g14s##TYPE, 14); \ + check##TYPE ( g15s##TYPE, 15); \ + check##TYPE ( g16s##TYPE, 16); \ +} \ + \ +void \ +test##TYPE (TYPE s1, TYPE s2, TYPE s3, TYPE s4, \ + TYPE s5, TYPE s6, TYPE s7, TYPE s8, \ + TYPE s9, TYPE s10, TYPE s11, TYPE s12, \ + TYPE s13, TYPE s14, TYPE s15, TYPE s16) \ +{ \ + DEBUG_DOT; \ + check##TYPE (s1, 1); \ + DEBUG_DOT; \ + check##TYPE (s2, 2); \ + DEBUG_DOT; \ + check##TYPE (s3, 3); \ + DEBUG_DOT; \ + check##TYPE (s4, 4); \ + DEBUG_DOT; \ + check##TYPE (s5, 5); \ + DEBUG_DOT; \ + check##TYPE (s6, 6); \ + DEBUG_DOT; \ + check##TYPE (s7, 7); \ + DEBUG_DOT; \ + check##TYPE (s8, 8); \ + DEBUG_DOT; \ + check##TYPE (s9, 9); \ + DEBUG_DOT; \ + check##TYPE (s10, 10); \ + DEBUG_DOT; \ + check##TYPE (s11, 11); \ + DEBUG_DOT; \ + check##TYPE (s12, 12); \ + DEBUG_DOT; \ + check##TYPE (s13, 13); \ + DEBUG_DOT; \ + check##TYPE (s14, 14); \ + DEBUG_DOT; \ + check##TYPE (s15, 15); \ + DEBUG_DOT; \ + check##TYPE (s16, 16); \ +} \ + \ +void \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + va_list ap; \ + if (test_va) \ + { \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + { \ + TYPE t = va_arg (ap, TYPE); \ + DEBUG_DOT; \ + check##TYPE (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +T(Sc) +T(Ss) +T(Si) +T(Ssc) +T(Scs) +T(Sic) +T(Sci) +T(Ssi) +T(Sis) +T(Scsi) +T(Scis) +T(Ssci) +T(Ssic) +T(Sisc) +T(Sics) --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-4_main.c Fri May 2 15:58:31 2003 @@ -0,0 +1,13 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. Each struct contains an array + of small structs: 1, 2, 4, 8, and 12 bytes for LP64. */ + +extern void struct_by_value_4_x (void); +extern void exit (int); + +int +main () +{ + struct_by_value_4_x (); + exit (0); +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-4_x.c Fri May 2 15:58:31 2003 @@ -0,0 +1,370 @@ +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +#define T(N, TYPE) \ +struct S##TYPE##N { TYPE i[N]; }; \ + \ +struct S##TYPE##N g1s##TYPE##N, g2s##TYPE##N; \ +struct S##TYPE##N g3s##TYPE##N, g4s##TYPE##N; \ +struct S##TYPE##N g5s##TYPE##N, g6s##TYPE##N; \ +struct S##TYPE##N g7s##TYPE##N, g8s##TYPE##N; \ +struct S##TYPE##N g9s##TYPE##N, g10s##TYPE##N; \ +struct S##TYPE##N g11s##TYPE##N, g12s##TYPE##N; \ +struct S##TYPE##N g13s##TYPE##N, g14s##TYPE##N; \ +struct S##TYPE##N g15s##TYPE##N, g16s##TYPE##N; \ + \ +extern void init##TYPE (TYPE *p, int i); \ +extern void checkg##TYPE##N (void); \ +extern void \ +test##TYPE##N (struct S##TYPE##N s1, struct S##TYPE##N s2, \ + struct S##TYPE##N s3, struct S##TYPE##N s4, \ + struct S##TYPE##N s5, struct S##TYPE##N s6, \ + struct S##TYPE##N s7, struct S##TYPE##N s8, \ + struct S##TYPE##N s9, struct S##TYPE##N s10, \ + struct S##TYPE##N s11, struct S##TYPE##N s12, \ + struct S##TYPE##N s13, struct S##TYPE##N s14, \ + struct S##TYPE##N s15, struct S##TYPE##N s16); \ +extern void testva##TYPE##N (int n, ...); \ + \ + \ +void \ +init##TYPE##N (struct S##TYPE##N *p, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + init##TYPE(&p->i[j], i+j); \ +} \ + \ +void \ +check##TYPE##N (struct S##TYPE##N *p, int i) \ +{ \ + int j; \ + for (j = 0; j < N; j++) \ + check##TYPE(p->i[j], i+j); \ +} \ + \ +void \ +test2_##TYPE##N (struct S##TYPE##N s1, struct S##TYPE##N s2, \ + struct S##TYPE##N s3, struct S##TYPE##N s4, \ + struct S##TYPE##N s5, struct S##TYPE##N s6, \ + struct S##TYPE##N s7, struct S##TYPE##N s8) \ +{ \ + test##TYPE##N (s1, g2s##TYPE##N, s2, g4s##TYPE##N, \ + s3, g6s##TYPE##N, s4, g8s##TYPE##N, \ + s5, g10s##TYPE##N, s6, g12s##TYPE##N, \ + s7, g14s##TYPE##N, s8, g16s##TYPE##N); \ +} \ + \ +void \ +testit##TYPE##N (void) \ +{ \ + DEBUG_FPUTS (#TYPE "[" #N "]"); \ + init##TYPE##N ( &g1s##TYPE##N, 1*16); \ + init##TYPE##N ( &g2s##TYPE##N, 2*16); \ + init##TYPE##N ( &g3s##TYPE##N, 3*16); \ + init##TYPE##N ( &g4s##TYPE##N, 4*16); \ + init##TYPE##N ( &g5s##TYPE##N, 5*16); \ + init##TYPE##N ( &g6s##TYPE##N, 6*16); \ + init##TYPE##N ( &g7s##TYPE##N, 7*16); \ + init##TYPE##N ( &g8s##TYPE##N, 8*16); \ + init##TYPE##N ( &g9s##TYPE##N, 9*16); \ + init##TYPE##N (&g10s##TYPE##N, 10*16); \ + init##TYPE##N (&g11s##TYPE##N, 11*16); \ + init##TYPE##N (&g12s##TYPE##N, 12*16); \ + init##TYPE##N (&g13s##TYPE##N, 13*16); \ + init##TYPE##N (&g14s##TYPE##N, 14*16); \ + init##TYPE##N (&g15s##TYPE##N, 15*16); \ + init##TYPE##N (&g16s##TYPE##N, 16*16); \ + checkg##TYPE##N (); \ + DEBUG_FPUTS (" test"); \ + test##TYPE##N (g1s##TYPE##N, g2s##TYPE##N, \ + g3s##TYPE##N, g4s##TYPE##N, \ + g5s##TYPE##N, g6s##TYPE##N, \ + g7s##TYPE##N, g8s##TYPE##N, \ + g9s##TYPE##N, g10s##TYPE##N, \ + g11s##TYPE##N, g12s##TYPE##N, \ + g13s##TYPE##N, g14s##TYPE##N, \ + g15s##TYPE##N, g16s##TYPE##N); \ + DEBUG_FPUTS (" testva"); \ + testva##TYPE##N (16, \ + g1s##TYPE##N, g2s##TYPE##N, \ + g3s##TYPE##N, g4s##TYPE##N, \ + g5s##TYPE##N, g6s##TYPE##N, \ + g7s##TYPE##N, g8s##TYPE##N, \ + g9s##TYPE##N, g10s##TYPE##N, \ + g11s##TYPE##N, g12s##TYPE##N, \ + g13s##TYPE##N, g14s##TYPE##N, \ + g15s##TYPE##N, g16s##TYPE##N); \ + DEBUG_FPUTS (" test2"); \ + test2_##TYPE##N (g1s##TYPE##N, g3s##TYPE##N, \ + g5s##TYPE##N, g7s##TYPE##N, \ + g9s##TYPE##N, g11s##TYPE##N, \ + g13s##TYPE##N, g15s##TYPE##N); \ + DEBUG_NL; \ +} + +typedef struct { char c; } Sc; +typedef struct { short s; } Ss; +typedef struct { int i; } Si; +typedef struct { short s; char c; } Ssc; +typedef struct { int i; short s; } Sis; +typedef struct { char c; short s; int i; } Scsi; +typedef struct { char c; int i; short s; } Scis; + +extern void abort (void); + +void checkSc (Sc x, int i) { if (x.c != i/16) { DEBUG_NL; abort (); } } +void checkSs (Ss x, int i) { if (x.s != i) { DEBUG_NL; abort (); } } +void checkSi (Si x, int i) { if (x.i != i) { DEBUG_NL; abort (); } } +void checkSsc (Ssc x, int i) +{ if (x.s != i || x.c != (i/16)+1) { DEBUG_NL; abort (); } } +void checkSis (Sis x, int i) +{ if (x.i != i || x.s != i+1) { DEBUG_NL; abort (); } } +void checkScsi (Scsi x, int i) +{ if (x.c != i/16 || x.s != i+1 || x.i != i+2) { DEBUG_NL; abort (); } } +void checkScis (Scis x, int i) +{ if (x.c != i/16 || x.i != i+1 || x.s != i+2) { DEBUG_NL; abort (); } } + +T(0, Sc) +T(1, Sc) +T(2, Sc) +T(3, Sc) +T(4, Sc) +T(5, Sc) +T(6, Sc) +T(7, Sc) +T(8, Sc) +T(9, Sc) +T(10, Sc) +T(11, Sc) +T(12, Sc) +T(13, Sc) +T(14, Sc) +T(15, Sc) +T(0, Ss) +T(1, Ss) +T(2, Ss) +T(3, Ss) +T(4, Ss) +T(5, Ss) +T(6, Ss) +T(7, Ss) +T(8, Ss) +T(9, Ss) +T(10, Ss) +T(11, Ss) +T(12, Ss) +T(13, Ss) +T(14, Ss) +T(15, Ss) +T(0, Si) +T(1, Si) +T(2, Si) +T(3, Si) +T(4, Si) +T(5, Si) +T(6, Si) +T(7, Si) +T(8, Si) +T(9, Si) +T(10, Si) +T(11, Si) +T(12, Si) +T(13, Si) +T(14, Si) +T(15, Si) +T(0, Ssc) +T(1, Ssc) +T(2, Ssc) +T(3, Ssc) +T(4, Ssc) +T(5, Ssc) +T(6, Ssc) +T(7, Ssc) +T(8, Ssc) +T(9, Ssc) +T(10, Ssc) +T(11, Ssc) +T(12, Ssc) +T(13, Ssc) +T(14, Ssc) +T(15, Ssc) +T(0, Sis) +T(1, Sis) +T(2, Sis) +T(3, Sis) +T(4, Sis) +T(5, Sis) +T(6, Sis) +T(7, Sis) +T(8, Sis) +T(9, Sis) +T(10, Sis) +T(11, Sis) +T(12, Sis) +T(13, Sis) +T(14, Sis) +T(15, Sis) +T(0, Scsi) +T(1, Scsi) +T(2, Scsi) +T(3, Scsi) +T(4, Scsi) +T(5, Scsi) +T(6, Scsi) +T(7, Scsi) +T(8, Scsi) +T(9, Scsi) +T(10, Scsi) +T(11, Scsi) +T(12, Scsi) +T(13, Scsi) +T(14, Scsi) +T(15, Scsi) +T(0, Scis) +T(1, Scis) +T(2, Scis) +T(3, Scis) +T(4, Scis) +T(5, Scis) +T(6, Scis) +T(7, Scis) +T(8, Scis) +T(9, Scis) +T(10, Scis) +T(11, Scis) +T(12, Scis) +T(13, Scis) +T(14, Scis) +T(15, Scis) + +#undef T + +void +struct_by_value_4_x () +{ +#define T(N, TYPE) testit##TYPE##N (); + +T(0, Sc) +T(1, Sc) +T(2, Sc) +T(3, Sc) +T(4, Sc) +T(5, Sc) +T(6, Sc) +T(7, Sc) +T(8, Sc) +T(9, Sc) +T(10, Sc) +T(11, Sc) +T(12, Sc) +T(13, Sc) +T(14, Sc) +T(15, Sc) +T(0, Ss) +T(1, Ss) +T(2, Ss) +T(3, Ss) +T(4, Ss) +T(5, Ss) +T(6, Ss) +T(7, Ss) +T(8, Ss) +T(9, Ss) +T(10, Ss) +T(11, Ss) +T(12, Ss) +T(13, Ss) +T(14, Ss) +T(15, Ss) +T(0, Si) +T(1, Si) +T(2, Si) +T(3, Si) +T(4, Si) +T(5, Si) +T(6, Si) +T(7, Si) +T(8, Si) +T(9, Si) +T(10, Si) +T(11, Si) +T(12, Si) +T(13, Si) +T(14, Si) +T(15, Si) +T(0, Ssc) +T(1, Ssc) +T(2, Ssc) +T(3, Ssc) +T(4, Ssc) +T(5, Ssc) +T(6, Ssc) +T(7, Ssc) +T(8, Ssc) +T(9, Ssc) +T(10, Ssc) +T(11, Ssc) +T(12, Ssc) +T(13, Ssc) +T(14, Ssc) +T(15, Ssc) +T(0, Sis) +T(1, Sis) +T(2, Sis) +T(3, Sis) +T(4, Sis) +T(5, Sis) +T(6, Sis) +T(7, Sis) +T(8, Sis) +T(9, Sis) +T(10, Sis) +T(11, Sis) +T(12, Sis) +T(13, Sis) +T(14, Sis) +T(15, Sis) +T(0, Scsi) +T(1, Scsi) +T(2, Scsi) +T(3, Scsi) +T(4, Scsi) +T(5, Scsi) +T(6, Scsi) +T(7, Scsi) +T(8, Scsi) +T(9, Scsi) +T(10, Scsi) +T(11, Scsi) +T(12, Scsi) +T(13, Scsi) +T(14, Scsi) +T(15, Scsi) +T(0, Scis) +T(1, Scis) +T(2, Scis) +T(3, Scis) +T(4, Scis) +T(5, Scis) +T(6, Scis) +T(7, Scis) +T(8, Scis) +T(9, Scis) +T(10, Scis) +T(11, Scis) +T(12, Scis) +T(13, Scis) +T(14, Scis) +T(15, Scis) + +#undef T +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-4_y.c Fri May 2 15:58:31 2003 @@ -0,0 +1,247 @@ +#include + +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +/* Turn off checking for variable arguments with -DSKIPVA. */ +#ifdef SKIPVA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +typedef struct { char c; } Sc; +typedef struct { short s; } Ss; +typedef struct { int i; } Si; +typedef struct { short s; char c; } Ssc; +typedef struct { int i; short s; } Sis; +typedef struct { char c; short s; int i; } Scsi; +typedef struct { char c; int i; short s; } Scis; + +void initSc (Sc *p, int i) { p->c = i/16; } +void initSs (Ss *p, int i) { p->s = i; } +void initSi (Si *p, int i) { p->i = i; } +void initSsc (Ssc *p, int i) { p->s = i; p->c = (i/16)+1; } +void initSis (Sis *p, int i) { p->i = i; p->s = i+1; } +void initScsi (Scsi *p, int i) { p->c = i/16; p->s = i+1; p->i = i+2; } +void initScis (Scis *p, int i) { p->c = i/16; p->i = i+1; p->s = i+2; } + +#define T(N, TYPE) \ +struct S##TYPE##N { TYPE i[N]; }; \ + \ +extern struct S##TYPE##N g1s##TYPE##N, g2s##TYPE##N; \ +extern struct S##TYPE##N g3s##TYPE##N, g4s##TYPE##N; \ +extern struct S##TYPE##N g5s##TYPE##N, g6s##TYPE##N; \ +extern struct S##TYPE##N g7s##TYPE##N, g8s##TYPE##N; \ +extern struct S##TYPE##N g9s##TYPE##N, g10s##TYPE##N; \ +extern struct S##TYPE##N g11s##TYPE##N, g12s##TYPE##N; \ +extern struct S##TYPE##N g13s##TYPE##N, g14s##TYPE##N; \ +extern struct S##TYPE##N g15s##TYPE##N, g16s##TYPE##N; \ + \ +extern void check##TYPE (TYPE x, int i); \ +extern void \ +check##TYPE##N (struct S##TYPE##N *p, int i); \ + \ +void \ +checkg##TYPE##N (void) \ +{ \ + check##TYPE##N ( &g1s##TYPE##N, 1*16); \ + check##TYPE##N ( &g2s##TYPE##N, 2*16); \ + check##TYPE##N ( &g3s##TYPE##N, 3*16); \ + check##TYPE##N ( &g4s##TYPE##N, 4*16); \ + check##TYPE##N ( &g5s##TYPE##N, 5*16); \ + check##TYPE##N ( &g6s##TYPE##N, 6*16); \ + check##TYPE##N ( &g7s##TYPE##N, 7*16); \ + check##TYPE##N ( &g8s##TYPE##N, 8*16); \ + check##TYPE##N ( &g9s##TYPE##N, 9*16); \ + check##TYPE##N (&g10s##TYPE##N, 10*16); \ + check##TYPE##N (&g11s##TYPE##N, 11*16); \ + check##TYPE##N (&g12s##TYPE##N, 12*16); \ + check##TYPE##N (&g13s##TYPE##N, 13*16); \ + check##TYPE##N (&g14s##TYPE##N, 14*16); \ + check##TYPE##N (&g15s##TYPE##N, 15*16); \ + check##TYPE##N (&g16s##TYPE##N, 16*16); \ +} \ + \ +void \ +test##TYPE##N (struct S##TYPE##N s1, struct S##TYPE##N s2, \ + struct S##TYPE##N s3, struct S##TYPE##N s4, \ + struct S##TYPE##N s5, struct S##TYPE##N s6, \ + struct S##TYPE##N s7, struct S##TYPE##N s8, \ + struct S##TYPE##N s9, struct S##TYPE##N s10, \ + struct S##TYPE##N s11, struct S##TYPE##N s12, \ + struct S##TYPE##N s13, struct S##TYPE##N s14, \ + struct S##TYPE##N s15, struct S##TYPE##N s16) \ +{ \ + DEBUG_DOT; \ + check##TYPE##N (&s1, 1*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s2, 2*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s3, 3*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s4, 4*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s5, 5*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s6, 6*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s7, 7*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s8, 8*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s9, 9*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s10, 10*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s11, 11*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s12, 12*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s13, 13*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s14, 14*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s15, 15*16); \ + DEBUG_DOT; \ + check##TYPE##N (&s16, 16*16); \ +} \ + \ +void \ +testva##TYPE##N (int n, ...) \ +{ \ + int i; \ + va_list ap; \ + if (test_va) \ + { \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + { \ + struct S##TYPE##N t = va_arg (ap, struct S##TYPE##N); \ + DEBUG_DOT; \ + check##TYPE##N (&t, (i+1)*16); \ + } \ + va_end (ap); \ + } \ +} + +T(0, Sc) +T(1, Sc) +T(2, Sc) +T(3, Sc) +T(4, Sc) +T(5, Sc) +T(6, Sc) +T(7, Sc) +T(8, Sc) +T(9, Sc) +T(10, Sc) +T(11, Sc) +T(12, Sc) +T(13, Sc) +T(14, Sc) +T(15, Sc) +T(0, Ss) +T(1, Ss) +T(2, Ss) +T(3, Ss) +T(4, Ss) +T(5, Ss) +T(6, Ss) +T(7, Ss) +T(8, Ss) +T(9, Ss) +T(10, Ss) +T(11, Ss) +T(12, Ss) +T(13, Ss) +T(14, Ss) +T(15, Ss) +T(0, Si) +T(1, Si) +T(2, Si) +T(3, Si) +T(4, Si) +T(5, Si) +T(6, Si) +T(7, Si) +T(8, Si) +T(9, Si) +T(10, Si) +T(11, Si) +T(12, Si) +T(13, Si) +T(14, Si) +T(15, Si) +T(0, Ssc) +T(1, Ssc) +T(2, Ssc) +T(3, Ssc) +T(4, Ssc) +T(5, Ssc) +T(6, Ssc) +T(7, Ssc) +T(8, Ssc) +T(9, Ssc) +T(10, Ssc) +T(11, Ssc) +T(12, Ssc) +T(13, Ssc) +T(14, Ssc) +T(15, Ssc) +T(0, Sis) +T(1, Sis) +T(2, Sis) +T(3, Sis) +T(4, Sis) +T(5, Sis) +T(6, Sis) +T(7, Sis) +T(8, Sis) +T(9, Sis) +T(10, Sis) +T(11, Sis) +T(12, Sis) +T(13, Sis) +T(14, Sis) +T(15, Sis) +T(0, Scsi) +T(1, Scsi) +T(2, Scsi) +T(3, Scsi) +T(4, Scsi) +T(5, Scsi) +T(6, Scsi) +T(7, Scsi) +T(8, Scsi) +T(9, Scsi) +T(10, Scsi) +T(11, Scsi) +T(12, Scsi) +T(13, Scsi) +T(14, Scsi) +T(15, Scsi) +T(0, Scis) +T(1, Scis) +T(2, Scis) +T(3, Scis) +T(4, Scis) +T(5, Scis) +T(6, Scis) +T(7, Scis) +T(8, Scis) +T(9, Scis) +T(10, Scis) +T(11, Scis) +T(12, Scis) +T(13, Scis) +T(14, Scis) +T(15, Scis) --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-5_main.c Fri May 2 15:58:31 2003 @@ -0,0 +1,13 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are floating + point scalars. */ + +extern void struct_by_value_5_x (void); +extern void exit (int); + +int +main () +{ + struct_by_value_5_x (); + exit (0); +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-5_x.c Fri May 2 15:58:31 2003 @@ -0,0 +1,349 @@ +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +#define X(NAME,TYPEM) \ +typedef struct { TYPEM a; } S##NAME##1; \ +typedef struct { TYPEM a; TYPEM b; } S##NAME##2; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; } S##NAME##3; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; } \ + S##NAME##4; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; } \ + S##NAME##5; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; } S##NAME##6; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; } S##NAME##7; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; } S##NAME##8; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; } \ + S##NAME##9; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; } \ + S##NAME##10; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; } S##NAME##11; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; } S##NAME##12; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; } S##NAME##13; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; TYPEM n; } \ + S##NAME##14; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; TYPEM n; TYPEM o; } \ + S##NAME##15; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; TYPEM n; TYPEM o; \ + TYPEM p; } S##NAME##16; \ + \ +void checkS##NAME##1 (S##NAME##1 x, TYPEM y) \ +{ if (x.a != y) { DEBUG_NL; DEBUG_NL; abort (); } } \ +void checkS##NAME##2 (S##NAME##2 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 ) { DEBUG_NL; abort (); } } \ +void checkS##NAME##3 (S##NAME##3 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 ) \ + { DEBUG_NL; abort (); } } \ +void checkS##NAME##4 (S##NAME##4 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3) \ + { DEBUG_NL; abort (); } } \ +void checkS##NAME##5 (S##NAME##5 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4) { DEBUG_NL; abort (); } } \ +void checkS##NAME##6 (S##NAME##6 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5) { DEBUG_NL; abort (); } } \ +void checkS##NAME##7 (S##NAME##7 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6) \ + { DEBUG_NL; abort (); } } \ +void checkS##NAME##8 (S##NAME##8 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7) { DEBUG_NL; abort (); } } \ +void checkS##NAME##9 (S##NAME##9 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8) { DEBUG_NL; abort (); } } \ +void checkS##NAME##10 (S##NAME##10 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8 || x.j != y+9) \ + { DEBUG_NL; abort (); } } \ +void checkS##NAME##11 (S##NAME##11 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8 || x.j != y+9 \ + || x.k != y+10) { DEBUG_NL; abort (); } } \ +void checkS##NAME##12 (S##NAME##12 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8 || x.j != y+9 \ + || x.k != y+10 || x.l != y+11) { DEBUG_NL; abort (); } } \ +void checkS##NAME##13 (S##NAME##13 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8 || x.j != y+9 \ + || x.k != y+10 || x.l != y+11 || x.m != y+12) \ + { DEBUG_NL; abort (); } } \ +void checkS##NAME##14 (S##NAME##14 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8 || x.j != y+9 \ + || x.k != y+10 || x.l != y+11 || x.m != y+12 \ + || x.n != y+13) { DEBUG_NL; abort (); } } \ +void checkS##NAME##15 (S##NAME##15 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8 || x.j != y+9 \ + || x.k != y+10 || x.l != y+11 || x.m != y+12 \ + || x.n != y+13 || x.o != y+14) { DEBUG_NL; abort (); } } \ +void checkS##NAME##16 (S##NAME##16 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 || x.d != y+3 \ + || x.e != y+4 || x.f != y+5 || x.g != y+6 \ + || x.h != y+7 || x.i != y+8 || x.j != y+9 \ + || x.k != y+10 || x.l != y+11 || x.m != y+12 \ + || x.n != y+13 || x.o != y+14 || x.p != y+15) \ + { DEBUG_NL; abort (); } } + +#define T(TYPE,MTYPE) \ +TYPE g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE; \ +TYPE g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE; \ +TYPE g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE; \ +TYPE g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE; \ + \ +extern void init##TYPE (TYPE *p, MTYPE x); \ +extern void checkg##TYPE (void); \ +extern void \ +test##TYPE (TYPE s1, TYPE s2, TYPE s3, TYPE s4, \ + TYPE s5, TYPE s6, TYPE s7, TYPE s8, \ + TYPE s9, TYPE s10, TYPE s11, TYPE s12, \ + TYPE s13, TYPE s14, TYPE s15, TYPE s16); \ +extern void testva##TYPE (int n, ...); \ + \ +void \ +test2_##TYPE (TYPE s1, TYPE s2, TYPE s3, TYPE s4, \ + TYPE s5, TYPE s6, TYPE s7, TYPE s8) \ +{ \ + test##TYPE (s1, g2s##TYPE, s2, g4s##TYPE, \ + s3, g6s##TYPE, s4, g8s##TYPE, \ + s5, g10s##TYPE, s6, g12s##TYPE, \ + s7, g14s##TYPE, s8, g16s##TYPE); \ +} \ + \ +void \ +testit##TYPE (void) \ +{ \ + DEBUG_FPUTS (#TYPE); \ + init##TYPE ( &g1s##TYPE, (MTYPE)1); \ + init##TYPE ( &g2s##TYPE, (MTYPE)2); \ + init##TYPE ( &g3s##TYPE, (MTYPE)3); \ + init##TYPE ( &g4s##TYPE, (MTYPE)4); \ + init##TYPE ( &g5s##TYPE, (MTYPE)5); \ + init##TYPE ( &g6s##TYPE, (MTYPE)6); \ + init##TYPE ( &g7s##TYPE, (MTYPE)7); \ + init##TYPE ( &g8s##TYPE, (MTYPE)8); \ + init##TYPE ( &g9s##TYPE, (MTYPE)9); \ + init##TYPE (&g10s##TYPE, (MTYPE)10); \ + init##TYPE (&g11s##TYPE, (MTYPE)11); \ + init##TYPE (&g12s##TYPE, (MTYPE)12); \ + init##TYPE (&g13s##TYPE, (MTYPE)13); \ + init##TYPE (&g14s##TYPE, (MTYPE)14); \ + init##TYPE (&g15s##TYPE, (MTYPE)15); \ + init##TYPE (&g16s##TYPE, (MTYPE)16); \ + checkg##TYPE (); \ + DEBUG_FPUTS (" test"); \ + test##TYPE (g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE); \ + DEBUG_FPUTS (" testva"); \ + testva##TYPE (1, \ + g1s##TYPE); \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + testva##TYPE (11, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE); \ + testva##TYPE (12, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE); \ + testva##TYPE (13, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE); \ + testva##TYPE (14, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE); \ + testva##TYPE (15, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE, g15s##TYPE); \ + testva##TYPE (16, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE, \ + g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE); \ + DEBUG_FPUTS (" test2"); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +extern void abort (void); + +X(f, float) +X(d, double) +X(ld, long double) + +T(Sf1, float) +T(Sf2, float) +T(Sf3, float) +T(Sf4, float) +T(Sf5, float) +T(Sf6, float) +T(Sf7, float) +T(Sf8, float) +T(Sf9, float) +T(Sf10, float) +T(Sf11, float) +T(Sf12, float) +T(Sf13, float) +T(Sf14, float) +T(Sf15, float) +T(Sf16, float) +T(Sd1, double) +T(Sd2, double) +T(Sd3, double) +T(Sd4, double) +T(Sd5, double) +T(Sd6, double) +T(Sd7, double) +T(Sd8, double) +T(Sd9, double) +T(Sd10, double) +T(Sd11, double) +T(Sd12, double) +T(Sd13, double) +T(Sd14, double) +T(Sd15, double) +T(Sd16, double) +T(Sld1, long double) +T(Sld2, long double) +T(Sld3, long double) +T(Sld4, long double) +T(Sld5, long double) +T(Sld6, long double) +T(Sld7, long double) +T(Sld8, long double) +T(Sld9, long double) +T(Sld10, long double) +T(Sld11, long double) +T(Sld12, long double) +T(Sld13, long double) +T(Sld14, long double) +T(Sld15, long double) +T(Sld16, long double) + +#undef T + +void +struct_by_value_5_x () +{ +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sf1, float) +T(Sf2, float) +T(Sf3, float) +T(Sf4, float) +T(Sf5, float) +T(Sf6, float) +T(Sf7, float) +T(Sf8, float) +T(Sf9, float) +T(Sf10, float) +T(Sf11, float) +T(Sf12, float) +T(Sf13, float) +T(Sf14, float) +T(Sf15, float) +T(Sf16, float) +T(Sd1, double) +T(Sd2, double) +T(Sd3, double) +T(Sd4, double) +T(Sd5, double) +T(Sd6, double) +T(Sd7, double) +T(Sd8, double) +T(Sd9, double) +T(Sd10, double) +T(Sd11, double) +T(Sd12, double) +T(Sd13, double) +T(Sd14, double) +T(Sd15, double) +T(Sd16, double) +T(Sld1, long double) +T(Sld2, long double) +T(Sld3, long double) +T(Sld4, long double) +T(Sld5, long double) +T(Sld6, long double) +T(Sld7, long double) +T(Sld8, long double) +T(Sld9, long double) +T(Sld10, long double) +T(Sld11, long double) +T(Sld12, long double) +T(Sld13, long double) +T(Sld14, long double) +T(Sld15, long double) +T(Sld16, long double) + +#undef T +} --- /dev/null Tue Oct 29 09:27:24 2002 +++ gcc/testsuite/gcc.dg/compat/struct-by-value-5_y.c Fri May 2 15:58:31 2003 @@ -0,0 +1,253 @@ +#include + +#ifdef DBG +#include +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#else +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#endif + +/* Turn off checking for variable arguments with -DSKIPVA. */ +#ifdef SKIPVA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define X(NAME,TYPEM) \ +typedef struct { TYPEM a; } S##NAME##1; \ +typedef struct { TYPEM a; TYPEM b; } S##NAME##2; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; } S##NAME##3; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; } \ + S##NAME##4; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; } \ + S##NAME##5; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; } S##NAME##6; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; } S##NAME##7; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; } S##NAME##8; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; } \ + S##NAME##9; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; } \ + S##NAME##10; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; } S##NAME##11; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; } S##NAME##12; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; } S##NAME##13; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; TYPEM n; } \ + S##NAME##14; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; TYPEM n; TYPEM o; } \ + S##NAME##15; \ +typedef struct { TYPEM a; TYPEM b; TYPEM c; TYPEM d; TYPEM e; \ + TYPEM f; TYPEM g; TYPEM h; TYPEM i; TYPEM j; \ + TYPEM k; TYPEM l; TYPEM m; TYPEM n; TYPEM o; \ + TYPEM p; } S##NAME##16; \ + \ +void initS##NAME##1 (S##NAME##1 *p, TYPEM y) \ +{ p->a = y; } \ +void initS##NAME##2 (S##NAME##2 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; } \ +void initS##NAME##3 (S##NAME##3 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; } \ +void initS##NAME##4 (S##NAME##4 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; } \ +void initS##NAME##5 (S##NAME##5 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; } \ +void initS##NAME##6 (S##NAME##6 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; } \ +void initS##NAME##7 (S##NAME##7 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; } \ +void initS##NAME##8 (S##NAME##8 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; } \ +void initS##NAME##9 (S##NAME##9 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; } \ +void initS##NAME##10 (S##NAME##10 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; p->j = y+9; } \ +void initS##NAME##11 (S##NAME##11 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; p->j = y+9; \ + p->k = y+10; } \ +void initS##NAME##12 (S##NAME##12 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; p->j = y+9; \ + p->k = y+10; p->l = y+11; } \ +void initS##NAME##13 (S##NAME##13 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; p->j = y+9; \ + p->k = y+10; p->l = y+11; p->m = y+12; } \ +void initS##NAME##14 (S##NAME##14 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; p->j = y+9; \ + p->k = y+10; p->l = y+11; p->m = y+12; p->n = y+13; } \ +void initS##NAME##15 (S##NAME##15 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; p->j = y+9; \ + p->k = y+10; p->l = y+11; p->m = y+12; p->n = y+13; \ + p->o = y+14; } \ +void initS##NAME##16 (S##NAME##16 *p, TYPEM y) \ +{ p->a = y; p->b = y+1; p->c = y+2; p->d = y+3; p->e = y+4; \ + p->f = y+5; p->g = y+6; p->h = y+7; p->i = y+8; p->j = y+9; \ + p->k = y+10; p->l = y+11; p->m = y+12; p->n = y+13; \ + p->o = y+14; p->p = y+15; } + +#define T(TYPE,TYPE2) \ +extern TYPE g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE; \ +extern TYPE g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE; \ +extern TYPE g9s##TYPE, g10s##TYPE, g11s##TYPE, g12s##TYPE; \ +extern TYPE g13s##TYPE, g14s##TYPE, g15s##TYPE, g16s##TYPE; \ + \ +extern void check##TYPE (TYPE x, TYPE2 y); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE ( g1s##TYPE, (TYPE2)1); \ + check##TYPE ( g2s##TYPE, (TYPE2)2); \ + check##TYPE ( g3s##TYPE, (TYPE2)3); \ + check##TYPE ( g4s##TYPE, (TYPE2)4); \ + check##TYPE ( g5s##TYPE, (TYPE2)5); \ + check##TYPE ( g6s##TYPE, (TYPE2)6); \ + check##TYPE ( g7s##TYPE, (TYPE2)7); \ + check##TYPE ( g8s##TYPE, (TYPE2)8); \ + check##TYPE ( g9s##TYPE, (TYPE2)9); \ + check##TYPE ( g10s##TYPE, (TYPE2)10); \ + check##TYPE ( g11s##TYPE, (TYPE2)11); \ + check##TYPE ( g12s##TYPE, (TYPE2)12); \ + check##TYPE ( g13s##TYPE, (TYPE2)13); \ + check##TYPE ( g14s##TYPE, (TYPE2)14); \ + check##TYPE ( g15s##TYPE, (TYPE2)15); \ + check##TYPE ( g16s##TYPE, (TYPE2)16); \ +} \ + \ +void \ +test##TYPE (TYPE s1, TYPE s2, TYPE s3, TYPE s4, \ + TYPE s5, TYPE s6, TYPE s7, TYPE s8, \ + TYPE s9, TYPE s10, TYPE s11, TYPE s12, \ + TYPE s13, TYPE s14, TYPE s15, TYPE s16) \ +{ \ + DEBUG_DOT; \ + check##TYPE (s1, (TYPE2)1); \ + DEBUG_DOT; \ + check##TYPE (s2, (TYPE2)2); \ + DEBUG_DOT; \ + check##TYPE (s3, (TYPE2)3); \ + DEBUG_DOT; \ + check##TYPE (s4, (TYPE2)4); \ + DEBUG_DOT; \ + check##TYPE (s5, (TYPE2)5); \ + DEBUG_DOT; \ + check##TYPE (s6, (TYPE2)6); \ + DEBUG_DOT; \ + check##TYPE (s7, (TYPE2)7); \ + DEBUG_DOT; \ + check##TYPE (s8, (TYPE2)8); \ + DEBUG_DOT; \ + check##TYPE (s9, (TYPE2)9); \ + DEBUG_DOT; \ + check##TYPE (s10, (TYPE2)10); \ + DEBUG_DOT; \ + check##TYPE (s11, (TYPE2)11); \ + DEBUG_DOT; \ + check##TYPE (s12, (TYPE2)12); \ + DEBUG_DOT; \ + check##TYPE (s13, (TYPE2)13); \ + DEBUG_DOT; \ + check##TYPE (s14, (TYPE2)14); \ + DEBUG_DOT; \ + check##TYPE (s15, (TYPE2)15); \ + DEBUG_DOT; \ + check##TYPE (s16, (TYPE2)16); \ +} \ + \ +void \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + va_list ap; \ + if (test_va) \ + { \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + { \ + TYPE t = va_arg (ap, TYPE); \ + DEBUG_DOT; \ + check##TYPE (t, (TYPE2)i+1); \ + } \ + va_end (ap); \ + } \ +} + +X(f, float) +X(d, double) +X(ld, long double) + +T(Sf1, float) +T(Sf2, float) +T(Sf3, float) +T(Sf4, float) +T(Sf5, float) +T(Sf6, float) +T(Sf7, float) +T(Sf8, float) +T(Sf9, float) +T(Sf10, float) +T(Sf11, float) +T(Sf12, float) +T(Sf13, float) +T(Sf14, float) +T(Sf15, float) +T(Sf16, float) +T(Sd1, double) +T(Sd2, double) +T(Sd3, double) +T(Sd4, double) +T(Sd5, double) +T(Sd6, double) +T(Sd7, double) +T(Sd8, double) +T(Sd9, double) +T(Sd10, double) +T(Sd11, double) +T(Sd12, double) +T(Sd13, double) +T(Sd14, double) +T(Sd15, double) +T(Sd16, double) +T(Sld1, long double) +T(Sld2, long double) +T(Sld3, long double) +T(Sld4, long double) +T(Sld5, long double) +T(Sld6, long double) +T(Sld7, long double) +T(Sld8, long double) +T(Sld9, long double) +T(Sld10, long double) +T(Sld11, long double) +T(Sld12, long double) +T(Sld13, long double) +T(Sld14, long double) +T(Sld15, long double) +T(Sld16, long double)