diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/compat | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/compat')
232 files changed, 15843 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/compat/compat-common.h b/gcc/testsuite/gcc.dg/compat/compat-common.h new file mode 100644 index 000000000..8a92ea3e6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/compat-common.h @@ -0,0 +1,55 @@ +/* Several of the binary compatibility tests use these macros to + allow debugging the test or tracking down a failure by getting an + indication of whether each individual check passed or failed. + When DBG is defined, each check is shown by a dot (pass) or 'F' + (fail) rather than aborting as soon as a failure is detected. */ + +#ifdef DBG +#include <stdio.h> +#define DEBUG_INIT setbuf (stdout, NULL); +#define DEBUG_FPUTS(x) fputs (x, stdout) +#define DEBUG_DOT putc ('.', stdout) +#define DEBUG_NL putc ('\n', stdout) +#define DEBUG_FAIL putc ('F', stdout); fails++ +#define DEBUG_CHECK { DEBUG_FAIL; } else { DEBUG_DOT; } +#define DEBUG_FINI if (fails) DEBUG_FPUTS ("failed\n"); \ + else DEBUG_FPUTS ("passed\n"); +#else +#define DEBUG_INIT +#define DEBUG_FPUTS(x) +#define DEBUG_DOT +#define DEBUG_NL +#define DEBUG_FAIL abort () +#define DEBUG_CHECK abort (); +#define DEBUG_FINI +#endif + +#ifdef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +#define SKIP_COMPLEX_INT +#endif +#endif + +#ifndef SKIP_COMPLEX +#ifdef __GNUC__ +#define CINT(x, y) (x + y * __extension__ 1i) +#define CDBL(x, y) (x + y * __extension__ 1i) +#else +#ifdef __SUNPRO_C +/* ??? Complex support without <complex.h>. */ +#else +#include <complex.h> +#endif +#ifndef SKIP_COMPLEX_INT +#define CINT(x, y) ((_Complex int) (x + y * _Complex_I)) +#endif +#define CDBL(x, y) (x + y * _Complex_I) +#endif +#endif + +#ifdef __cplusplus +extern "C" void abort (void); +#else +extern void abort (void); +#endif +extern int fails; diff --git a/gcc/testsuite/gcc.dg/compat/compat.exp b/gcc/testsuite/gcc.dg/compat/compat.exp new file mode 100644 index 000000000..1302d5259 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/compat.exp @@ -0,0 +1,86 @@ +# Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. +# +# This file was written by Janis Johnson, <janis187@us.ibm.com> + + +# Test interoperability of two compilers that follow the same ABI. +# +# Break simple tests into two pieces and see that they work when linked +# together. If an alternate compiler is specified then the two main +# pieces of each test are compiled with different compilers. The +# alternate compiler must be installed, and is specified by defining +# ALT_CC_UNDER_TEST in the environment. + +if $tracelevel then { + strace $tracelevel +} + +global GCC_UNDER_TEST +global ALT_CC_UNDER_TEST +global compat_save_gcc_under_test +global compat_use_alt +global compat_same_alt +global compat_have_dfp + +# Load procedures from common libraries. +load_lib standard.exp +load_lib gcc.exp + +# Load the language-dependent compatibility support procedures. +load_lib c-compat.exp + +# Load the language-independent compabibility support procedures. +load_lib compat.exp + +gcc_init + +# Save variables for the C compiler under test, which each test will +# change a couple of times. This must be done after calling gcc-init. +set compat_save_gcc_under_test $GCC_UNDER_TEST + +# Define an identifier for use with this suite to avoid name conflicts +# with other compat tests running at the same time. +set sid "c_compat" + +# Find out whether there is an alternate compiler to test. If the +# variable is defined but is set to "same", that means we use the same +# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS +# are different. +set compat_use_alt 0 +set compat_same_alt 0 + +if [info exists ALT_CC_UNDER_TEST] then { + set compat_use_alt 1 + if [string match "same" $ALT_CC_UNDER_TEST] then { + set compat_same_alt 1 + } +} + +compat_setup_dfp + +# Main loop. +foreach src [lsort [find $srcdir/$subdir *_main.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + compat-execute $src $sid $compat_use_alt +} + +# Restore the original compiler under test. +compat-use-tst-compiler diff --git a/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_main.c b/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_main.c new file mode 100644 index 000000000..35c94aaea --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_main.c @@ -0,0 +1,12 @@ +/* Test passing function pointers. */ + +extern void fnptr_by_value_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + fnptr_by_value_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_x.c b/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_x.c new file mode 100644 index 000000000..156a417a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_x.c @@ -0,0 +1,162 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +typedef void (*fpi)(int); +typedef void (*fpd)(double); + +extern void test1a (fpi); +extern void test1b (fpi, int); +extern void test1c (double, fpd); +extern void test2a (fpi, fpd); +extern void test2b (fpi, fpd, int); +extern void test2c (fpi, int, fpd); +extern void test2d (int, fpi, fpd); +extern void test2e (fpi, fpd, int, double); +extern void test2f (fpi, int, fpd, double); +extern void test2g (fpi, int, double, fpd); +extern void test2h (double, fpd, fpi, int); +extern void test2i (double, fpd, int, fpi); +extern void test2j (int, double, fpi, fpd); +extern void testva (int, ...); + +int f1_val; +double f2_val; + +void f1 (int i) { f1_val = i; } +void f2 (double x) { f2_val = x; } + +void +checki (int x, int v) +{ + if (x != v) + DEBUG_CHECK +} + +void +checkd (double x, double v) +{ + if (x != v) + DEBUG_CHECK +} + +void +testit (void) +{ + DEBUG_FPUTS ("test1a: "); + test1a (f1); + checki (f1_val, 1); + DEBUG_NL; + DEBUG_FPUTS ("test1b: "); + test1b (f1, 2); + checki (f1_val, 2); + DEBUG_NL; + DEBUG_FPUTS ("test1c: "); + test1c (3.0, f2); + checkd (f2_val, 3.0); + DEBUG_NL; + DEBUG_FPUTS ("test2a: "); + test2a (f1, f2); + checki (f1_val, 10); + checkd (f2_val, 10.0); + DEBUG_NL; + DEBUG_FPUTS ("test2b: "); + test2b (f1, f2, 11); + checki (f1_val, 11); + checkd (f2_val, 11.0); + DEBUG_NL; + DEBUG_FPUTS ("test2c: "); + test2c (f1, 12, f2); + checki (f1_val, 12); + checkd (f2_val, 12.0); + DEBUG_NL; + DEBUG_FPUTS ("test2d: "); + test2d (13, f1, f2); + checki (f1_val, 13); + checkd (f2_val, 13.0); + DEBUG_NL; + DEBUG_FPUTS ("test2e: "); + test2e (f1, f2, 14, 15.0); + checki (f1_val, 14); + checkd (f2_val, 15.0); + DEBUG_NL; + DEBUG_FPUTS ("test2f: "); + test2f (f1, 16, f2, 17.0); + checki (f1_val, 16); + checkd (f2_val, 17.0); + DEBUG_NL; + DEBUG_FPUTS ("test2g: "); + test2g (f1, 18, 19.0, f2); + checki (f1_val, 18); + checkd (f2_val, 19.0); + DEBUG_NL; + DEBUG_FPUTS ("test2h: "); + test2h (20.0, f2, f1, 21); + checkd (f2_val, 20.0); + checki (f1_val, 21); + DEBUG_NL; + DEBUG_FPUTS ("test2i: "); + test2i (22.0, f2, 23, f1); + checkd (f2_val, 22.0); + checki (f1_val, 23); + DEBUG_NL; + DEBUG_FPUTS ("test2j: "); + test2j (24, 25.0, f1, f2); + checki (f1_val, 24); + checkd (f2_val, 25.0); + if (test_va) + { + DEBUG_NL; + DEBUG_FPUTS ("testva: "); + testva (1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (2, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (3, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (4, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (5, f1, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (6, f1, f1, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (7, f1, f1, f1, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (8, f1, f1, f1, f1, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (9, f1, f1, f1, f1, f1, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (10, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (11, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1); + DEBUG_NL; + DEBUG_FPUTS (" "); + testva (12, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1, f1); + } + DEBUG_NL; +} + +void +fnptr_by_value_1_x () +{ + DEBUG_INIT + testit (); + DEBUG_FINI + + if (fails != 0) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_y.c b/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_y.c new file mode 100644 index 000000000..1f6917cdc --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fnptr-by-value-1_y.c @@ -0,0 +1,111 @@ +#include <stdarg.h> + +#include "compat-common.h" + +typedef void (*fpi)(int); +typedef void (*fpd)(double); + +extern int f1_val; +extern void checki (int, int); + +void +test1a (fpi f) +{ + (*f)(1); +} + +void +test1b (fpi f, int i) +{ + (*f)(i); +} + +void +test1c (double x, fpd f) +{ + (*f)(x); +} + +void +test2a (fpi f1, fpd f2) +{ + (*f1)(10); + (*f2)(10.0); +} + +void +test2b (fpi f1, fpd f2, int i) +{ + (*f1)(i); + (*f2)((double)i); +} + +void +test2c (fpi f1, int i, fpd f2) +{ + (*f1)(i); + (*f2)((double)i); +} + +void +test2d (int i, fpi f1, fpd f2) +{ + (*f1)(i); + (*f2)((double)i); +} + +void +test2e (fpi f1, fpd f2, int i, double x) +{ + (*f1)(i); + (*f2)(x); +} + +void +test2f (fpi f1, int i, fpd f2, double x) +{ + (*f1)(i); + (*f2)(x); +} + +void +test2g (fpi f1, int i, double x, fpd f2) +{ + (*f1)(i); + (*f2)(x); +} + +void +test2h (double x, fpd f1, fpi f2, int i) +{ + (*f1)(x); + (*f2)(i); +} + +void +test2i (double x, fpd f1, int i, fpi f2) +{ + (*f1)(x); + (*f2)(i); +} + +void +test2j (int i, double x, fpi f1, fpd f2) +{ + (*f1)(i); + (*f2)(x); +} + +void +testva (int n, ...) +{ + int i; + va_list ap; + va_start (ap, n); + for (i = 0; i < n; i++) + { + fpi fp = va_arg (ap, fpi); + (*fp)(i); + checki (f1_val, i); + } +} diff --git a/gcc/testsuite/gcc.dg/compat/fp-struct-check.h b/gcc/testsuite/gcc.dg/compat/fp-struct-check.h new file mode 100644 index 000000000..bd3283b6b --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp-struct-check.h @@ -0,0 +1,71 @@ +/* Function definitions that are used by multiple tests. */ + +#define CHECKS(NAME,TYPEM) \ +void checkS##NAME##1 (S##NAME##1 x, TYPEM y) \ +{ if (x.a != y) DEBUG_CHECK } \ +void checkS##NAME##2 (S##NAME##2 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 ) DEBUG_CHECK } \ +void checkS##NAME##3 (S##NAME##3 x, TYPEM y) \ +{ if (x.a != y || x.b != y+1 || x.c != y+2 ) \ + DEBUG_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } \ +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_CHECK } diff --git a/gcc/testsuite/gcc.dg/compat/fp-struct-defs.h b/gcc/testsuite/gcc.dg/compat/fp-struct-defs.h new file mode 100644 index 000000000..67d63f23b --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp-struct-defs.h @@ -0,0 +1,43 @@ +/* Type definitions that are used by multiple tests. */ + +#define DEFS(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; diff --git a/gcc/testsuite/gcc.dg/compat/fp-struct-init.h b/gcc/testsuite/gcc.dg/compat/fp-struct-init.h new file mode 100644 index 000000000..46a0cef1d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp-struct-init.h @@ -0,0 +1,54 @@ +/* Function definitions that are used by multiple tests. */ + +#define INITS(NAME,TYPEM) \ +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; } diff --git a/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-x.h b/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-x.h new file mode 100644 index 000000000..876f1b355 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-x.h @@ -0,0 +1,136 @@ +#define TEST(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); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##TYPE (1, \ + g1s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test2: "); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} diff --git a/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-y.h b/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-y.h new file mode 100644 index 000000000..49fccdd09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp-struct-test-by-value-y.h @@ -0,0 +1,69 @@ +#define TEST(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) \ +{ \ + check##TYPE (s1, (TYPE2)1); \ + check##TYPE (s2, (TYPE2)2); \ + check##TYPE (s3, (TYPE2)3); \ + check##TYPE (s4, (TYPE2)4); \ + check##TYPE (s5, (TYPE2)5); \ + check##TYPE (s6, (TYPE2)6); \ + check##TYPE (s7, (TYPE2)7); \ + check##TYPE (s8, (TYPE2)8); \ + check##TYPE (s9, (TYPE2)9); \ + check##TYPE (s10, (TYPE2)10); \ + check##TYPE (s11, (TYPE2)11); \ + check##TYPE (s12, (TYPE2)12); \ + check##TYPE (s13, (TYPE2)13); \ + check##TYPE (s14, (TYPE2)14); \ + check##TYPE (s15, (TYPE2)15); \ + 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); \ + check##TYPE (t, (TYPE2)i+1); \ + } \ + va_end (ap); \ + } \ +} diff --git a/gcc/testsuite/gcc.dg/compat/fp2-struct-check.h b/gcc/testsuite/gcc.dg/compat/fp2-struct-check.h new file mode 100644 index 000000000..c00f70547 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp2-struct-check.h @@ -0,0 +1,27 @@ +/* Function definitions that are used by multiple tests. */ + +void checkSfd (Sfd x, double y) +{ if (x.f != y || x.d != y+1) DEBUG_CHECK } +void checkSfl (Sfl x, double y) +{ if (x.f != y || x.l != y+1) DEBUG_CHECK } +void checkSdf (Sdf x, double y) +{ if (x.d != y || x.f != y+1) DEBUG_CHECK } +void checkSdl (Sdl x, double y) +{ if (x.d != y || x.l != y+1) DEBUG_CHECK } +void checkSlf (Slf x, double y) +{ if (x.l != y || x.f != y+1) DEBUG_CHECK } +void checkSld (Sld x, double y) +{ if (x.l != y || x.d != y+1) DEBUG_CHECK } + +void checkSfdl (Sfdl x, double y) +{ if (x.f != y || x.d != y+1 || x.l != y+2) DEBUG_CHECK } +void checkSfld (Sfld x, double y) +{ if (x.f != y || x.l != y+1 || x.d != y+2) DEBUG_CHECK } +void checkSdfl (Sdfl x, double y) +{ if (x.d != y || x.f != y+1 || x.l != y+2) DEBUG_CHECK } +void checkSdlf (Sdlf x, double y) +{ if (x.d != y || x.l != y+1 || x.f != y+2) DEBUG_CHECK } +void checkSlfd (Slfd x, double y) +{ if (x.l != y || x.f != y+1 || x.d != y+2) DEBUG_CHECK } +void checkSldf (Sldf x, double y) +{ if (x.l != y || x.d != y+1 || x.f != y+2) DEBUG_CHECK } diff --git a/gcc/testsuite/gcc.dg/compat/fp2-struct-defs.h b/gcc/testsuite/gcc.dg/compat/fp2-struct-defs.h new file mode 100644 index 000000000..be387a70a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp2-struct-defs.h @@ -0,0 +1,15 @@ +/* Type definitions that are used by multiple tests. */ + +typedef struct { float f; double d; } Sfd; +typedef struct { float f; long double l; } Sfl; +typedef struct { double d; float f; } Sdf; +typedef struct { double d; long double l; } Sdl; +typedef struct { long double l; float f; } Slf; +typedef struct { long double l; double d; } Sld; + +typedef struct { float f; double d; long double l; } Sfdl; +typedef struct { float f; long double l; double d; } Sfld; +typedef struct { double d; float f; long double l; } Sdfl; +typedef struct { double d; long double l; float f; } Sdlf; +typedef struct { long double l; float f; double d; } Slfd; +typedef struct { long double l; double d; float f; } Sldf; diff --git a/gcc/testsuite/gcc.dg/compat/fp2-struct-init.h b/gcc/testsuite/gcc.dg/compat/fp2-struct-init.h new file mode 100644 index 000000000..35fe77e00 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/fp2-struct-init.h @@ -0,0 +1,27 @@ +/* Function definitions that are used by multiple tests. */ + +void initSfd (Sfd *p, double y) +{ p->f = y; p->d = y+1; } +void initSfl (Sfl *p, double y) +{ p->f = y; p->l = y+1; } +void initSdf (Sdf *p, double y) +{ p->d = y; p->f = y+1; } +void initSdl (Sdl *p, double y) +{ p->d = y; p->l = y+1; } +void initSlf (Slf *p, double y) +{ p->l = y; p->f = y+1; } +void initSld (Sld *p, double y) +{ p->l = y; p->d = y+1; } + +void initSfdl (Sfdl *p, double y) +{ p->f = y; p->d = y+1; p->l = y+2; } +void initSfld (Sfld *p, double y) +{ p->f = y; p->l = y+1; p->d = y+2; } +void initSdfl (Sdfl *p, double y) +{ p->d = y; p->f = y+1; p->l = y+2; } +void initSdlf (Sdlf *p, double y) +{ p->d = y; p->l = y+1; p->f = y+2; } +void initSlfd (Slfd *p, double y) +{ p->l = y; p->f = y+1; p->d = y+2; } +void initSldf (Sldf *p, double y) +{ p->l = y; p->d = y+1; p->f = y+2; } diff --git a/gcc/testsuite/gcc.dg/compat/generate-random.c b/gcc/testsuite/gcc.dg/compat/generate-random.c new file mode 100644 index 000000000..c4b06db67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/generate-random.c @@ -0,0 +1,265 @@ +/* Copyright (C) 1995, 2004 Free Software Foundation + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +/* + * This is derived from the Berkeley source: + * @(#)random.c 5.5 (Berkeley) 7/6/88 + * It was reworked for the GNU C Library by Roland McGrath. + * Rewritten to use reentrant functions by Ulrich Drepper, 1995. + */ + +/* + Copyright (C) 1983 Regents of the University of California. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE.*/ + +#include <limits.h> +#include <stdlib.h> +#include "generate-random.h" + + +/* An improved random number generation package. In addition to the standard + rand()/srand() like interface, this package also has a special state info + interface. The initstate() routine is called with a seed, an array of + bytes, and a count of how many bytes are being passed in; this array is + then initialized to contain information for random number generation with + that much state information. Good sizes for the amount of state + information are 32, 64, 128, and 256 bytes. The state can be switched by + calling the setstate() function with the same array as was initialized + with initstate(). By default, the package runs with 128 bytes of state + information and generates far better random numbers than a linear + congruential generator. If the amount of state information is less than + 32 bytes, a simple linear congruential R.N.G. is used. Internally, the + state information is treated as an array of longs; the zeroth element of + the array is the type of R.N.G. being used (small integer); the remainder + of the array is the state information for the R.N.G. Thus, 32 bytes of + state information will give 7 longs worth of state information, which will + allow a degree seven polynomial. (Note: The zeroth word of state + information also has some other information stored in it; see setstate + for details). The random number generation technique is a linear feedback + shift register approach, employing trinomials (since there are fewer terms + to sum up that way). In this approach, the least significant bit of all + the numbers in the state table will act as a linear feedback shift register, + and will have period 2^deg - 1 (where deg is the degree of the polynomial + being used, assuming that the polynomial is irreducible and primitive). + The higher order bits will have longer periods, since their values are + also influenced by pseudo-random carries out of the lower bits. The + total period of the generator is approximately deg*(2**deg - 1); thus + doubling the amount of state information has a vast influence on the + period of the generator. Note: The deg*(2**deg - 1) is an approximation + only good for large deg, when the period of the shift register is the + dominant factor. With deg equal to seven, the period is actually much + longer than the 7*(2**7 - 1) predicted by this formula. */ + + + +/* For each of the currently supported random number generators, we have a + break value on the amount of state information (you need at least this many + bytes of state info to support this random number generator), a degree for + the polynomial (actually a trinomial) that the R.N.G. is based on, and + separation between the two lower order coefficients of the trinomial. */ + +/* Linear congruential. */ +#define TYPE_0 0 +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +/* x**7 + x**3 + 1. */ +#define TYPE_1 1 +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +/* x**15 + x + 1. */ +#define TYPE_2 2 +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +/* x**31 + x**3 + 1. */ +#define TYPE_3 3 +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +/* x**63 + x + 1. */ +#define TYPE_4 4 +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + + +/* Array versions of the above information to make code run faster. + Relies on fact that TYPE_i == i. */ + +#define MAX_TYPES 5 /* Max number of types above. */ + + +/* Initially, everything is set up as if from: + initstate(1, randtbl, 128); + Note that this initialization takes advantage of the fact that srandom + advances the front and rear pointers 10*rand_deg times, and hence the + rear pointer which starts at 0 will also end up at zero; thus the zeroth + element of the state information, which contains info about the current + position of the rear pointer is just + (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */ + +static int randtbl[DEG_3 + 1] = + { + TYPE_3, + + -1726662223, 379960547, 1735697613, 1040273694, 1313901226, + 1627687941, -179304937, -2073333483, 1780058412, -1989503057, + -615974602, 344556628, 939512070, -1249116260, 1507946756, + -812545463, 154635395, 1388815473, -1926676823, 525320961, + -1009028674, 968117788, -123449607, 1284210865, 435012392, + -2017506339, -911064859, -370259173, 1132637927, 1398500161, + -205601318, + }; + + +static struct generate_random_data unsafe_state = + { +/* FPTR and RPTR are two pointers into the state info, a front and a rear + pointer. These two pointers are always rand_sep places aparts, as they + cycle through the state information. (Yes, this does mean we could get + away with just one pointer, but the code for random is more efficient + this way). The pointers are left positioned as they would be from the call: + initstate(1, randtbl, 128); + (The position of the rear pointer, rptr, is really 0 (as explained above + in the initialization of randtbl) because the state table pointer is set + to point to randtbl[1] (as explained below).) */ + + &randtbl[SEP_3 + 1], /* fptr */ + &randtbl[1], /* rptr */ + +/* The following things are the pointer to the state information table, + the type of the current generator, the degree of the current polynomial + being used, and the separation between the two pointers. + Note that for efficiency of random, we remember the first location of + the state information, not the zeroth. Hence it is valid to access + state[-1], which is used to store the type of the R.N.G. + Also, we remember the last location, since this is more efficient than + indexing every time to find the address of the last element to see if + the front and rear pointers have wrapped. */ + + &randtbl[1], /* state */ + + TYPE_3, /* rand_type */ + DEG_3, /* rand_deg */ + SEP_3, /* rand_sep */ + + &randtbl[sizeof (randtbl) / sizeof (randtbl[0])] /* end_ptr */ +}; + +/* Initialize the random number generator based on the given seed. If the + type is the trivial no-state-information type, just remember the seed. + Otherwise, initializes state[] based on the given "seed" via a linear + congruential generator. Then, the pointers are set to known locations + that are exactly rand_sep places apart. Lastly, it cycles the state + information a given number of times to get rid of any initial dependencies + introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + for default usage relies on values produced by this routine. */ +void +generate_srandom (unsigned int x) +{ + (void) generate_srandom_r (x, &unsafe_state); +} + +/* Initialize the state information in the given array of N bytes for + future random number generation. Based on the number of bytes we + are given, and the break values for the different R.N.G.'s, we choose + the best (largest) one we can and set things up for it. srandom is + then called to initialize the state information. Note that on return + from srandom, we set state[-1] to be the type multiplexed with the current + value of the rear pointer; this is so successive calls to initstate won't + lose this information and will be able to restart with setstate. + Note: The first thing we do is save the current state, if any, just like + setstate so that it doesn't matter when initstate is called. + Returns a pointer to the old state. */ +char * +generate_initstate (unsigned int seed, char *arg_state, size_t n) +{ + int *ostate; + + ostate = &unsafe_state.state[-1]; + generate_initstate_r (seed, arg_state, n, &unsafe_state); + return (char *) ostate; +} + +/* Restore the state from the given state array. + Note: It is important that we also remember the locations of the pointers + in the current state information, and restore the locations of the pointers + from the old state information. This is done by multiplexing the pointer + location into the zeroth word of the state information. Note that due + to the order in which things are done, it is OK to call setstate with the + same state as the current state + Returns a pointer to the old state information. */ +char * +generate_setstate (char *arg_state) +{ + int *ostate; + + ostate = &unsafe_state.state[-1]; + if (generate_setstate_r (arg_state, &unsafe_state) < 0) + ostate = NULL; + return (char *) ostate; +} + +/* If we are using the trivial TYPE_0 R.N.G., just do the old linear + congruential bit. Otherwise, we do our fancy trinomial stuff, which is the + same in all the other cases due to all the global variables that have been + set up. The basic operation is to add the number at the rear pointer into + the one at the front pointer. Then both pointers are advanced to the next + location cyclically in the table. The value returned is the sum generated, + reduced to 31 bits by throwing away the "least random" low bit. + Note: The code takes advantage of the fact that both the front and + rear pointers can't wrap on the same call by not testing the rear + pointer if the front one has wrapped. Returns a 31-bit random number. */ + +long int +generate_random (void) +{ + int retval; + (void) generate_random_r (&unsafe_state, &retval); + return retval; +} diff --git a/gcc/testsuite/gcc.dg/compat/generate-random.h b/gcc/testsuite/gcc.dg/compat/generate-random.h new file mode 100644 index 000000000..e14f526bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/generate-random.h @@ -0,0 +1,33 @@ +/* Copyright (C) 2004 Free Software Foundation + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +struct generate_random_data + { + int *fptr, *rptr, *state; + int rand_type, rand_deg, rand_sep; + int *end_ptr; + }; + +extern void generate_srandom (unsigned int); +extern char *generate_initstate (unsigned int, char *, size_t); +extern char *generate_setstate (char *); +extern long int generate_random (void); +extern int generate_random_r (struct generate_random_data *, int *); +extern int generate_srandom_r (unsigned int, struct generate_random_data *); +extern int generate_initstate_r (unsigned int, char *, size_t, + struct generate_random_data *); +extern int generate_setstate_r (char *, struct generate_random_data *); diff --git a/gcc/testsuite/gcc.dg/compat/generate-random_r.c b/gcc/testsuite/gcc.dg/compat/generate-random_r.c new file mode 100644 index 000000000..6e83f3596 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/generate-random_r.c @@ -0,0 +1,385 @@ +/* + Copyright (C) 1995, 2004 Free Software Foundation + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +/* + Copyright (C) 1983 Regents of the University of California. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 4. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE.*/ + +/* + * This is derived from the Berkeley source: + * @(#)random.c 5.5 (Berkeley) 7/6/88 + * It was reworked for the GNU C Library by Roland McGrath. + * Rewritten to be reentrant by Ulrich Drepper, 1995 + */ + +#include <limits.h> +#include <stdlib.h> +#include "generate-random.h" + + +/* An improved random number generation package. In addition to the standard + rand()/srand() like interface, this package also has a special state info + interface. The initstate() routine is called with a seed, an array of + bytes, and a count of how many bytes are being passed in; this array is + then initialized to contain information for random number generation with + that much state information. Good sizes for the amount of state + information are 32, 64, 128, and 256 bytes. The state can be switched by + calling the setstate() function with the same array as was initialized + with initstate(). By default, the package runs with 128 bytes of state + information and generates far better random numbers than a linear + congruential generator. If the amount of state information is less than + 32 bytes, a simple linear congruential R.N.G. is used. Internally, the + state information is treated as an array of longs; the zeroth element of + the array is the type of R.N.G. being used (small integer); the remainder + of the array is the state information for the R.N.G. Thus, 32 bytes of + state information will give 7 longs worth of state information, which will + allow a degree seven polynomial. (Note: The zeroth word of state + information also has some other information stored in it; see setstate + for details). The random number generation technique is a linear feedback + shift register approach, employing trinomials (since there are fewer terms + to sum up that way). In this approach, the least significant bit of all + the numbers in the state table will act as a linear feedback shift register, + and will have period 2^deg - 1 (where deg is the degree of the polynomial + being used, assuming that the polynomial is irreducible and primitive). + The higher order bits will have longer periods, since their values are + also influenced by pseudo-random carries out of the lower bits. The + total period of the generator is approximately deg*(2**deg - 1); thus + doubling the amount of state information has a vast influence on the + period of the generator. Note: The deg*(2**deg - 1) is an approximation + only good for large deg, when the period of the shift register is the + dominant factor. With deg equal to seven, the period is actually much + longer than the 7*(2**7 - 1) predicted by this formula. */ + + + +/* For each of the currently supported random number generators, we have a + break value on the amount of state information (you need at least this many + bytes of state info to support this random number generator), a degree for + the polynomial (actually a trinomial) that the R.N.G. is based on, and + separation between the two lower order coefficients of the trinomial. */ + +/* Linear congruential. */ +#define TYPE_0 0 +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +/* x**7 + x**3 + 1. */ +#define TYPE_1 1 +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +/* x**15 + x + 1. */ +#define TYPE_2 2 +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +/* x**31 + x**3 + 1. */ +#define TYPE_3 3 +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +/* x**63 + x + 1. */ +#define TYPE_4 4 +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + + +/* Array versions of the above information to make code run faster. + Relies on fact that TYPE_i == i. */ + +#define MAX_TYPES 5 /* Max number of types above. */ + +struct random_poly_info +{ + int seps[MAX_TYPES]; + int degrees[MAX_TYPES]; +}; + +static const struct random_poly_info random_poly_info = +{ + { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }, + { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 } +}; + + + + +/* Initialize the random number generator based on the given seed. If the + type is the trivial no-state-information type, just remember the seed. + Otherwise, initializes state[] based on the given "seed" via a linear + congruential generator. Then, the pointers are set to known locations + that are exactly rand_sep places apart. Lastly, it cycles the state + information a given number of times to get rid of any initial dependencies + introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + for default usage relies on values produced by this routine. */ +int +generate_srandom_r (unsigned int seed, struct generate_random_data *buf) +{ + int type; + int *state; + long int i; + long int word; + int *dst; + int kc; + + if (buf == NULL) + goto fail; + type = buf->rand_type; + if ((unsigned int) type >= MAX_TYPES) + goto fail; + + state = buf->state; + /* We must make sure the seed is not 0. Take arbitrarily 1 in this case. */ + if (seed == 0) + seed = 1; + state[0] = seed; + if (type == TYPE_0) + goto done; + + dst = state; + word = seed; + kc = buf->rand_deg; + for (i = 1; i < kc; ++i) + { + /* This does: + state[i] = (16807 * state[i - 1]) % 2147483647; + but avoids overflowing 31 bits. */ + long int hi = word / 127773; + long int lo = word % 127773; + word = 16807 * lo - 2836 * hi; + if (word < 0) + word += 2147483647; + *++dst = word; + } + + buf->fptr = &state[buf->rand_sep]; + buf->rptr = &state[0]; + kc *= 10; + while (--kc >= 0) + { + int discard; + (void) generate_random_r (buf, &discard); + } + + done: + return 0; + + fail: + return -1; +} + +/* Initialize the state information in the given array of N bytes for + future random number generation. Based on the number of bytes we + are given, and the break values for the different R.N.G.'s, we choose + the best (largest) one we can and set things up for it. srandom is + then called to initialize the state information. Note that on return + from srandom, we set state[-1] to be the type multiplexed with the current + value of the rear pointer; this is so successive calls to initstate won't + lose this information and will be able to restart with setstate. + Note: The first thing we do is save the current state, if any, just like + setstate so that it doesn't matter when initstate is called. + Returns a pointer to the old state. */ +int +generate_initstate_r (unsigned int seed, char *arg_state, size_t n, + struct generate_random_data *buf) +{ + int type; + int degree; + int separation; + int *state; + + if (buf == NULL) + goto fail; + + if (n >= BREAK_3) + type = n < BREAK_4 ? TYPE_3 : TYPE_4; + else if (n < BREAK_1) + { + if (n < BREAK_0) + { + goto fail; + } + type = TYPE_0; + } + else + type = n < BREAK_2 ? TYPE_1 : TYPE_2; + + degree = random_poly_info.degrees[type]; + separation = random_poly_info.seps[type]; + + buf->rand_type = type; + buf->rand_sep = separation; + buf->rand_deg = degree; + state = &((int *) arg_state)[1]; /* First location. */ + /* Must set END_PTR before srandom. */ + buf->end_ptr = &state[degree]; + + buf->state = state; + + generate_srandom_r (seed, buf); + + state[-1] = TYPE_0; + if (type != TYPE_0) + state[-1] = (buf->rptr - state) * MAX_TYPES + type; + + return 0; + + fail: + return -1; +} + +/* Restore the state from the given state array. + Note: It is important that we also remember the locations of the pointers + in the current state information, and restore the locations of the pointers + from the old state information. This is done by multiplexing the pointer + location into the zeroth word of the state information. Note that due + to the order in which things are done, it is OK to call setstate with the + same state as the current state + Returns a pointer to the old state information. */ +int +generate_setstate_r (char *arg_state, struct generate_random_data *buf) +{ + int *new_state = 1 + (int *) arg_state; + int type; + int old_type; + int *old_state; + int degree; + int separation; + + if (arg_state == NULL || buf == NULL) + goto fail; + + old_type = buf->rand_type; + old_state = buf->state; + if (old_type == TYPE_0) + old_state[-1] = TYPE_0; + else + old_state[-1] = (MAX_TYPES * (buf->rptr - old_state)) + old_type; + + type = new_state[-1] % MAX_TYPES; + if (type < TYPE_0 || type > TYPE_4) + goto fail; + + buf->rand_deg = degree = random_poly_info.degrees[type]; + buf->rand_sep = separation = random_poly_info.seps[type]; + buf->rand_type = type; + + if (type != TYPE_0) + { + int rear = new_state[-1] / MAX_TYPES; + buf->rptr = &new_state[rear]; + buf->fptr = &new_state[(rear + separation) % degree]; + } + buf->state = new_state; + /* Set end_ptr too. */ + buf->end_ptr = &new_state[degree]; + + return 0; + + fail: + return -1; +} + +/* If we are using the trivial TYPE_0 R.N.G., just do the old linear + congruential bit. Otherwise, we do our fancy trinomial stuff, which is the + same in all the other cases due to all the global variables that have been + set up. The basic operation is to add the number at the rear pointer into + the one at the front pointer. Then both pointers are advanced to the next + location cyclically in the table. The value returned is the sum generated, + reduced to 31 bits by throwing away the "least random" low bit. + Note: The code takes advantage of the fact that both the front and + rear pointers can't wrap on the same call by not testing the rear + pointer if the front one has wrapped. Returns a 31-bit random number. */ + +int +generate_random_r (struct generate_random_data *buf, int *result) +{ + int *state; + + if (buf == NULL || result == NULL) + goto fail; + + state = buf->state; + + if (buf->rand_type == TYPE_0) + { + int val = state[0]; + val = ((state[0] * 1103515245) + 12345) & 0x7fffffff; + state[0] = val; + *result = val; + } + else + { + int *fptr = buf->fptr; + int *rptr = buf->rptr; + int *end_ptr = buf->end_ptr; + int val; + + val = *fptr += *rptr; + /* Chucking least random bit. */ + *result = (val >> 1) & 0x7fffffff; + ++fptr; + if (fptr >= end_ptr) + { + fptr = state; + ++rptr; + } + else + { + ++rptr; + if (rptr >= end_ptr) + rptr = state; + } + buf->fptr = fptr; + buf->rptr = rptr; + } + return 0; + + fail: + return -1; +} diff --git a/gcc/testsuite/gcc.dg/compat/mixed-struct-check.h b/gcc/testsuite/gcc.dg/compat/mixed-struct-check.h new file mode 100644 index 000000000..248ffb215 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/mixed-struct-check.h @@ -0,0 +1,37 @@ +/* Function definitions that are used by multiple tests. */ + +void checkScd (Scd x, int i) +{ if (x.c != (char)i || x.d != (double)i+1) DEBUG_CHECK } +void checkScdc (Scdc x, int i) +{ if (x.c != (char)i || x.d != (double)i+1 || x.b != (char)i+2) DEBUG_CHECK } +void checkSd (Sd x, int i) +{ if (x.d != (double)i) DEBUG_CHECK } +void checkSdi (Sdi x, int i) +{ if (x.d != (double)i || x.i != i+1) DEBUG_CHECK } +void checkScsds (Scsds x, int i) +{ if (x.c != (char)i || x.sd.d != (double)i+1) DEBUG_CHECK } +void checkScsdsc (Scsdsc x, int i) +{ if (x.c != (char)i || x.sd.d != (double)i+1 || x.b != (char)i+2) DEBUG_CHECK } +void checkScsdis (Scsdis x, int i) +{ if (x.c != (char)i || x.sdi.d != (double)i+1 || x.sdi.i != i+2) DEBUG_CHECK } +void checkScsdisc (Scsdisc x, int i) +{ if (x.c != (char)i || x.sdi.d != (double)i+1 || x.sdi.i != i+2 + || x.b != (char)i+3) DEBUG_CHECK } +void checkSsds (Ssds x, int i) +{ if (x.sd.d != (double)i) DEBUG_CHECK } +void checkSsdsc (Ssdsc x, int i) +{ if (x.sd.d != (double)i || x.c != (char)i+1) DEBUG_CHECK } +void checkScssdss (Scssdss x, int i) +{ if (x.c != (char)i || x.ssds.sd.d != (double)i+1) DEBUG_CHECK } +void checkScssdssc (Scssdssc x, int i) +{ if (x.c != (char)i || x.ssds.sd.d != (double)i+1 + || x.b != (char)i+2) DEBUG_CHECK } + +void checkSfi (Sfi x, int i) +{ if (x.f != (float)i || x.i != i+1) DEBUG_CHECK } +void checkSfii (Sfii x, int i) +{ if (x.f != (float)i || x.i1 != i+1 || x.i2 != i+2) DEBUG_CHECK } +void checkSfifi (Sfifi x, int i) +{ if (x.fi.f != (float)i || x.fi.i != i+1) DEBUG_CHECK } +void checkSfiifii (Sfiifii x, int i) +{ if (x.fii.f != (float)i || x.fii.i1 != i+1 || x.fii.i2 != i+2) DEBUG_CHECK } diff --git a/gcc/testsuite/gcc.dg/compat/mixed-struct-defs.h b/gcc/testsuite/gcc.dg/compat/mixed-struct-defs.h new file mode 100644 index 000000000..9a313790f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/mixed-struct-defs.h @@ -0,0 +1,19 @@ +/* Type definitions that are used by multiple tests. */ + +typedef struct { char c; double d; } Scd; +typedef struct { char c; double d; char b; } Scdc; +typedef struct { double d; } Sd; +typedef struct { double d; int i; } Sdi; +typedef struct { char c; Sd sd; } Scsds; +typedef struct { char c; Sd sd; char b; } Scsdsc; +typedef struct { char c; Sdi sdi; } Scsdis; +typedef struct { char c; Sdi sdi; char b; } Scsdisc; +typedef struct { Sd sd; } Ssds; +typedef struct { Sd sd; char c; } Ssdsc; +typedef struct { char c; Ssds ssds; } Scssdss; +typedef struct { char c; Ssds ssds; char b; } Scssdssc; + +typedef struct { float f; int i; } Sfi; +typedef struct { float f; int i1; int i2; } Sfii; +typedef struct { float f; int i; Sfi fi; } Sfifi; +typedef struct { float f; int i1; int i2; Sfii fii; } Sfiifii; diff --git a/gcc/testsuite/gcc.dg/compat/mixed-struct-init.h b/gcc/testsuite/gcc.dg/compat/mixed-struct-init.h new file mode 100644 index 000000000..b11fc2404 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/mixed-struct-init.h @@ -0,0 +1,35 @@ +/* Function definitions that are used by multiple tests. */ + +void initScd (Scd *p, int i) +{ p->c = (char)i; p->d = (double)i+1; } +void initScdc (Scdc *p, int i) +{ p->c = (char)i; p->d = (double)i+1; p->b = (char)i+2; } +void initSd (Sd *p, int i) +{ p->d = (double)i; } +void initSdi (Sdi *p, int i) +{ p->d = (double)i; p->i = i+1; } +void initScsds (Scsds *p, int i) +{ p->c = (char)i; p->sd.d = (double)i+1; } +void initScsdsc (Scsdsc *p, int i) +{ p->c = (char)i; p->sd.d = (double)i+1; p->b = (char)i+2; } +void initScsdis (Scsdis *p, int i) +{ p->c = (char)i; p->sdi.d = (double)i+1; p->sdi.i = i+2; } +void initScsdisc (Scsdisc *p, int i) +{ p->c = (char)i; p->sdi.d = (double)i+1; p->sdi.i = i+2; p->b = (char)i+3; } +void initSsds (Ssds *p, int i) +{ p->sd.d = (double)i; } +void initSsdsc (Ssdsc *p, int i) +{ p->sd.d = (double)i; p->c = (char)i+1; } +void initScssdss (Scssdss *p, int i) +{ p->c = (char)i; p->ssds.sd.d = (double)i+1; } +void initScssdssc (Scssdssc *p, int i) +{ p->c = (char)i; p->ssds.sd.d = (double)i+1; p->b = (char)i+2; } + +void initSfi (Sfi *x, int i) +{ x->f = (float)i; x->i = i+1; } +void initSfii (Sfii *x, int i) +{ x->f = (float)i; x->i1 = i+1; x->i2 = i+2; } +void initSfifi (Sfifi *x, int i) +{ x->fi.f = (float)i; x->fi.i = i+1; } +void initSfiifii (Sfiifii *x, int i) +{ x->fii.f = (float)i; x->fii.i1 = i+1; x->fii.i2 = i+2; } diff --git a/gcc/testsuite/gcc.dg/compat/pr38736_main.c b/gcc/testsuite/gcc.dg/compat/pr38736_main.c new file mode 100644 index 000000000..8f221083c --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/pr38736_main.c @@ -0,0 +1,18 @@ +/* PR target/38736 */ +/* { dg-skip-if "attribute ((aligned))" { ! { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target avx_runtime } */ + +/* Test compatibility of attribute ((aligned)) with and without -mavx. */ + +extern int aligned_x (void); +extern int aligned_y_avx (void); +extern void abort (void); + +int +main () +{ + if (aligned_x () != aligned_y_avx ()) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/compat/pr38736_x.c b/gcc/testsuite/gcc.dg/compat/pr38736_x.c new file mode 100644 index 000000000..aeab257aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/pr38736_x.c @@ -0,0 +1,15 @@ +/* PR target/38736 */ +/* { dg-options "-O2" } */ + +struct alignment_test_struct +{ + char space[4] __attribute__((__aligned__)); +}; + +extern int aligned_x (void); + +int +aligned_x (void) +{ + return __alignof__(struct alignment_test_struct); +} diff --git a/gcc/testsuite/gcc.dg/compat/pr38736_y.c b/gcc/testsuite/gcc.dg/compat/pr38736_y.c new file mode 100644 index 000000000..7e46afa8d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/pr38736_y.c @@ -0,0 +1,6 @@ +/* PR target/38736 */ +/* { dg-options "-O2 -mavx" } */ + +#define aligned_x aligned_y_avx + +#include "pr38736_x.c" diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_main.c new file mode 100644 index 000000000..5272a379f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_main.c @@ -0,0 +1,13 @@ +/* Test passing scalars by value. This test includes scalar types that + are supported by va_arg. */ + +extern void scalar_by_value_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_by_value_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_x.c new file mode 100644 index 000000000..3bfa76644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_x.c @@ -0,0 +1,180 @@ +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16); \ +extern void testva##NAME (int n, ...); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v + INITVAL) \ + DEBUG_CHECK \ +} \ + \ +void \ +test2_##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08) \ +{ \ + test##NAME (x01, g02##NAME, x02, g04##NAME, \ + x03, g06##NAME, x04, g08##NAME, \ + x05, g10##NAME, x06, g12##NAME, \ + x07, g14##NAME, x08, g16##NAME); \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test: "); \ + test##NAME (g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##NAME (1, \ + g01##NAME); \ + DEBUG_NL; \ + testva##NAME (2, \ + g01##NAME, g02##NAME); \ + DEBUG_NL; \ + testva##NAME (3, \ + g01##NAME, g02##NAME, g03##NAME); \ + DEBUG_NL; \ + testva##NAME (4, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME); \ + DEBUG_NL; \ + testva##NAME (5, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME); \ + DEBUG_NL; \ + testva##NAME (6, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME); \ + DEBUG_NL; \ + testva##NAME (7, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME); \ + DEBUG_NL; \ + testva##NAME (8, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME); \ + DEBUG_NL; \ + testva##NAME (9, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME); \ + DEBUG_NL; \ + testva##NAME (10, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME); \ + DEBUG_NL; \ + testva##NAME (11, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME); \ + DEBUG_NL; \ + testva##NAME (12, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME); \ + DEBUG_NL; \ + testva##NAME (13, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME); \ + DEBUG_NL; \ + testva##NAME (14, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME); \ + DEBUG_NL; \ + testva##NAME (15, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME); \ + DEBUG_NL; \ + testva##NAME (16, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test2: "); \ + test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \ + g09##NAME, g11##NAME, g13##NAME, g15##NAME); \ + DEBUG_NL; \ +} + +T(ui, unsigned int, 51) +T(si, int, (-55)) +T(ul, unsigned long, 61) +T(sl, long, (-66)) +T(ull, unsigned long long, 71) +T(sll, long long, (-77)) +T(d, double, 91.0) +T(ld, long double, 92.0) + +#undef T + +void +scalar_by_value_1_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +T(ui) +T(si) +T(ul) +T(sl) +T(ull) +T(sll) +T(d) +T(ld) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_y.c new file mode 100644 index 000000000..73f3de0e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-1_y.c @@ -0,0 +1,94 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1); \ + check##NAME (g02##NAME, 2); \ + check##NAME (g03##NAME, 3); \ + check##NAME (g04##NAME, 4); \ + check##NAME (g05##NAME, 5); \ + check##NAME (g06##NAME, 6); \ + check##NAME (g07##NAME, 7); \ + check##NAME (g08##NAME, 8); \ + check##NAME (g09##NAME, 9); \ + check##NAME (g10##NAME, 10); \ + check##NAME (g11##NAME, 11); \ + check##NAME (g12##NAME, 12); \ + check##NAME (g13##NAME, 13); \ + check##NAME (g14##NAME, 14); \ + check##NAME (g15##NAME, 15); \ + check##NAME (g16##NAME, 16); \ +} \ + \ +void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16) \ +{ \ + check##NAME (x01, 1); \ + check##NAME (x02, 2); \ + check##NAME (x03, 3); \ + check##NAME (x04, 4); \ + check##NAME (x05, 5); \ + check##NAME (x06, 6); \ + check##NAME (x07, 7); \ + check##NAME (x08, 8); \ + check##NAME (x09, 9); \ + check##NAME (x10, 10); \ + check##NAME (x11, 11); \ + check##NAME (x12, 12); \ + check##NAME (x13, 13); \ + check##NAME (x14, 14); \ + check##NAME (x15, 15); \ + check##NAME (x16, 16); \ +} \ + \ +void \ +testva##NAME (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); \ + check##NAME (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +T(ui, unsigned int, 51) +T(si, int, (-55)) +T(ul, unsigned long, 61) +T(sl, long, (-66)) +T(ull, unsigned long long, 71) +T(sll, long long, (-77)) +T(d, double, 91.0) +T(ld, long double, 92.0) diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_main.c new file mode 100644 index 000000000..8426b7894 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_main.c @@ -0,0 +1,15 @@ +/* Test passing scalars by value. This test includes scalar types that + are not supported by va_arg; since they require casts to pass to a + function with a variable argument list, testing them with variable + arguments is not interesting. */ + +extern void scalar_by_value_2_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_by_value_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_x.c new file mode 100644 index 000000000..48ea1d997 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_x.c @@ -0,0 +1,100 @@ +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v + INITVAL) \ + DEBUG_CHECK \ +} \ + \ +void \ +test2_##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08) \ +{ \ + test##NAME (x01, g02##NAME, x02, g04##NAME, \ + x03, g06##NAME, x04, g08##NAME, \ + x05, g10##NAME, x06, g12##NAME, \ + x07, g14##NAME, x08, g16##NAME); \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test: "); \ + test##NAME (g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test2: "); \ + test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \ + g09##NAME, g11##NAME, g13##NAME, g15##NAME); \ + DEBUG_NL; \ +} + +T(c, char, 21) +T(uc, unsigned char, 22) +T(sc, signed char, (-33)) +T(us, unsigned short, 41) +T(ss, short, (-44)) +T(f, float, 90.0) + +#undef T + +void +scalar_by_value_2_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +T(c) +T(uc) +T(sc) +T(us) +T(ss) +T(f) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_y.c new file mode 100644 index 000000000..2eea6135d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-2_y.c @@ -0,0 +1,69 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1); \ + check##NAME (g02##NAME, 2); \ + check##NAME (g03##NAME, 3); \ + check##NAME (g04##NAME, 4); \ + check##NAME (g05##NAME, 5); \ + check##NAME (g06##NAME, 6); \ + check##NAME (g07##NAME, 7); \ + check##NAME (g08##NAME, 8); \ + check##NAME (g09##NAME, 9); \ + check##NAME (g10##NAME, 10); \ + check##NAME (g11##NAME, 11); \ + check##NAME (g12##NAME, 12); \ + check##NAME (g13##NAME, 13); \ + check##NAME (g14##NAME, 14); \ + check##NAME (g15##NAME, 15); \ + check##NAME (g16##NAME, 16); \ +} \ + \ +void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16) \ +{ \ + check##NAME (x01, 1); \ + check##NAME (x02, 2); \ + check##NAME (x03, 3); \ + check##NAME (x04, 4); \ + check##NAME (x05, 5); \ + check##NAME (x06, 6); \ + check##NAME (x07, 7); \ + check##NAME (x08, 8); \ + check##NAME (x09, 9); \ + check##NAME (x10, 10); \ + check##NAME (x11, 11); \ + check##NAME (x12, 12); \ + check##NAME (x13, 13); \ + check##NAME (x14, 14); \ + check##NAME (x15, 15); \ + check##NAME (x16, 16); \ +} + +T(c, char, 21) +T(uc, unsigned char, 22) +T(sc, signed char, (-33)) +T(us, unsigned short, 41) +T(ss, short, (-44)) +T(f, float, 90.0) diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_main.c new file mode 100644 index 000000000..307e6ccb6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_main.c @@ -0,0 +1,14 @@ +/* Test passing scalars by value. This test includes _Complex types + whose real and imaginary parts can be used in variable-length + argument lists. */ + +extern void scalar_by_value_3_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_by_value_3_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_x.c new file mode 100644 index 000000000..e63f5fd38 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_x.c @@ -0,0 +1,182 @@ +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16); \ +extern void testva##NAME (int n, ...); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v + INITVAL) \ + DEBUG_CHECK \ +} \ + \ +void \ +test2_##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08) \ +{ \ + test##NAME (x01, g02##NAME, x02, g04##NAME, \ + x03, g06##NAME, x04, g08##NAME, \ + x05, g10##NAME, x06, g12##NAME, \ + x07, g14##NAME, x08, g16##NAME); \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test: "); \ + test##NAME (g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##NAME (1, \ + g01##NAME); \ + DEBUG_NL; \ + testva##NAME (2, \ + g01##NAME, g02##NAME); \ + DEBUG_NL; \ + testva##NAME (3, \ + g01##NAME, g02##NAME, g03##NAME); \ + DEBUG_NL; \ + testva##NAME (4, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME); \ + DEBUG_NL; \ + testva##NAME (5, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME); \ + DEBUG_NL; \ + testva##NAME (6, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME); \ + DEBUG_NL; \ + testva##NAME (7, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME); \ + DEBUG_NL; \ + testva##NAME (8, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME); \ + DEBUG_NL; \ + testva##NAME (9, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME); \ + DEBUG_NL; \ + testva##NAME (10, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME); \ + DEBUG_NL; \ + testva##NAME (11, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME); \ + DEBUG_NL; \ + testva##NAME (12, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME); \ + DEBUG_NL; \ + testva##NAME (13, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME); \ + DEBUG_NL; \ + testva##NAME (14, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME); \ + DEBUG_NL; \ + testva##NAME (15, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME); \ + DEBUG_NL; \ + testva##NAME (16, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test2: "); \ + test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \ + g09##NAME, g11##NAME, g13##NAME, g15##NAME); \ + DEBUG_NL; \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(ci, _Complex int, CINT (2, 3)) +T(cl, _Complex long, CINT (3, 4)) +T(cll, _Complex long long, CINT (5, 6)) +#endif +T(cd, _Complex double, CDBL (7.0, 8.0)) +T(cld, _Complex long double, CDBL (8.0, 9.0)) +#endif + +#undef T + +void +scalar_by_value_3_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(ci) +T(cl) +T(cll) +#endif +T(cd) +T(cld) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_y.c new file mode 100644 index 000000000..d470ef605 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-3_y.c @@ -0,0 +1,95 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1); \ + check##NAME (g02##NAME, 2); \ + check##NAME (g03##NAME, 3); \ + check##NAME (g04##NAME, 4); \ + check##NAME (g05##NAME, 5); \ + check##NAME (g06##NAME, 6); \ + check##NAME (g07##NAME, 7); \ + check##NAME (g08##NAME, 8); \ + check##NAME (g09##NAME, 9); \ + check##NAME (g10##NAME, 10); \ + check##NAME (g11##NAME, 11); \ + check##NAME (g12##NAME, 12); \ + check##NAME (g13##NAME, 13); \ + check##NAME (g14##NAME, 14); \ + check##NAME (g15##NAME, 15); \ + check##NAME (g16##NAME, 16); \ +} \ + \ +void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16) \ +{ \ + check##NAME (x01, 1); \ + check##NAME (x02, 2); \ + check##NAME (x03, 3); \ + check##NAME (x04, 4); \ + check##NAME (x05, 5); \ + check##NAME (x06, 6); \ + check##NAME (x07, 7); \ + check##NAME (x08, 8); \ + check##NAME (x09, 9); \ + check##NAME (x10, 10); \ + check##NAME (x11, 11); \ + check##NAME (x12, 12); \ + check##NAME (x13, 13); \ + check##NAME (x14, 14); \ + check##NAME (x15, 15); \ + check##NAME (x16, 16); \ +} \ + \ +void \ +testva##NAME (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); \ + check##NAME (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(ci, _Complex int, CINT (2, 3)) +T(cl, _Complex long, CINT (3, 4)) +T(cll, _Complex long long, CINT (5, 6)) +#endif +T(cd, _Complex double, CDBL (7.0, 8.0)) +T(cld, _Complex long double, CDBL (8.0, 9.0)) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c new file mode 100644 index 000000000..8164b4428 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c @@ -0,0 +1,14 @@ +/* Test passing scalars by value. This test includes _Complex types + whose real and imaginary parts cannot be used in variable-length + argument lists. */ + +extern void scalar_by_value_4_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_by_value_4_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c new file mode 100644 index 000000000..a4e73c9fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c @@ -0,0 +1,102 @@ +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v + INITVAL) \ + DEBUG_CHECK \ +} \ + \ +void \ +test2_##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08) \ +{ \ + test##NAME (x01, g02##NAME, x02, g04##NAME, \ + x03, g06##NAME, x04, g08##NAME, \ + x05, g10##NAME, x06, g12##NAME, \ + x07, g14##NAME, x08, g16##NAME); \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test: "); \ + test##NAME (g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test2: "); \ + test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \ + g09##NAME, g11##NAME, g13##NAME, g15##NAME); \ + DEBUG_NL; \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(cc, _Complex char, CINT (0, 1)) +T(cs, _Complex short, CINT (1, 2)) +#endif +T(cf, _Complex float, CDBL (6.0, 7.0)) +#endif + +#undef T + +void +scalar_by_value_4_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(cc) +T(cs) +#endif +T(cf) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c new file mode 100644 index 000000000..e0fa70539 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c @@ -0,0 +1,76 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1); \ + check##NAME (g02##NAME, 2); \ + check##NAME (g03##NAME, 3); \ + check##NAME (g04##NAME, 4); \ + check##NAME (g05##NAME, 5); \ + check##NAME (g06##NAME, 6); \ + check##NAME (g07##NAME, 7); \ + check##NAME (g08##NAME, 8); \ + check##NAME (g09##NAME, 9); \ + check##NAME (g10##NAME, 10); \ + check##NAME (g11##NAME, 11); \ + check##NAME (g12##NAME, 12); \ + check##NAME (g13##NAME, 13); \ + check##NAME (g14##NAME, 14); \ + check##NAME (g15##NAME, 15); \ + check##NAME (g16##NAME, 16); \ +} \ + \ +void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16) \ +{ \ + check##NAME (x01, 1); \ + check##NAME (x02, 2); \ + check##NAME (x03, 3); \ + check##NAME (x04, 4); \ + check##NAME (x05, 5); \ + check##NAME (x06, 6); \ + check##NAME (x07, 7); \ + check##NAME (x08, 8); \ + check##NAME (x09, 9); \ + check##NAME (x10, 10); \ + check##NAME (x11, 11); \ + check##NAME (x12, 12); \ + check##NAME (x13, 13); \ + check##NAME (x14, 14); \ + check##NAME (x15, 15); \ + check##NAME (x16, 16); \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(cc, _Complex char, CINT (0, 1)) +T(cs, _Complex short, CINT (1, 2)) +#endif +T(cf, _Complex float, CDBL (6.0, 7.0)) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-5.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5.c new file mode 100644 index 000000000..1c336d81a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5.c @@ -0,0 +1,22 @@ +TEST_FUNCS (longlong_i, long long, int, + 1234LL, -987) +TEST_FUNCS (longlong_d, long long, double, + 1234LL, -987.0) +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +TEST_FUNCS (complexint_i, _Complex int, int, + 1234 + 567i, -987) +TEST_FUNCS (complexint_d, _Complex int, double, + 1234 + 567i, -987.0) +#endif +TEST_FUNCS (complexdouble_i, _Complex double, int, + 1234.0 + 567.0i, -987) +TEST_FUNCS (complexdouble_d, _Complex double, double, + 1234.0 + 567.0i, -987.0) +#ifndef SKIP_COMPLEX_INT +TEST_FUNCS (complexlonglong_i, _Complex long long, int, + 1234LL + 567LLi, -987) +TEST_FUNCS (complexlonglong_d, _Complex long long, double, + 1234LL + 567LLi, -987.0) +#endif +#endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_main.c new file mode 100644 index 000000000..d29597e3d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_main.c @@ -0,0 +1,32 @@ +/* Test that function args can be passed in various positions to both fixed + and variable arg functions. */ +/* { dg-options "-O" } */ + +extern void exit (int); +extern void longlong_i_doit (void); +extern void longlong_d_doit (void); +extern void complexint_i_doit (void); +extern void complexint_d_doit (void); +extern void complexdouble_i_doit (void); +extern void complexdouble_d_doit (void); +extern void complexlonglong_i_doit (void); +extern void complexlonglong_d_doit (void); + +int main (void) +{ + longlong_i_doit (); + longlong_d_doit (); +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT + complexint_i_doit (); + complexint_d_doit (); +#endif + complexdouble_i_doit (); + complexdouble_d_doit (); +#ifndef SKIP_COMPLEX_INT + complexlonglong_i_doit (); + complexlonglong_d_doit (); +#endif +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_x.c new file mode 100644 index 000000000..5266bdf67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_x.c @@ -0,0 +1,2 @@ +#include "scalar-by-value-x.h" +#include "scalar-by-value-5.c" diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_y.c new file mode 100644 index 000000000..78d985a24 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-5_y.c @@ -0,0 +1,2 @@ +#include "scalar-by-value-y.h" +#include "scalar-by-value-5.c" diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-6.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6.c new file mode 100644 index 000000000..af65398f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6.c @@ -0,0 +1,6 @@ +TEST_FUNCS (longdouble_i, long double, int, d, -987) +TEST_FUNCS (longdouble_d, long double, double, d, -987.0) +#ifndef SKIP_COMPLEX +TEST_FUNCS (complexlongdouble_i, _Complex long double, int, cd, -987) +TEST_FUNCS (complexlongdouble_d, _Complex long double, double, cd, -987.0) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_main.c new file mode 100644 index 000000000..f6b3c1d8a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_main.c @@ -0,0 +1,23 @@ +/* Test that function args can be passed in various positions to both fixed + and variable arg functions. */ +/* { dg-options "-O" } */ +/* { dg-options "-O -mlong-double-128" { target powerpc*-*-* } } */ + +extern void exit (int); +extern void longdouble_i_doit (void); +extern void longdouble_d_doit (void); +#ifndef SKIP_COMPLEX +extern void complexlongdouble_i_doit (void); +extern void complexlongdouble_d_doit (void); +#endif + +int main (void) +{ + longdouble_i_doit (); + longdouble_d_doit (); +#ifndef SKIP_COMPLEX + complexlongdouble_i_doit (); + complexlongdouble_d_doit (); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_x.c new file mode 100644 index 000000000..27aa48fbe --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_x.c @@ -0,0 +1,8 @@ +#include "scalar-by-value-x.h" + +extern long double d; +#ifndef SKIP_COMPLEX +extern _Complex long double cd; +#endif + +#include "scalar-by-value-6.c" diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_y.c new file mode 100644 index 000000000..2e9aed282 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-6_y.c @@ -0,0 +1,8 @@ +#include "scalar-by-value-y.h" + +long double d = 1234.0L + 0x0.abcdp-70L; +#ifndef SKIP_COMPLEX +_Complex long double cd = 234.0L + 0x0.abcp-70L + 567.0Li +0x0defp-70Li; +#endif + +#include "scalar-by-value-6.c" diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_main.c new file mode 100644 index 000000000..7f81d6a37 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_main.c @@ -0,0 +1,15 @@ +/* Test passing scalars by value. This test includes scalar types that + are supported by va_arg. */ + +/* { dg-require-compat-dfp "" } */ + +extern void scalar_by_value_dfp_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_by_value_dfp_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_x.c new file mode 100644 index 000000000..8f55671c3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_x.c @@ -0,0 +1,170 @@ +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16); \ +extern void testva##NAME (int n, ...); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v + INITVAL) \ + DEBUG_CHECK \ +} \ + \ +void \ +test2_##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08) \ +{ \ + test##NAME (x01, g02##NAME, x02, g04##NAME, \ + x03, g06##NAME, x04, g08##NAME, \ + x05, g10##NAME, x06, g12##NAME, \ + x07, g14##NAME, x08, g16##NAME); \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test: "); \ + test##NAME (g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##NAME (1, \ + g01##NAME); \ + DEBUG_NL; \ + testva##NAME (2, \ + g01##NAME, g02##NAME); \ + DEBUG_NL; \ + testva##NAME (3, \ + g01##NAME, g02##NAME, g03##NAME); \ + DEBUG_NL; \ + testva##NAME (4, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME); \ + DEBUG_NL; \ + testva##NAME (5, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME); \ + DEBUG_NL; \ + testva##NAME (6, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME); \ + DEBUG_NL; \ + testva##NAME (7, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME); \ + DEBUG_NL; \ + testva##NAME (8, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME); \ + DEBUG_NL; \ + testva##NAME (9, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME); \ + DEBUG_NL; \ + testva##NAME (10, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME); \ + DEBUG_NL; \ + testva##NAME (11, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME); \ + DEBUG_NL; \ + testva##NAME (12, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME); \ + DEBUG_NL; \ + testva##NAME (13, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME); \ + DEBUG_NL; \ + testva##NAME (14, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME); \ + DEBUG_NL; \ + testva##NAME (15, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME); \ + DEBUG_NL; \ + testva##NAME (16, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test2: "); \ + test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \ + g09##NAME, g11##NAME, g13##NAME, g15##NAME); \ + DEBUG_NL; \ +} + +T(d32, _Decimal32, 1.2df) +T(d64, _Decimal64, 12.34dd) +T(d128, _Decimal128, 123.456dl) + +#undef T + +void +scalar_by_value_dfp_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +T(d32) +T(d64) +T(d128) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_y.c new file mode 100644 index 000000000..9b1f49f69 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-dfp_y.c @@ -0,0 +1,89 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1); \ + check##NAME (g02##NAME, 2); \ + check##NAME (g03##NAME, 3); \ + check##NAME (g04##NAME, 4); \ + check##NAME (g05##NAME, 5); \ + check##NAME (g06##NAME, 6); \ + check##NAME (g07##NAME, 7); \ + check##NAME (g08##NAME, 8); \ + check##NAME (g09##NAME, 9); \ + check##NAME (g10##NAME, 10); \ + check##NAME (g11##NAME, 11); \ + check##NAME (g12##NAME, 12); \ + check##NAME (g13##NAME, 13); \ + check##NAME (g14##NAME, 14); \ + check##NAME (g15##NAME, 15); \ + check##NAME (g16##NAME, 16); \ +} \ + \ +void \ +test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ + TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ + TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ + TYPE x13, TYPE x14, TYPE x15, TYPE x16) \ +{ \ + check##NAME (x01, 1); \ + check##NAME (x02, 2); \ + check##NAME (x03, 3); \ + check##NAME (x04, 4); \ + check##NAME (x05, 5); \ + check##NAME (x06, 6); \ + check##NAME (x07, 7); \ + check##NAME (x08, 8); \ + check##NAME (x09, 9); \ + check##NAME (x10, 10); \ + check##NAME (x11, 11); \ + check##NAME (x12, 12); \ + check##NAME (x13, 13); \ + check##NAME (x14, 14); \ + check##NAME (x15, 15); \ + check##NAME (x16, 16); \ +} \ + \ +void \ +testva##NAME (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); \ + check##NAME (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +T(d32, _Decimal32, 1.2df) +T(d64, _Decimal64, 12.34dd) +T(d128, _Decimal128, 123.456dl) diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-x.h b/gcc/testsuite/gcc.dg/compat/scalar-by-value-x.h new file mode 100644 index 000000000..f0ac216ad --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-x.h @@ -0,0 +1,77 @@ +#if DEBUG +#include <stdio.h> +#define DBG(x) fputs (x, stdout); fflush (stdout); +#else +#define DBG(x) +#endif + +#define TEST_FUNCS(NAME, TYPE, PADT, VAL, VAL2) \ +extern void NAME##_f0 (TYPE a, PADT b); \ +extern void NAME##_f1 (PADT z0, TYPE a, PADT b); \ +extern void NAME##_f2 (PADT z0, PADT z1, TYPE a, PADT b); \ +extern void NAME##_f3 (PADT z0, PADT z1, PADT z2, TYPE a, PADT b); \ +extern void NAME##_f4 (PADT z0, PADT z1, PADT z2, PADT z3, TYPE a, \ + PADT b); \ +extern void NAME##_f5 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, \ + TYPE a, PADT b); \ +extern void NAME##_f6 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, \ + PADT z5, TYPE a, PADT b); \ +extern void NAME##_f7 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, \ + PADT z5, PADT z6, TYPE a, PADT b); \ +extern void NAME##_f8 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, \ + PADT z5, PADT z6, PADT z7, TYPE a, PADT b); \ +extern void NAME##_f9 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, \ + PADT z5, PADT z6, PADT z7, PADT z8, TYPE a, \ + PADT b); \ +extern void NAME##_fv (int n, ...); \ + \ +void NAME##_doit (void) \ +{ \ + NAME##_f0 (VAL, VAL2); \ + DBG ("."); \ + NAME##_f1 ((PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_f2 ((PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_f3 ((PADT) 0, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_f4 ((PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_f5 ((PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + VAL, VAL2); \ + DBG ("."); \ + NAME##_f6 ((PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_f7 ((PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_f8 ((PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + (PADT) 0, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_f9 ((PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (1, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (2, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (3, (PADT) 0, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (4, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (5, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (6, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (7, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("."); \ + NAME##_fv (8, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, (PADT) 0, \ + (PADT) 0, (PADT) 0, (PADT) 0, VAL, VAL2); \ + DBG ("\n"); \ +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-y.h b/gcc/testsuite/gcc.dg/compat/scalar-by-value-y.h new file mode 100644 index 000000000..e181a7e34 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-y.h @@ -0,0 +1,277 @@ +extern void abort (void); + +#ifdef __GNUC__ +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end +#else +#include <stdarg.h> +#endif + +#if USE_MEMCMP +/* For comparing vectors. */ +#define TEST_FUNCS(NAME, TYPE, PADT, VAL, VAL2) \ +void NAME##_f0 (TYPE a, PADT b) \ +{ \ + if (memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f1 (PADT z0, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f2 (PADT z0, PADT z1, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f3 (PADT z0, PADT z1, PADT z2, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f4 (PADT z0, PADT z1, PADT z2, PADT z3, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f5 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, TYPE a, \ + PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f6 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f7 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + PADT z6, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || z6 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f8 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + PADT z6, PADT z7, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || z6 != (PADT) 0 \ + || z7 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f9 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + PADT z6, PADT z7, PADT z8, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || z6 != (PADT) 0 \ + || z7 != (PADT) 0 \ + || z8 != (PADT) 0 \ + || memcmp (&a, &VAL, sizeof (a)) != 0 || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_fv (int n, ...) \ +{ \ + va_list ap; \ + TYPE x; \ + va_start (ap, n); \ + \ + while (n-- != 0) \ + if (va_arg (ap, PADT) != (PADT) 0) \ + abort (); \ + \ + x = va_arg (ap, TYPE); \ + if (memcmp (&x, &VAL, sizeof (x)) != 0 ) \ + abort (); \ + \ + if (va_arg (ap, PADT) != VAL2) \ + abort (); \ + \ + va_end (ap); \ +} + +#else + +#define TEST_FUNCS(NAME, TYPE, PADT, VAL, VAL2) \ +void NAME##_f0 (TYPE a, PADT b) \ +{ \ + if (a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f1 (PADT z0, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f2 (PADT z0, PADT z1, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f3 (PADT z0, PADT z1, PADT z2, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f4 (PADT z0, PADT z1, PADT z2, PADT z3, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f5 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, TYPE a, \ + PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f6 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f7 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + PADT z6, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || z6 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f8 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + PADT z6, PADT z7, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || z6 != (PADT) 0 \ + || z7 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_f9 (PADT z0, PADT z1, PADT z2, PADT z3, PADT z4, PADT z5, \ + PADT z6, PADT z7, PADT z8, TYPE a, PADT b) \ +{ \ + if (z0 != (PADT) 0 \ + || z1 != (PADT) 0 \ + || z2 != (PADT) 0 \ + || z3 != (PADT) 0 \ + || z4 != (PADT) 0 \ + || z5 != (PADT) 0 \ + || z6 != (PADT) 0 \ + || z7 != (PADT) 0 \ + || z8 != (PADT) 0 \ + || a != VAL || b != VAL2) \ + abort (); \ +} \ + \ +void NAME##_fv (int n, ...) \ +{ \ + va_list ap; \ + \ + va_start (ap, n); \ + \ + while (n-- != 0) \ + if (va_arg (ap, PADT) != (PADT) 0) \ + abort (); \ + \ + if (va_arg (ap, TYPE) != VAL) \ + abort (); \ + \ + if (va_arg (ap, PADT) != VAL2) \ + abort (); \ + \ + va_end (ap); \ +} + +#endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-1_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-1_main.c new file mode 100644 index 000000000..0a27f5416 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-1_main.c @@ -0,0 +1,13 @@ +/* Test function return values. This test includes scalar types that + are supported by va_arg. */ + +extern void scalar_return_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_return_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-1_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-1_x.c new file mode 100644 index 000000000..5556f9510 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-1_x.c @@ -0,0 +1,119 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern TYPE test0##NAME (void); \ +extern TYPE test1##NAME (TYPE); \ +extern TYPE testva##NAME (int n, ...); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v) \ + DEBUG_CHECK \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##NAME (); \ + check##NAME (rslt, g01##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##NAME (g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva:"); \ + rslt = testva##NAME (1, g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME); \ + check##NAME (rslt, g05##NAME); \ + rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME); \ + check##NAME (rslt, g09##NAME); \ + rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME, \ + g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, \ + g16##NAME); \ + check##NAME (rslt, g16##NAME); \ + } \ + DEBUG_NL; \ +} + +T(ui, unsigned int, 51) +T(si, int, (-55)) +T(ul, unsigned long, 61) +T(sl, long, (-66)) +T(ull, unsigned long long, 71) +T(sll, long long, (-77)) +T(d, double, 91.0) +T(ld, long double, 92.0) + +#undef T + +void +scalar_return_1_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +T(ui) +T(si) +T(ul) +T(sl) +T(ull) +T(sll) +T(d) +T(ld) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-1_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-1_y.c new file mode 100644 index 000000000..f913dbbb8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-1_y.c @@ -0,0 +1,72 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1+INITVAL); \ + check##NAME (g02##NAME, 2+INITVAL); \ + check##NAME (g03##NAME, 3+INITVAL); \ + check##NAME (g04##NAME, 4+INITVAL); \ + check##NAME (g05##NAME, 5+INITVAL); \ + check##NAME (g06##NAME, 6+INITVAL); \ + check##NAME (g07##NAME, 7+INITVAL); \ + check##NAME (g08##NAME, 8+INITVAL); \ + check##NAME (g09##NAME, 9+INITVAL); \ + check##NAME (g10##NAME, 10+INITVAL); \ + check##NAME (g11##NAME, 11+INITVAL); \ + check##NAME (g12##NAME, 12+INITVAL); \ + check##NAME (g13##NAME, 13+INITVAL); \ + check##NAME (g14##NAME, 14+INITVAL); \ + check##NAME (g15##NAME, 15+INITVAL); \ + check##NAME (g16##NAME, 16+INITVAL); \ +} \ + \ +TYPE \ +test0##NAME (void) \ +{ \ + return g01##NAME; \ +} \ + \ +TYPE \ +test1##NAME (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##NAME (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +T(ui, unsigned int, 51) +T(si, int, (-55)) +T(ul, unsigned long, 61) +T(sl, long, (-66)) +T(ull, unsigned long long, 71) +T(sll, long long, (-77)) +T(d, double, 91.0) +T(ld, long double, 92.0) diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-2_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-2_main.c new file mode 100644 index 000000000..11a5e5044 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-2_main.c @@ -0,0 +1,13 @@ +/* Test function return values. This test includes scalar types that + are not supported by va_arg. */ + +extern void scalar_return_2_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_return_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-2_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-2_x.c new file mode 100644 index 000000000..f864d4c96 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-2_x.c @@ -0,0 +1,86 @@ +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern TYPE test0##NAME (void); \ +extern TYPE test1##NAME (TYPE); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v) \ + DEBUG_CHECK \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##NAME (); \ + check##NAME (rslt, g01##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##NAME (g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + DEBUG_NL; \ +} + +T(c, char, 21) +T(uc, unsigned char, 22) +T(sc, signed char, (-33)) +T(us, unsigned short, 41) +T(ss, short, (-44)) +T(f, float, 90.0) + +#undef T + +void +scalar_return_2_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +T(c) +T(uc) +T(sc) +T(us) +T(ss) +T(f) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-2_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-2_y.c new file mode 100644 index 000000000..485165c71 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-2_y.c @@ -0,0 +1,63 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1+INITVAL); \ + check##NAME (g02##NAME, 2+INITVAL); \ + check##NAME (g03##NAME, 3+INITVAL); \ + check##NAME (g04##NAME, 4+INITVAL); \ + check##NAME (g05##NAME, 5+INITVAL); \ + check##NAME (g06##NAME, 6+INITVAL); \ + check##NAME (g07##NAME, 7+INITVAL); \ + check##NAME (g08##NAME, 8+INITVAL); \ + check##NAME (g09##NAME, 9+INITVAL); \ + check##NAME (g10##NAME, 10+INITVAL); \ + check##NAME (g11##NAME, 11+INITVAL); \ + check##NAME (g12##NAME, 12+INITVAL); \ + check##NAME (g13##NAME, 13+INITVAL); \ + check##NAME (g14##NAME, 14+INITVAL); \ + check##NAME (g15##NAME, 15+INITVAL); \ + check##NAME (g16##NAME, 16+INITVAL); \ +} \ + \ +TYPE \ +test0##NAME (void) \ +{ \ + return g01##NAME; \ +} \ + \ +TYPE \ +test1##NAME (TYPE x01) \ +{ \ + return x01; \ +} + +T(c, char, 21) +T(uc, unsigned char, 22) +T(sc, signed char, (-33)) +T(us, unsigned short, 41) +T(ss, short, (-44)) +T(f, float, 90.0) diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-3_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-3_main.c new file mode 100644 index 000000000..8f2738be6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-3_main.c @@ -0,0 +1,14 @@ +/* Test function return values. This test includes _Complex types + whose real and imaginary parts can be used in variable-length + argument lists. */ + +extern void scalar_return_3_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_return_3_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-3_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-3_x.c new file mode 100644 index 000000000..5b33ce880 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-3_x.c @@ -0,0 +1,121 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern TYPE test0##NAME (void); \ +extern TYPE test1##NAME (TYPE); \ +extern TYPE testva##NAME (int n, ...); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v) \ + DEBUG_CHECK \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##NAME (); \ + check##NAME (rslt, g01##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##NAME (g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##NAME (1, g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME); \ + check##NAME (rslt, g05##NAME); \ + rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME); \ + check##NAME (rslt, g09##NAME); \ + rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME, \ + g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, \ + g16##NAME); \ + check##NAME (rslt, g16##NAME); \ + } \ + DEBUG_NL; \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(ci, _Complex int, CINT (2, 3)) +T(cl, _Complex long, CINT (3, 4)) +T(cll, _Complex long long, CINT (4, 5)) +#endif +T(cd, _Complex double, CDBL (2.0, 3.0)) +T(cld, _Complex long double, CDBL (3.0, 4.0)) +#endif + +#undef T + +void +scalar_return_3_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(ci) +T(cl) +T(cll) +#endif +T(cd) +T(cld) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-3_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-3_y.c new file mode 100644 index 000000000..245c4c571 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-3_y.c @@ -0,0 +1,73 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1+INITVAL); \ + check##NAME (g02##NAME, 2+INITVAL); \ + check##NAME (g03##NAME, 3+INITVAL); \ + check##NAME (g04##NAME, 4+INITVAL); \ + check##NAME (g05##NAME, 5+INITVAL); \ + check##NAME (g06##NAME, 6+INITVAL); \ + check##NAME (g07##NAME, 7+INITVAL); \ + check##NAME (g08##NAME, 8+INITVAL); \ + check##NAME (g09##NAME, 9+INITVAL); \ + check##NAME (g10##NAME, 10+INITVAL); \ + check##NAME (g11##NAME, 11+INITVAL); \ + check##NAME (g12##NAME, 12+INITVAL); \ + check##NAME (g13##NAME, 13+INITVAL); \ + check##NAME (g14##NAME, 14+INITVAL); \ + check##NAME (g15##NAME, 15+INITVAL); \ + check##NAME (g16##NAME, 16+INITVAL); \ +} \ + \ +TYPE \ +test0##NAME (void) \ +{ \ + return g01##NAME; \ +} \ + \ +TYPE \ +test1##NAME (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##NAME (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(ci, _Complex int, CINT (2, 3)) +T(cl, _Complex long, CINT (3, 4)) +T(cll, _Complex long long, CINT (4, 5)) +#endif +T(cd, _Complex double, CDBL (2.0, 3.0)) +T(cld, _Complex long double, CDBL (3.0, 4.0)) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c new file mode 100644 index 000000000..2bcfa0487 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c @@ -0,0 +1,14 @@ +/* Test function return values. This test includes _Complex types + whose real and imaginary parts cannot be used in variable-length + argument lists. */ + +extern void scalar_return_4_x (void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_return_4_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c new file mode 100644 index 000000000..50305be4d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c @@ -0,0 +1,70 @@ +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern TYPE test0##NAME (void); \ +extern TYPE test1##NAME (TYPE); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v) \ + DEBUG_CHECK \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##NAME (); \ + check##NAME (rslt, g01##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##NAME (g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + DEBUG_NL; \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(cc, _Complex char, CINT (0, 1)) +T(cs, _Complex short, CINT (1 + 2)) +#endif +T(cf, _Complex float, CDBL (1.0, 2.0)) +#endif + +#undef T + +void +scalar_return_4_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(cc) +T(cs) +#endif +T(cf) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c new file mode 100644 index 000000000..3c9685697 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c @@ -0,0 +1,46 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1+INITVAL); \ +} \ + \ +TYPE \ +test0##NAME (void) \ +{ \ + return g01##NAME; \ +} \ + \ +TYPE \ +test1##NAME (TYPE x01) \ +{ \ + return x01; \ +} + +#ifndef SKIP_COMPLEX +#ifndef SKIP_COMPLEX_INT +T(cc, _Complex char, CINT (0, 1)) +T(cs, _Complex short, CINT (1, 2)) +#endif +T(cf, _Complex float, CDBL (1.0, 2.0)) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_main.c new file mode 100644 index 000000000..eeb62869f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_main.c @@ -0,0 +1,15 @@ +/* Test function return values. This test includes scalar types that + are supported by va_arg. */ + +/* { dg-require-compat-dfp "" } */ + +extern void scalar_return_dfp_x(void); +extern void exit (int); +int fails; + +int +main () +{ + scalar_return_dfp_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_x.c new file mode 100644 index 000000000..aee0a9717 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_x.c @@ -0,0 +1,109 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(NAME, TYPE, INITVAL) \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void init##NAME (TYPE *p, TYPE v); \ +extern void checkg##NAME (void); \ +extern TYPE test0##NAME (void); \ +extern TYPE test1##NAME (TYPE); \ +extern TYPE testva##NAME (int n, ...); \ + \ +void \ +check##NAME (TYPE x, TYPE v) \ +{ \ + if (x != v) \ + DEBUG_CHECK \ +} \ + \ +void \ +testit##NAME (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" init: "); \ + init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ + checkg##NAME (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##NAME (); \ + check##NAME (rslt, g01##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##NAME (g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva:"); \ + rslt = testva##NAME (1, g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME); \ + check##NAME (rslt, g05##NAME); \ + rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME); \ + check##NAME (rslt, g09##NAME); \ + rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME, \ + g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, \ + g16##NAME); \ + check##NAME (rslt, g16##NAME); \ + } \ + DEBUG_NL; \ +} + +T(d32, _Decimal32, 1.2df) +T(d64, _Decimal64, 12.34dd) +T(d128, _Decimal128, 123.456dl) + +#undef T + +void +scalar_return_dfp_x () +{ +DEBUG_INIT + +#define T(NAME) testit##NAME (); + +T(d32) +T(d64) +T(d128) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_y.c new file mode 100644 index 000000000..5fd9373fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-dfp_y.c @@ -0,0 +1,67 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#define T(NAME, TYPE, INITVAL) \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ + \ +extern void check##NAME (TYPE x, TYPE v); \ + \ +void \ +init##NAME (TYPE *p, TYPE v) \ +{ \ + *p = v + INITVAL; \ +} \ + \ +void \ +checkg##NAME (void) \ +{ \ + check##NAME (g01##NAME, 1+INITVAL); \ + check##NAME (g02##NAME, 2+INITVAL); \ + check##NAME (g03##NAME, 3+INITVAL); \ + check##NAME (g04##NAME, 4+INITVAL); \ + check##NAME (g05##NAME, 5+INITVAL); \ + check##NAME (g06##NAME, 6+INITVAL); \ + check##NAME (g07##NAME, 7+INITVAL); \ + check##NAME (g08##NAME, 8+INITVAL); \ + check##NAME (g09##NAME, 9+INITVAL); \ + check##NAME (g10##NAME, 10+INITVAL); \ + check##NAME (g11##NAME, 11+INITVAL); \ + check##NAME (g12##NAME, 12+INITVAL); \ + check##NAME (g13##NAME, 13+INITVAL); \ + check##NAME (g14##NAME, 14+INITVAL); \ + check##NAME (g15##NAME, 15+INITVAL); \ + check##NAME (g16##NAME, 16+INITVAL); \ +} \ + \ +TYPE \ +test0##NAME (void) \ +{ \ + return g01##NAME; \ +} \ + \ +TYPE \ +test1##NAME (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##NAME (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +T(d32, _Decimal32, 1.2df) +T(d64, _Decimal64, 12.34dd) +T(d128, _Decimal128, 123.456dl) diff --git a/gcc/testsuite/gcc.dg/compat/sdata-1_main.c b/gcc/testsuite/gcc.dg/compat/sdata-1_main.c new file mode 100644 index 000000000..68e9f8f09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/sdata-1_main.c @@ -0,0 +1,12 @@ +/* Check that sdata qualification doesn't produce out-of-range relocations + and that compilers agree on the way these declarations are handled. */ + +extern void sdata_1_x (void); +extern void exit (int); + +int +main () +{ + sdata_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/sdata-1_x.c b/gcc/testsuite/gcc.dg/compat/sdata-1_x.c new file mode 100644 index 000000000..fc7b8cef3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/sdata-1_x.c @@ -0,0 +1,25 @@ +#include "sdata-section.h" + +struct s { int x; int y[4]; }; +extern struct s small_struct SDATA_SECTION; + +/* Test "load address" operations. */ +int *xaddr (void) { return &small_struct.x; } +int *yaddr (int i) { return &small_struct.y[i]; } + +void sdata_1_x (void) +{ + int i; + + /* Test direct accesses. */ + small_struct.x = 5; + for (i = 0; i < 4; i++) + small_struct.y[i] = i + 42; + + if (*xaddr () != 5) + abort (); + + for (i = 0; i < 4; i++) + if (*yaddr (i) != i + 42) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/compat/sdata-1_y.c b/gcc/testsuite/gcc.dg/compat/sdata-1_y.c new file mode 100644 index 000000000..8bc878a85 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/sdata-1_y.c @@ -0,0 +1,4 @@ +#include "sdata-section.h" + +struct s { int x; int y[4]; }; +struct s small_struct SDATA_SECTION; diff --git a/gcc/testsuite/gcc.dg/compat/sdata-section.h b/gcc/testsuite/gcc.dg/compat/sdata-section.h new file mode 100644 index 000000000..15be84386 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/sdata-section.h @@ -0,0 +1,7 @@ +#if defined (__mips) && !defined(SKIP_ATTRIBUTE) +#define SDATA_SECTION __attribute__((__section__(".sdata"))) +#else +#define SDATA_SECTION +#endif + +extern void abort (void); diff --git a/gcc/testsuite/gcc.dg/compat/small-struct-check.h b/gcc/testsuite/gcc.dg/compat/small-struct-check.h new file mode 100644 index 000000000..85b334c44 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/small-struct-check.h @@ -0,0 +1,29 @@ +/* Function definitions that are used by multiple tests. */ + +void checkSc (Sc x, int i) { if (x.c != (char)i) DEBUG_CHECK } +void checkSs (Ss x, int i) { if (x.s != i) DEBUG_CHECK } +void checkSi (Si x, int i) { if (x.i != i) DEBUG_CHECK } +void checkSsc (Ssc x, int i) +{ if (x.s != i || x.c != (char)i+1) DEBUG_CHECK } +void checkScs (Scs x, int i) +{ if (x.c != (char)i || x.s != i+1) DEBUG_CHECK } +void checkSsi (Ssi x, int i) +{ if (x.s != i || x.i != i+1) DEBUG_CHECK } +void checkSis (Sis x, int i) +{ if (x.i != i || x.s != i+1) DEBUG_CHECK } +void checkSic (Sic x, int i) +{ if (x.i != i || x.c != (char)i+1) DEBUG_CHECK } +void checkSci (Sci x, int i) +{ if (x.c != (char)i || x.i != i+1) DEBUG_CHECK } +void checkScsi (Scsi x, int i) +{ if (x.c != (char)i || x.s != i+1 || x.i != i+2) DEBUG_CHECK } +void checkScis (Scis x, int i) +{ if (x.c != (char)i || x.i != i+1 || x.s != i+2) DEBUG_CHECK } +void checkSsci (Ssci x, int i) +{ if (x.s != i || x.c != (char)i+1 || x.i != i+2) DEBUG_CHECK } +void checkSsic (Ssic x, int i) +{ if (x.s != i || x.i != i+1 || x.c != (char)i+2) DEBUG_CHECK } +void checkSisc (Sisc x, int i) +{ if (x.i != i || x.s != i+1 || x.c != (char)i+2) DEBUG_CHECK } +void checkSics (Sics x, int i) +{ if (x.i != i || x.c != (char)i+1 || x.s != i+2) DEBUG_CHECK } diff --git a/gcc/testsuite/gcc.dg/compat/small-struct-defs.h b/gcc/testsuite/gcc.dg/compat/small-struct-defs.h new file mode 100644 index 000000000..1a46b26e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/small-struct-defs.h @@ -0,0 +1,17 @@ +/* Type definitions that are used by multiple tests. */ + +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; diff --git a/gcc/testsuite/gcc.dg/compat/small-struct-init.h b/gcc/testsuite/gcc.dg/compat/small-struct-init.h new file mode 100644 index 000000000..97009b6ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/small-struct-init.h @@ -0,0 +1,17 @@ +/* Function definitions that are used by multiple tests. */ + +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; } diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-1.h b/gcc/testsuite/gcc.dg/compat/struct-align-1.h new file mode 100644 index 000000000..d9006c741 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-1.h @@ -0,0 +1,180 @@ +/* Define several variants of a struct for which the alignment differs + between powerpc64-linux and powerpc64-aix. This might be interesting + for other targets as well. */ + +#define DESC_orig "original" +struct B1_orig { + char c; + double d; +}; + +struct A2_orig { + double d; +}; + +struct B2_orig { + char c; + struct A2_orig a2; +}; + +struct A3_orig { + double d; + int i; +}; + +struct B3_orig { + char c; + struct A3_orig a3; +}; + +#ifndef SKIP_ATTRIBUTE +#define DESC_p_all "packed attribute for all" +struct B1_p_all { + char c; + double d; +} __attribute__ ((packed)); + +struct A2_p_all { + double d; +} __attribute__ ((packed)); + +struct B2_p_all { + char c; + struct A2_p_all a2; +} __attribute__ ((packed)); + +struct A3_p_all { + double d; + int i; +} __attribute__ ((packed)); + +struct B3_p_all { + char c; + struct A3_p_all a3; +} __attribute__ ((packed)); + +#define DESC_p_inner "packed attribute for inner" +struct B1_p_inner { + char c; + double d; +}; + +struct A2_p_inner { + double d; +} __attribute__ ((packed)); + +struct B2_p_inner { + char c; + struct A2_p_inner a2; +}; + +struct A3_p_inner { + double d; + int i; +} __attribute__ ((packed)); + +struct B3_p_inner { + char c; + struct A3_p_inner a3; +}; + +#define DESC_p_outer "packed attribute for outer" +struct B1_p_outer { + char c; + double d; +} __attribute__ ((packed)); + +struct A2_p_outer { + double d; +}; + +struct B2_p_outer { + char c; + struct A2_p_outer a2; +} __attribute__ ((packed)); + +struct A3_p_outer { + double d; + int i; +}; + +struct B3_p_outer { + char c; + struct A3_p_outer a3; +} __attribute__ ((packed)); + +#define DESC_a_max "maximum useful struct alignment for all" +struct B1_a_max { + char c; + double d; +} __attribute__ ((aligned)); + +struct A2_a_max { + double d; +} __attribute__ ((aligned)); + +struct B2_a_max { + char c; + struct A2_a_max a2; +} __attribute__ ((aligned)); + +struct A3_a_max { + double d; + int i; +} __attribute__ ((aligned)); + +struct B3_a_max { + char c; + struct A3_a_max a3; +} __attribute__ ((aligned)); + +#define DESC_m_outer_p_inner "maximum alignment for outer, packed inner" +struct B1_m_outer_p_inner { + char c; + double d; +} __attribute__ ((aligned)) __attribute__ ((packed)); + +struct A2_m_outer_p_inner { + double d; +} __attribute__ ((packed)); + +struct B2_m_outer_p_inner { + char c; + struct A2_m_outer_p_inner a2; +} __attribute__ ((aligned)); + +struct A3_m_outer_p_inner { + double d; + int i; +} __attribute__ ((packed)); + +struct B3_m_outer_p_inner { + char c; + struct A3_m_outer_p_inner a3; +} __attribute__ ((aligned)); + +#define DESC_m_inner_p_outer "maximum alignment for inner, packed outer" +struct B1_m_inner_p_outer { + char c; + double d; +} __attribute__ ((aligned)) __attribute__ ((packed)); + +struct A2_m_inner_p_outer { + double d; +} __attribute__ ((aligned)); + +struct B2_m_inner_p_outer { + char c; + struct A2_m_inner_p_outer a2; +} __attribute__ ((packed)); + +struct A3_m_inner_p_outer { + double d; + int i; +} __attribute__ ((aligned)); + +struct B3_m_inner_p_outer { + char c; + struct A3_m_inner_p_outer a3; +} __attribute__ ((packed)); +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-1_main.c b/gcc/testsuite/gcc.dg/compat/struct-align-1_main.c new file mode 100644 index 000000000..0b7f27bea --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-1_main.c @@ -0,0 +1,13 @@ +/* Test compatibility of structure layout and alignment for structs + which contain doubles. The original structs here are from PR 10645. */ + +extern void struct_align_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_align_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-1_x.c b/gcc/testsuite/gcc.dg/compat/struct-align-1_x.c new file mode 100644 index 000000000..939db9d21 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-1_x.c @@ -0,0 +1,110 @@ +/* { dg-options "-Wno-psabi" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +#include "compat-common.h" +#include "struct-align-1.h" + +#define SETUP(NAME,V1,V2,V3) \ +char v1_##NAME = V1; \ +double v2_##NAME = V2; \ +int v3_##NAME = V3; \ + \ +struct B1_##NAME b1_##NAME = { V1, V2 }; \ +struct B2_##NAME b2_##NAME = { V1, { V2 } }; \ +struct B3_##NAME b3_##NAME = { V1, { V2, V3 } }; \ + \ +struct B1_##NAME ab1_##NAME[2] = \ + { { V1, V2 }, { V1, V2 } }; \ +struct B2_##NAME ab2_##NAME[2] = \ + { { V1, { V2 } }, { V1, { V2 } } }; \ +struct B3_##NAME ab3_##NAME[2] = \ + { { V1, { V2, V3 } }, { V1, { V2, V3 } } }; \ + \ +extern void test_##NAME (void); \ +extern void checkp1_##NAME (struct B1_##NAME *); \ +extern void checkp2_##NAME (struct B2_##NAME *); \ +extern void checkp3_##NAME (struct B3_##NAME *); \ +extern void checkg1_##NAME (void); \ +extern void checkg2_##NAME (void); \ +extern void checkg3_##NAME (void); \ + \ +void \ +pass1_##NAME (struct B1_##NAME s) \ +{ \ + checkp1_##NAME (&s); \ +} \ + \ +void \ +pass2_##NAME (struct B2_##NAME s) \ +{ \ + checkp2_##NAME (&s); \ +} \ + \ +void \ +pass3_##NAME (struct B3_##NAME s) \ +{ \ + checkp3_##NAME (&s); \ +} \ + \ +struct B1_##NAME \ +return1_##NAME (void) \ +{ \ + return ab1_##NAME[0]; \ +} \ + \ +struct B2_##NAME \ +return2_##NAME (void) \ +{ \ + return ab2_##NAME[0]; \ +} \ + \ +struct B3_##NAME \ +return3_##NAME (void) \ +{ \ + return ab3_##NAME[0]; \ +} + +#define CHECK(NAME) test_##NAME() + +#if __INT_MAX__ > 32767 +SETUP (orig, 49, 1.0, 111111) +#else +SETUP (orig, 49, 1.0, 1111) +#endif +#ifndef SKIP_ATTRIBUTE +#if __INT_MAX__ > 32767 +SETUP (p_all, 50, 2.0, 222222) +SETUP (p_inner, 51, 3.0, 333333) +SETUP (p_outer, 52, 4.0, 444444) +SETUP (a_max, 53, 5.0, 555555) +SETUP (m_outer_p_inner, 54, 6.0, 666666) +SETUP (m_inner_p_outer, 55, 7.0, 777777) +#else +SETUP (p_all, 50, 2.0, 2222) +SETUP (p_inner, 51, 3.0, 3333) +SETUP (p_outer, 52, 4.0, 4444) +SETUP (a_max, 53, 5.0, 5555) +SETUP (m_outer_p_inner, 54, 6.0, 6666) +SETUP (m_inner_p_outer, 55, 7.0, 7777) +#endif +#endif + +void +struct_align_1_x (void) +{ + DEBUG_INIT + + CHECK (orig); +#ifndef SKIP_ATTRIBUTE + CHECK (p_all); + CHECK (p_inner); + CHECK (p_outer); + CHECK (a_max); + CHECK (m_outer_p_inner); + CHECK (m_inner_p_outer); +#endif + + DEBUG_FINI + + if (fails != 0) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-1_y.c b/gcc/testsuite/gcc.dg/compat/struct-align-1_y.c new file mode 100644 index 000000000..77cb09880 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-1_y.c @@ -0,0 +1,92 @@ +/* { dg-options "-Wno-psabi" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +#include "compat-common.h" +#include "struct-align-1.h" + +#define TEST(NAME) \ +extern char v1_##NAME; \ +extern double v2_##NAME; \ +extern int v3_##NAME; \ + \ +extern struct B1_##NAME b1_##NAME, ab1_##NAME[2]; \ +extern struct B2_##NAME b2_##NAME, ab2_##NAME[2]; \ +extern struct B3_##NAME b3_##NAME, ab3_##NAME[2]; \ + \ +extern void pass1_##NAME (struct B1_##NAME); \ +extern void pass2_##NAME (struct B2_##NAME); \ +extern void pass3_##NAME (struct B3_##NAME); \ +extern struct B1_##NAME return1_##NAME (void); \ +extern struct B2_##NAME return2_##NAME (void); \ +extern struct B3_##NAME return3_##NAME (void); \ + \ +void \ +checkp1_##NAME (struct B1_##NAME *p) \ +{ \ + if (p->c != v1_##NAME) \ + DEBUG_CHECK; \ + if (p->d != v2_##NAME) \ + DEBUG_CHECK; \ +} \ + \ +void \ +checkp2_##NAME (struct B2_##NAME *p) \ +{ \ + if (p->c != v1_##NAME) \ + DEBUG_CHECK; \ + if (p->a2.d != v2_##NAME) \ + DEBUG_CHECK; \ +} \ + \ +void \ +checkp3_##NAME (struct B3_##NAME *p) \ +{ \ + if (p->c != v1_##NAME) \ + DEBUG_CHECK; \ + if (p->a3.d != v2_##NAME) \ + DEBUG_CHECK; \ + if (p->a3.i != v3_##NAME) \ + DEBUG_CHECK; \ +} \ + \ +void \ +test_##NAME (void) \ +{ \ + struct B1_##NAME s1; \ + struct B2_##NAME s2; \ + struct B3_##NAME s3; \ + DEBUG_FPUTS (DESC_##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (" global variable"); \ + checkp1_##NAME (&b1_##NAME); \ + checkp2_##NAME (&b2_##NAME); \ + checkp3_##NAME (&b3_##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (" global array"); \ + checkp1_##NAME (&ab1_##NAME[1]); \ + checkp2_##NAME (&ab2_##NAME[1]); \ + checkp3_##NAME (&ab3_##NAME[1]); \ + DEBUG_NL; \ + DEBUG_FPUTS (" argument"); \ + pass1_##NAME (b1_##NAME); \ + pass2_##NAME (b2_##NAME); \ + pass3_##NAME (b3_##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (" function result"); \ + s1 = return1_##NAME (); \ + checkp1_##NAME (&s1); \ + s2 = return2_##NAME (); \ + checkp2_##NAME (&s2); \ + s3 = return3_##NAME (); \ + checkp3_##NAME (&s3); \ + DEBUG_NL; \ +} + +TEST (orig) +#ifndef SKIP_ATTRIBUTE +TEST (p_all) +TEST (p_inner) +TEST (p_outer) +TEST (a_max) +TEST (m_outer_p_inner) +TEST (m_inner_p_outer) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-2.h b/gcc/testsuite/gcc.dg/compat/struct-align-2.h new file mode 100644 index 000000000..f94fe57e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-2.h @@ -0,0 +1,75 @@ +/* Define several variants of struct epoll_event from the Linux kernel, + specifying various attributes that affect alignment and size. + + This test was developed for systems for which int is 32 bits and + long long is 64 bits; it might need to be disabled for systems where + either of those is not true. */ + +#define DESC_orig "original" +struct epoll_event_orig { + unsigned int events; + unsigned long long data; +}; + +#ifndef SKIP_ATTRIBUTE +#define DESC_structmax "maximum useful struct alignment" +struct epoll_event_structmax { + unsigned int events; + unsigned long long data; +} __attribute__ ((aligned)); + + +#define DESC_struct4 "4-byte struct alignment" +struct epoll_event_struct4 { + unsigned int events; + unsigned long long data; +} __attribute__ ((aligned(4))); + +#define DESC_struct8 "8-byte struct alignment" +struct epoll_event_struct8 { + unsigned int events; + unsigned long long data; +} __attribute__ ((aligned(8))); + +#define DESC_data4 "4-byte alignment for data" +struct epoll_event_data4 { + unsigned int events; + unsigned long long data __attribute__ ((aligned(4))); +}; + +#define DESC_data8 "8-byte alignment for data" +struct epoll_event_data8 { + unsigned int events; + unsigned long long data __attribute__ ((aligned(8))); +}; + +#define DESC_p "packed attribute" +struct epoll_event_p { + unsigned int events; + unsigned long long data; +} __attribute__ ((packed)); + +#define DESC_pstruct4 "packed attribute, 4-byte struct alignment" +struct epoll_event_pstruct4 { + unsigned int events; + unsigned long long data; +} __attribute__ ((packed)) __attribute__ ((aligned(4))); + +#define DESC_pstruct8 "packed attribute, 8-byte struct alignment" +struct epoll_event_pstruct8 { + unsigned int events; + unsigned long long data; +} __attribute__ ((packed)) __attribute__ ((aligned(8))); + +#define DESC_pdata4 "packed attribute, 4-byte alignment for data" +struct epoll_event_pdata4 { + unsigned int events; + unsigned long long data __attribute__ ((aligned(4))); +} __attribute__ ((packed)); + +#define DESC_pdata8 "packed attribute, 8-byte alignment for data" +struct epoll_event_pdata8 { + unsigned int events; + unsigned long long data __attribute__ ((aligned(8))); +} __attribute__ ((packed)); +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-2_main.c b/gcc/testsuite/gcc.dg/compat/struct-align-2_main.c new file mode 100644 index 000000000..b1dece1b7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-2_main.c @@ -0,0 +1,14 @@ +/* Test compatibility of structure layout and alignment for a struct + containing an int and a long long, with various combinations of + packed and aligned attributes. The struct is from the Linux kernel. */ + +extern void struct_align_2_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_align_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-2_x.c b/gcc/testsuite/gcc.dg/compat/struct-align-2_x.c new file mode 100644 index 000000000..6bfc22268 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-2_x.c @@ -0,0 +1,87 @@ +/* { dg-options "-Wno-psabi" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +/* Disable this test for 16-bit targets. */ + +#include <limits.h> + +#if !(defined __GNUC__) || (INT_MAX > 32767) + +#include "compat-common.h" +#include "struct-align-2.h" + +#define SETUP(NAME,V1,V2,V3) \ +struct outer_##NAME { \ + int i; \ + struct epoll_event_##NAME ee; \ +}; \ + \ +unsigned int v1_##NAME = V1; \ +unsigned int v2_##NAME = V2; \ +unsigned long long v3_##NAME = V3; \ + \ +struct outer_##NAME s_##NAME[2] = \ + { {V1, { V2, V3 } }, { V1, { V2, V3 } } }; \ + \ +extern void test_##NAME (void); \ +extern void checkp_##NAME (struct outer_##NAME *); \ +extern void checkg_##NAME (void); \ + \ +void \ +pass_##NAME (struct outer_##NAME s) \ +{ \ + checkp_##NAME (&s); \ +} \ + \ +struct outer_##NAME \ +return_##NAME (void) \ +{ \ + return s_##NAME[0]; \ +} + +#define CHECK(NAME) \ + test_##NAME() + +SETUP (orig,101, 102, 0x0101010101010101ULL) +#ifndef SKIP_ATTRIBUTE +SETUP (structmax, 103, 104, 0x1212121212121212ULL) +SETUP (struct4, 105, 106, 0x2323232323232323ULL) +SETUP (struct8, 107, 108, 0x3434343434343434ULL) +SETUP (data4, 109, 110, 0x4545454545454545ULL) +SETUP (data8, 111, 112, 0x5656565656565656ULL) +SETUP (p, 113, 114, 0x6767676767676767ULL) +SETUP (pstruct4, 115, 116, 0x7878787878787878ULL) +SETUP (pstruct8, 117, 118, 0x8989898989898989ULL) +SETUP (pdata4, 119, 120, 0x9A9A9A9A9A9A9A9AULL) +SETUP (pdata8, 121, 122, 0xABABABABABABABABULL) +#endif + +void +struct_align_2_x (void) +{ + DEBUG_INIT + + CHECK (orig); +#ifndef SKIP_ATTRIBUTE + CHECK (structmax); + CHECK (struct4); + CHECK (struct8); + CHECK (data4); + CHECK (data8); + CHECK (p); + CHECK (pstruct4); + CHECK (pstruct8); + CHECK (pdata4); + CHECK (pdata8); +#endif + + DEBUG_FINI + + if (fails != 0) + abort (); +} + +#else + +void struct_align_2_x (void) {} + +#endif /* INT_MAX */ diff --git a/gcc/testsuite/gcc.dg/compat/struct-align-2_y.c b/gcc/testsuite/gcc.dg/compat/struct-align-2_y.c new file mode 100644 index 000000000..2727015a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-align-2_y.c @@ -0,0 +1,75 @@ +/* { dg-options "-Wno-psabi" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +/* Disable this test for 16-bit targets. */ + +#include <limits.h> + +#if !(defined __GNUC__) || (INT_MAX > 32767) + +#include "compat-common.h" +#include "struct-align-2.h" + +#define TEST(NAME) \ +struct outer_##NAME { \ + int i; \ + struct epoll_event_##NAME ee; \ +}; \ + \ +extern unsigned int v1_##NAME; \ +extern unsigned int v2_##NAME; \ +extern unsigned long long v3_##NAME; \ + \ +extern struct outer_##NAME s_##NAME[2]; \ + \ +extern void pass_##NAME (struct outer_##NAME); \ +extern struct outer_##NAME return_##NAME (void); \ + \ +void \ +checkp_##NAME (struct outer_##NAME *p) \ +{ \ + if (p->i != v1_##NAME) \ + DEBUG_CHECK; \ + if (p->ee.events != v2_##NAME) \ + DEBUG_CHECK; \ + if (p->ee.data != v3_##NAME) \ + DEBUG_CHECK; \ +} \ + \ +void \ +test_##NAME (void) \ +{ \ + struct outer_##NAME s; \ + DEBUG_FPUTS (DESC_##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (" global array"); \ + checkp_##NAME (&s_##NAME[0]); \ + checkp_##NAME (&s_##NAME[1]); \ + DEBUG_NL; \ + DEBUG_FPUTS (" argument"); \ + pass_##NAME (s_##NAME[0]); \ + DEBUG_NL; \ + DEBUG_FPUTS (" function result"); \ + s = return_##NAME (); \ + checkp_##NAME (&s); \ + DEBUG_NL; \ +} + +TEST (orig) +#ifndef SKIP_ATTRIBUTE +TEST (structmax) +TEST (struct4) +TEST (struct8) +TEST (data4) +TEST (data8) +TEST (p) +TEST (pstruct4) +TEST (pstruct8) +TEST (pdata4) +TEST (pdata8) +#endif + +#else + +int i; /* prevent compiling an empty file */ + +#endif /* INT_MAX */ diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-10_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-10_main.c new file mode 100644 index 000000000..e41b93c57 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-10_main.c @@ -0,0 +1,14 @@ +/* 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_10_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_10_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-10_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-10_x.c new file mode 100644 index 000000000..5954104aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-10_x.c @@ -0,0 +1,184 @@ +#include "compat-common.h" + +#include "fp2-struct-defs.h" +#include "fp2-struct-check.h" + +#define TEST(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, double 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); \ + DEBUG_FPUTS (" init: "); \ + init##TYPE ( &g1s##TYPE, (double)1); \ + init##TYPE ( &g2s##TYPE, (double)2); \ + init##TYPE ( &g3s##TYPE, (double)3); \ + init##TYPE ( &g4s##TYPE, (double)4); \ + init##TYPE ( &g5s##TYPE, (double)5); \ + init##TYPE ( &g6s##TYPE, (double)6); \ + init##TYPE ( &g7s##TYPE, (double)7); \ + init##TYPE ( &g8s##TYPE, (double)8); \ + init##TYPE ( &g9s##TYPE, (double)9); \ + init##TYPE (&g10s##TYPE, (double)10); \ + init##TYPE (&g11s##TYPE, (double)11); \ + init##TYPE (&g12s##TYPE, (double)12); \ + init##TYPE (&g13s##TYPE, (double)13); \ + init##TYPE (&g14s##TYPE, (double)14); \ + init##TYPE (&g15s##TYPE, (double)15); \ + init##TYPE (&g16s##TYPE, (double)16); \ + checkg##TYPE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##TYPE (1, \ + g1s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test2: "); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +TEST(Sfd) +TEST(Sfl) +TEST(Sdf) +TEST(Sdl) +TEST(Slf) +TEST(Sld) +TEST(Sfdl) +TEST(Sfld) +TEST(Sdfl) +TEST(Sdlf) +TEST(Slfd) +TEST(Sldf) + +#undef T + +void +struct_by_value_10_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Sfd) +T(Sfl) +T(Sdf) +T(Sdl) +T(Slf) +T(Sld) +T(Sfdl) +T(Sfld) +T(Sdfl) +T(Sdlf) +T(Slfd) +T(Sldf) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-10_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-10_y.c new file mode 100644 index 000000000..6c9589d02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-10_y.c @@ -0,0 +1,95 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp2-struct-defs.h" +#include "fp2-struct-init.h" + +#define TEST(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; \ + \ +extern void check##TYPE (TYPE x, double y); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE ( g1s##TYPE, (double)1); \ + check##TYPE ( g2s##TYPE, (double)2); \ + check##TYPE ( g3s##TYPE, (double)3); \ + check##TYPE ( g4s##TYPE, (double)4); \ + check##TYPE ( g5s##TYPE, (double)5); \ + check##TYPE ( g6s##TYPE, (double)6); \ + check##TYPE ( g7s##TYPE, (double)7); \ + check##TYPE ( g8s##TYPE, (double)8); \ + check##TYPE ( g9s##TYPE, (double)9); \ + check##TYPE ( g10s##TYPE, (double)10); \ + check##TYPE ( g11s##TYPE, (double)11); \ + check##TYPE ( g12s##TYPE, (double)12); \ + check##TYPE ( g13s##TYPE, (double)13); \ + check##TYPE ( g14s##TYPE, (double)14); \ + check##TYPE ( g15s##TYPE, (double)15); \ + check##TYPE ( g16s##TYPE, (double)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) \ +{ \ + check##TYPE (s1, (double)1); \ + check##TYPE (s2, (double)2); \ + check##TYPE (s3, (double)3); \ + check##TYPE (s4, (double)4); \ + check##TYPE (s5, (double)5); \ + check##TYPE (s6, (double)6); \ + check##TYPE (s7, (double)7); \ + check##TYPE (s8, (double)8); \ + check##TYPE (s9, (double)9); \ + check##TYPE (s10, (double)10); \ + check##TYPE (s11, (double)11); \ + check##TYPE (s12, (double)12); \ + check##TYPE (s13, (double)13); \ + check##TYPE (s14, (double)14); \ + check##TYPE (s15, (double)15); \ + check##TYPE (s16, (double)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); \ + check##TYPE (t, (double)i+1); \ + } \ + va_end (ap); \ + } \ +} + +TEST(Sfd) +TEST(Sfl) +TEST(Sdf) +TEST(Sdl) +TEST(Slf) +TEST(Sld) +TEST(Sfdl) +TEST(Sfld) +TEST(Sdfl) +TEST(Sdlf) +TEST(Slfd) +TEST(Sldf) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-11_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-11_main.c new file mode 100644 index 000000000..400e94c2c --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-11_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex char. */ + +extern void struct_by_value_11_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_11_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-11_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-11_x.c new file mode 100644 index 000000000..cea1ac096 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-11_x.c @@ -0,0 +1,63 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cc, _Complex char) +CHECKS(cc, _Complex char) + +TEST(Scc1, _Complex char) +TEST(Scc2, _Complex char) +TEST(Scc3, _Complex char) +TEST(Scc4, _Complex char) +TEST(Scc5, _Complex char) +TEST(Scc6, _Complex char) +TEST(Scc7, _Complex char) +TEST(Scc8, _Complex char) +TEST(Scc9, _Complex char) +TEST(Scc10, _Complex char) +TEST(Scc11, _Complex char) +TEST(Scc12, _Complex char) +TEST(Scc13, _Complex char) +TEST(Scc14, _Complex char) +TEST(Scc15, _Complex char) +TEST(Scc16, _Complex char) +#endif + +#undef T + +void +struct_by_value_11_x () +{ +#ifndef SKIP_COMPLEX_INT +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Scc1, _Complex char) +T(Scc2, _Complex char) +T(Scc3, _Complex char) +T(Scc4, _Complex char) +T(Scc5, _Complex char) +T(Scc6, _Complex char) +T(Scc7, _Complex char) +T(Scc8, _Complex char) +T(Scc9, _Complex char) +T(Scc10, _Complex char) +T(Scc11, _Complex char) +T(Scc12, _Complex char) +T(Scc13, _Complex char) +T(Scc14, _Complex char) +T(Scc15, _Complex char) +T(Scc16, _Complex char) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +#endif +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-11_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-11_y.c new file mode 100644 index 000000000..c4e47fc35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-11_y.c @@ -0,0 +1,35 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cc,_Complex char) +INITS(cc, _Complex char) + +TEST(Scc1, _Complex char) +TEST(Scc2, _Complex char) +TEST(Scc3, _Complex char) +TEST(Scc4, _Complex char) +TEST(Scc5, _Complex char) +TEST(Scc6, _Complex char) +TEST(Scc7, _Complex char) +TEST(Scc8, _Complex char) +TEST(Scc9, _Complex char) +TEST(Scc10, _Complex char) +TEST(Scc11, _Complex char) +TEST(Scc12, _Complex char) +TEST(Scc13, _Complex char) +TEST(Scc14, _Complex char) +TEST(Scc15, _Complex char) +TEST(Scc16, _Complex char) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-12_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-12_main.c new file mode 100644 index 000000000..ab4faac09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-12_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex short. */ + +extern void struct_by_value_12_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_12_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-12_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-12_x.c new file mode 100644 index 000000000..925ce9270 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-12_x.c @@ -0,0 +1,63 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cs, _Complex short) +CHECKS(cs, _Complex short) + +TEST(Scs1, _Complex short) +TEST(Scs2, _Complex short) +TEST(Scs3, _Complex short) +TEST(Scs4, _Complex short) +TEST(Scs5, _Complex short) +TEST(Scs6, _Complex short) +TEST(Scs7, _Complex short) +TEST(Scs8, _Complex short) +TEST(Scs9, _Complex short) +TEST(Scs10, _Complex short) +TEST(Scs11, _Complex short) +TEST(Scs12, _Complex short) +TEST(Scs13, _Complex short) +TEST(Scs14, _Complex short) +TEST(Scs15, _Complex short) +TEST(Scs16, _Complex short) +#endif + +#undef T + +void +struct_by_value_12_x () +{ +#ifndef SKIP_COMPLEX_INT +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Scs1, _Complex short) +T(Scs2, _Complex short) +T(Scs3, _Complex short) +T(Scs4, _Complex short) +T(Scs5, _Complex short) +T(Scs6, _Complex short) +T(Scs7, _Complex short) +T(Scs8, _Complex short) +T(Scs9, _Complex short) +T(Scs10, _Complex short) +T(Scs11, _Complex short) +T(Scs12, _Complex short) +T(Scs13, _Complex short) +T(Scs14, _Complex short) +T(Scs15, _Complex short) +T(Scs16, _Complex short) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +#endif +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-12_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-12_y.c new file mode 100644 index 000000000..2e8e393ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-12_y.c @@ -0,0 +1,35 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cs,_Complex short) +INITS(cs, _Complex short) + +TEST(Scs1, _Complex short) +TEST(Scs2, _Complex short) +TEST(Scs3, _Complex short) +TEST(Scs4, _Complex short) +TEST(Scs5, _Complex short) +TEST(Scs6, _Complex short) +TEST(Scs7, _Complex short) +TEST(Scs8, _Complex short) +TEST(Scs9, _Complex short) +TEST(Scs10, _Complex short) +TEST(Scs11, _Complex short) +TEST(Scs12, _Complex short) +TEST(Scs13, _Complex short) +TEST(Scs14, _Complex short) +TEST(Scs15, _Complex short) +TEST(Scs16, _Complex short) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-13_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-13_main.c new file mode 100644 index 000000000..b853bb88e --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-13_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are type + _Complex int. */ + +extern void struct_by_value_l3_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_13_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-13_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-13_x.c new file mode 100644 index 000000000..f27222f2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-13_x.c @@ -0,0 +1,63 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(ci, _Complex int) +CHECKS(ci, _Complex int) + +TEST(Sci1, _Complex int) +TEST(Sci2, _Complex int) +TEST(Sci3, _Complex int) +TEST(Sci4, _Complex int) +TEST(Sci5, _Complex int) +TEST(Sci6, _Complex int) +TEST(Sci7, _Complex int) +TEST(Sci8, _Complex int) +TEST(Sci9, _Complex int) +TEST(Sci10, _Complex int) +TEST(Sci11, _Complex int) +TEST(Sci12, _Complex int) +TEST(Sci13, _Complex int) +TEST(Sci14, _Complex int) +TEST(Sci15, _Complex int) +TEST(Sci16, _Complex int) +#endif + +#undef T + +void +struct_by_value_13_x () +{ +#ifndef SKIP_COMPLEX_INT +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sci1, _Complex int) +T(Sci2, _Complex int) +T(Sci3, _Complex int) +T(Sci4, _Complex int) +T(Sci5, _Complex int) +T(Sci6, _Complex int) +T(Sci7, _Complex int) +T(Sci8, _Complex int) +T(Sci9, _Complex int) +T(Sci10, _Complex int) +T(Sci11, _Complex int) +T(Sci12, _Complex int) +T(Sci13, _Complex int) +T(Sci14, _Complex int) +T(Sci15, _Complex int) +T(Sci16, _Complex int) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +#endif +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-13_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-13_y.c new file mode 100644 index 000000000..7a3657e0f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-13_y.c @@ -0,0 +1,35 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(ci,_Complex int) +INITS(ci, _Complex int) + +TEST(Sci1, _Complex int) +TEST(Sci2, _Complex int) +TEST(Sci3, _Complex int) +TEST(Sci4, _Complex int) +TEST(Sci5, _Complex int) +TEST(Sci6, _Complex int) +TEST(Sci7, _Complex int) +TEST(Sci8, _Complex int) +TEST(Sci9, _Complex int) +TEST(Sci10, _Complex int) +TEST(Sci11, _Complex int) +TEST(Sci12, _Complex int) +TEST(Sci13, _Complex int) +TEST(Sci14, _Complex int) +TEST(Sci15, _Complex int) +TEST(Sci16, _Complex int) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-14_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-14_main.c new file mode 100644 index 000000000..a332e93b1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-14_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex long. */ + +extern void struct_by_value_14_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_14_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-14_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-14_x.c new file mode 100644 index 000000000..bb8db7072 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-14_x.c @@ -0,0 +1,63 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cl, _Complex long) +CHECKS(cl, _Complex long) + +TEST(Scl1, _Complex long) +TEST(Scl2, _Complex long) +TEST(Scl3, _Complex long) +TEST(Scl4, _Complex long) +TEST(Scl5, _Complex long) +TEST(Scl6, _Complex long) +TEST(Scl7, _Complex long) +TEST(Scl8, _Complex long) +TEST(Scl9, _Complex long) +TEST(Scl10, _Complex long) +TEST(Scl11, _Complex long) +TEST(Scl12, _Complex long) +TEST(Scl13, _Complex long) +TEST(Scl14, _Complex long) +TEST(Scl15, _Complex long) +TEST(Scl16, _Complex long) +#endif + +#undef T + +void +struct_by_value_14_x () +{ +#ifndef SKIP_COMPLEX_INT +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Scl1, _Complex long) +T(Scl2, _Complex long) +T(Scl3, _Complex long) +T(Scl4, _Complex long) +T(Scl5, _Complex long) +T(Scl6, _Complex long) +T(Scl7, _Complex long) +T(Scl8, _Complex long) +T(Scl9, _Complex long) +T(Scl10, _Complex long) +T(Scl11, _Complex long) +T(Scl12, _Complex long) +T(Scl13, _Complex long) +T(Scl14, _Complex long) +T(Scl15, _Complex long) +T(Scl16, _Complex long) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +#endif +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-14_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-14_y.c new file mode 100644 index 000000000..5abd063ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-14_y.c @@ -0,0 +1,35 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cl,_Complex long) +INITS(cl, _Complex long) + +TEST(Scl1, _Complex long) +TEST(Scl2, _Complex long) +TEST(Scl3, _Complex long) +TEST(Scl4, _Complex long) +TEST(Scl5, _Complex long) +TEST(Scl6, _Complex long) +TEST(Scl7, _Complex long) +TEST(Scl8, _Complex long) +TEST(Scl9, _Complex long) +TEST(Scl10, _Complex long) +TEST(Scl11, _Complex long) +TEST(Scl12, _Complex long) +TEST(Scl13, _Complex long) +TEST(Scl14, _Complex long) +TEST(Scl15, _Complex long) +TEST(Scl16, _Complex long) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-15_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-15_main.c new file mode 100644 index 000000000..6e5d8e0f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-15_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex long long. */ + +extern void struct_by_value_15_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_15_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-15_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-15_x.c new file mode 100644 index 000000000..4409c9668 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-15_x.c @@ -0,0 +1,63 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cll, _Complex long long) +CHECKS(cll, _Complex long long) + +TEST(Scll1, _Complex long long) +TEST(Scll2, _Complex long long) +TEST(Scll3, _Complex long long) +TEST(Scll4, _Complex long long) +TEST(Scll5, _Complex long long) +TEST(Scll6, _Complex long long) +TEST(Scll7, _Complex long long) +TEST(Scll8, _Complex long long) +TEST(Scll9, _Complex long long) +TEST(Scll10, _Complex long long) +TEST(Scll11, _Complex long long) +TEST(Scll12, _Complex long long) +TEST(Scll13, _Complex long long) +TEST(Scll14, _Complex long long) +TEST(Scll15, _Complex long long) +TEST(Scll16, _Complex long long) +#endif + +#undef T + +void +struct_by_value_15_x () +{ +#ifndef SKIP_COMPLEX_INT +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Scll1, _Complex long long) +T(Scll2, _Complex long long) +T(Scll3, _Complex long long) +T(Scll4, _Complex long long) +T(Scll5, _Complex long long) +T(Scll6, _Complex long long) +T(Scll7, _Complex long long) +T(Scll8, _Complex long long) +T(Scll9, _Complex long long) +T(Scll10, _Complex long long) +T(Scll11, _Complex long long) +T(Scll12, _Complex long long) +T(Scll13, _Complex long long) +T(Scll14, _Complex long long) +T(Scll15, _Complex long long) +T(Scll16, _Complex long long) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +#endif +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-15_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-15_y.c new file mode 100644 index 000000000..a5fec4fdb --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-15_y.c @@ -0,0 +1,35 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX_INT +DEFS(cll,_Complex long long) +INITS(cll, _Complex long long) + +TEST(Scll1, _Complex long long) +TEST(Scll2, _Complex long long) +TEST(Scll3, _Complex long long) +TEST(Scll4, _Complex long long) +TEST(Scll5, _Complex long long) +TEST(Scll6, _Complex long long) +TEST(Scll7, _Complex long long) +TEST(Scll8, _Complex long long) +TEST(Scll9, _Complex long long) +TEST(Scll10, _Complex long long) +TEST(Scll11, _Complex long long) +TEST(Scll12, _Complex long long) +TEST(Scll13, _Complex long long) +TEST(Scll14, _Complex long long) +TEST(Scll15, _Complex long long) +TEST(Scll16, _Complex long long) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-16_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-16_main.c new file mode 100644 index 000000000..31447bee6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-16_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex float. */ + +extern void struct_by_value_16_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_16_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-16_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-16_x.c new file mode 100644 index 000000000..05e36fe26 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-16_x.c @@ -0,0 +1,55 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX +DEFS(cf, _Complex float) +CHECKS(cf, _Complex float) + +TEST(Scf1, _Complex float) +TEST(Scf2, _Complex float) +TEST(Scf3, _Complex float) +TEST(Scf4, _Complex float) +TEST(Scf5, _Complex float) +TEST(Scf6, _Complex float) +TEST(Scf7, _Complex float) +TEST(Scf8, _Complex float) +TEST(Scf9, _Complex float) +TEST(Scf10, _Complex float) +TEST(Scf11, _Complex float) +TEST(Scf12, _Complex float) +#endif + +#undef T + +void +struct_by_value_16_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +#ifndef SKIP_COMPLEX +T(Scf1, _Complex float) +T(Scf2, _Complex float) +T(Scf3, _Complex float) +T(Scf4, _Complex float) +T(Scf5, _Complex float) +T(Scf6, _Complex float) +T(Scf7, _Complex float) +T(Scf8, _Complex float) +T(Scf9, _Complex float) +T(Scf10, _Complex float) +T(Scf11, _Complex float) +T(Scf12, _Complex float) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-16_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-16_y.c new file mode 100644 index 000000000..ce99a68a0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-16_y.c @@ -0,0 +1,31 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX +DEFS(cf,_Complex float) +INITS(cf, _Complex float) + +TEST(Scf1, _Complex float) +TEST(Scf2, _Complex float) +TEST(Scf3, _Complex float) +TEST(Scf4, _Complex float) +TEST(Scf5, _Complex float) +TEST(Scf6, _Complex float) +TEST(Scf7, _Complex float) +TEST(Scf8, _Complex float) +TEST(Scf9, _Complex float) +TEST(Scf10, _Complex float) +TEST(Scf11, _Complex float) +TEST(Scf12, _Complex float) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_main.c new file mode 100644 index 000000000..6a71d15b8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a
+ variable-length argument lists. All struct members are of type
+ _Complex float. */
+
+extern void struct_by_value_16_x (void);
+extern void exit (int);
+int fails;
+
+int
+main ()
+{
+ struct_by_value_16a_x ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_x.c new file mode 100644 index 000000000..f563f6ea9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_x.c @@ -0,0 +1,39 @@ +#include "compat-common.h"
+
+#include "fp-struct-defs.h"
+#include "fp-struct-check.h"
+#include "fp-struct-test-by-value-x.h"
+
+#ifndef SKIP_COMPLEX
+DEFS(cf, _Complex float)
+CHECKS(cf, _Complex float)
+
+TEST(Scf13, _Complex float)
+TEST(Scf14, _Complex float)
+TEST(Scf15, _Complex float)
+TEST(Scf16, _Complex float)
+#endif
+
+#undef T
+
+void
+struct_by_value_16a_x ()
+{
+DEBUG_INIT
+
+#define T(TYPE, MTYPE) testit##TYPE ();
+
+#ifndef SKIP_COMPLEX
+T(Scf13, _Complex float)
+T(Scf14, _Complex float)
+T(Scf15, _Complex float)
+T(Scf16, _Complex float)
+#endif
+
+DEBUG_FINI
+
+if (fails != 0)
+ abort ();
+
+#undef T
+}
diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_y.c new file mode 100644 index 000000000..0575b3c1d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-16a_y.c @@ -0,0 +1,23 @@ +#include <stdarg.h>
+
+#include "compat-common.h"
+
+#ifdef SKIP_VA
+const int test_va = 0;
+#else
+const int test_va = 1;
+#endif
+
+#include "fp-struct-defs.h"
+#include "fp-struct-init.h"
+#include "fp-struct-test-by-value-y.h"
+
+#ifndef SKIP_COMPLEX
+DEFS(cf,_Complex float)
+INITS(cf, _Complex float)
+
+TEST(Scf13, _Complex float)
+TEST(Scf14, _Complex float)
+TEST(Scf15, _Complex float)
+TEST(Scf16, _Complex float)
+#endif
diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-17_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-17_main.c new file mode 100644 index 000000000..3d97146b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-17_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex double. */ + +extern void struct_by_value_17_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_17_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-17_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-17_x.c new file mode 100644 index 000000000..8c2704522 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-17_x.c @@ -0,0 +1,55 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX +DEFS(cd, _Complex double) +CHECKS(cd, _Complex double) + +TEST(Scd1, _Complex double) +TEST(Scd2, _Complex double) +TEST(Scd3, _Complex double) +TEST(Scd4, _Complex double) +TEST(Scd5, _Complex double) +TEST(Scd6, _Complex double) +TEST(Scd7, _Complex double) +TEST(Scd8, _Complex double) +TEST(Scd9, _Complex double) +TEST(Scd10, _Complex double) +TEST(Scd11, _Complex double) +TEST(Scd12, _Complex double) +#endif + +#undef T + +void +struct_by_value_17_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +#ifndef SKIP_COMPLEX +T(Scd1, _Complex double) +T(Scd2, _Complex double) +T(Scd3, _Complex double) +T(Scd4, _Complex double) +T(Scd5, _Complex double) +T(Scd6, _Complex double) +T(Scd7, _Complex double) +T(Scd8, _Complex double) +T(Scd9, _Complex double) +T(Scd10, _Complex double) +T(Scd11, _Complex double) +T(Scd12, _Complex double) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-17_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-17_y.c new file mode 100644 index 000000000..d05ff8407 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-17_y.c @@ -0,0 +1,31 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX +DEFS(cd,_Complex double) +INITS(cd, _Complex double) + +TEST(Scd1, _Complex double) +TEST(Scd2, _Complex double) +TEST(Scd3, _Complex double) +TEST(Scd4, _Complex double) +TEST(Scd5, _Complex double) +TEST(Scd6, _Complex double) +TEST(Scd7, _Complex double) +TEST(Scd8, _Complex double) +TEST(Scd9, _Complex double) +TEST(Scd10, _Complex double) +TEST(Scd11, _Complex double) +TEST(Scd12, _Complex double) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_main.c new file mode 100644 index 000000000..1db00215f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex double. */ + +extern void struct_by_value_17_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_17a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_x.c new file mode 100644 index 000000000..804b5c255 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_x.c @@ -0,0 +1,39 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX +DEFS(cd, _Complex double) +CHECKS(cd, _Complex double) + +TEST(Scd13, _Complex double) +TEST(Scd14, _Complex double) +TEST(Scd15, _Complex double) +TEST(Scd16, _Complex double) +#endif + +#undef T + +void +struct_by_value_17a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +#ifndef SKIP_COMPLEX +T(Scd13, _Complex double) +T(Scd14, _Complex double) +T(Scd15, _Complex double) +T(Scd16, _Complex double) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_y.c new file mode 100644 index 000000000..3119e5448 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-17a_y.c @@ -0,0 +1,23 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX +DEFS(cd,_Complex double) +INITS(cd, _Complex double) + +TEST(Scd13, _Complex double) +TEST(Scd14, _Complex double) +TEST(Scd15, _Complex double) +TEST(Scd16, _Complex double) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-18_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-18_main.c new file mode 100644 index 000000000..8a4889cc0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-18_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are of type + _Complex long double. */ + +extern void struct_by_value_18_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_18_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-18_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-18_x.c new file mode 100644 index 000000000..aa10a6e1a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-18_x.c @@ -0,0 +1,55 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +#ifndef SKIP_COMPLEX +DEFS(cld, _Complex long double) +CHECKS(cld, _Complex long double) + +TEST(Scld1, _Complex long double) +TEST(Scld2, _Complex long double) +TEST(Scld3, _Complex long double) +TEST(Scld4, _Complex long double) +TEST(Scld5, _Complex long double) +TEST(Scld6, _Complex long double) +TEST(Scld7, _Complex long double) +TEST(Scld8, _Complex long double) +TEST(Scld9, _Complex long double) +TEST(Scld10, _Complex long double) +TEST(Scld11, _Complex long double) +TEST(Scld12, _Complex long double) +#endif + +#undef T + +void +struct_by_value_18_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +#ifndef SKIP_COMPLEX +T(Scld1, _Complex long double) +T(Scld2, _Complex long double) +T(Scld3, _Complex long double) +T(Scld4, _Complex long double) +T(Scld5, _Complex long double) +T(Scld6, _Complex long double) +T(Scld7, _Complex long double) +T(Scld8, _Complex long double) +T(Scld9, _Complex long double) +T(Scld10, _Complex long double) +T(Scld11, _Complex long double) +T(Scld12, _Complex long double) +#endif + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-18_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-18_y.c new file mode 100644 index 000000000..d98debb6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-18_y.c @@ -0,0 +1,31 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +#ifndef SKIP_COMPLEX +DEFS(cld,_Complex long double) +INITS(cld, _Complex long double) + +TEST(Scld1, _Complex long double) +TEST(Scld2, _Complex long double) +TEST(Scld3, _Complex long double) +TEST(Scld4, _Complex long double) +TEST(Scld5, _Complex long double) +TEST(Scld6, _Complex long double) +TEST(Scld7, _Complex long double) +TEST(Scld8, _Complex long double) +TEST(Scld9, _Complex long double) +TEST(Scld10, _Complex long double) +TEST(Scld11, _Complex long double) +TEST(Scld12, _Complex long double) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_main.c new file mode 100644 index 000000000..5b9dfd983 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a
+ variable-length argument lists. All struct members are of type
+ _Complex long double. */
+
+extern void struct_by_value_18_x (void);
+extern void exit (int);
+int fails;
+
+int
+main ()
+{
+ struct_by_value_18a_x ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_x.c new file mode 100644 index 000000000..986c4dded --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_x.c @@ -0,0 +1,39 @@ +#include "compat-common.h"
+
+#include "fp-struct-defs.h"
+#include "fp-struct-check.h"
+#include "fp-struct-test-by-value-x.h"
+
+#ifndef SKIP_COMPLEX
+DEFS(cld, _Complex long double)
+CHECKS(cld, _Complex long double)
+
+TEST(Scld13, _Complex long double)
+TEST(Scld14, _Complex long double)
+TEST(Scld15, _Complex long double)
+TEST(Scld16, _Complex long double)
+#endif
+
+#undef T
+
+void
+struct_by_value_18a_x ()
+{
+DEBUG_INIT
+
+#define T(TYPE, MTYPE) testit##TYPE ();
+
+#ifndef SKIP_COMPLEX
+T(Scld13, _Complex long double)
+T(Scld14, _Complex long double)
+T(Scld15, _Complex long double)
+T(Scld16, _Complex long double)
+#endif
+
+DEBUG_FINI
+
+if (fails != 0)
+ abort ();
+
+#undef T
+}
diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_y.c new file mode 100644 index 000000000..12ac53418 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-18a_y.c @@ -0,0 +1,23 @@ +#include <stdarg.h>
+
+#include "compat-common.h"
+
+#ifdef SKIP_VA
+const int test_va = 0;
+#else
+const int test_va = 1;
+#endif
+
+#include "fp-struct-defs.h"
+#include "fp-struct-init.h"
+#include "fp-struct-test-by-value-y.h"
+
+#ifndef SKIP_COMPLEX
+DEFS(cld,_Complex long double)
+INITS(cld, _Complex long double)
+
+TEST(Scld13, _Complex long double)
+TEST(Scld14, _Complex long double)
+TEST(Scld15, _Complex long double)
+TEST(Scld16, _Complex long double)
+#endif
diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-19_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-19_main.c new file mode 100644 index 000000000..b0eed4c3a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-19_main.c @@ -0,0 +1,17 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. Struct members are char, int, double, + and other structs containing these types. This test was written in + response to a layout change for such structs for powerpc64-linux, + but this test only checks similar structs that are not affected by + that break in compatibility. */ + +extern void struct_by_value_19_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_19_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-19_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-19_x.c new file mode 100644 index 000000000..4ccedfde3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-19_x.c @@ -0,0 +1,178 @@ +#include "compat-common.h" + +#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); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##TYPE (1, \ + g1s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test2:"); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +#include "mixed-struct-defs.h" +#include "mixed-struct-check.h" + +T(Scdc) +T(Sd) +T(Sdi) +T(Scsdsc) +T(Scsdis) +T(Scsdisc) +T(Ssds) +T(Ssdsc) +T(Scssdssc) + +#undef T + +void +struct_by_value_19_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Scdc) +T(Sd) +T(Sdi) +T(Scsdsc) +T(Scsdis) +T(Scsdisc) +T(Ssds) +T(Ssdsc) +T(Scssdssc) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-19_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-19_y.c new file mode 100644 index 000000000..036c6b618 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-19_y.c @@ -0,0 +1,104 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "mixed-struct-defs.h" + +extern void checkScd (Scd x, int i); +extern void checkScdc (Scdc x, int i); +extern void checkSd (Sd x, int i); +extern void checkSdi (Sdi x, int i); +extern void checkScsds (Scsds x, int i); +extern void checkScsdsc (Scsdsc x, int i); +extern void checkScsdis (Scsdis x, int i); +extern void checkScsdisc (Scsdisc x, int i); +extern void checkSsds (Ssds x, int i); +extern void checkSsdsc (Ssdsc x, int i); +extern void checkScssdss (Scssdss x, int i); +extern void checkScssdssc (Scssdssc x, int i); + +#include "mixed-struct-init.h" + +#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) \ +{ \ + check##TYPE (s1, 1); \ + check##TYPE (s2, 2); \ + check##TYPE (s3, 3); \ + check##TYPE (s4, 4); \ + check##TYPE (s5, 5); \ + check##TYPE (s6, 6); \ + check##TYPE (s7, 7); \ + check##TYPE (s8, 8); \ + check##TYPE (s9, 9); \ + check##TYPE (s10, 10); \ + check##TYPE (s11, 11); \ + check##TYPE (s12, 12); \ + check##TYPE (s13, 13); \ + check##TYPE (s14, 14); \ + check##TYPE (s15, 15); \ + 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); \ + check##TYPE (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +T(Scdc) +T(Sd) +T(Sdi) +T(Scsdsc) +T(Scsdis) +T(Scsdisc) +T(Ssds) +T(Ssdsc) +T(Scssdssc) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-1_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-1_main.c new file mode 100644 index 000000000..d2f9de505 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-1_main.c @@ -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); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-1_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-1_x.c new file mode 100644 index 000000000..67ac16d1d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-1_x.c @@ -0,0 +1,69 @@ +#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); + +#ifndef SKIP_ZERO_ARRAY +T(0) +#endif +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 (); + +#ifndef SKIP_ZERO_ARRAY +T(0) +#endif +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 +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-1_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-1_y.c new file mode 100644 index 000000000..8370dbac3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-1_y.c @@ -0,0 +1,43 @@ +#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); \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0) +#endif +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) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-20_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-20_main.c new file mode 100644 index 000000000..64c8f27ae --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-20_main.c @@ -0,0 +1,16 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. Tested structs end with double. + This test was written in response to a layout change for such + structs for powerpc64-linux that breaks compatibility between + 3.3 and 3.4. */ + +extern void struct_by_value_20_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_20_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-20_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-20_x.c new file mode 100644 index 000000000..183e32dc4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-20_x.c @@ -0,0 +1,166 @@ +#include "compat-common.h" + +#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); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##TYPE (1, \ + g1s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test2:"); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +#include "mixed-struct-defs.h" +#include "mixed-struct-check.h" + +T(Scd) +T(Scsds) +T(Scssdss) + +#undef T + +void +struct_by_value_20_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Scd) +T(Scsds) +T(Scssdss) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-20_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-20_y.c new file mode 100644 index 000000000..1a4a6775d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-20_y.c @@ -0,0 +1,98 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "mixed-struct-defs.h" + +extern void checkScd (Scd x, int i); +extern void checkScdc (Scdc x, int i); +extern void checkSd (Sd x, int i); +extern void checkSdi (Sdi x, int i); +extern void checkScsds (Scsds x, int i); +extern void checkScsdsc (Scsdsc x, int i); +extern void checkScsdis (Scsdis x, int i); +extern void checkScsdisc (Scsdisc x, int i); +extern void checkSsds (Ssds x, int i); +extern void checkSsdsc (Ssdsc x, int i); +extern void checkScssdss (Scssdss x, int i); +extern void checkScssdssc (Scssdssc x, int i); + +#include "mixed-struct-init.h" + +#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) \ +{ \ + check##TYPE (s1, 1); \ + check##TYPE (s2, 2); \ + check##TYPE (s3, 3); \ + check##TYPE (s4, 4); \ + check##TYPE (s5, 5); \ + check##TYPE (s6, 6); \ + check##TYPE (s7, 7); \ + check##TYPE (s8, 8); \ + check##TYPE (s9, 9); \ + check##TYPE (s10, 10); \ + check##TYPE (s11, 11); \ + check##TYPE (s12, 12); \ + check##TYPE (s13, 13); \ + check##TYPE (s14, 14); \ + check##TYPE (s15, 15); \ + 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); \ + check##TYPE (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +T(Scd) +T(Scsds) +T(Scssdss) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-21_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-21_main.c new file mode 100644 index 000000000..b722bccd2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-21_main.c @@ -0,0 +1,13 @@ +/* Test function argument passing. This was written when correcting + a deviation from the ABI on SPARC64 between 3.3 and 3.4. */ + +extern void struct_by_value_21_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_21_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-21_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-21_x.c new file mode 100644 index 000000000..3b01ba86e --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-21_x.c @@ -0,0 +1,168 @@ +#include "compat-common.h" + +#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); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##TYPE (1, \ + g1s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test2:"); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +#include "mixed-struct-defs.h" +#include "mixed-struct-check.h" + +T(Sfi) +T(Sfii) +T(Sfifi) +T(Sfiifii) + +#undef T + +void +struct_by_value_21_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Sfi) +T(Sfii) +T(Sfifi) +T(Sfiifii) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-21_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-21_y.c new file mode 100644 index 000000000..fc06d9d4f --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-21_y.c @@ -0,0 +1,86 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "mixed-struct-defs.h" +#include "mixed-struct-init.h" + +#define T(TYPE) \ +extern void check##TYPE (TYPE x, int i); \ +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) \ +{ \ + check##TYPE (s1, 1); \ + check##TYPE (s2, 2); \ + check##TYPE (s3, 3); \ + check##TYPE (s4, 4); \ + check##TYPE (s5, 5); \ + check##TYPE (s6, 6); \ + check##TYPE (s7, 7); \ + check##TYPE (s8, 8); \ + check##TYPE (s9, 9); \ + check##TYPE (s10, 10); \ + check##TYPE (s11, 11); \ + check##TYPE (s12, 12); \ + check##TYPE (s13, 13); \ + check##TYPE (s14, 14); \ + check##TYPE (s15, 15); \ + 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); \ + check##TYPE (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +T(Sfi) +T(Sfii) +T(Sfifi) +T(Sfiifii) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-22_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-22_main.c new file mode 100644 index 000000000..1fd2eba1c --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-22_main.c @@ -0,0 +1,20 @@ +/* Test variable sized function argument passing. + GCC 3.2 and earlier is incompatible with GCC 3.3+ on x86-64, + the latter passes variable sized arguments by reference while + the former doesn't. + See http://gcc.gnu.org/ml/gcc-patches/2003-01/msg01830.html */ + +#ifndef SKIP_VLA_IN_STRUCT +extern void struct_by_value_22_x (void); +#endif +extern void exit (int); +int fails; + +int +main () +{ +#ifndef SKIP_VLA_IN_STRUCT + struct_by_value_22_x (); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-22_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-22_x.c new file mode 100644 index 000000000..6f1cdc860 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-22_x.c @@ -0,0 +1,83 @@ +#ifndef SKIP_VLA_IN_STRUCT + +#ifndef T +#include "compat-common.h" +#include "mixed-struct-defs.h" +#include "mixed-struct-init.h" + +#define T(NAME, FIELDS, TYPE, FIELDINIT, FIELDTEST) \ +extern void testva##NAME (int n, ...); \ + \ +void \ +testit##NAME (int n) \ +{ \ + struct S { FIELDS TYPE a[n]; } s; \ + int i; \ + FIELDINIT; \ + for (i = 0; i < n; ++i) \ + s.a[i] = 12 + n - i; \ + testva##NAME (n, s, n, s); \ +} + +#include "struct-by-value-22_x.c" + +#undef T + +void +struct_by_value_22_x () +{ + int n; +DEBUG_INIT + +#define T(NAME, FIELDS, TYPE, FIELDINIT, FIELDTEST) testit##NAME (n); + + for (n = 0; n < 16; ++n) + { +#include "struct-by-value-22_x.c" + DEBUG_NL; + } + for (; n < 110; n += 13) + { +#include "struct-by-value-22_x.c" + DEBUG_NL; + } + +DEBUG_FINI + +if (fails != 0) + abort (); +} + +#else + +#define S(NAME, FIELDS, FIELDINIT, FIELDTEST) \ + T(c##NAME, FIELDS, char, FIELDINIT, FIELDTEST) \ + T(s##NAME, FIELDS, short, FIELDINIT, FIELDTEST) \ + T(u##NAME, FIELDS, unsigned, FIELDINIT, FIELDTEST) \ + T(d##NAME, FIELDS, double, FIELDINIT, FIELDTEST) +S(E, , do {} while (0), DEBUG_DOT) +S(n, int n;, s.n = n, if (s.n != n) DEBUG_CHECK) +#define U(TYPE) \ +S(TYPE, TYPE s;, init##TYPE (&s.s, n), check##TYPE (s.s, n)) +U(Scd) +U(Scdc) +U(Sd) +U(Sdi) +U(Scsds) +U(Scsdsc) +U(Scsdis) +U(Scsdisc) +U(Ssds) +U(Ssdsc) +U(Scssdss) +U(Scssdssc) +U(Sfi) +U(Sfii) +U(Sfifi) +U(Sfiifii) +#undef S +#undef U + +#endif + +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-22_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-22_y.c new file mode 100644 index 000000000..ea5dec226 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-22_y.c @@ -0,0 +1,41 @@ +#include <stdarg.h> +#include "compat-common.h" +#include "mixed-struct-defs.h" +#include "mixed-struct-check.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#ifndef SKIP_VLA_IN_STRUCT +#define T(NAME, FIELDS, TYPE, FIELDINIT, FIELDTEST) \ +void \ +testva##NAME (int n, ...) \ +{ \ + va_list ap; \ + if (test_va) \ + { \ + struct S { FIELDS TYPE a[n]; } s; \ + int fail = 0, i, j; \ + \ + va_start (ap, n); \ + for (j = 0; j < 2; ++j) \ + { \ + s = va_arg (ap, struct S); \ + for (i = 0; i < n; ++i) \ + if (s.a[i] != 12 + n - i) \ + ++fail; \ + if (fail) \ + { DEBUG_FAIL; } \ + if (!j && va_arg (ap, int) != n) \ + { DEBUG_FAIL; } \ + FIELDTEST; \ + } \ + va_end (ap); \ + } \ +} + +#include "struct-by-value-22_x.c" +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-2_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-2_main.c new file mode 100644 index 000000000..8cb6fc078 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-2_main.c @@ -0,0 +1,14 @@ +/* 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 fails; + +int +main () +{ + struct_by_value_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-2_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-2_x.c new file mode 100644 index 000000000..57c6da0c0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-2_x.c @@ -0,0 +1,233 @@ +#include "compat-common.h" + +#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_CHECK \ +} \ + \ +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 "]"); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#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; \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0, uc, unsigned char) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, us, unsigned short) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, ui, unsigned int) +#endif +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 () +{ +DEBUG_INIT + +#define T(N, NAME, TYPE) testit##NAME##N (); + +#ifndef SKIP_ZERO_ARRAY +T(0, uc, unsigned char) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, us, unsigned short) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, ui, unsigned int) +#endif +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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-2_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-2_y.c new file mode 100644 index 000000000..3b203fab2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-2_y.c @@ -0,0 +1,157 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +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) \ +{ \ + check##NAME##N (&s1, 1*16); \ + check##NAME##N (&s2, 2*16); \ + check##NAME##N (&s3, 3*16); \ + check##NAME##N (&s4, 4*16); \ + check##NAME##N (&s5, 5*16); \ + check##NAME##N (&s6, 6*16); \ + check##NAME##N (&s7, 7*16); \ + check##NAME##N (&s8, 8*16); \ + check##NAME##N (&s9, 9*16); \ + check##NAME##N (&s10, 10*16); \ + check##NAME##N (&s11, 11*16); \ + check##NAME##N (&s12, 12*16); \ + check##NAME##N (&s13, 13*16); \ + check##NAME##N (&s14, 14*16); \ + check##NAME##N (&s15, 15*16); \ + 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); \ + check##NAME##N (&t, (i+1)*16); \ + } \ + va_end (ap); \ + } \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0, uc, unsigned char) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, us, unsigned short) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, ui, unsigned int) +#endif +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) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-3_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-3_main.c new file mode 100644 index 000000000..0b7206895 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-3_main.c @@ -0,0 +1,15 @@ +/* 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 fails; + +int +main () +{ + struct_by_value_3_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-3_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-3_x.c new file mode 100644 index 000000000..38e5b546a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-3_x.c @@ -0,0 +1,190 @@ +#include "compat-common.h" + +#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); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##TYPE (1, \ + g1s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test2:"); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +#include "small-struct-defs.h" +#include "small-struct-check.h" + +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 () +{ +DEBUG_INIT + +#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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-3_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-3_y.c new file mode 100644 index 000000000..d5a31c9d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-3_y.c @@ -0,0 +1,113 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "small-struct-defs.h" + +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); + +#include "small-struct-init.h" + +#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) \ +{ \ + check##TYPE (s1, 1); \ + check##TYPE (s2, 2); \ + check##TYPE (s3, 3); \ + check##TYPE (s4, 4); \ + check##TYPE (s5, 5); \ + check##TYPE (s6, 6); \ + check##TYPE (s7, 7); \ + check##TYPE (s8, 8); \ + check##TYPE (s9, 9); \ + check##TYPE (s10, 10); \ + check##TYPE (s11, 11); \ + check##TYPE (s12, 12); \ + check##TYPE (s13, 13); \ + check##TYPE (s14, 14); \ + check##TYPE (s15, 15); \ + 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); \ + 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) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-4_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-4_main.c new file mode 100644 index 000000000..570eddc5d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-4_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. Each struct contains an array + of small structs with a single member. */ + +extern void struct_by_value_4_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_4_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-4_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-4_x.c new file mode 100644 index 000000000..def20ce8b --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-4_x.c @@ -0,0 +1,257 @@ +#include "compat-common.h" + +#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 "]"); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#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; + +void checkSc (Sc x, int i) { if (x.c != i/16) DEBUG_CHECK } +void checkSs (Ss x, int i) { if (x.s != i) DEBUG_CHECK } +void checkSi (Si x, int i) { if (x.i != i) DEBUG_CHECK } +void checkSsc (Ssc x, int i) +{ if (x.s != i || x.c != (i/16)+1) DEBUG_CHECK } +void checkSis (Sis x, int i) +{ if (x.i != i || x.s != i+1) DEBUG_CHECK } +void checkScsi (Scsi x, int i) +{ if (x.c != i/16 || x.s != i+1 || x.i != i+2) DEBUG_CHECK } +void checkScis (Scis x, int i) +{ if (x.c != i/16 || x.i != i+1 || x.s != i+2) DEBUG_CHECK } + +#ifndef SKIP_ZERO_ARRAY +T(0, Sc) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Ss) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Si) +#endif +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) + +#undef T + +void +struct_by_value_4_x () +{ +DEBUG_INIT + +#define T(N, TYPE) testit##TYPE##N (); + +#ifndef SKIP_ZERO_ARRAY +T(0, Sc) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Ss) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Si) +#endif +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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-4_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-4_y.c new file mode 100644 index 000000000..fe1b09577 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-4_y.c @@ -0,0 +1,162 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +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) \ +{ \ + check##TYPE##N (&s1, 1*16); \ + check##TYPE##N (&s2, 2*16); \ + check##TYPE##N (&s3, 3*16); \ + check##TYPE##N (&s4, 4*16); \ + check##TYPE##N (&s5, 5*16); \ + check##TYPE##N (&s6, 6*16); \ + check##TYPE##N (&s7, 7*16); \ + check##TYPE##N (&s8, 8*16); \ + check##TYPE##N (&s9, 9*16); \ + check##TYPE##N (&s10, 10*16); \ + check##TYPE##N (&s11, 11*16); \ + check##TYPE##N (&s12, 12*16); \ + check##TYPE##N (&s13, 13*16); \ + check##TYPE##N (&s14, 14*16); \ + check##TYPE##N (&s15, 15*16); \ + 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); \ + check##TYPE##N (&t, (i+1)*16); \ + } \ + va_end (ap); \ + } \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0, Sc) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Ss) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Si) +#endif +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) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c new file mode 100644 index 000000000..d6f9eff25 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are float + scalars. */ + +extern void struct_by_value_5a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_5a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c new file mode 100644 index 000000000..90738a7a7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(f, float) +CHECKS(f, float) + +TEST(Sf1, float) +TEST(Sf2, float) +TEST(Sf3, float) +TEST(Sf4, float) +TEST(Sf5, float) +TEST(Sf6, float) +TEST(Sf7, float) +TEST(Sf8, float) + +#undef T + +void +struct_by_value_5a_x () +{ +DEBUG_INIT + +#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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c new file mode 100644 index 000000000..9ac1f9134 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(f,float) +INITS(f, float) + +TEST(Sf1, float) +TEST(Sf2, float) +TEST(Sf3, float) +TEST(Sf4, float) +TEST(Sf5, float) +TEST(Sf6, float) +TEST(Sf7, float) +TEST(Sf8, float) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c new file mode 100644 index 000000000..dcb5f27ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are float + scalars. */ + +extern void struct_by_value_5b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_5b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c new file mode 100644 index 000000000..3c3715587 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(f, float) +CHECKS(f, float) + +TEST(Sf9, float) +TEST(Sf10, float) +TEST(Sf11, float) +TEST(Sf12, float) +TEST(Sf13, float) +TEST(Sf14, float) +TEST(Sf15, float) +TEST(Sf16, float) + +#undef T + +void +struct_by_value_5b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sf9, float) +T(Sf10, float) +T(Sf11, float) +T(Sf12, float) +T(Sf13, float) +T(Sf14, float) +T(Sf15, float) +T(Sf16, float) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c new file mode 100644 index 000000000..cedc16607 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-5b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(f,float) +INITS(f, float) + +TEST(Sf9, float) +TEST(Sf10, float) +TEST(Sf11, float) +TEST(Sf12, float) +TEST(Sf13, float) +TEST(Sf14, float) +TEST(Sf15, float) +TEST(Sf16, float) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c new file mode 100644 index 000000000..609c1d673 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are double + scalars. */ + +extern void struct_by_value_6a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_6a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c new file mode 100644 index 000000000..e6852d9c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(d, double) +CHECKS(d, double) + +TEST(Sd1, double) +TEST(Sd2, double) +TEST(Sd3, double) +TEST(Sd4, double) +TEST(Sd5, double) +TEST(Sd6, double) +TEST(Sd7, double) +TEST(Sd8, double) + +#undef T + +void +struct_by_value_6a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sd1, double) +T(Sd2, double) +T(Sd3, double) +T(Sd4, double) +T(Sd5, double) +T(Sd6, double) +T(Sd7, double) +T(Sd8, double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c new file mode 100644 index 000000000..8684b53c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(d, double) +INITS(d, double) + +TEST(Sd1, double) +TEST(Sd2, double) +TEST(Sd3, double) +TEST(Sd4, double) +TEST(Sd5, double) +TEST(Sd6, double) +TEST(Sd7, double) +TEST(Sd8, double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c new file mode 100644 index 000000000..ff1722171 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are double + scalars. */ + +extern void struct_by_value_6b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_6b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c new file mode 100644 index 000000000..5b285c9c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(d, double) +CHECKS(d, double) + +TEST(Sd9, double) +TEST(Sd10, double) +TEST(Sd11, double) +TEST(Sd12, double) +TEST(Sd13, double) +TEST(Sd14, double) +TEST(Sd15, double) +TEST(Sd16, double) + +#undef T + +void +struct_by_value_6b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +T(Sd9, double) +T(Sd10, double) +T(Sd11, double) +T(Sd12, double) +T(Sd13, double) +T(Sd14, double) +T(Sd15, double) +T(Sd16, double) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c new file mode 100644 index 000000000..c568761b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-6b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(d, double) +INITS(d, double) + +TEST(Sd9, double) +TEST(Sd10, double) +TEST(Sd11, double) +TEST(Sd12, double) +TEST(Sd13, double) +TEST(Sd14, double) +TEST(Sd15, double) +TEST(Sd16, double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c new file mode 100644 index 000000000..8379dc563 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are long double + scalars. */ + +extern void struct_by_value_7a_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_7a_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c new file mode 100644 index 000000000..9818c3c22 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(ld, long double) +CHECKS(ld, long double) + +TEST(Sld1, long double) +TEST(Sld2, long double) +TEST(Sld3, long double) +TEST(Sld4, long double) +TEST(Sld5, long double) +TEST(Sld6, long double) +TEST(Sld7, long double) +TEST(Sld8, long double) + +#undef T + +void +struct_by_value_7a_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c new file mode 100644 index 000000000..cb53df89d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7a_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(ld, long double) +INITS(ld, long double) + +TEST(Sld1, long double) +TEST(Sld2, long double) +TEST(Sld3, long double) +TEST(Sld4, long double) +TEST(Sld5, long double) +TEST(Sld6, long double) +TEST(Sld7, long double) +TEST(Sld8, long double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c new file mode 100644 index 000000000..5d6908bfc --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument lists. All struct members are long double + scalars. */ + +extern void struct_by_value_7b_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_7b_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c new file mode 100644 index 000000000..508ff6165 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_x.c @@ -0,0 +1,43 @@ +#include "compat-common.h" + +#include "fp-struct-defs.h" +#include "fp-struct-check.h" +#include "fp-struct-test-by-value-x.h" + +DEFS(ld, long double) +CHECKS(ld, long double) + +TEST(Sld9, long double) +TEST(Sld10, long double) +TEST(Sld11, long double) +TEST(Sld12, long double) +TEST(Sld13, long double) +TEST(Sld14, long double) +TEST(Sld15, long double) +TEST(Sld16, long double) + +#undef T + +void +struct_by_value_7b_x () +{ +DEBUG_INIT + +#define T(TYPE, MTYPE) testit##TYPE (); + +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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c new file mode 100644 index 000000000..cc70a7d29 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-7b_y.c @@ -0,0 +1,25 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "fp-struct-defs.h" +#include "fp-struct-init.h" +#include "fp-struct-test-by-value-y.h" + +DEFS(ld, long double) +INITS(ld, long double) + +TEST(Sld9, long double) +TEST(Sld10, long double) +TEST(Sld11, long double) +TEST(Sld12, long double) +TEST(Sld13, long double) +TEST(Sld14, long double) +TEST(Sld15, long double) +TEST(Sld16, long double) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-8_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-8_main.c new file mode 100644 index 000000000..cc094fcc9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-8_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. Each struct contains an array + of small structs with two scalar members. */ + +extern void struct_by_value_8_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_8_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-8_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-8_x.c new file mode 100644 index 000000000..5a376fd38 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-8_x.c @@ -0,0 +1,221 @@ +#include "compat-common.h" + +#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 "]"); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#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; + +void checkSc (Sc x, int i) { if (x.c != i/16) DEBUG_CHECK } +void checkSs (Ss x, int i) { if (x.s != i) DEBUG_CHECK } +void checkSi (Si x, int i) { if (x.i != i) DEBUG_CHECK } +void checkSsc (Ssc x, int i) +{ if (x.s != i || x.c != (i/16)+1) DEBUG_CHECK } +void checkSis (Sis x, int i) +{ if (x.i != i || x.s != i+1) DEBUG_CHECK } +void checkScsi (Scsi x, int i) +{ if (x.c != i/16 || x.s != i+1 || x.i != i+2) DEBUG_CHECK } +void checkScis (Scis x, int i) +{ if (x.c != i/16 || x.i != i+1 || x.s != i+2) DEBUG_CHECK } + +#ifndef SKIP_ZERO_ARRAY +T(0, Ssc) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Sis) +#endif +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) + +#undef T + +void +struct_by_value_8_x () +{ +DEBUG_INIT + +#define T(N, TYPE) testit##TYPE##N (); + +#ifndef SKIP_ZERO_ARRAY +T(0, Ssc) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Sis) +#endif +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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-8_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-8_y.c new file mode 100644 index 000000000..b246fd448 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-8_y.c @@ -0,0 +1,144 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +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) \ +{ \ + check##TYPE##N (&s1, 1*16); \ + check##TYPE##N (&s2, 2*16); \ + check##TYPE##N (&s3, 3*16); \ + check##TYPE##N (&s4, 4*16); \ + check##TYPE##N (&s5, 5*16); \ + check##TYPE##N (&s6, 6*16); \ + check##TYPE##N (&s7, 7*16); \ + check##TYPE##N (&s8, 8*16); \ + check##TYPE##N (&s9, 9*16); \ + check##TYPE##N (&s10, 10*16); \ + check##TYPE##N (&s11, 11*16); \ + check##TYPE##N (&s12, 12*16); \ + check##TYPE##N (&s13, 13*16); \ + check##TYPE##N (&s14, 14*16); \ + check##TYPE##N (&s15, 15*16); \ + 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); \ + check##TYPE##N (&t, (i+1)*16); \ + } \ + va_end (ap); \ + } \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0, Ssc) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Sis) +#endif +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) diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-9_main.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-9_main.c new file mode 100644 index 000000000..942de1355 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-9_main.c @@ -0,0 +1,14 @@ +/* Test structures passed by value, including to a function with a + variable-length argument list. Each struct contains an array + of small structs, each with three scalar members. */ + +extern void struct_by_value_9_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_by_value_9_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-9_x.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-9_x.c new file mode 100644 index 000000000..5bbef770a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-9_x.c @@ -0,0 +1,224 @@ +#include "compat-common.h" + +#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 "]"); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE "[" #N "]"); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#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_CHECK } +void checkSs (Ss x, int i) { if (x.s != i) DEBUG_CHECK } +void checkSi (Si x, int i) { if (x.i != i) DEBUG_CHECK } +void checkSsc (Ssc x, int i) +{ if (x.s != i || x.c != (i/16)+1) DEBUG_CHECK } +void checkSis (Sis x, int i) +{ if (x.i != i || x.s != i+1) DEBUG_CHECK } +void checkScsi (Scsi x, int i) +{ if (x.c != i/16 || x.s != i+1 || x.i != i+2) DEBUG_CHECK } +void checkScis (Scis x, int i) +{ if (x.c != i/16 || x.i != i+1 || x.s != i+2) DEBUG_CHECK } + +#ifndef SKIP_ZERO_ARRAY +T(0, Scsi) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Scis) +#endif +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_9_x () +{ +DEBUG_INIT + +#define T(N, TYPE) testit##TYPE##N (); + +#ifndef SKIP_ZERO_ARRAY +T(0, Scsi) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Scis) +#endif +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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-by-value-9_y.c b/gcc/testsuite/gcc.dg/compat/struct-by-value-9_y.c new file mode 100644 index 000000000..0f6521800 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-by-value-9_y.c @@ -0,0 +1,144 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +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) \ +{ \ + check##TYPE##N (&s1, 1*16); \ + check##TYPE##N (&s2, 2*16); \ + check##TYPE##N (&s3, 3*16); \ + check##TYPE##N (&s4, 4*16); \ + check##TYPE##N (&s5, 5*16); \ + check##TYPE##N (&s6, 6*16); \ + check##TYPE##N (&s7, 7*16); \ + check##TYPE##N (&s8, 8*16); \ + check##TYPE##N (&s9, 9*16); \ + check##TYPE##N (&s10, 10*16); \ + check##TYPE##N (&s11, 11*16); \ + check##TYPE##N (&s12, 12*16); \ + check##TYPE##N (&s13, 13*16); \ + check##TYPE##N (&s14, 14*16); \ + check##TYPE##N (&s15, 15*16); \ + 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); \ + check##TYPE##N (&t, (i+1)*16); \ + } \ + va_end (ap); \ + } \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0, Scsi) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, Scis) +#endif +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) diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-1.h b/gcc/testsuite/gcc.dg/compat/struct-complex-1.h new file mode 100644 index 000000000..8b5393774 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-1.h @@ -0,0 +1,17 @@ +#include <complex.h> + +struct st +{ + int s1; + float complex x; + int s2; +}; + +typedef struct { float r, i; } _complex; + +struct stc +{ + int s1; + _complex x; + int s2; +}; diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-1_main.c b/gcc/testsuite/gcc.dg/compat/struct-complex-1_main.c new file mode 100644 index 000000000..92e886acf --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-1_main.c @@ -0,0 +1,21 @@ +/* { dg-options "-O" } */ + +#ifdef __x86_64__ +/* Test function argument passing. PR target/15302. */ + +extern void struct_complex_1_x (void); +extern void exit (int); + +int +main () +{ + struct_complex_1_x (); + exit (0); +} +#else +int +main () +{ + return 0; +} +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-1_x.c b/gcc/testsuite/gcc.dg/compat/struct-complex-1_x.c new file mode 100644 index 000000000..0c6723948 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-1_x.c @@ -0,0 +1,33 @@ +/* { dg-options "-O -Wno-psabi" } */ + + +#ifdef __x86_64__ +#include "struct-complex-1.h" + +struct st st1; +struct stc st2; + +extern void foo (); +extern void bar (); + +int +struct_complex_1_x () +{ + st1.s1 = 1; + st1.s2 = 2; + __real__ st1.x = 2; + __imag__ st1.x = 4; + st2.s1 = 1; + st2.s2 = 2; + st2.x.r = 2; + st2.x.i = 4; + foo (st1); + foo (st2); + bar (st1); + bar (st2); + return 0; +} +#else +int dummy_x; +#endif + diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-1_y.c b/gcc/testsuite/gcc.dg/compat/struct-complex-1_y.c new file mode 100644 index 000000000..858e6a9da --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-1_y.c @@ -0,0 +1,24 @@ +/* { dg-options "-O -Wno-psabi" } */ + +#ifdef __x86_64__ +#include <stdlib.h> +#include "struct-complex-1.h" + +void +bar(struct st x) +{ + if (x.s1 != 1 || x.s2 != 2 + || __real__ x.x != 2 || __imag__ x.x != 4) + abort (); +} + +void +foo(struct stc x) +{ + if (x.s1 != 1 || x.s2 != 2 || x.x.r != 2 || x.x.i != 4) + abort (); +} +#else +int dummy_y; +#endif + diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-2.h b/gcc/testsuite/gcc.dg/compat/struct-complex-2.h new file mode 100644 index 000000000..1fd1e86c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-2.h @@ -0,0 +1,15 @@ +#include <complex.h> + +struct st +{ + int s1; + float complex x; +}; + +typedef struct { float r, i; } _complex; + +struct stc +{ + int s1; + _complex x; +}; diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-2_main.c b/gcc/testsuite/gcc.dg/compat/struct-complex-2_main.c new file mode 100644 index 000000000..74eae6242 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-2_main.c @@ -0,0 +1,21 @@ +/* { dg-options "-O" } */ + +#ifdef __x86_64__ +/* Test function argument passing. PR target/39678. */ + +extern void struct_complex_2_x (void); +extern void exit (int); + +int +main () +{ + struct_complex_2_x (); + exit (0); +} +#else +int +main () +{ + return 0; +} +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-2_x.c b/gcc/testsuite/gcc.dg/compat/struct-complex-2_x.c new file mode 100644 index 000000000..2fb9826eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-2_x.c @@ -0,0 +1,30 @@ +/* { dg-options "-O -Wno-psabi" } */ + + +#ifdef __x86_64__ +#include "struct-complex-2.h" + +struct st st1; +struct stc st2; + +extern void foo (); +extern void bar (); + +int +struct_complex_2_x () +{ + st1.s1 = 1; + __real__ st1.x = 2; + __imag__ st1.x = 4; + st2.s1 = 1; + st2.x.r = 2; + st2.x.i = 4; + foo (st1); + foo (st2); + bar (st1); + bar (st2); + return 0; +} +#else +int dummy_x; +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-complex-2_y.c b/gcc/testsuite/gcc.dg/compat/struct-complex-2_y.c new file mode 100644 index 000000000..54a72fa43 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-complex-2_y.c @@ -0,0 +1,23 @@ +/* { dg-options "-O -Wno-psabi" } */ + +#ifdef __x86_64__ +#include <stdlib.h> +#include "struct-complex-2.h" + +void +bar(struct st x) +{ + if (x.s1 != 1 + || __real__ x.x != 2 || __imag__ x.x != 4) + abort (); +} + +void +foo(struct stc x) +{ + if (x.s1 != 1 || x.x.r != 2 || x.x.i != 4) + abort (); +} +#else +int dummy_y; +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp b/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp new file mode 100644 index 000000000..e541f6ed3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1.exp @@ -0,0 +1,130 @@ +# Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. +# +# This file was written by Jakub Jelinek, <jakub@redhat.com> +# Based on compat.exp writte by Janis Johnson, <janis187@us.ibm.com> + + +# Test interoperability of two compilers that follow the same ABI. +# +# Break simple tests into two pieces and see that they work when linked +# together. If an alternate compiler is specified then the two main +# pieces of each test are compiled with different compilers. The +# alternate compiler must be installed, and is specified by defining +# ALT_CC_UNDER_TEST in the environment. +# +# struct-layout-1 are generated structure layout interoperability tests, +# so a generator first needs to be compiled on host, run there and the +# generated tests then compiled on build and executed on target. + +if $tracelevel then { + strace $tracelevel +} + +global GCC_UNDER_TEST +global compat_save_gcc_under_test +global compat_use_alt +global compat_same_alt +global compat_have_dfp + +# Load procedures from common libraries. +load_lib standard.exp +load_lib gcc.exp +load_lib target-libpath.exp + +# Load the language-dependent compabibility support procedures. +load_lib c-compat.exp + +# Load the language-independent compabibility support procedures. +load_lib compat.exp + +gcc_init + +# Save variables for the C compiler under test, which each test will +# change a couple of times. This must be done after calling gcc-init. +set compat_save_gcc_under_test $GCC_UNDER_TEST + +# Define an identifier for use with this suite to avoid name conflicts +# with other compat tests running at the same time. +set sid "c_compat" + +# Find out whether there is an alternate compiler to test. If the +# variable is defined but is set to "same", that means we use the same +# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS +# are different. +set compat_use_alt 0 +set compat_same_alt 0 + +if [info exists ALT_CC_UNDER_TEST] then { + set compat_use_alt 1 + if [string match "same" $ALT_CC_UNDER_TEST] then { + set compat_same_alt 1 + } +} + +compat_setup_dfp + +if { $compat_have_dfp == 0 } { + set skip_dfp "-DSKIP_DECIMAL_FLOAT" +} else { + set skip_dfp "" +} + +set tstobjdir "$tmpdir/gcc.dg-struct-layout-1" +set generator "$tmpdir/gcc.dg-struct-layout-1_generate.exe" + +set generator_src "$srcdir/$subdir/struct-layout-1_generate.c" +set generator_src "$generator_src $srcdir/$subdir/generate-random.c" +set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c" +set generator_cmd "-o $generator $skip_dfp $generator_src" + +# Temporarily switch to the environment for the host compiler. +restore_ld_library_path_env_vars +set status [remote_exec build "$HOSTCC $HOSTCFLAGS $generator_cmd"] +set status [lindex $status 0] +set_ld_library_path_env_vars + +if { $status == 0 } then { + file delete -force $tstobjdir + file mkdir $tstobjdir + set generator_args "-s $srcdir/$subdir -d $tstobjdir" + if [info exists env(RUN_ALL_COMPAT_TESTS) ] then { + set generator_args "$generator_args -n 15000" + } + if [check_effective_target_short_enums] then { + set generator_args "-e $generator_args" + } + set status [remote_exec host "$generator $generator_args"] + set status [lindex $status 0] + if { $status == 0 } then { + foreach src [lsort [find $tstobjdir *_main.c]] { + # If we're only testing specific files and this isn't one + # of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + compat-execute $src $sid $compat_use_alt + } + } else { + warning "Could not execute gcc.dg/compat/struct-layout-1 generator" + } +} else { + warning "Could not compile gcc.dg/compat/struct-layout-1 generator" +} + +# Restore the original compiler under test. +compat-use-tst-compiler diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1.h b/gcc/testsuite/gcc.dg/compat/struct-layout-1.h new file mode 100644 index 000000000..82ac9f82c --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1.h @@ -0,0 +1,787 @@ +#include <limits.h> +#include <stdarg.h> +#include <stdbool.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "compat-common.h" + +#ifndef SKIP_ATTRIBUTE +# include "vector-defs.h" +#else +typedef int qi; +typedef int hi; +typedef int si; +typedef int di; +typedef float sf; +typedef float df; +typedef int v8qi; +typedef int v16qi; +typedef int v2hi; +typedef int v4hi; +typedef int v8hi; +typedef int v2si; +typedef int v4si; +typedef int v1di; +typedef int v2di; +typedef int v2sf; +typedef int v4sf; +typedef int v16sf; +typedef int v2df; +typedef int u8qi; +typedef int u16qi; +typedef int u2hi; +typedef int u4hi; +typedef int u8hi; +typedef int u2si; +typedef int u4si; +typedef int u1di; +typedef int u2di; +typedef int u2sf; +typedef int u4sf; +typedef int u16sf; +typedef int u2df; +#endif +#if (defined __i386__ || defined __x86_64__) && !defined SKIP_ATTRIBUTE +# ifdef __MMX__ +typedef int __m64 __attribute__ ((__vector_size__ (8))); +# else +typedef int __m64; +# endif +# ifdef __SSE__ +typedef float __m128 __attribute__ ((__vector_size__ (16))); +# else +typedef int __m128; +# endif +#else +typedef int __m64; +typedef int __m128; +#endif +#if defined (__uClinux__) +/* The maximum achievable alignment on uClinux is usually 16 bytes. */ +#define v16sf v4sf +#define u16sf u4sf +#endif + +#define FLDS_MAX 32 +extern struct Info +{ + int nfields, nbitfields; + void *sp, *a0p, *a3p; + void *flds[FLDS_MAX]; + size_t sz, sizes[FLDS_MAX]; + size_t als, ala0, ala3, aligns[FLDS_MAX]; +} info; + +extern int intarray[256]; +extern int fn0 (void), fn1 (void), fn2 (void), fn3 (void), fn4 (void); +extern int fn5 (void), fn6 (void), fn7 (void), fn8 (void), fn9 (void); + +#ifdef DBG +#define FAIL(n, m) printf ("fail %d.%d\n", n, m), ++fails +#else +#define FAIL(n, m) ++fails +#endif + +#ifdef SKIP_ATTRIBUTE +# define __attribute__(x) +#endif +#define atal __attribute__((aligned)) +#define atpa __attribute__((packed)) +#define atalpa __attribute__((aligned, packed)) +#define atpaal __attribute__((packed, aligned)) +#define atal1 __attribute__((aligned (1))) +#define atal2 __attribute__((aligned (2))) +#define atal4 __attribute__((aligned (4))) +#define atal8 __attribute__((aligned (8))) +#define atal16 __attribute__((aligned (16))) +#define atal1pa __attribute__((aligned (1), packed)) +#define atal2pa __attribute__((aligned (2), packed)) +#define atal4pa __attribute__((aligned (4), packed)) +#define atal8pa __attribute__((aligned (8), packed)) +#define atal16pa __attribute__((aligned (16), packed)) +#define atpaal1 __attribute__((packed, aligned (1))) +#define atpaal2 __attribute__((packed, aligned (2))) +#define atpaal4 __attribute__((packed, aligned (4))) +#define atpaal8 __attribute__((packed, aligned (8))) +#define atpaal16 __attribute__((packed, aligned (16))) + +#if UCHAR_MAX == 255 && USHORT_MAX == 65535 && UINT_MAX == 4294967295U \ + && ULLONG_MAX == 18446744073709551615ULL +/* For ILP32 and LP64 targets, assume float is at least 32-bit + and double plus long double at least 64-bit. */ +# define atalx1 atal1 +# define atalx2 atal2 +# define atalx4 atal4 +# define atalx8 atal8 +# define atalx16 atal16 +# define atalx1pa atal1pa +# define atalx2pa atal2pa +# define atalx4pa atal4pa +# define atalx8pa atal8pa +# define atalx16pa atal16pa +# define atpaalx1 atpaal1 +# define atpaalx2 atpaal2 +# define atpaalx4 atpaal4 +# define atpaalx8 atpaal8 +# define atpaalx16 atpaal16 +# if ULONG_MAX > 4294967295UL +# define ataly8 atal8 +# define ataly8pa atal8pa +# define atpaaly8 atpaal8 +# define ataly16 atal16 +# define ataly16pa atal16pa +# define atpaaly16 atpaal16 +# else +# define ataly8 +# define ataly8pa +# define atpaaly8 +# define ataly16 +# define ataly16pa +# define atpaaly16 +# endif +#else +# define atalx1 +# define atalx2 +# define atalx4 +# define atalx8 +# define atalx16 +# define atalx1pa +# define atalx2pa +# define atalx4pa +# define atalx8pa +# define atalx16pa +# define atpaalx1 +# define atpaalx2 +# define atpaalx4 +# define atpaalx8 +# define atpaalx16 +# define ataly8 +# define ataly8pa +# define atpaaly8 +# define ataly16 +# define ataly16pa +# define atpaaly16 +#endif + +#define atQI __attribute__((mode (QI))) +#define atHI __attribute__((mode (HI))) +#define atSI __attribute__((mode (SI))) +#define atDI __attribute__((mode (DI))) + +enum E0 { e0_0 }; +enum E1 { e1_0, e1_1 }; +enum E2 { e2_m3 = -3, e2_m2, e2_m1, e2_0, e2_1, e2_2, e2_3 }; +enum E3 { e3_m127 = -127, e3_m126, e3_m125, e3_0 = 0, e3_125 = 125, e3_126, e3_127 }; +enum E4 { e4_0, e4_1, e4_2, e4_3, e4_253 = 253, e4_254, e4_255 }; +enum E5 { e5_m32767 = -32767, e5_m32766, e5_m32765, e5_0 = 0, e5_32765 = 32765, e5_32766, e5_32767 }; +enum E6 { e6_0, e6_1, e6_2, e6_3, e6_65533 = 65533, e6_65534, e6_65535 }; +enum E7 { e7_m2147483647 = -2147483647, e7_m2147483646, e7_m2147483645, + e7_0, e7_2147483645 = 2147483645, e7_2147483646, e7_2147483647 }; +enum E8 { e8_0, e8_1, e8_2, e8_3, e8_4294967293 = 4294967293U, e8_4294967294, e8_4294967295 }; +enum E9 { e9_m1099511627775 = -1099511627775LL, e9_m1099511627774, e9_m1099511627773, + e9_0, e9_1099511627773 = 1099511627773LL, e9_1099511627774, e9_1099511627775 }; + +typedef char Tchar; +typedef signed char Tschar; +typedef unsigned char Tuchar; +typedef short int Tshort; +typedef unsigned short int Tushort; +typedef int Tint; +typedef unsigned int Tuint; +typedef long int Tlong; +typedef unsigned long int Tulong; +typedef long long int Tllong; +typedef unsigned long long int Tullong; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tcchar; +typedef _Complex signed char Tcschar; +typedef _Complex unsigned char Tcuchar; +typedef _Complex short int Tcshort; +typedef _Complex unsigned short int Tcushort; +typedef _Complex int Tcint; +typedef _Complex unsigned int Tcuint; +typedef _Complex long int Tclong; +typedef _Complex unsigned long int Tculong; +typedef _Complex long long int Tcllong; +typedef _Complex unsigned long long int Tcullong; +#endif +typedef float Tfloat; +typedef double Tdouble; +typedef long double Tldouble; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 TDecimal32; +typedef _Decimal64 TDecimal64; +typedef _Decimal128 TDecimal128; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Tcfloat; +typedef _Complex double Tcdouble; +typedef _Complex long double Tcldouble; +#endif +typedef bool Tbool; +typedef enum E0 TE0; +typedef enum E1 TE1; +typedef enum E2 TE2; +typedef enum E3 TE3; +typedef enum E4 TE4; +typedef enum E5 TE5; +typedef enum E6 TE6; +typedef enum E7 TE7; +typedef enum E8 TE8; +typedef enum E9 TE9; +typedef void *Tptr; +typedef char *Tcptr; +typedef int *Tiptr; +typedef char Talchar atal; +typedef signed char Talschar atal; +typedef unsigned char Taluchar atal; +typedef short int Talshort atal; +typedef unsigned short int Talushort atal; +typedef int Talint atal; +typedef unsigned int Taluint atal; +typedef long int Tallong atal; +typedef unsigned long int Talulong atal; +typedef long long int Talllong atal; +typedef unsigned long long int Talullong atal; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Talcchar atal; +typedef _Complex signed char Talcschar atal; +typedef _Complex unsigned char Talcuchar atal; +typedef _Complex short int Talcshort atal; +typedef _Complex unsigned short int Talcushort atal; +typedef _Complex int Talcint atal; +typedef _Complex unsigned int Talcuint atal; +typedef _Complex long int Talclong atal; +typedef _Complex unsigned long int Talculong atal; +typedef _Complex long long int Talcllong atal; +typedef _Complex unsigned long long int Talcullong atal; +#endif +typedef float Talfloat atal; +typedef double Taldouble atal; +typedef long double Talldouble atal; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 TalDecimal32 atal; +typedef _Decimal64 TalDecimal64 atal; +typedef _Decimal128 TalDecimal128 atal; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Talcfloat atal; +typedef _Complex double Talcdouble atal; +typedef _Complex long double Talcldouble atal; +#endif +typedef bool Talbool atal; +typedef enum E0 TalE0 atal; +typedef enum E1 TalE1 atal; +typedef enum E2 TalE2 atal; +typedef enum E3 TalE3 atal; +typedef enum E4 TalE4 atal; +typedef enum E5 TalE5 atal; +typedef enum E6 TalE6 atal; +typedef enum E7 TalE7 atal; +typedef enum E8 TalE8 atal; +typedef enum E9 TalE9 atal; +typedef void *Talptr atal; +typedef char *Talcptr atal; +typedef int *Taliptr atal; +typedef char Tal1char atal1; +typedef signed char Tal1schar atal1; +typedef unsigned char Tal1uchar atal1; +typedef short int Tal1short atal1; +typedef unsigned short int Tal1ushort atal1; +typedef int Tal1int atal1; +typedef unsigned int Tal1uint atal1; +typedef long int Tal1long atal1; +typedef unsigned long int Tal1ulong atal1; +typedef long long int Tal1llong atal1; +typedef unsigned long long int Tal1ullong atal1; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal1cchar atal1; +typedef _Complex signed char Tal1cschar atal1; +typedef _Complex unsigned char Tal1cuchar atal1; +typedef _Complex short int Tal1cshort atal1; +typedef _Complex unsigned short int Tal1cushort atal1; +typedef _Complex int Tal1cint atal1; +typedef _Complex unsigned int Tal1cuint atal1; +typedef _Complex long int Tal1clong atal1; +typedef _Complex unsigned long int Tal1culong atal1; +typedef _Complex long long int Tal1cllong atal1; +typedef _Complex unsigned long long int Tal1cullong atal1; +#endif +typedef float Tal1float atal1; +typedef double Tal1double atal1; +typedef long double Tal1ldouble atal1; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Tal1Decimal32 atal1; +typedef _Decimal64 Tal1Decimal64 atal1; +typedef _Decimal128 Tal1Decimal128 atal1; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Tal1cfloat atal1; +typedef _Complex double Tal1cdouble atal1; +typedef _Complex long double Tal1cldouble atal1; +#endif +typedef bool Tal1bool atal1; +typedef enum E0 Tal1E0 atal1; +typedef enum E1 Tal1E1 atal1; +typedef enum E2 Tal1E2 atal1; +typedef enum E3 Tal1E3 atal1; +typedef enum E4 Tal1E4 atal1; +typedef enum E5 Tal1E5 atal1; +typedef enum E6 Tal1E6 atal1; +typedef enum E7 Tal1E7 atal1; +typedef enum E8 Tal1E8 atal1; +typedef enum E9 Tal1E9 atal1; +typedef void *Tal1ptr atal1; +typedef char *Tal1cptr atal1; +typedef int *Tal1iptr atal1; +typedef char Tal2char atal2; +typedef signed char Tal2schar atal2; +typedef unsigned char Tal2uchar atal2; +typedef short int Tal2short atal2; +typedef unsigned short int Tal2ushort atal2; +typedef int Tal2int atal2; +typedef unsigned int Tal2uint atal2; +typedef long int Tal2long atal2; +typedef unsigned long int Tal2ulong atal2; +typedef long long int Tal2llong atal2; +typedef unsigned long long int Tal2ullong atal2; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal2cchar atal2; +typedef _Complex signed char Tal2cschar atal2; +typedef _Complex unsigned char Tal2cuchar atal2; +typedef _Complex short int Tal2cshort atal2; +typedef _Complex unsigned short int Tal2cushort atal2; +typedef _Complex int Tal2cint atal2; +typedef _Complex unsigned int Tal2cuint atal2; +typedef _Complex long int Tal2clong atal2; +typedef _Complex unsigned long int Tal2culong atal2; +typedef _Complex long long int Tal2cllong atal2; +typedef _Complex unsigned long long int Tal2cullong atal2; +#endif +typedef float Tal2float atal2; +typedef double Tal2double atal2; +typedef long double Tal2ldouble atal2; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Tal2Decimal32 atal2; +typedef _Decimal64 Tal2Decimal64 atal2; +typedef _Decimal128 Tal2Decimal128 atal2; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Tal2cfloat atal2; +typedef _Complex double Tal2cdouble atal2; +typedef _Complex long double Tal2cldouble atal2; +#endif +typedef bool Tal2bool atal2; +typedef enum E0 Tal2E0 atal2; +typedef enum E1 Tal2E1 atal2; +typedef enum E2 Tal2E2 atal2; +typedef enum E3 Tal2E3 atal2; +typedef enum E4 Tal2E4 atal2; +typedef enum E5 Tal2E5 atal2; +typedef enum E6 Tal2E6 atal2; +typedef enum E7 Tal2E7 atal2; +typedef enum E8 Tal2E8 atal2; +typedef enum E9 Tal2E9 atal2; +typedef void *Tal2ptr atal2; +typedef char *Tal2cptr atal2; +typedef int *Tal2iptr atal2; +typedef char Tal4char atal4; +typedef signed char Tal4schar atal4; +typedef unsigned char Tal4uchar atal4; +typedef short int Tal4short atal4; +typedef unsigned short int Tal4ushort atal4; +typedef int Tal4int atal4; +typedef unsigned int Tal4uint atal4; +typedef long int Tal4long atal4; +typedef unsigned long int Tal4ulong atal4; +typedef long long int Tal4llong atal4; +typedef unsigned long long int Tal4ullong atal4; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal4cchar atal4; +typedef _Complex signed char Tal4cschar atal4; +typedef _Complex unsigned char Tal4cuchar atal4; +typedef _Complex short int Tal4cshort atal4; +typedef _Complex unsigned short int Tal4cushort atal4; +typedef _Complex int Tal4cint atal4; +typedef _Complex unsigned int Tal4cuint atal4; +typedef _Complex long int Tal4clong atal4; +typedef _Complex unsigned long int Tal4culong atal4; +typedef _Complex long long int Tal4cllong atal4; +typedef _Complex unsigned long long int Tal4cullong atal4; +#endif +typedef float Tal4float atal4; +typedef double Tal4double atal4; +typedef long double Tal4ldouble atal4; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Tal4Decimal32 atal4; +typedef _Decimal64 Tal4Decimal64 atal4; +typedef _Decimal128 Tal4Decimal128 atal4; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Tal4cfloat atal4; +typedef _Complex double Tal4cdouble atal4; +typedef _Complex long double Tal4cldouble atal4; +#endif +typedef bool Tal4bool atal4; +typedef enum E0 Tal4E0 atal4; +typedef enum E1 Tal4E1 atal4; +typedef enum E2 Tal4E2 atal4; +typedef enum E3 Tal4E3 atal4; +typedef enum E4 Tal4E4 atal4; +typedef enum E5 Tal4E5 atal4; +typedef enum E6 Tal4E6 atal4; +typedef enum E7 Tal4E7 atal4; +typedef enum E8 Tal4E8 atal4; +typedef enum E9 Tal4E9 atal4; +typedef void *Tal4ptr atal4; +typedef char *Tal4cptr atal4; +typedef int *Tal4iptr atal4; +typedef char Tal8char atal8; +typedef signed char Tal8schar atal8; +typedef unsigned char Tal8uchar atal8; +typedef short int Tal8short atal8; +typedef unsigned short int Tal8ushort atal8; +typedef int Tal8int atal8; +typedef unsigned int Tal8uint atal8; +typedef long int Tal8long atal8; +typedef unsigned long int Tal8ulong atal8; +typedef long long int Tal8llong atal8; +typedef unsigned long long int Tal8ullong atal8; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal8cchar atal8; +typedef _Complex signed char Tal8cschar atal8; +typedef _Complex unsigned char Tal8cuchar atal8; +typedef _Complex short int Tal8cshort atal8; +typedef _Complex unsigned short int Tal8cushort atal8; +typedef _Complex int Tal8cint atal8; +typedef _Complex unsigned int Tal8cuint atal8; +typedef _Complex long int Tal8clong atal8; +typedef _Complex unsigned long int Tal8culong atal8; +typedef _Complex long long int Tal8cllong atal8; +typedef _Complex unsigned long long int Tal8cullong atal8; +#endif +typedef float Tal8float atal8; +typedef double Tal8double atal8; +typedef long double Tal8ldouble atal8; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Tal8Decimal32 atal8; +typedef _Decimal64 Tal8Decimal64 atal8; +typedef _Decimal128 Tal8Decimal128 atal8; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Tal8cfloat atal8; +typedef _Complex double Tal8cdouble atal8; +typedef _Complex long double Tal8cldouble atal8; +#endif +typedef bool Tal8bool atal8; +typedef enum E0 Tal8E0 atal8; +typedef enum E1 Tal8E1 atal8; +typedef enum E2 Tal8E2 atal8; +typedef enum E3 Tal8E3 atal8; +typedef enum E4 Tal8E4 atal8; +typedef enum E5 Tal8E5 atal8; +typedef enum E6 Tal8E6 atal8; +typedef enum E7 Tal8E7 atal8; +typedef enum E8 Tal8E8 atal8; +typedef enum E9 Tal8E9 atal8; +typedef void *Tal8ptr atal8; +typedef char *Tal8cptr atal8; +typedef int *Tal8iptr atal8; +typedef char Tal16char atal16; +typedef signed char Tal16schar atal16; +typedef unsigned char Tal16uchar atal16; +typedef short int Tal16short atal16; +typedef unsigned short int Tal16ushort atal16; +typedef int Tal16int atal16; +typedef unsigned int Tal16uint atal16; +typedef long int Tal16long atal16; +typedef unsigned long int Tal16ulong atal16; +typedef long long int Tal16llong atal16; +typedef unsigned long long int Tal16ullong atal16; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Tal16cchar atal16; +typedef _Complex signed char Tal16cschar atal16; +typedef _Complex unsigned char Tal16cuchar atal16; +typedef _Complex short int Tal16cshort atal16; +typedef _Complex unsigned short int Tal16cushort atal16; +typedef _Complex int Tal16cint atal16; +typedef _Complex unsigned int Tal16cuint atal16; +typedef _Complex long int Tal16clong atal16; +typedef _Complex unsigned long int Tal16culong atal16; +typedef _Complex long long int Tal16cllong atal16; +typedef _Complex unsigned long long int Tal16cullong atal16; +#endif +typedef float Tal16float atal16; +typedef double Tal16double atal16; +typedef long double Tal16ldouble atal16; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Tal16Decimal32 atal16; +typedef _Decimal64 Tal16Decimal64 atal16; +typedef _Decimal128 Tal16Decimal128 atal16; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Tal16cfloat atal16; +typedef _Complex double Tal16cdouble atal16; +typedef _Complex long double Tal16cldouble atal16; +#endif +typedef bool Tal16bool atal16; +typedef enum E0 Tal16E0 atal16; +typedef enum E1 Tal16E1 atal16; +typedef enum E2 Tal16E2 atal16; +typedef enum E3 Tal16E3 atal16; +typedef enum E4 Tal16E4 atal16; +typedef enum E5 Tal16E5 atal16; +typedef enum E6 Tal16E6 atal16; +typedef enum E7 Tal16E7 atal16; +typedef enum E8 Tal16E8 atal16; +typedef enum E9 Tal16E9 atal16; +typedef void *Tal16ptr atal16; +typedef char *Tal16cptr atal16; +typedef int *Tal16iptr atal16; +typedef char Talx1char atalx1; +typedef signed char Talx1schar atalx1; +typedef unsigned char Talx1uchar atalx1; +typedef short int Talx1short atalx1; +typedef unsigned short int Talx1ushort atalx1; +typedef int Talx1int atalx1; +typedef unsigned int Talx1uint atalx1; +typedef long int Talx1long atalx1; +typedef unsigned long int Talx1ulong atalx1; +typedef long long int Talx1llong atalx1; +typedef unsigned long long int Talx1ullong atalx1; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Talx1cchar atalx1; +typedef _Complex signed char Talx1cschar atalx1; +typedef _Complex unsigned char Talx1cuchar atalx1; +typedef _Complex short int Talx1cshort atalx1; +typedef _Complex unsigned short int Talx1cushort atalx1; +typedef _Complex int Talx1cint atalx1; +typedef _Complex unsigned int Talx1cuint atalx1; +typedef _Complex long int Talx1clong atalx1; +typedef _Complex unsigned long int Talx1culong atalx1; +typedef _Complex long long int Talx1cllong atalx1; +typedef _Complex unsigned long long int Talx1cullong atalx1; +#endif +typedef float Talx1float atalx1; +typedef double Talx1double atalx1; +typedef long double Talx1ldouble atalx1; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Talx1Decimal32 atalx1; +typedef _Decimal64 Talx1Decimal64 atalx1; +typedef _Decimal128 Talx1Decimal128 atalx1; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Talx1cfloat atalx1; +typedef _Complex double Talx1cdouble atalx1; +typedef _Complex long double Talx1cldouble atalx1; +#endif +typedef bool Talx1bool atalx1; +typedef enum E0 Talx1E0 atalx1; +typedef enum E1 Talx1E1 atalx1; +typedef enum E2 Talx1E2 atalx1; +typedef enum E3 Talx1E3 atalx1; +typedef enum E4 Talx1E4 atalx1; +typedef enum E5 Talx1E5 atalx1; +typedef enum E6 Talx1E6 atalx1; +typedef enum E7 Talx1E7 atalx1; +typedef enum E8 Talx1E8 atalx1; +typedef enum E9 Talx1E9 atalx1; +typedef void *Talx1ptr atalx1; +typedef char *Talx1cptr atalx1; +typedef int *Talx1iptr atalx1; +typedef short int Talx2short atalx2; +typedef unsigned short int Talx2ushort atalx2; +typedef int Talx2int atalx2; +typedef unsigned int Talx2uint atalx2; +typedef long int Talx2long atalx2; +typedef unsigned long int Talx2ulong atalx2; +typedef long long int Talx2llong atalx2; +typedef unsigned long long int Talx2ullong atalx2; +#ifndef SKIP_COMPLEX_INT +typedef _Complex char Talx2cchar atalx2; +typedef _Complex signed char Talx2cschar atalx2; +typedef _Complex unsigned char Talx2cuchar atalx2; +typedef _Complex short int Talx2cshort atalx2; +typedef _Complex unsigned short int Talx2cushort atalx2; +typedef _Complex int Talx2cint atalx2; +typedef _Complex unsigned int Talx2cuint atalx2; +typedef _Complex long int Talx2clong atalx2; +typedef _Complex unsigned long int Talx2culong atalx2; +typedef _Complex long long int Talx2cllong atalx2; +typedef _Complex unsigned long long int Talx2cullong atalx2; +#endif +typedef float Talx2float atalx2; +typedef double Talx2double atalx2; +typedef long double Talx2ldouble atalx2; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Talx2Decimal32 atalx2; +typedef _Decimal64 Talx2Decimal64 atalx2; +typedef _Decimal128 Talx2Decimal128 atalx2; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Talx2cfloat atalx2; +typedef _Complex double Talx2cdouble atalx2; +typedef _Complex long double Talx2cldouble atalx2; +#endif +typedef enum E0 Talx2E0 atalx2; +typedef enum E1 Talx2E1 atalx2; +typedef enum E2 Talx2E2 atalx2; +typedef enum E3 Talx2E3 atalx2; +typedef enum E4 Talx2E4 atalx2; +typedef enum E5 Talx2E5 atalx2; +typedef enum E6 Talx2E6 atalx2; +typedef enum E7 Talx2E7 atalx2; +typedef enum E8 Talx2E8 atalx2; +typedef enum E9 Talx2E9 atalx2; +typedef void *Talx2ptr atalx2; +typedef char *Talx2cptr atalx2; +typedef int *Talx2iptr atalx2; +typedef int Talx4int atalx4; +typedef unsigned int Talx4uint atalx4; +typedef long int Talx4long atalx4; +typedef unsigned long int Talx4ulong atalx4; +typedef long long int Talx4llong atalx4; +typedef unsigned long long int Talx4ullong atalx4; +#ifndef SKIP_COMPLEX_INT +typedef _Complex short int Talx4cshort atalx4; +typedef _Complex unsigned short int Talx4cushort atalx4; +typedef _Complex int Talx4cint atalx4; +typedef _Complex unsigned int Talx4cuint atalx4; +typedef _Complex long int Talx4clong atalx4; +typedef _Complex unsigned long int Talx4culong atalx4; +typedef _Complex long long int Talx4cllong atalx4; +typedef _Complex unsigned long long int Talx4cullong atalx4; +#endif +typedef float Talx4float atalx4; +typedef double Talx4double atalx4; +typedef long double Talx4ldouble atalx4; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal32 Talx4Decimal32 atalx4; +typedef _Decimal64 Talx4Decimal64 atalx4; +typedef _Decimal128 Talx4Decimal128 atalx4; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Talx4cfloat atalx4; +typedef _Complex double Talx4cdouble atalx4; +typedef _Complex long double Talx4cldouble atalx4; +#endif +typedef enum E0 Talx4E0 atalx4; +typedef enum E1 Talx4E1 atalx4; +typedef enum E2 Talx4E2 atalx4; +typedef enum E3 Talx4E3 atalx4; +typedef enum E4 Talx4E4 atalx4; +typedef enum E5 Talx4E5 atalx4; +typedef enum E6 Talx4E6 atalx4; +typedef enum E7 Talx4E7 atalx4; +typedef enum E8 Talx4E8 atalx4; +typedef enum E9 Talx4E9 atalx4; +typedef void *Talx4ptr atalx4; +typedef char *Talx4cptr atalx4; +typedef int *Talx4iptr atalx4; +typedef long int Taly8long ataly8; +typedef unsigned long int Taly8ulong ataly8; +typedef long long int Talx8llong atalx8; +typedef unsigned long long int Talx8ullong atalx8; +#ifndef SKIP_COMPLEX_INT +typedef _Complex int Talx8cint atalx8; +typedef _Complex unsigned int Talx8cuint atalx8; +typedef _Complex long int Talx8clong atalx8; +typedef _Complex unsigned long int Talx8culong atalx8; +typedef _Complex long long int Talx8cllong atalx8; +typedef _Complex unsigned long long int Talx8cullong atalx8; +#endif +typedef double Talx8double atalx8; +typedef long double Talx8ldouble atalx8; +#ifndef SKIP_DECIMAL_FLOAT +typedef _Decimal64 Talx8Decimal64 atalx8; +typedef _Decimal128 Talx8Decimal128 atalx8; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex float Talx8cfloat atalx8; +typedef _Complex double Talx8cdouble atalx8; +typedef _Complex long double Talx8cldouble atalx8; +#endif +typedef void *Taly8ptr ataly8; +typedef char *Taly8cptr ataly8; +typedef int *Taly8iptr ataly8; +#ifndef SKIP_COMPLEX_INT +typedef _Complex long int Taly16clong ataly16; +typedef _Complex unsigned long int Taly16culong ataly16; +typedef _Complex long long int Talx16cllong atalx16; +typedef _Complex unsigned long long int Talx16cullong atalx16; +#endif +#ifndef SKIP_COMPLEX +typedef _Complex double Talx16cdouble atalx16; +typedef _Complex long double Talx16cldouble atalx16; +#endif +typedef int (*Tfnptr) (void); + +/* Bitfield macros. In C, it is invalid to use numbers larger + than type's bitsize, but we don't know the size when generating + the testcases. */ +#define BN8(n) ((((n) - 1) & 7) + 1) +#define BN16(n) ((((n) - 1) & 15) + 1) +#define BN32(n) ((((n) - 1) & 31) + 1) +#define BN64(n) ((((n) - 1) & 63) + 1) +#define BCN(n) BN8 (n) +#if USHRT_MAX == 255 +# define BSN(n) BN8 (n) +#elif USHRT_MAX == 65535 +# define BSN(n) BN16 (n) +#elif USHRT_MAX == 4294967295U +# define BSN(n) BN32 (n) +#elif USHRT_MAX == 18446744073709551615ULL +# define BSN(n) BN64 (n) +#endif +#if UINT_MAX == 255 +# define BIN(n) BN8 (n) +#elif UINT_MAX == 65535 +# define BIN(n) BN16 (n) +#elif UINT_MAX == 4294967295U +# define BIN(n) BN32 (n) +#elif UINT_MAX == 18446744073709551615ULL +# define BIN(n) BN64 (n) +#endif +#if ULONG_MAX == 255 +# define BLN(n) BN8 (n) +#elif ULONG_MAX == 65535 +# define BLN(n) BN16 (n) +#elif ULONG_MAX == 4294967295U +# define BLN(n) BN32 (n) +#elif ULONG_MAX == 18446744073709551615ULL +# define BLN(n) BN64 (n) +#endif +#if ULONG_MAX == 255 +# define BLN(n) BN8 (n) +#elif ULONG_MAX == 65535 +# define BLN(n) BN16 (n) +#elif ULONG_MAX == 4294967295U +# define BLN(n) BN32 (n) +#elif ULONG_MAX == 18446744073709551615ULL +# define BLN(n) BN64 (n) +#endif +#if !defined ULLONG_MAX && defined __LONG_LONG_MAX__ +# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL) +#endif +#if ULLONG_MAX == 255 +# define BQN(n) BN8 (n) +#elif ULLONG_MAX == 65535 +# define BQN(n) BN16 (n) +#elif ULLONG_MAX == 4294967295U +# define BQN(n) BN32 (n) +#elif ULLONG_MAX == 18446744073709551615ULL +# define BQN(n) BN64 (n) +#endif + +#define T(n, fields, ops) TX(n, struct, , fields, ({ ops });) +#define U(n, fields, ops) TX(n, union, , fields, ({ ops });) +#ifdef SKIP_COMPLEX_INT +#define TXCI(n, type, attrs, fields, ops) +#define TCI(n, fields, ops) +#define UCI(n, fields, ops) +#else +#define TXCI(n, type, attrs, fields, ops) TX(n, type, attrs, fields, ({ ops });) +#define TCI(n, fields, ops) TX(n, struct, , fields, ({ ops });) +#define UCI(n, fields, ops) TX(n, union, , fields, ({ ops });) +#endif diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c b/gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c new file mode 100644 index 000000000..4f5315df2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_generate.c @@ -0,0 +1,2086 @@ +/* Structure layout test generator. + Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. + Contributed by Jakub Jelinek <jakub@redhat.com>. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + + +/* Compile with gcc -o struct-layout-1_generate{,.c} generate_random{,_r}.c */ + +/* N.B. -- This program cannot use libiberty as that will not work + when testing an installed compiler. */ +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stddef.h> +/* We use our own pseudo-random number generator, so that it gives the same + values on all hosts. */ +#include "generate-random.h" + +#if LLONG_MAX != 9223372036854775807LL && __LONG_LONG_MAX__ != 9223372036854775807LL +# error Need 64-bit long long +#endif + +#if defined __MSVCRT__ +#define COMPAT_PRLL "I64" +#else +#define COMPAT_PRLL "ll" +#endif + +const char *dg_options[] = { +"/* { dg-options \"%s-I%s\" } */\n", +"/* { dg-options \"%s-I%s -Wno-abi\" } */\n", +"/* { dg-options \"%s-I%s -mno-mmx -Wno-abi\" { target i?86-*-* x86_64-*-* } } */\n", +"/* { dg-options \"%s-I%s -fno-common\" { target hppa*-*-hpux* powerpc*-*-darwin* } } */\n", +"/* { dg-options \"%s-I%s -mno-mmx -fno-common -Wno-abi\" { target i?86-*-darwin* x86_64-*-darwin* } } */\n", +"/* { dg-options \"%s-I%s -mno-base-addresses\" { target mmix-*-* } } */\n", +"/* { dg-options \"%s-I%s -mlongcalls -mtext-section-literals\" { target xtensa*-*-* } } */\n" +#define NDG_OPTIONS (sizeof (dg_options) / sizeof (dg_options[0])) +}; + +typedef unsigned int hashval_t; + +enum TYPE +{ + TYPE_INT, + TYPE_UINT, + TYPE_CINT, + TYPE_CUINT, + TYPE_FLOAT, + TYPE_CFLOAT, + TYPE_DEC_FLOAT, + TYPE_SENUM, + TYPE_UENUM, + TYPE_PTR, + TYPE_FNPTR, + TYPE_OTHER +}; + +struct types +{ + const char *name; + enum TYPE type; + unsigned long long int maxval; + char bitfld; +}; + +struct types base_types[] = { +/* As we don't know whether char will be signed or not, just limit ourselves + to unsigned values less than maximum signed char value. */ +{ "char", TYPE_UINT, 127, 'C' }, +{ "signed char", TYPE_INT, 127, 'C' }, +{ "unsigned char", TYPE_UINT, 255, 'C' }, +{ "short int", TYPE_INT, 32767, 'S' }, +{ "unsigned short int", TYPE_UINT, 65535, 'S' }, +{ "int", TYPE_INT, 2147483647, 'I' }, +{ "unsigned int", TYPE_UINT, 4294967295U, 'I' }, +{ "long int", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "unsigned long int", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "long long int", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "unsigned long long int", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "bool", TYPE_UINT, 1, 'B' }, +{ "void *", TYPE_PTR, 0, 0 }, +{ "char *", TYPE_PTR, 0, 0 }, +{ "int *", TYPE_PTR, 0, 0 }, +{ "float", TYPE_FLOAT, 0, 0 }, +{ "double", TYPE_FLOAT, 0, 0 }, +{ "long double", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "_Decimal32", TYPE_DEC_FLOAT, 0, 0 }, +{ "_Decimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "_Decimal128", TYPE_DEC_FLOAT, 0, 0 }, +#define NTYPES1 21 +#else +#define NTYPES1 18 +#endif +{ "Tchar", TYPE_UINT, 127, 'C' }, +{ "Tschar", TYPE_INT, 127, 'C' }, +{ "Tuchar", TYPE_UINT, 255, 'C' }, +{ "Tshort", TYPE_INT, 32767, 'S' }, +{ "Tushort", TYPE_UINT, 65535, 'S' }, +{ "Tint", TYPE_INT, 2147483647, 'I' }, +{ "Tuint", TYPE_UINT, 4294967295U, 'I' }, +{ "Tlong", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Tulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Tllong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Tullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Tbool", TYPE_UINT, 1, 'B' }, +{ "size_t", TYPE_UINT, 18446744073709551615ULL, 0 }, +{ "Tptr", TYPE_PTR, 0, 0 }, +{ "Tcptr", TYPE_PTR, 0, 0 }, +{ "Tiptr", TYPE_PTR, 0, 0 }, +{ "Tfnptr", TYPE_FNPTR, 0, 0 }, +{ "Tfloat", TYPE_FLOAT, 0, 0 }, +{ "Tdouble", TYPE_FLOAT, 0, 0 }, +{ "Tldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "TDecimal32", TYPE_DEC_FLOAT, 0, 0 }, +{ "TDecimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "TDecimal128", TYPE_DEC_FLOAT, 0, 0 }, +#endif +{ "enum E0", TYPE_UENUM, 0, ' ' }, +{ "enum E1", TYPE_UENUM, 1, ' ' }, +{ "enum E2", TYPE_SENUM, 3, ' ' }, +{ "enum E3", TYPE_SENUM, 127, ' ' }, +{ "enum E4", TYPE_UENUM, 255, ' ' }, +{ "enum E5", TYPE_SENUM, 32767, ' ' }, +{ "enum E6", TYPE_UENUM, 65535, ' ' }, +{ "enum E7", TYPE_SENUM, 2147483647, ' ' }, +{ "enum E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "enum E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "TE0", TYPE_UENUM, 0, ' ' }, +{ "TE1", TYPE_UENUM, 1, ' ' }, +{ "TE2", TYPE_SENUM, 3, ' ' }, +{ "TE3", TYPE_SENUM, 127, ' ' }, +{ "TE4", TYPE_UENUM, 255, ' ' }, +{ "TE5", TYPE_SENUM, 32767, ' ' }, +{ "TE6", TYPE_UENUM, 65535, ' ' }, +{ "TE7", TYPE_SENUM, 2147483647, ' ' }, +{ "TE8", TYPE_UENUM, 4294967295U, ' ' }, +{ "TE9", TYPE_SENUM, 1099511627775LL, ' ' }, +/* vector-defs.h typedefs */ +{ "qi", TYPE_INT, 127, 0 }, +{ "hi", TYPE_INT, 32767, 0 }, +{ "si", TYPE_INT, 2147483647, 0 }, +{ "di", TYPE_INT, 9223372036854775807LL, 0 }, +{ "sf", TYPE_FLOAT, 0, 0 }, +{ "df", TYPE_FLOAT, 0, 0 } +#define NTYPES2 (sizeof (base_types) / sizeof (base_types[0])) +}; +struct types complex_types[] = { +{ "_Complex char", TYPE_CUINT, 127, 0 }, +{ "_Complex signed char", TYPE_CINT, 127, 0 }, +{ "_Complex unsigned char", TYPE_CUINT, 255, 0 }, +{ "_Complex short int", TYPE_CINT, 32767, 0 }, +{ "_Complex unsigned short int", TYPE_CUINT, 65535, 0 }, +{ "_Complex int", TYPE_CINT, 2147483647, 0 }, +{ "_Complex unsigned int", TYPE_CUINT, 4294967295U, 0 }, +{ "_Complex long int", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "_Complex unsigned long int", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "_Complex long long int", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "_Complex unsigned long long int", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "_Complex float", TYPE_CFLOAT, 0, 0 }, +{ "_Complex double", TYPE_CFLOAT, 0, 0 }, +{ "_Complex long double", TYPE_CFLOAT, 0, 0 }, +{ "Tcchar", TYPE_CUINT, 127, 0 }, +{ "Tcschar", TYPE_CINT, 127, 0 }, +{ "Tcuchar", TYPE_CUINT, 255, 0 }, +{ "Tcshort", TYPE_CINT, 32767, 0 }, +{ "Tcushort", TYPE_CUINT, 65535, 0 }, +{ "Tcint", TYPE_CINT, 2147483647, 0 }, +{ "Tcuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Tclong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tculong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tcllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tcullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tcfloat", TYPE_CFLOAT, 0, 0 }, +{ "Tcdouble", TYPE_CFLOAT, 0, 0 }, +{ "Tcldouble", TYPE_CFLOAT, 0, 0 } +#define NCTYPES2 (sizeof (complex_types) / sizeof (complex_types[0])) +}; +struct types vector_types[] = { +/* vector-defs.h typedefs */ +{ "v8qi", TYPE_OTHER, 0, 0 }, +{ "v16qi", TYPE_OTHER, 0, 0 }, +{ "v32qi", TYPE_OTHER, 0, 0 }, +{ "v2hi", TYPE_OTHER, 0, 0 }, +{ "v4hi", TYPE_OTHER, 0, 0 }, +{ "v8hi", TYPE_OTHER, 0, 0 }, +{ "v16hi", TYPE_OTHER, 0, 0 }, +{ "v2si", TYPE_OTHER, 0, 0 }, +{ "v4si", TYPE_OTHER, 0, 0 }, +{ "v8si", TYPE_OTHER, 0, 0 }, +{ "v1di", TYPE_OTHER, 0, 0 }, +{ "v2di", TYPE_OTHER, 0, 0 }, +{ "v4di", TYPE_OTHER, 0, 0 }, +{ "v2sf", TYPE_OTHER, 0, 0 }, +{ "v4sf", TYPE_OTHER, 0, 0 }, +{ "v8sf", TYPE_OTHER, 0, 0 }, +{ "v16sf", TYPE_OTHER, 0, 0 }, +{ "v2df", TYPE_OTHER, 0, 0 }, +{ "v4df", TYPE_OTHER, 0, 0 }, +{ "u8qi", TYPE_OTHER, 0, 0 }, +{ "u16qi", TYPE_OTHER, 0, 0 }, +{ "u32qi", TYPE_OTHER, 0, 0 }, +{ "u2hi", TYPE_OTHER, 0, 0 }, +{ "u4hi", TYPE_OTHER, 0, 0 }, +{ "u8hi", TYPE_OTHER, 0, 0 }, +{ "u16hi", TYPE_OTHER, 0, 0 }, +{ "u2si", TYPE_OTHER, 0, 0 }, +{ "u4si", TYPE_OTHER, 0, 0 }, +{ "u8si", TYPE_OTHER, 0, 0 }, +{ "u1di", TYPE_OTHER, 0, 0 }, +{ "u2di", TYPE_OTHER, 0, 0 }, +{ "u4di", TYPE_OTHER, 0, 0 }, +{ "u2sf", TYPE_OTHER, 0, 0 }, +{ "u4sf", TYPE_OTHER, 0, 0 }, +{ "u8sf", TYPE_OTHER, 0, 0 }, +{ "u16sf", TYPE_OTHER, 0, 0 }, +{ "u2df", TYPE_OTHER, 0, 0 }, +{ "u4df", TYPE_OTHER, 0, 0 }, +{ "__m64", TYPE_OTHER, 0, 0 }, +{ "__m128", TYPE_OTHER, 0, 0 } +#define NVTYPES2 (sizeof (vector_types) / sizeof (vector_types[0])) +}; +struct types attrib_types[] = { +{ "Talchar", TYPE_UINT, 127, 'C' }, +{ "Talschar", TYPE_INT, 127, 'C' }, +{ "Taluchar", TYPE_UINT, 255, 'C' }, +{ "Talshort", TYPE_INT, 32767, 'S' }, +{ "Talushort", TYPE_UINT, 65535, 'S' }, +{ "Talint", TYPE_INT, 2147483647, 'I' }, +{ "Taluint", TYPE_UINT, 4294967295U, 'I' }, +{ "Tallong", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Talulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talllong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Talbool", TYPE_UINT, 1, 'B' }, +{ "Talptr", TYPE_PTR, 0, 0 }, +{ "Talcptr", TYPE_PTR, 0, 0 }, +{ "Taliptr", TYPE_PTR, 0, 0 }, +{ "Talfloat", TYPE_FLOAT, 0, 0 }, +{ "Taldouble", TYPE_FLOAT, 0, 0 }, +{ "Talldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "TalDecimal32", TYPE_DEC_FLOAT, 0, 0 }, +{ "TalDecimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "TalDecimal128", TYPE_DEC_FLOAT, 0, 0 }, +#endif +{ "TalE0", TYPE_UENUM, 0, ' ' }, +{ "TalE1", TYPE_UENUM, 1, ' ' }, +{ "TalE2", TYPE_SENUM, 3, ' ' }, +{ "TalE3", TYPE_SENUM, 127, ' ' }, +{ "TalE4", TYPE_UENUM, 255, ' ' }, +{ "TalE5", TYPE_SENUM, 32767, ' ' }, +{ "TalE6", TYPE_UENUM, 65535, ' ' }, +{ "TalE7", TYPE_SENUM, 2147483647, ' ' }, +{ "TalE8", TYPE_UENUM, 4294967295U, ' ' }, +{ "TalE9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Tal1char", TYPE_UINT, 127, 'C' }, +{ "Tal1schar", TYPE_INT, 127, 'C' }, +{ "Tal1uchar", TYPE_UINT, 255, 'C' }, +{ "Tal1short", TYPE_INT, 32767, 'S' }, +{ "Tal1ushort", TYPE_UINT, 65535, 'S' }, +{ "Tal1int", TYPE_INT, 2147483647, 'I' }, +{ "Tal1uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Tal1long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Tal1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Tal1llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Tal1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Tal1bool", TYPE_UINT, 1, 'B' }, +{ "Tal1ptr", TYPE_PTR, 0, 0 }, +{ "Tal1cptr", TYPE_PTR, 0, 0 }, +{ "Tal1iptr", TYPE_PTR, 0, 0 }, +{ "Tal1float", TYPE_FLOAT, 0, 0 }, +{ "Tal1double", TYPE_FLOAT, 0, 0 }, +{ "Tal1ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Tal1Decimal32", TYPE_DEC_FLOAT, 0, 0}, +{ "Tal1Decimal64", TYPE_DEC_FLOAT, 0, 0}, +{ "Tal1Decimal128", TYPE_DEC_FLOAT, 0, 0}, +#endif +{ "Tal1E0", TYPE_UENUM, 0, ' ' }, +{ "Tal1E1", TYPE_UENUM, 1, ' ' }, +{ "Tal1E2", TYPE_SENUM, 3, ' ' }, +{ "Tal1E3", TYPE_SENUM, 127, ' ' }, +{ "Tal1E4", TYPE_UENUM, 255, ' ' }, +{ "Tal1E5", TYPE_SENUM, 32767, ' ' }, +{ "Tal1E6", TYPE_UENUM, 65535, ' ' }, +{ "Tal1E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Tal1E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Tal1E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Tal2char", TYPE_UINT, 127, 'C' }, +{ "Tal2schar", TYPE_INT, 127, 'C' }, +{ "Tal2uchar", TYPE_UINT, 255, 'C' }, +{ "Tal2short", TYPE_INT, 32767, 'S' }, +{ "Tal2ushort", TYPE_UINT, 65535, 'S' }, +{ "Tal2int", TYPE_INT, 2147483647, 'I' }, +{ "Tal2uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Tal2long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Tal2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Tal2llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Tal2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Tal2bool", TYPE_UINT, 1, 'B' }, +{ "Tal2ptr", TYPE_PTR, 0, 0 }, +{ "Tal2cptr", TYPE_PTR, 0, 0 }, +{ "Tal2iptr", TYPE_PTR, 0, 0 }, +{ "Tal2float", TYPE_FLOAT, 0, 0 }, +{ "Tal2double", TYPE_FLOAT, 0, 0 }, +{ "Tal2ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Tal2Decimal32", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal2Decimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal2Decimal128", TYPE_DEC_FLOAT, 0, 0 }, +#endif +{ "Tal2E0", TYPE_UENUM, 0, ' ' }, +{ "Tal2E1", TYPE_UENUM, 1, ' ' }, +{ "Tal2E2", TYPE_SENUM, 3, ' ' }, +{ "Tal2E3", TYPE_SENUM, 127, ' ' }, +{ "Tal2E4", TYPE_UENUM, 255, ' ' }, +{ "Tal2E5", TYPE_SENUM, 32767, ' ' }, +{ "Tal2E6", TYPE_UENUM, 65535, ' ' }, +{ "Tal2E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Tal2E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Tal2E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Tal4char", TYPE_UINT, 127, 'C' }, +{ "Tal4schar", TYPE_INT, 127, 'C' }, +{ "Tal4uchar", TYPE_UINT, 255, 'C' }, +{ "Tal4short", TYPE_INT, 32767, 'S' }, +{ "Tal4ushort", TYPE_UINT, 65535, 'S' }, +{ "Tal4int", TYPE_INT, 2147483647, 'I' }, +{ "Tal4uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Tal4long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Tal4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Tal4llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Tal4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Tal4bool", TYPE_UINT, 1, 'B' }, +{ "Tal4ptr", TYPE_PTR, 0, 0 }, +{ "Tal4cptr", TYPE_PTR, 0, 0 }, +{ "Tal4iptr", TYPE_PTR, 0, 0 }, +{ "Tal4float", TYPE_FLOAT, 0, 0 }, +{ "Tal4double", TYPE_FLOAT, 0, 0 }, +{ "Tal4ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Tal4Decimal32", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal4Decimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal4Decimal128", TYPE_DEC_FLOAT, 0, 0 }, +#endif +{ "Tal4E0", TYPE_UENUM, 0, ' ' }, +{ "Tal4E1", TYPE_UENUM, 1, ' ' }, +{ "Tal4E2", TYPE_SENUM, 3, ' ' }, +{ "Tal4E3", TYPE_SENUM, 127, ' ' }, +{ "Tal4E4", TYPE_UENUM, 255, ' ' }, +{ "Tal4E5", TYPE_SENUM, 32767, ' ' }, +{ "Tal4E6", TYPE_UENUM, 65535, ' ' }, +{ "Tal4E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Tal4E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Tal4E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Tal8char", TYPE_UINT, 127, 'C' }, +{ "Tal8schar", TYPE_INT, 127, 'C' }, +{ "Tal8uchar", TYPE_UINT, 255, 'C' }, +{ "Tal8short", TYPE_INT, 32767, 'S' }, +{ "Tal8ushort", TYPE_UINT, 65535, 'S' }, +{ "Tal8int", TYPE_INT, 2147483647, 'I' }, +{ "Tal8uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Tal8long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Tal8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Tal8llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Tal8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Tal8bool", TYPE_UINT, 1, 'B' }, +{ "Tal8ptr", TYPE_PTR, 0, 0 }, +{ "Tal8cptr", TYPE_PTR, 0, 0 }, +{ "Tal8iptr", TYPE_PTR, 0, 0 }, +{ "Tal8float", TYPE_FLOAT, 0, 0 }, +{ "Tal8double", TYPE_FLOAT, 0, 0 }, +{ "Tal8ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Tal8Decimal32", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal8Decimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal8Decimal128", TYPE_DEC_FLOAT, 0, 0 }, +#endif +{ "Tal8E0", TYPE_UENUM, 0, ' ' }, +{ "Tal8E1", TYPE_UENUM, 1, ' ' }, +{ "Tal8E2", TYPE_SENUM, 3, ' ' }, +{ "Tal8E3", TYPE_SENUM, 127, ' ' }, +{ "Tal8E4", TYPE_UENUM, 255, ' ' }, +{ "Tal8E5", TYPE_SENUM, 32767, ' ' }, +{ "Tal8E6", TYPE_UENUM, 65535, ' ' }, +{ "Tal8E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Tal8E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Tal8E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Tal16char", TYPE_UINT, 127, 'C' }, +{ "Tal16schar", TYPE_INT, 127, 'C' }, +{ "Tal16uchar", TYPE_UINT, 255, 'C' }, +{ "Tal16short", TYPE_INT, 32767, 'S' }, +{ "Tal16ushort", TYPE_UINT, 65535, 'S' }, +{ "Tal16int", TYPE_INT, 2147483647, 'I' }, +{ "Tal16uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Tal16long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Tal16ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Tal16llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Tal16ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Tal16bool", TYPE_UINT, 1, 'B' }, +{ "Tal16ptr", TYPE_PTR, 0, 0 }, +{ "Tal16cptr", TYPE_PTR, 0, 0 }, +{ "Tal16iptr", TYPE_PTR, 0, 0 }, +{ "Tal16float", TYPE_FLOAT, 0, 0 }, +{ "Tal16double", TYPE_FLOAT, 0, 0 }, +{ "Tal16ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Tal16Decimal32", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal16Decimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "Tal16Decimal128", TYPE_DEC_FLOAT, 0, 0 }, +#endif +{ "Tal16E0", TYPE_UENUM, 0, ' ' }, +{ "Tal16E1", TYPE_UENUM, 1, ' ' }, +{ "Tal16E2", TYPE_SENUM, 3, ' ' }, +{ "Tal16E3", TYPE_SENUM, 127, ' ' }, +{ "Tal16E4", TYPE_UENUM, 255, ' ' }, +{ "Tal16E5", TYPE_SENUM, 32767, ' ' }, +{ "Tal16E6", TYPE_UENUM, 65535, ' ' }, +{ "Tal16E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Tal16E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Tal16E9", TYPE_SENUM, 1099511627775LL, ' ' } +#define NATYPES2 (sizeof (attrib_types) / sizeof (attrib_types[0])) +}; +struct types complex_attrib_types[] = { +{ "Talcchar", TYPE_CUINT, 127, 0 }, +{ "Talcschar", TYPE_CINT, 127, 0 }, +{ "Talcuchar", TYPE_CUINT, 255, 0 }, +{ "Talcshort", TYPE_CINT, 32767, 0 }, +{ "Talcushort", TYPE_CUINT, 65535, 0 }, +{ "Talcint", TYPE_CINT, 2147483647, 0 }, +{ "Talcuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Talclong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talculong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talcllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talcullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talcfloat", TYPE_CFLOAT, 0, 0 }, +{ "Talcdouble", TYPE_CFLOAT, 0, 0 }, +{ "Talcldouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal1cchar", TYPE_CUINT, 127, 0 }, +{ "Tal1cschar", TYPE_CINT, 127, 0 }, +{ "Tal1cuchar", TYPE_CUINT, 255, 0 }, +{ "Tal1cshort", TYPE_CINT, 32767, 0 }, +{ "Tal1cushort", TYPE_CUINT, 65535, 0 }, +{ "Tal1cint", TYPE_CINT, 2147483647, 0 }, +{ "Tal1cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Tal1clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal1culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal1cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal1cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal1cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Tal1cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal1cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal2cchar", TYPE_CUINT, 127, 0 }, +{ "Tal2cschar", TYPE_CINT, 127, 0 }, +{ "Tal2cuchar", TYPE_CUINT, 255, 0 }, +{ "Tal2cshort", TYPE_CINT, 32767, 0 }, +{ "Tal2cushort", TYPE_CUINT, 65535, 0 }, +{ "Tal2cint", TYPE_CINT, 2147483647, 0 }, +{ "Tal2cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Tal2clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal2culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal2cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal2cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal2cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Tal2cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal2cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal4cchar", TYPE_CUINT, 127, 0 }, +{ "Tal4cschar", TYPE_CINT, 127, 0 }, +{ "Tal4cuchar", TYPE_CUINT, 255, 0 }, +{ "Tal4cshort", TYPE_CINT, 32767, 0 }, +{ "Tal4cushort", TYPE_CUINT, 65535, 0 }, +{ "Tal4cint", TYPE_CINT, 2147483647, 0 }, +{ "Tal4cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Tal4clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal4culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal4cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal4cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal4cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Tal4cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal4cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal8cchar", TYPE_CUINT, 127, 0 }, +{ "Tal8cschar", TYPE_CINT, 127, 0 }, +{ "Tal8cuchar", TYPE_CUINT, 255, 0 }, +{ "Tal8cshort", TYPE_CINT, 32767, 0 }, +{ "Tal8cushort", TYPE_CUINT, 65535, 0 }, +{ "Tal8cint", TYPE_CINT, 2147483647, 0 }, +{ "Tal8cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Tal8clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal8culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal8cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal8cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal8cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Tal8cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal8cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal16cchar", TYPE_CUINT, 127, 0 }, +{ "Tal16cschar", TYPE_CINT, 127, 0 }, +{ "Tal16cuchar", TYPE_CUINT, 255, 0 }, +{ "Tal16cshort", TYPE_CINT, 32767, 0 }, +{ "Tal16cushort", TYPE_CUINT, 65535, 0 }, +{ "Tal16cint", TYPE_CINT, 2147483647, 0 }, +{ "Tal16cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Tal16clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal16culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal16cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Tal16cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Tal16cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Tal16cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Tal16cldouble", TYPE_CFLOAT, 0, 0 } +#define NCATYPES2 (sizeof (complex_attrib_types) / sizeof (complex_attrib_types[0])) +}; +struct types attrib_array_types[] = { +{ "Talx1char", TYPE_UINT, 127, 'C' }, +{ "Talx1schar", TYPE_INT, 127, 'C' }, +{ "Talx1uchar", TYPE_UINT, 255, 'C' }, +{ "Talx1short", TYPE_INT, 32767, 'S' }, +{ "Talx1ushort", TYPE_UINT, 65535, 'S' }, +{ "Talx1int", TYPE_INT, 2147483647, 'I' }, +{ "Talx1uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Talx1long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Talx1ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx1llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx1ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Talx1bool", TYPE_UINT, 1, 'B' }, +{ "Talx1ptr", TYPE_PTR, 0, 0 }, +{ "Talx1cptr", TYPE_PTR, 0, 0 }, +{ "Talx1iptr", TYPE_PTR, 0, 0 }, +{ "Talx1float", TYPE_FLOAT, 0, 0 }, +{ "Talx1double", TYPE_FLOAT, 0, 0 }, +{ "Talx1ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Talx1Decimal32", TYPE_DEC_FLOAT, 0 ,0 }, +{ "Talx1Decimal64", TYPE_DEC_FLOAT, 0 ,0 }, +{ "Talx1Decimal128", TYPE_DEC_FLOAT, 0 ,0 }, +#endif +{ "Talx1E0", TYPE_UENUM, 0, ' ' }, +{ "Talx1E1", TYPE_UENUM, 1, ' ' }, +{ "Talx1E2", TYPE_SENUM, 3, ' ' }, +{ "Talx1E3", TYPE_SENUM, 127, ' ' }, +{ "Talx1E4", TYPE_UENUM, 255, ' ' }, +{ "Talx1E5", TYPE_SENUM, 32767, ' ' }, +{ "Talx1E6", TYPE_UENUM, 65535, ' ' }, +{ "Talx1E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Talx1E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Talx1E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Talx2short", TYPE_INT, 32767, 'S' }, +{ "Talx2ushort", TYPE_UINT, 65535, 'S' }, +{ "Talx2int", TYPE_INT, 2147483647, 'I' }, +{ "Talx2uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Talx2long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Talx2ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx2llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx2ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Talx2ptr", TYPE_PTR, 0, 0 }, +{ "Talx2cptr", TYPE_PTR, 0, 0 }, +{ "Talx2iptr", TYPE_PTR, 0, 0 }, +{ "Talx2float", TYPE_FLOAT, 0, 0 }, +{ "Talx2double", TYPE_FLOAT, 0, 0 }, +{ "Talx2ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Talx2Decimal32", TYPE_DEC_FLOAT, 0 , 0 }, +{ "Talx2Decimal64", TYPE_DEC_FLOAT, 0 , 0 }, +{ "Talx2Decimal128", TYPE_DEC_FLOAT, 0 , 0 }, +#endif +{ "Talx2E0", TYPE_UENUM, 0, ' ' }, +{ "Talx2E1", TYPE_UENUM, 1, ' ' }, +{ "Talx2E2", TYPE_SENUM, 3, ' ' }, +{ "Talx2E3", TYPE_SENUM, 127, ' ' }, +{ "Talx2E4", TYPE_UENUM, 255, ' ' }, +{ "Talx2E5", TYPE_SENUM, 32767, ' ' }, +{ "Talx2E6", TYPE_UENUM, 65535, ' ' }, +{ "Talx2E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Talx2E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Talx2E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Talx4int", TYPE_INT, 2147483647, 'I' }, +{ "Talx4uint", TYPE_UINT, 4294967295U, 'I' }, +{ "Talx4long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Talx4ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx4llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx4ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Talx4ptr", TYPE_PTR, 0, 0 }, +{ "Talx4cptr", TYPE_PTR, 0, 0 }, +{ "Talx4iptr", TYPE_PTR, 0, 0 }, +{ "Talx4float", TYPE_FLOAT, 0, 0 }, +{ "Talx4double", TYPE_FLOAT, 0, 0 }, +{ "Talx4ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Talx4Decimal32", TYPE_DEC_FLOAT, 0 , 0 }, +{ "Talx4Decimal64", TYPE_DEC_FLOAT, 0 , 0 }, +{ "Talx4Decimal128", TYPE_DEC_FLOAT, 0 , 0 }, +#endif +{ "Talx4E0", TYPE_UENUM, 0, ' ' }, +{ "Talx4E1", TYPE_UENUM, 1, ' ' }, +{ "Talx4E2", TYPE_SENUM, 3, ' ' }, +{ "Talx4E3", TYPE_SENUM, 127, ' ' }, +{ "Talx4E4", TYPE_UENUM, 255, ' ' }, +{ "Talx4E5", TYPE_SENUM, 32767, ' ' }, +{ "Talx4E6", TYPE_UENUM, 65535, ' ' }, +{ "Talx4E7", TYPE_SENUM, 2147483647, ' ' }, +{ "Talx4E8", TYPE_UENUM, 4294967295U, ' ' }, +{ "Talx4E9", TYPE_SENUM, 1099511627775LL, ' ' }, +{ "Taly8long", TYPE_INT, 9223372036854775807LL, 'L' }, +{ "Taly8ulong", TYPE_UINT, 18446744073709551615ULL, 'L' }, +{ "Talx8llong", TYPE_INT, 9223372036854775807LL, 'Q' }, +{ "Talx8ullong", TYPE_UINT, 18446744073709551615ULL, 'Q' }, +{ "Taly8ptr", TYPE_PTR, 0, 0 }, +{ "Taly8cptr", TYPE_PTR, 0, 0 }, +{ "Taly8iptr", TYPE_PTR, 0, 0 }, +{ "Talx8double", TYPE_FLOAT, 0, 0 }, +{ "Talx8ldouble", TYPE_FLOAT, 0, 0 }, +#ifndef SKIP_DECIMAL_FLOAT +{ "Talx8Decimal64", TYPE_DEC_FLOAT, 0, 0 }, +{ "Talx8Decimal128", TYPE_DEC_FLOAT, 0, 0 } +#endif +#define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0])) +}; +struct types complex_attrib_array_types[] = { +{ "Talx1cchar", TYPE_CUINT, 127, 0 }, +{ "Talx1cschar", TYPE_CINT, 127, 0 }, +{ "Talx1cuchar", TYPE_CUINT, 255, 0 }, +{ "Talx1cshort", TYPE_CINT, 32767, 0 }, +{ "Talx1cushort", TYPE_CUINT, 65535, 0 }, +{ "Talx1cint", TYPE_CINT, 2147483647, 0 }, +{ "Talx1cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Talx1clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx1culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx1cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx1cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx1cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Talx1cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx1cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx2cchar", TYPE_CUINT, 127, 0 }, +{ "Talx2cschar", TYPE_CINT, 127, 0 }, +{ "Talx2cuchar", TYPE_CUINT, 255, 0 }, +{ "Talx2cshort", TYPE_CINT, 32767, 0 }, +{ "Talx2cushort", TYPE_CUINT, 65535, 0 }, +{ "Talx2cint", TYPE_CINT, 2147483647, 0 }, +{ "Talx2cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Talx2clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx2culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx2cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx2cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx2cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Talx2cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx2cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx4cshort", TYPE_CINT, 32767, 0 }, +{ "Talx4cushort", TYPE_CUINT, 65535, 0 }, +{ "Talx4cint", TYPE_CINT, 2147483647, 0 }, +{ "Talx4cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Talx4clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx4culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx4cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx4cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx4cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Talx4cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx4cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx8cint", TYPE_CINT, 2147483647, 0 }, +{ "Talx8cuint", TYPE_CUINT, 4294967295U, 0 }, +{ "Talx8clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx8culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx8cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx8cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx8cfloat", TYPE_CFLOAT, 0, 0 }, +{ "Talx8cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx8cldouble", TYPE_CFLOAT, 0, 0 }, +{ "Taly16clong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Taly16culong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx16cllong", TYPE_CINT, 9223372036854775807LL, 0 }, +{ "Talx16cullong", TYPE_CUINT, 18446744073709551615ULL, 0 }, +{ "Talx16cdouble", TYPE_CFLOAT, 0, 0 }, +{ "Talx16cldouble", TYPE_CFLOAT, 0, 0 } +#define NCAATYPES2 (sizeof (complex_attrib_array_types) / sizeof (complex_attrib_array_types[0])) +}; + +struct types bitfld_types[NTYPES2]; +int n_bitfld_types; +struct types aligned_bitfld_types[NATYPES2]; +int n_aligned_bitfld_types; + +const char *attributes[] = { +"atal", +"atpa", +"atal1", +"atal2", +"atal4", +"atal8", +"atal16", +#define NATTRIBS1 7 +"atalpa", +"atpaal", +"atal1pa", +"atal2pa", +"atal4pa", +"atal8pa", +"atal16pa", +"atpaal1", +"atpaal2", +"atpaal4", +"atpaal8", +"atpaal16" +#define NATTRIBS2 (sizeof (attributes) / sizeof (attributes[0])) +}; + +enum ETYPE +{ + ETYPE_TYPE, + ETYPE_ARRAY, + ETYPE_BITFLD, + ETYPE_STRUCT, + ETYPE_UNION, + ETYPE_STRUCT_ARRAY, + ETYPE_UNION_ARRAY +}; + +struct entry +{ +#ifdef __GNUC__ + enum ETYPE etype : 8; +#else + unsigned char etype; +#endif + unsigned short len; + unsigned char arr_len; + struct types *type; + const char *attrib; + /* Used to chain together entries in the hash table. */ + struct entry *next; +}; + +/* A prime number giving the number of slots in the hash table. */ +#define HASH_SIZE 32749 +static struct entry *hash_table[HASH_SIZE]; + +static int idx, limidx, output_one, short_enums; +static const char *destdir; +static const char *srcdir; +static const char *srcdir_safe; +FILE *outfile; + +void +switchfiles (int fields) +{ + static int filecnt; + static char *destbuf, *destptr; + int i; + + ++filecnt; + if (outfile) + fclose (outfile); + if (output_one) + { + outfile = stdout; + return; + } + if (destbuf == NULL) + { + size_t len = strlen (destdir); + destbuf = malloc (len + 20); + if (!destbuf) + abort (); + memcpy (destbuf, destdir, len); + if (!len || destbuf[len - 1] != '/') + destbuf[len++] = '/'; + destptr = destbuf + len; + } + sprintf (destptr, "t%03d_main.c", filecnt); + outfile = fopen (destbuf, "w"); + if (outfile == NULL) + { + fail: + fputs ("failed to create test files\n", stderr); + exit (1); + } + fprintf (outfile, "/* { dg-require-effective-target int32plus } */\n"); + for (i = 0; i < NDG_OPTIONS; i++) + fprintf (outfile, dg_options[i], "", srcdir_safe); + fprintf (outfile, "/* { dg-prune-output \".*-Wno-abi.*\" } */\n"); + fprintf (outfile, "/* { dg-prune-output \".*Offset of packed bit-field.*\" } */\n"); + fprintf (outfile, "\ +#include \"struct-layout-1.h\"\n\ +\n\ +#define TX(n, type, attrs, fields, ops) extern void test##n (void);\n\ +#include \"t%03d_test.h\"\n\ +#undef TX\n\ +\n\ +int main (void)\n\ +{\n\ +#define TX(n, type, attrs, fields, ops) test##n ();\n\ +#include \"t%03d_test.h\"\n\ +#undef TX\n\ + if (fails)\n\ + {\n\ + fflush (stdout);\n\ + abort ();\n\ + }\n\ + exit (0);\n\ +}\n", filecnt, filecnt); + fclose (outfile); + sprintf (destptr, "t%03d_x.c", filecnt); + outfile = fopen (destbuf, "w"); + if (outfile == NULL) + goto fail; + for (i = 0; i < NDG_OPTIONS; i++) + fprintf (outfile, dg_options[i], "-w ", srcdir_safe); + fprintf (outfile, "\ +#include \"struct-layout-1_x1.h\"\n\ +#include \"t%03d_test.h\"\n\ +#include \"struct-layout-1_x2.h\"\n\ +#include \"t%03d_test.h\"\n", filecnt, filecnt); + fclose (outfile); + sprintf (destptr, "t%03d_y.c", filecnt); + outfile = fopen (destbuf, "w"); + if (outfile == NULL) + goto fail; + for (i = 0; i < NDG_OPTIONS; i++) + fprintf (outfile, dg_options[i], "-w ", srcdir_safe); + fprintf (outfile, "\ +#include \"struct-layout-1_y1.h\"\n\ +#include \"t%03d_test.h\"\n\ +#include \"struct-layout-1_y2.h\"\n\ +#include \"t%03d_test.h\"\n", filecnt, filecnt); + fclose (outfile); + sprintf (destptr, "t%03d_test.h", filecnt); + outfile = fopen (destbuf, "w"); + if (outfile == NULL) + goto fail; + if (fields <= 2) + limidx = idx + 300; + else if (fields <= 4) + limidx = idx + 200; + else if (fields <= 6) + limidx = idx + 100; + else + limidx = idx + 50; +} + +unsigned long long int +getrandll (void) +{ + unsigned long long int ret; + ret = generate_random () & 0xffffff; + ret |= (generate_random () & 0xffffffLL) << 24; + ret |= ((unsigned long long int) generate_random ()) << 48; + return ret; +} + +int +subfield (struct entry *e, char *letter) +{ + int i, type; + char buf[20]; + const char *p; + switch (e[0].etype) + { + case ETYPE_STRUCT: + case ETYPE_UNION: + case ETYPE_STRUCT_ARRAY: + case ETYPE_UNION_ARRAY: + type = e[0].attrib ? 1 + (generate_random () & 3) : 0; + if (e[0].etype == ETYPE_STRUCT || e[0].etype == ETYPE_STRUCT_ARRAY) + p = "struct"; + else + p = "union"; + if (e[0].etype == ETYPE_STRUCT_ARRAY || e[0].etype == ETYPE_UNION_ARRAY) + { + if (e[0].arr_len == 255) + snprintf (buf, 20, "%c[]", *letter); + else + snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len); + /* If this is an array type, do not put aligned attributes on + elements. Aligning elements to a value greater than their + size will result in a compiler error. */ + if (type == 1 + && ((strncmp (e[0].attrib, "atal", 4) == 0) + || strncmp (e[0].attrib, "atpaal", 6) == 0)) + type = 2; + } + else + { + buf[0] = *letter; + buf[1] = '\0'; + } + ++*letter; + switch (type) + { + case 0: + case 3: + case 4: + fprintf (outfile, "%s{", p); + break; + case 1: + fprintf (outfile, "%s %s{", e[0].attrib, p); + break; + case 2: + fprintf (outfile, "%s %s{", p, e[0].attrib); + break; + } + + for (i = 1; i <= e[0].len; ) + i += subfield (e + i, letter); + + switch (type) + { + case 0: + case 1: + case 2: + fprintf (outfile, "}%s;", buf); + break; + case 3: + fprintf (outfile, "}%s %s;", e[0].attrib, buf); + break; + case 4: + fprintf (outfile, "}%s %s;", buf, e[0].attrib); + break; + } + return 1 + e[0].len; + case ETYPE_TYPE: + case ETYPE_ARRAY: + if (e[0].etype == ETYPE_ARRAY) + { + if (e[0].arr_len == 255) + snprintf (buf, 20, "%c[]", *letter); + else + snprintf (buf, 20, "%c[%d]", *letter, e[0].arr_len); + } + else + { + buf[0] = *letter; + buf[1] = '\0'; + } + ++*letter; + if (e[0].attrib) + { + /* If this is an array type, do not put aligned attributes on + elements. Aligning elements to a value greater than their + size will result in a compiler error. */ + if (e[0].etype == ETYPE_ARRAY + && ((strncmp (e[0].attrib, "atal", 4) == 0) + || strncmp (e[0].attrib, "atpaal", 6) == 0)) + type = 2; + else + type = generate_random () % 3; + switch (type) + { + case 0: + fprintf (outfile, "%s %s %s;", e[0].attrib, e[0].type->name, + buf); + break; + case 1: + fprintf (outfile, "%s %s %s;", e[0].type->name, e[0].attrib, + buf); + break; + case 2: + fprintf (outfile, "%s %s %s;", e[0].type->name, buf, + e[0].attrib); + break; + } + } + else + fprintf (outfile, "%s %s;", e[0].type->name, buf); + return 1; + case ETYPE_BITFLD: + if (e[0].len == 0) + { + if (e[0].attrib) + switch (generate_random () % 3) + { + case 0: + fprintf (outfile, "%s %s:0;", e[0].attrib, e[0].type->name); + break; + case 1: + fprintf (outfile, "%s %s:0;", e[0].type->name, e[0].attrib); + break; + case 2: + fprintf (outfile, "%s:0 %s;", e[0].type->name, e[0].attrib); + break; + } + else + fprintf (outfile, "%s:0;", e[0].type->name); + ++*letter; + return 1; + } + switch (e[0].type->bitfld) + { + case 'C': + case 'S': + case 'I': + case 'L': + case 'Q': + snprintf (buf, 20, "B%cN(%d)", e[0].type->bitfld, e[0].len); + break; + case 'B': + case ' ': + snprintf (buf, 20, "%d", e[0].len); + break; + default: + abort (); + } + if (e[0].attrib) + switch (generate_random () % 3) + { + case 0: + fprintf (outfile, "%s %s %c:%s;", e[0].attrib, e[0].type->name, + *letter, buf); + break; + case 1: + fprintf (outfile, "%s %s %c:%s;", e[0].type->name, e[0].attrib, + *letter, buf); + break; + case 2: + fprintf (outfile, "%s %c:%s %s;", e[0].type->name, *letter, + buf, e[0].attrib); + break; + } + else + fprintf (outfile, "%s %c:%s;", e[0].type->name, *letter, buf); + ++*letter; + return 1; + default: + abort (); + } +} + +char namebuf[1024]; + +void +output_FNB (char mode, struct entry *e) +{ + unsigned long long int l1, l2, m; + int signs = 0; +#ifndef SKIP_DECIMAL_FLOAT + int suffix = 0; + char DEC_SUFFIX[3][3]={"DF","DD","DL"}; +#endif + + const char *p, *q; + + if (e->type->type == TYPE_OTHER) + { + if (mode == 'B') + abort (); + fprintf (outfile, "N(%d,%s)", idx, namebuf); + return; + } + fprintf (outfile, "%c(%d,%s,", mode, idx, namebuf); + l1 = getrandll (); + l2 = getrandll (); + switch (e->type->type) + { + case TYPE_INT: + signs = generate_random () & 3; + m = e->type->maxval; + if (mode == 'B') + m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1; + l1 &= m; + l2 &= m; + fprintf (outfile, "%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s", + (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "", + (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : ""); + break; + case TYPE_UINT: + m = e->type->maxval; + if (mode == 'B') + m &= (1ULL << e->len) - 1; + l1 &= m; + l2 &= m; + fprintf (outfile, "%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s", + l1, l1 > 4294967295U ? "LL" : "", + l2, l2 > 4294967295U ? "LL" : ""); + break; + case TYPE_FLOAT: + l1 &= 0xffffff; + l2 &= 0xffffff; + signs = generate_random () & 3; + fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "", + ((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64); + break; +#ifndef SKIP_DECIMAL_FLOAT + case TYPE_DEC_FLOAT: + l1 &= 0xffffff; + l2 &= 0xffffff; + signs = generate_random () & 3; + + /* Get the suffix of Decimal Floting Points per + e->type->name. Distinguish these three DFP types by + e->type->name. */ + if (strstr(e->type->name, "Decimal32")) suffix=0; + else if (strstr(e->type->name, "Decimal64")) suffix=1; + else if (strstr(e->type->name, "Decimal128")) suffix=2; + else + abort (); + + /* Formatted input/output specifiers for DFP types have not been + implemented in GLIBC. %f here used in fprintf is just to + dump the numbers to outfile. */ + fprintf (outfile, "%s%f%s,%s%f%s", + (signs & 1) ? "-" : "", ((double) l1) / 64, DEC_SUFFIX[suffix], + (signs & 2) ? "-" : "", ((double) l2) / 64, DEC_SUFFIX[suffix]); + break; +#endif + case TYPE_CINT: + signs = generate_random () & 3; + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, + "CINT(%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s),", + (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "", + (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : ""); + signs = generate_random () & 3; + l1 = getrandll (); + l2 = getrandll (); + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, + "CINT(%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s)", + (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "", + (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : ""); + break; + case TYPE_CUINT: + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, + "CINT(%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s),", + l1, l1 > 4294967295U ? "LL" : "", + l2, l2 > 4294967295U ? "LL" : ""); + l1 = getrandll (); + l2 = getrandll (); + l1 &= e->type->maxval; + l2 &= e->type->maxval; + fprintf (outfile, + "CINT(%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s)", + l1, l1 > 4294967295U ? "LL" : "", + l2, l2 > 4294967295U ? "LL" : ""); + break; + case TYPE_CFLOAT: + l1 &= 0xffffff; + l2 &= 0xffffff; + signs = generate_random () & 3; + fprintf (outfile, "CDBL(%s%f,%s%f),", + (signs & 1) ? "-" : "", ((double) l1) / 64, + (signs & 2) ? "-" : "", ((double) l2) / 64); + l1 = getrandll (); + l2 = getrandll (); + l1 &= 0xffffff; + l2 &= 0xffffff; + signs = generate_random () & 3; + fprintf (outfile, "CDBL(%s%f,%s%f)", + (signs & 1) ? "-" : "", ((double) l1) / 64, + (signs & 2) ? "-" : "", ((double) l2) / 64); + break; + case TYPE_UENUM: + if (e->type->maxval == 0) + fputs ("e0_0,e0_0", outfile); + else if (e->type->maxval == 1) + fprintf (outfile, "e1_%" COMPAT_PRLL "d,e1_%" COMPAT_PRLL "d", + l1 & 1, l2 & 1); + else + { + p = strchr (e->type->name, '\0'); + while (--p >= e->type->name && *p >= '0' && *p <= '9'); + p++; + l1 %= 7; + l2 %= 7; + if (l1 > 3) + l1 += e->type->maxval - 6; + if (l2 > 3) + l2 += e->type->maxval - 6; + fprintf (outfile, "e%s_%" COMPAT_PRLL "d,e%s_%" COMPAT_PRLL "d", + p, l1, p, l2); + } + break; + case TYPE_SENUM: + p = strchr (e->type->name, '\0'); + while (--p >= e->type->name && *p >= '0' && *p <= '9'); + p++; + l1 %= 7; + l2 %= 7; + fprintf (outfile, "e%s_%s%" COMPAT_PRLL "d,e%s_%s%" COMPAT_PRLL "d", + p, l1 < 3 ? "m" : "", + l1 == 3 ? 0LL : e->type->maxval - (l1 & 3), + p, l2 < 3 ? "m" : "", + l2 == 3 ? 0LL : e->type->maxval - (l2 & 3)); + break; + case TYPE_PTR: + l1 %= 256; + l2 %= 256; + fprintf (outfile, + "(%s)&intarray[%" COMPAT_PRLL "d], (%s)&intarray[%" COMPAT_PRLL "d]", + e->type->name, l1, e->type->name, l2); + break; + case TYPE_FNPTR: + l1 %= 10; + l2 %= 10; + fprintf (outfile, "fn%" COMPAT_PRLL "d,fn%" COMPAT_PRLL "d", l1, l2); + break; + default: + abort (); + } + fputs (")", outfile); +} + +int +subvalues (struct entry *e, char *p, char *letter) +{ + int i, j; + char *q; + if (p >= namebuf + sizeof (namebuf) - 32) + abort (); + p[0] = *letter; + p[1] = '\0'; + q = p + 1; + switch (e[0].etype) + { + case ETYPE_STRUCT_ARRAY: + case ETYPE_UNION_ARRAY: + if (e[0].arr_len == 0 || e[0].arr_len == 255) + { + *letter += 1 + e[0].len; + return 1 + e[0].len; + } + i = generate_random () % e[0].arr_len; + snprintf (p, sizeof (namebuf) - (p - namebuf) - 1, + "%c[%d]", *letter, i); + q = strchr (p, '\0'); + /* FALLTHROUGH */ + case ETYPE_STRUCT: + case ETYPE_UNION: + *q++ = '.'; + ++*letter; + for (i = 1; i <= e[0].len; ) + { + i += subvalues (e + i, q, letter); + if (e[0].etype == ETYPE_UNION || e[0].etype == ETYPE_UNION_ARRAY) + { + *letter += e[0].len - i + 1; + break; + } + } + return 1 + e[0].len; + case ETYPE_TYPE: + ++*letter; + output_FNB ('F', e); + return 1; + case ETYPE_ARRAY: + if (e[0].arr_len == 0 || e[0].arr_len == 255) + { + ++*letter; + return 1; + } + i = generate_random () % e[0].arr_len; + snprintf (p, sizeof (namebuf) - (p - namebuf), + "%c[%d]", *letter, i); + output_FNB ('F', e); + if ((generate_random () & 7) == 0) + { + j = generate_random () % e[0].arr_len; + if (i != j) + { + snprintf (p, sizeof (namebuf) - (p - namebuf), + "%c[%d]", *letter, j); + output_FNB ('F', e); + } + } + ++*letter; + return 1; + case ETYPE_BITFLD: + ++*letter; + if (e[0].len != 0) + output_FNB ('B', e); + return 1; + } +} + +/* DERIVED FROM: +-------------------------------------------------------------------- +lookup2.c, by Bob Jenkins, December 1996, Public Domain. +hash(), hash2(), hash3, and mix() are externally useful functions. +Routines to test the hash are included if SELF_TEST is defined. +You can use this free for any purpose. It has no warranty. +-------------------------------------------------------------------- +*/ + +/* +-------------------------------------------------------------------- +mix -- mix 3 32-bit values reversibly. +For every delta with one or two bit set, and the deltas of all three + high bits or all three low bits, whether the original value of a,b,c + is almost all zero or is uniformly distributed, +* If mix() is run forward or backward, at least 32 bits in a,b,c + have at least 1/4 probability of changing. +* If mix() is run forward, every bit of c will change between 1/3 and + 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) +mix() was built out of 36 single-cycle latency instructions in a + structure that could supported 2x parallelism, like so: + a -= b; + a -= c; x = (c>>13); + b -= c; a ^= x; + b -= a; x = (a<<8); + c -= a; b ^= x; + c -= b; x = (b>>13); + ... + Unfortunately, superscalar Pentiums and Sparcs can't take advantage + of that parallelism. They've also turned some of those single-cycle + latency instructions into multi-cycle latency instructions. Still, + this is the fastest good hash I could find. There were about 2^^68 + to choose from. I only looked at a billion or so. +-------------------------------------------------------------------- +*/ +/* same, but slower, works on systems that might have 8 byte hashval_t's */ +#define mix(a,b,c) \ +{ \ + a -= b; a -= c; a ^= (c>>13); \ + b -= c; b -= a; b ^= (a<< 8); \ + c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \ + a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \ + b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \ + c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \ + a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \ + b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \ + c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \ +} + +/* +-------------------------------------------------------------------- +hash() -- hash a variable-length key into a 32-bit value + k : the key (the unaligned variable-length array of bytes) + len : the length of the key, counting by bytes + level : can be any 4-byte value +Returns a 32-bit value. Every bit of the key affects every bit of +the return value. Every 1-bit and 2-bit delta achieves avalanche. +About 36+6len instructions. + +The best hash table sizes are powers of 2. There is no need to do +mod a prime (mod is sooo slow!). If you need less than 32 bits, +use a bitmask. For example, if you need only 10 bits, do + h = (h & hashmask(10)); +In which case, the hash table should have hashsize(10) elements. + +If you are hashing n strings (ub1 **)k, do it like this: + for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h); + +By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this +code any way you wish, private, educational, or commercial. It's free. + +See http://burtleburtle.net/bob/hash/evahash.html +Use for hash table lookup, or anything where one collision in 2^32 is +acceptable. Do NOT use for cryptographic purposes. +-------------------------------------------------------------------- +*/ + +static hashval_t +iterative_hash (const void *k_in /* the key */, + register size_t length /* the length of the key */, + register hashval_t initval /* the previous hash, or + an arbitrary value */) +{ + register const unsigned char *k = (const unsigned char *)k_in; + register hashval_t a,b,c,len; + + /* Set up the internal state */ + len = length; + a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */ + c = initval; /* the previous hash value */ + + /*---------------------------------------- handle most of the key */ + while (len >= 12) + { + a += (k[0] +((hashval_t)k[1]<<8) +((hashval_t)k[2]<<16) +((hashval_t)k[3]<<24)); + b += (k[4] +((hashval_t)k[5]<<8) +((hashval_t)k[6]<<16) +((hashval_t)k[7]<<24)); + c += (k[8] +((hashval_t)k[9]<<8) +((hashval_t)k[10]<<16)+((hashval_t)k[11]<<24)); + mix(a,b,c); + k += 12; len -= 12; + } + + /*------------------------------------- handle the last 11 bytes */ + c += length; + switch(len) /* all the case statements fall through */ + { + case 11: c+=((hashval_t)k[10]<<24); + case 10: c+=((hashval_t)k[9]<<16); + case 9 : c+=((hashval_t)k[8]<<8); + /* the first byte of c is reserved for the length */ + case 8 : b+=((hashval_t)k[7]<<24); + case 7 : b+=((hashval_t)k[6]<<16); + case 6 : b+=((hashval_t)k[5]<<8); + case 5 : b+=k[4]; + case 4 : a+=((hashval_t)k[3]<<24); + case 3 : a+=((hashval_t)k[2]<<16); + case 2 : a+=((hashval_t)k[1]<<8); + case 1 : a+=k[0]; + /* case 0: nothing left to add */ + } + mix(a,b,c); + /*-------------------------------------------- report the result */ + return c; +} + +hashval_t +e_hash (const void *a) +{ + const struct entry *e = a; + hashval_t ret = 0; + int i; + + if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION) + abort (); + for (i = 0; i <= e[0].len; ++i) + { + int attriblen; + ret = iterative_hash (&e[i], offsetof (struct entry, attrib), ret); + attriblen = e[i].attrib ? strlen (e[i].attrib) : -1; + ret = iterative_hash (&attriblen, sizeof (int), ret); + if (e[i].attrib) + ret = iterative_hash (e[i].attrib, attriblen, ret); + } + return ret; +} + +int +e_eq (const void *a, const void *b) +{ + const struct entry *ea = a, *eb = b; + int i; + if (ea[0].etype != ETYPE_STRUCT && ea[0].etype != ETYPE_UNION) + abort (); + if (ea[0].len != eb[0].len) + return 0; + for (i = 0; i <= ea[0].len; ++i) + { + if (ea[i].etype != eb[i].etype + || ea[i].len != eb[i].len + || ea[i].arr_len != eb[i].arr_len + || ea[i].type != eb[i].type) + return 0; + if ((ea[i].attrib == NULL) ^ (eb[i].attrib == NULL)) + return 0; + if (ea[i].attrib && strcmp (ea[i].attrib, eb[i].attrib) != 0) + return 0; + } + return 1; +} + +static int +e_exists (const struct entry *e) +{ + struct entry *h; + hashval_t hval; + + hval = e_hash (e); + for (h = hash_table[hval % HASH_SIZE]; h; h = h->next) + if (e_eq (e, h)) + return 1; + return 0; +} + +static void +e_insert (struct entry *e) +{ + hashval_t hval; + + hval = e_hash (e); + e->next = hash_table[hval % HASH_SIZE]; + hash_table[hval % HASH_SIZE] = e; +} + +void +output (struct entry *e) +{ + int i; + char c; + struct entry *n; + const char *skip_cint = ""; + + if (e[0].etype != ETYPE_STRUCT && e[0].etype != ETYPE_UNION) + abort (); + + if (e_exists (e)) + return; + + n = (struct entry *) malloc ((e[0].len + 1) * sizeof (struct entry)); + memcpy (n, e, (e[0].len + 1) * sizeof (struct entry)); + e_insert (n); + + if (idx == limidx) + switchfiles (e[0].len); + + for (i = 1; i <= e[0].len; ++i) + if ((e[i].etype == ETYPE_TYPE || e[i].etype == ETYPE_ARRAY) + && (e[i].type->type == TYPE_CINT || e[i].type->type == TYPE_CUINT)) + break; + if (i <= e[0].len) + skip_cint = "CI"; + if (e[0].attrib) + fprintf (outfile, (generate_random () & 1) + ? "TX%s(%d,%s %s,," : "TX%s(%d,%s,%s,", skip_cint, + idx, e[0].etype == ETYPE_STRUCT ? "struct" : "union", + e[0].attrib); + else if (e[0].etype == ETYPE_STRUCT) + fprintf (outfile, "T%s(%d,", skip_cint, idx); + else + fprintf (outfile, "U%s(%d,", skip_cint, idx); + c = 'a'; + for (i = 1; i <= e[0].len; ) + i += subfield (e + i, &c); + fputs (",", outfile); + c = 'a'; + for (i = 1; i <= e[0].len; ) + { + i += subvalues (e + i, namebuf, &c); + if (e[0].etype == ETYPE_UNION) + break; + } + fputs (")\n", outfile); + if (output_one && idx == limidx) + exit (0); + ++idx; +} + +enum FEATURE +{ + FEATURE_VECTOR = 1, + FEATURE_COMPLEX = 2, + FEATURE_ALIGNEDPACKED = 4, + FEATURE_ZEROARRAY = 8, + FEATURE_ZEROBITFLD = 16, + ALL_FEATURES = FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY + | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD +}; + +void +singles (enum FEATURE features) +{ + struct entry e[2]; + int i; + memset (e, 0, sizeof (e)); + e[0].etype = ETYPE_STRUCT; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + for (i = 0; + i < ((features & FEATURE_ALIGNEDPACKED) ? NATTRIBS2 : NATTRIBS1); + ++i) + { + e[0].attrib = attributes[i]; + e[0].etype = ETYPE_STRUCT; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + } + e[0].len = 1; + e[0].attrib = NULL; + for (i = 0; i < NTYPES2; ++i) + { + e[0].etype = ETYPE_STRUCT; + e[1].etype = ETYPE_TYPE; + e[1].type = &base_types[i]; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + } + if (features & FEATURE_COMPLEX) + for (i = 0; i < NCTYPES2; ++i) + { + e[0].etype = ETYPE_STRUCT; + e[1].etype = ETYPE_TYPE; + e[1].type = &complex_types[i]; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + } + if (features & FEATURE_VECTOR) + for (i = 0; i < NVTYPES2; ++i) + { + e[0].etype = ETYPE_STRUCT; + e[1].etype = ETYPE_TYPE; + e[1].type = &vector_types[i]; + output (e); + e[0].etype = ETYPE_UNION; + output (e); + } +} + +void +choose_type (enum FEATURE features, struct entry *e, int r, int in_array) +{ + int i; + + i = NTYPES2 - NTYPES1; + if (features & FEATURE_COMPLEX) + i += NCTYPES2; + if (features & FEATURE_VECTOR) + i += NVTYPES2; + if ((r & 3) == 0) + { + if (in_array) + { + i += NAATYPES2; + if (features & FEATURE_COMPLEX) + i += NCAATYPES2; + } + else + { + i += NATYPES2; + if (features & FEATURE_COMPLEX) + i += NCATYPES2; + } + } + r >>= 2; + r %= i; + if (r < NTYPES2 - NTYPES1) + e->type = &base_types[r + NTYPES1]; + r -= NTYPES2 - NTYPES1; + if (e->type == NULL && (features & FEATURE_COMPLEX)) + { + if (r < NCTYPES2) + e->type = &complex_types[r]; + r -= NCTYPES2; + } + if (e->type == NULL && (features & FEATURE_VECTOR)) + { + if (r < NVTYPES2) + e->type = &vector_types[r]; + r -= NVTYPES2; + } + if (e->type == NULL && !in_array) + { + if (r < NATYPES2) + e->type = &attrib_types[r]; + r -= NATYPES2; + } + if (e->type == NULL && !in_array && (features & FEATURE_COMPLEX)) + { + if (r < NCATYPES2) + e->type = &complex_attrib_types[r]; + r -= NCATYPES2; + } + if (e->type == NULL && in_array) + { + if (r < NAATYPES2) + e->type = &attrib_array_types[r]; + r -= NAATYPES2; + } + if (e->type == NULL && in_array && (features & FEATURE_COMPLEX)) + { + if (r < NCAATYPES2) + e->type = &complex_attrib_array_types[r]; + r -= NCAATYPES2; + } + if (e->type == NULL) + abort (); +} + +/* This is from gcc.c-torture/execute/builtin-bitops-1.c. */ +static int +my_ffsll (unsigned long long x) +{ + int i; + if (x == 0) + return 0; + /* We've tested LLONG_MAX for 64 bits so this should be safe. */ + for (i = 0; i < 64; i++) + if (x & (1ULL << i)) + break; + return i + 1; +} + +void +generate_fields (enum FEATURE features, struct entry *e, struct entry *parent, + int len) +{ + int r, i, j, ret = 1, n, incr, sametype; + + for (n = 0; n < len; n += incr) + { + r = generate_random (); + /* 50% ETYPE_TYPE base_types NTYPES1 + 12.5% ETYPE_TYPE other + 12.5% ETYPE_ARRAY + 12.5% ETYPE_BITFLD + 12.5% ETYPE_STRUCT|ETYPE_UNION|ETYPE_STRUCT_ARRAY|ETYPE_UNION_ARRAY */ + i = (r & 7); + r >>= 3; + incr = 1; + switch (i) + { + case 0: + case 1: + case 2: + case 3: + e[n].etype = ETYPE_TYPE; + e[n].type = &base_types[r % NTYPES1]; + break; + case 4: + e[n].etype = ETYPE_TYPE; + choose_type (features, &e[n], r, 0); + break; + case 5: + e[n].etype = ETYPE_ARRAY; + i = r & 1; + r >>= 1; + if (i) + e[n].type = &base_types[r % NTYPES1]; + else + choose_type (features, &e[n], r, 1); + r = generate_random (); + if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0) + { + e[n].arr_len = 0; + if (n == len - 1 && (r & 4) + && (parent->etype == ETYPE_STRUCT + || parent->etype == ETYPE_STRUCT_ARRAY)) + { + int k; + for (k = 0; k < n; ++k) + if (e[k].etype != ETYPE_BITFLD || e[k].len) + { + e[n].arr_len = 255; + break; + } + } + } + else if ((r & 3) != 3) + e[n].arr_len = (r >> 2) & 7; + else + e[n].arr_len = (r >> 2) & 31; + break; + case 6: + sametype = 1; + switch (r & 7) + { + case 0: + case 1: + case 2: + break; + case 3: + case 4: + case 5: + incr = 1 + (r >> 3) % (len - n); + break; + case 6: + case 7: + sametype = 0; + incr = 1 + (r >> 3) % (len - n); + break; + } + for (j = n; j < n + incr; ++j) + { + int mi, ma; + + e[j].etype = ETYPE_BITFLD; + if (j == n || !sametype) + { + int k; + r = generate_random (); + k = r & 3; + r >>= 2; + if (!k) + e[j].type + = &aligned_bitfld_types[r % n_aligned_bitfld_types]; + else + e[j].type + = &bitfld_types[r % n_bitfld_types]; + } + else + e[j].type = e[n].type; + r = generate_random (); + mi = 0; + ma = 0; + switch (e[j].type->bitfld) + { + case 'C': ma = 8; break; + case 'S': ma = 16; break; + case 'I': ma = 32; break; + case 'L': + case 'Q': ma = 64; break; + case 'B': ma = 1; break; + case ' ': + if (e[j].type->type == TYPE_UENUM) + mi = my_ffsll (e[j].type->maxval + 1) - 1; + else if (e[j].type->type == TYPE_SENUM) + mi = my_ffsll (e[j].type->maxval + 1); + else + abort (); + if (!mi) + mi = 1; + if (mi > 32) + ma = 64; + else if (mi > 16 || !short_enums) + ma = 32; + else if (mi > 8) + ma = 16; + else + ma = 8; + break; + default: + abort (); + } + e[j].len = ma + 1; + if (sametype && (r & 3) == 0 && ma > 1) + { + int sum = 0, k; + for (k = n; k < j; ++k) + sum += e[k].len; + sum %= ma; + e[j].len = sum ? ma - sum : ma; + } + r >>= 2; + if (! (features & FEATURE_ZEROBITFLD) && mi == 0) + mi = 1; + if (e[j].len < mi || e[j].len > ma) + e[j].len = mi + (r % (ma + 1 - mi)); + r >>= 6; + if ((features & FEATURE_ZEROBITFLD) && (r & 3) == 0 + && mi == 0) + e[j].len = 0; + } + break; + case 7: + switch (r & 7) + { + case 0: + case 1: + case 2: + e[n].etype = ETYPE_STRUCT; + break; + case 3: + case 4: + e[n].etype = ETYPE_UNION; + break; + case 5: + case 6: + e[n].etype = ETYPE_STRUCT_ARRAY; + break; + case 7: + e[n].etype = ETYPE_UNION_ARRAY; + break; + } + r >>= 3; + e[n].len = r % (len - n); + incr = 1 + e[n].len; + generate_fields (features, &e[n + 1], &e[n], e[n].len); + if (e[n].etype == ETYPE_STRUCT_ARRAY + || e[n].etype == ETYPE_UNION_ARRAY) + { + r = generate_random (); + if ((features & FEATURE_ZEROARRAY) && (r & 3) == 0) + { + e[n].arr_len = 0; + if (n + incr == len && (r & 4) + && (parent->etype == ETYPE_STRUCT + || parent->etype == ETYPE_STRUCT_ARRAY)) + { + int k; + for (k = 0; k < n; ++k) + if (e[k].etype != ETYPE_BITFLD || e[k].len) + { + e[n].arr_len = 255; + break; + } + } + } + else if ((r & 3) != 3) + e[n].arr_len = (r >> 2) & 7; + else + e[n].arr_len = (r >> 2) & 31; + } + break; + } + r = generate_random (); + if ((r & 7) == 0) + { + r >>= 3; + i = (features & FEATURE_ALIGNEDPACKED) ? NATTRIBS2 : NATTRIBS1; + e[n].attrib = attributes[r % i]; + if (! (features & FEATURE_ALIGNEDPACKED) + && strcmp (e[n].attrib, "atpa") == 0 + && ((e[n].type >= &attrib_types[0] + && e[n].type < &attrib_types[NATYPES2]) + || (e[n].type >= &complex_attrib_types[0] + && e[n].type < &complex_attrib_types[NCATYPES2]) + || (e[n].type >= &attrib_array_types[0] + && e[n].type < &attrib_array_types[NAATYPES2]) + || (e[n].type >= &complex_attrib_array_types[0] + && e[n].type < &complex_attrib_array_types[NAATYPES2]) + || (e[n].type >= &aligned_bitfld_types[0] + && e[n].type < &aligned_bitfld_types[n_aligned_bitfld_types]))) + e[n].attrib = NULL; + } + } +} + +void +generate_random_tests (enum FEATURE features, int len) +{ + struct entry e[len + 1]; + int i, r; + if (len > 'z' - 'a' + 1) + abort (); + memset (e, 0, sizeof (e)); + r = generate_random (); + if ((r & 7) == 0) + e[0].etype = ETYPE_UNION; + else + e[0].etype = ETYPE_STRUCT; + r >>= 3; + e[0].len = len; + if ((r & 31) == 0) + { + r >>= 5; + if (features & FEATURE_ALIGNEDPACKED) + r %= NATTRIBS2; + else + r %= NATTRIBS1; + e[0].attrib = attributes[r]; + } + generate_fields (features, &e[1], &e[0], len); + output (e); +} + +struct { const char *name; enum FEATURE f; } +features[] = { +{ "normal", 0 }, +{ "complex", FEATURE_COMPLEX }, +{ "vector", FEATURE_VECTOR }, +{ "[0] :0", FEATURE_ZEROARRAY | FEATURE_ZEROBITFLD }, +{ "complex vector [0]", + FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY }, +{ "aligned packed complex vector [0] :0", + FEATURE_COMPLEX | FEATURE_VECTOR | FEATURE_ZEROARRAY + | FEATURE_ALIGNEDPACKED | FEATURE_ZEROBITFLD }, +}; + +int +main (int argc, char **argv) +{ + int i, j, count, c, n = 3000; + char *optarg; + + if (sizeof (int) != 4 || sizeof (long long) != 8) + return 1; + + i = 1; + while (i < argc) + { + c = '\0'; + if (argv[i][0] == '-' && argv[i][2] == '\0') + c = argv[i][1]; + optarg = argv[i + 1]; + if (!optarg) + goto usage; + switch (c) + { + case 'n': + n = atoi (optarg); + break; + case 'd': + destdir = optarg; + break; + case 's': + srcdir = optarg; + break; + case 'i': + output_one = 1; + limidx = atoi (optarg); + break; + case 'e': + short_enums = 1; + i--; + break; + default: + fprintf (stderr, "unrecognized option %s\n", argv[i]); + goto usage; + } + i += 2; + } + + if (output_one) + { + outfile = fopen ("/dev/null", "w"); + if (outfile == NULL) + { + fputs ("could not open /dev/null", stderr); + return 1; + } + n = limidx + 1; + } + + if (destdir == NULL && !output_one) + { + usage: + fprintf (stderr, "Usage:\n\ +%s [-e] [-s srcdir -d destdir] [-n count] [-i idx]\n\ +Either -s srcdir -d destdir or -i idx must be used\n", argv[0]); + return 1; + } + + if (srcdir == NULL && !output_one) + goto usage; + + if (srcdir != NULL) + { + const char *s = srcdir; + char *ss, *t; + t = ss = malloc (strlen (srcdir) + 1); + if (!ss) + abort (); + do { + if (*s == '\\') + *t++ = '/'; + else + *t++ = *s; + } while (*s++); + srcdir_safe = ss; + } + + for (i = 0; i < NTYPES2; ++i) + if (base_types[i].bitfld) + bitfld_types[n_bitfld_types++] = base_types[i]; + for (i = 0; i < NATYPES2; ++i) + if (attrib_types[i].bitfld) + aligned_bitfld_types[n_aligned_bitfld_types++] = attrib_types[i]; + for (i = 0; i < sizeof (features) / sizeof (features[0]); ++i) + { + int startidx = idx; + if (! output_one) + limidx = idx; + if (!i) + count = 200; + else + count = 20; + for (j = 1; j <= 9; ++j) + while (idx < startidx + j * count) + generate_random_tests (features[i].f, j); + while (idx < startidx + count * 10) + generate_random_tests (features[i].f, 10 + (generate_random () % 16)); + } + for (i = 0; n > 3000 && i < sizeof (features) / sizeof (features[0]); ++i) + { + int startidx; + startidx = idx; + if (! output_one) + limidx = idx; + singles (features[i].f); + if (!i) + { + count = 1000; + while (idx < startidx + 1000) + generate_random_tests (features[i].f, 1); + } + else + { + startidx = idx; + count = 100; + while (idx < startidx + 100) + generate_random_tests (features[i].f, 1); + } + startidx = idx; + for (j = 2; j <= 9; ++j) + while (idx < startidx + (j - 1) * count) + generate_random_tests (features[i].f, j); + while (idx < startidx + count * 9) + generate_random_tests (features[i].f, 10 + (generate_random () % 16)); + } + if (! output_one) + limidx = idx; + while (idx < n) + generate_random_tests (ALL_FEATURES, 1 + (generate_random () % 25)); + fclose (outfile); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_main.c b/gcc/testsuite/gcc.dg/compat/struct-layout-1_main.c new file mode 100644 index 000000000..b59453e0b --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_main.c @@ -0,0 +1,17 @@ +/* { dg-prune-output ".*-Wno-abi.*" } */ + +#include "struct-layout-1.h" + +#define TX(n, type, attrs, fields, ops) extern void test##n (void); +#include "struct-layout-1_test.h" +#undef TX + +int main (void) +{ +#define TX(n, type, attrs, fields, ops) test##n (); +#include "struct-layout-1_test.h" +#undef TX + if (fails) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_test.h b/gcc/testsuite/gcc.dg/compat/struct-layout-1_test.h new file mode 100644 index 000000000..affddcaef --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_test.h @@ -0,0 +1 @@ +T(0,enum E2 a:7;,B(0,a,e2_m1,e2_0)) diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_x.c b/gcc/testsuite/gcc.dg/compat/struct-layout-1_x.c new file mode 100644 index 000000000..02c885c62 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_x.c @@ -0,0 +1,5 @@ +/* { dg-options "-w" } */ +#include "struct-layout-1_x1.h" +#include "struct-layout-1_test.h" +#include "struct-layout-1_x2.h" +#include "struct-layout-1_test.h" diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_x1.h b/gcc/testsuite/gcc.dg/compat/struct-layout-1_x1.h new file mode 100644 index 000000000..0c7696fa7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_x1.h @@ -0,0 +1,68 @@ +#include "struct-layout-1.h" + +struct Info info; +int fails; +int intarray[256]; +int fn0 (void) { return 0; } +int fn1 (void) { return 1; } +int fn2 (void) { return 2; } +int fn3 (void) { return 3; } +int fn4 (void) { return 4; } +int fn5 (void) { return 5; } +int fn6 (void) { return 6; } +int fn7 (void) { return 7; } +int fn8 (void) { return 8; } +int fn9 (void) { return 9; } + +/* This macro is intended for fields where their + addresses/sizes/alignments and value passing should be checked. */ +#define F(n, x, v, w) \ + info.flds[i] = &s##n.x; \ + info.sizes[i] = sizeof (s##n.x); \ + info.aligns[i] = __alignof__ (s##n.x); \ + s##n.x = v; \ + a##n[2].x = w; \ + ++i; +/* This macro is for fields where just their addresses/sizes/alignments + should be checked. */ +#define N(n, x) \ + info.flds[i] = &s##n.x; \ + info.sizes[i] = sizeof (s##n.x); \ + info.aligns[i] = __alignof__ (s##n.x); \ + ++i; +/* This macro is for fields where just value passing should be checked. */ +#define B(n, x, v, w) \ + s##n.x = v; \ + a##n[2].x = w; \ + ++j; +#define TX(n, type, attrs, fields, ops) \ +type S##n { fields } attrs; \ +type S##n s##n; \ +extern type S##n a##n[5]; \ +extern type S##n check##n (type S##n, type S##n *, \ + type S##n); \ +extern void check##n##va (int i, ...); \ +extern void checkx##n (type S##n); \ +void test##n (void) \ +{ \ + int i, j; \ + memset (&s##n, '\0', sizeof (s##n)); \ + memset (a##n, '\0', sizeof (a##n)); \ + memset (&info, '\0', sizeof (info)); \ + info.sp = &s##n; \ + info.a0p = &a##n[0]; \ + info.a3p = &a##n[3]; \ + info.sz = sizeof (s##n); \ + info.als = __alignof__ (s##n); \ + info.ala0 = __alignof__ (a##n[0]); \ + info.ala3 = __alignof__ (a##n[3]); \ + if (((long) &a##n[3]) & (info.als - 1)) \ + FAIL (n, 1); \ + i = 0; j = 0; \ + ops \ + info.nfields = i; \ + info.nbitfields = j; \ + checkx##n (check##n (s##n, &a##n[1], a##n[2])); \ + check##n##va (1, 1.0, s##n, 2LL, a##n[2], a##n[2]); \ + check##n##va (2, s##n, s##n, 2.0L, a##n[2], s##n); \ +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_x2.h b/gcc/testsuite/gcc.dg/compat/struct-layout-1_x2.h new file mode 100644 index 000000000..907a2c959 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_x2.h @@ -0,0 +1,14 @@ +#undef F +#undef N +#undef B +#undef TX +#define F(n, x, v, w) \ + if (arg.x != s##n.x) FAIL (n, 30); +#define N(n, x) +#define B(n, x, v, w) \ + if (arg.x != s##n.x) FAIL (n, 30); +#define TX(n, type, attrs, fields, ops) \ +void checkx##n (type S##n arg) \ +{ \ + ops \ +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_y.c b/gcc/testsuite/gcc.dg/compat/struct-layout-1_y.c new file mode 100644 index 000000000..ed95f5a50 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_y.c @@ -0,0 +1,5 @@ +/* { dg-options "-w" } */ +#include "struct-layout-1_y1.h" +#include "struct-layout-1_test.h" +#include "struct-layout-1_y2.h" +#include "struct-layout-1_test.h" diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_y1.h b/gcc/testsuite/gcc.dg/compat/struct-layout-1_y1.h new file mode 100644 index 000000000..9a5d2468a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_y1.h @@ -0,0 +1,76 @@ +#include "struct-layout-1.h" + +#define F(n, x, v, w) \ + if (info.flds[i] != &s##n.x) \ + FAIL (n, 50); \ + if (info.sizes[i] != sizeof (s##n.x)) \ + FAIL (n, 51); \ + if (info.aligns[i] != __alignof__ (s##n.x)) \ + FAIL (n, 52); \ + if (s##n.x != (__typeof__ (s##n.x)) v) \ + FAIL (n, 53); \ + if (a##n[2].x != (__typeof__ (s##n.x)) w) \ + FAIL (n, 54); \ + if (arg0.x != s##n.x) \ + FAIL (n, 55); \ + if (arg2.x != a##n[2].x) \ + FAIL (n, 56); \ + ret.x = s##n.x; \ + ++i; +#define N(n, x) \ + if (info.flds[i] != &s##n.x) \ + FAIL (n, 50); \ + if (info.sizes[i] != sizeof (s##n.x)) \ + FAIL (n, 51); \ + if (info.aligns[i] != __alignof__ (s##n.x)) \ + FAIL (n, 52); \ + ++i; +#define B(n, x, v, w) \ + b1.x = v; b2.x = w; \ + if (s##n.x != b1.x) \ + FAIL (n, 53); \ + if (a##n[2].x != b2.x) \ + FAIL (n, 54); \ + if (arg0.x != s##n.x) \ + FAIL (n, 55); \ + if (arg2.x != a##n[2].x) \ + FAIL (n, 56); \ + ret.x = s##n.x; \ + ++j; +#define TX(n, type, attrs, fields, ops) \ +type S##n { fields } attrs; \ +extern type S##n s##n; \ +type S##n a##n[5]; \ +type S##n \ +check##n (type S##n arg0, type S##n *arg1, type S##n arg2) \ +{ \ + type S##n ret; \ + type S##n b1, b2; \ + int i, j; \ + \ + memset (&ret, 0, sizeof (ret)); \ + memset (&b1, 0, sizeof (b1)); \ + memset (&b2, 0, sizeof (b2)); \ + if (info.sp != &s##n) \ + FAIL (n, 10); \ + if (info.a0p != &a##n[0]) \ + FAIL (n, 11); \ + if (info.a3p != &a##n[3]) \ + FAIL (n, 12); \ + if (info.sz != sizeof (s##n)) \ + FAIL (n, 13); \ + if (info.als != __alignof__ (s##n)) \ + FAIL (n, 14); \ + if (info.ala0 != __alignof__ (a##n[0])) \ + FAIL (n, 15); \ + if (info.ala3 != __alignof__ (a##n[3])) \ + FAIL (n, 16); \ + if (arg1 != &a##n[1]) \ + FAIL (n, 17); \ + i = 0; j = 0; \ + ops \ + if (i != info.nfields || j != info.nbitfields) \ + FAIL (n, 18); \ + \ + return ret; \ +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-layout-1_y2.h b/gcc/testsuite/gcc.dg/compat/struct-layout-1_y2.h new file mode 100644 index 000000000..02a341e1c --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-layout-1_y2.h @@ -0,0 +1,69 @@ +#undef F +#undef N +#undef B +#undef TX + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define F(n, x, v, w) \ + if (p->x != arg.x) FAIL (n, 74); +#define N(n, x) +#define B(n, x, v, w) \ + if (p->x != arg.x) FAIL (n, 74); +#define TX(n, type, attrs, fields, ops) \ +void \ +check##n##va (int z, ...) \ +{ \ + type S##n arg, *p; \ + va_list ap; \ + int i; \ + \ + if (test_va) \ + { \ + va_start (ap, z); \ + for (i = 0; i < 5; ++i) \ + { \ + p = NULL; \ + switch ((z << 4) | i) \ + { \ + case 0x10: \ + if (va_arg (ap, double) != 1.0) \ + FAIL (n, 70); \ + break; \ + case 0x12: \ + if (va_arg (ap, long long) != 2LL) \ + FAIL (n, 71); \ + break; \ + case 0x22: \ + if (va_arg (ap, long double) != 2.0L) \ + FAIL (n, 72); \ + break; \ + case 0x11: \ + case 0x20: \ + case 0x21: \ + case 0x24: \ + p = &s##n; \ + arg = va_arg (ap, type S##n); \ + break; \ + case 0x13: \ + case 0x14: \ + case 0x23: \ + p = &a##n[2]; \ + arg = va_arg (ap, type S##n); \ + break; \ + default: \ + FAIL (n, 73); \ + break; \ + } \ + if (p) \ + { \ + ops \ + } \ + } \ + va_end (ap); \ + } \ +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-10_main.c b/gcc/testsuite/gcc.dg/compat/struct-return-10_main.c new file mode 100644 index 000000000..fca68286c --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-10_main.c @@ -0,0 +1,13 @@ +/* Test function return values. For this test, all struct members are + scalar floating point types. */ + +extern void struct_return_10_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_return_10_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-10_x.c b/gcc/testsuite/gcc.dg/compat/struct-return-10_x.c new file mode 100644 index 000000000..d1531b179 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-10_x.c @@ -0,0 +1,119 @@ +#include "compat-common.h" + +#define T(TYPE) \ +TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void init##TYPE (TYPE *p, double y); \ +extern void checkg##TYPE (void); \ +extern TYPE test0##TYPE (void); \ +extern TYPE test1##TYPE (TYPE); \ +extern TYPE testva##TYPE (int n, ...); \ + \ +void \ +testit##TYPE (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" init: "); \ + init##TYPE (&g01##TYPE, 1.0); \ + init##TYPE (&g02##TYPE, 2.0); \ + init##TYPE (&g03##TYPE, 3.0); \ + init##TYPE (&g04##TYPE, 4.0); \ + init##TYPE (&g05##TYPE, 5.0); \ + init##TYPE (&g06##TYPE, 6.0); \ + init##TYPE (&g07##TYPE, 7.0); \ + init##TYPE (&g08##TYPE, 8.0); \ + init##TYPE (&g09##TYPE, 9.0); \ + init##TYPE (&g10##TYPE, 10.0); \ + init##TYPE (&g11##TYPE, 11.0); \ + init##TYPE (&g12##TYPE, 12.0); \ + init##TYPE (&g13##TYPE, 13.0); \ + init##TYPE (&g14##TYPE, 14.0); \ + init##TYPE (&g15##TYPE, 15.0); \ + init##TYPE (&g16##TYPE, 16.0); \ + checkg##TYPE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##TYPE (); \ + check##TYPE (rslt, 1.0); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##TYPE (g01##TYPE); \ + check##TYPE (rslt, 1.0); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + rslt = testva##TYPE (1, g01##TYPE); \ + check##TYPE (rslt, 1.0); \ + rslt = testva##TYPE (5, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE); \ + check##TYPE (rslt, 5.0); \ + rslt = testva##TYPE (9, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE); \ + check##TYPE (rslt, 9.0); \ + rslt = testva##TYPE (16, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE, g10##TYPE, \ + g11##TYPE, g12##TYPE, \ + g13##TYPE, g14##TYPE, \ + g15##TYPE, g16##TYPE); \ + check##TYPE (rslt, 16.0); \ + DEBUG_NL; \ +} + +#include "fp2-struct-defs.h" +#include "fp2-struct-check.h" + +T(Sfd) +T(Sfl) +T(Sdf) +T(Sdl) +T(Slf) +T(Sld) +T(Sfdl) +T(Sfld) +T(Sdfl) +T(Sdlf) +T(Slfd) +T(Sldf) + +#undef T + +void +struct_return_10_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Sfd); +T(Sfl); +T(Sdf); +T(Sdl); +T(Slf); +T(Sld); +T(Sfdl); +T(Sfld); +T(Sdfl); +T(Sdlf); +T(Slfd); +T(Sldf); + +DEBUG_FINI + +if (fails != 0) + return; + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-10_y.c b/gcc/testsuite/gcc.dg/compat/struct-return-10_y.c new file mode 100644 index 000000000..dcc0b93c1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-10_y.c @@ -0,0 +1,79 @@ +#include <stdarg.h> + +#include "compat-common.h" + + +#include "fp2-struct-defs.h" +#include "fp2-struct-init.h" + +#define T(TYPE) \ +extern TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +extern TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +extern TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +extern TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void check##TYPE (TYPE x, double y); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE (g01##TYPE, 1.0); \ + check##TYPE (g02##TYPE, 2.0); \ + check##TYPE (g03##TYPE, 3.0); \ + check##TYPE (g04##TYPE, 4.0); \ + check##TYPE (g05##TYPE, 5.0); \ + check##TYPE (g06##TYPE, 6.0); \ + check##TYPE (g07##TYPE, 7.0); \ + check##TYPE (g08##TYPE, 8.0); \ + check##TYPE (g09##TYPE, 9.0); \ + check##TYPE (g10##TYPE, 10.0); \ + check##TYPE (g11##TYPE, 11.0); \ + check##TYPE (g12##TYPE, 12.0); \ + check##TYPE (g13##TYPE, 13.0); \ + check##TYPE (g14##TYPE, 14.0); \ + check##TYPE (g15##TYPE, 15.0); \ + check##TYPE (g16##TYPE, 16.0); \ +} \ + \ +TYPE \ +test0##TYPE (void) \ +{ \ + return g01##TYPE; \ +} \ + \ +TYPE \ +test1##TYPE (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + if (1) \ + { \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + { \ + rslt = va_arg (ap, TYPE); \ + } \ + va_end (ap); \ + } \ + return rslt; \ +} + +T(Sfd) +T(Sfl) +T(Sdf) +T(Sdl) +T(Slf) +T(Sld) +T(Sfdl) +T(Sfld) +T(Sdfl) +T(Sdlf) +T(Slfd) +T(Sldf) diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-19_main.c b/gcc/testsuite/gcc.dg/compat/struct-return-19_main.c new file mode 100644 index 000000000..65d8365ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-19_main.c @@ -0,0 +1,16 @@ +/* Test function return values. Struct members are char, int, double, + and other structs containing these types. This test was written in + response to a layout change for such structs for powerpc64-linux, + but this test only checks similar structs that are not affected by + that break in compatibility. */ + +extern void struct_return_19_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_return_19_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-19_x.c b/gcc/testsuite/gcc.dg/compat/struct-return-19_x.c new file mode 100644 index 000000000..0085a9f68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-19_x.c @@ -0,0 +1,122 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(TYPE) \ +TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void init##TYPE (TYPE *p, int i); \ +extern void checkg##TYPE (void); \ +extern TYPE test0##TYPE (void); \ +extern TYPE test1##TYPE (TYPE); \ +extern TYPE testva##TYPE (int n, ...); \ + \ +void \ +testit##TYPE (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" init: "); \ + init##TYPE (&g01##TYPE, 1); \ + init##TYPE (&g02##TYPE, 2); \ + init##TYPE (&g03##TYPE, 3); \ + init##TYPE (&g04##TYPE, 4); \ + init##TYPE (&g05##TYPE, 5); \ + init##TYPE (&g06##TYPE, 6); \ + init##TYPE (&g07##TYPE, 7); \ + init##TYPE (&g08##TYPE, 8); \ + init##TYPE (&g09##TYPE, 9); \ + init##TYPE (&g10##TYPE, 10); \ + init##TYPE (&g11##TYPE, 11); \ + init##TYPE (&g12##TYPE, 12); \ + init##TYPE (&g13##TYPE, 13); \ + init##TYPE (&g14##TYPE, 14); \ + init##TYPE (&g15##TYPE, 15); \ + init##TYPE (&g16##TYPE, 16); \ + checkg##TYPE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##TYPE (); \ + check##TYPE (rslt, 1); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##TYPE (g01##TYPE); \ + check##TYPE (rslt, 1); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##TYPE (1, g01##TYPE); \ + check##TYPE (rslt, 1); \ + rslt = testva##TYPE (5, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE); \ + check##TYPE (rslt, 5); \ + rslt = testva##TYPE (9, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE); \ + check##TYPE (rslt, 9); \ + rslt = testva##TYPE (16, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE, g10##TYPE, \ + g11##TYPE, g12##TYPE, \ + g13##TYPE, g14##TYPE, \ + g15##TYPE, g16##TYPE); \ + check##TYPE (rslt, 16); \ + } \ + DEBUG_NL; \ +} + +#include "mixed-struct-defs.h" +#include "mixed-struct-check.h" + +T(Scdc) +T(Sd) +T(Sdi) +T(Scsdsc) +T(Scsdis) +T(Scsdisc) +T(Ssds) +T(Ssdsc) +T(Scssdssc) + +#undef T + +void +struct_return_19_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Scdc) +T(Sd) +T(Sdi) +T(Scsdsc) +T(Scsdis) +T(Scsdisc) +T(Ssds) +T(Ssdsc) +T(Scssdssc) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-19_y.c b/gcc/testsuite/gcc.dg/compat/struct-return-19_y.c new file mode 100644 index 000000000..6bbbb62cf --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-19_y.c @@ -0,0 +1,70 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#include "mixed-struct-defs.h" +#include "mixed-struct-init.h" + +#define T(TYPE) \ +extern TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +extern TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +extern TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +extern TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void check##TYPE (TYPE x, int i); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE (g01##TYPE, 1); \ + check##TYPE (g02##TYPE, 2); \ + check##TYPE (g03##TYPE, 3); \ + check##TYPE (g04##TYPE, 4); \ + check##TYPE (g05##TYPE, 5); \ + check##TYPE (g06##TYPE, 6); \ + check##TYPE (g07##TYPE, 7); \ + check##TYPE (g08##TYPE, 8); \ + check##TYPE (g09##TYPE, 9); \ + check##TYPE (g10##TYPE, 10); \ + check##TYPE (g11##TYPE, 11); \ + check##TYPE (g12##TYPE, 12); \ + check##TYPE (g13##TYPE, 13); \ + check##TYPE (g14##TYPE, 14); \ + check##TYPE (g15##TYPE, 15); \ + check##TYPE (g16##TYPE, 16); \ +} \ + \ +TYPE \ +test0##TYPE (void) \ +{ \ + return g01##TYPE; \ +} \ + \ +TYPE \ +test1##TYPE (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +T(Scdc) +T(Sd) +T(Sdi) +T(Scsdsc) +T(Scsdis) +T(Scsdisc) +T(Ssds) +T(Ssdsc) +T(Scssdssc) diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-20_main.c b/gcc/testsuite/gcc.dg/compat/struct-return-20_main.c new file mode 100644 index 000000000..7f928ba82 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-20_main.c @@ -0,0 +1,14 @@ +/* Test function return values. Tested structs end with double. This + was written in response to a layout change for such structs for + powerpc64-linux that breaks compatibility between 3.3 and 3.4. */ + +extern void struct_return_20_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_return_20_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-20_x.c b/gcc/testsuite/gcc.dg/compat/struct-return-20_x.c new file mode 100644 index 000000000..be7139f7d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-20_x.c @@ -0,0 +1,110 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(TYPE) \ +TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void init##TYPE (TYPE *p, int i); \ +extern void checkg##TYPE (void); \ +extern TYPE test0##TYPE (void); \ +extern TYPE test1##TYPE (TYPE); \ +extern TYPE testva##TYPE (int n, ...); \ + \ +void \ +testit##TYPE (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" init: "); \ + init##TYPE (&g01##TYPE, 1); \ + init##TYPE (&g02##TYPE, 2); \ + init##TYPE (&g03##TYPE, 3); \ + init##TYPE (&g04##TYPE, 4); \ + init##TYPE (&g05##TYPE, 5); \ + init##TYPE (&g06##TYPE, 6); \ + init##TYPE (&g07##TYPE, 7); \ + init##TYPE (&g08##TYPE, 8); \ + init##TYPE (&g09##TYPE, 9); \ + init##TYPE (&g10##TYPE, 10); \ + init##TYPE (&g11##TYPE, 11); \ + init##TYPE (&g12##TYPE, 12); \ + init##TYPE (&g13##TYPE, 13); \ + init##TYPE (&g14##TYPE, 14); \ + init##TYPE (&g15##TYPE, 15); \ + init##TYPE (&g16##TYPE, 16); \ + checkg##TYPE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##TYPE (); \ + check##TYPE (rslt, 1); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##TYPE (g01##TYPE); \ + check##TYPE (rslt, 1); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##TYPE (1, g01##TYPE); \ + check##TYPE (rslt, 1); \ + rslt = testva##TYPE (5, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE); \ + check##TYPE (rslt, 5); \ + rslt = testva##TYPE (9, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE); \ + check##TYPE (rslt, 9); \ + rslt = testva##TYPE (16, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE, g10##TYPE, \ + g11##TYPE, g12##TYPE, \ + g13##TYPE, g14##TYPE, \ + g15##TYPE, g16##TYPE); \ + check##TYPE (rslt, 16); \ + } \ + DEBUG_NL; \ +} + +#include "mixed-struct-defs.h" +#include "mixed-struct-check.h" + +T(Scd) +T(Scsds) +T(Scssdss) + +#undef T + +void +struct_return_20_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Scd) +T(Scsds) +T(Scssdss) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-20_y.c b/gcc/testsuite/gcc.dg/compat/struct-return-20_y.c new file mode 100644 index 000000000..2c1c33426 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-20_y.c @@ -0,0 +1,64 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#include "mixed-struct-defs.h" +#include "mixed-struct-init.h" + +#define T(TYPE) \ +extern TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +extern TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +extern TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +extern TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void check##TYPE (TYPE x, int i); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE (g01##TYPE, 1); \ + check##TYPE (g02##TYPE, 2); \ + check##TYPE (g03##TYPE, 3); \ + check##TYPE (g04##TYPE, 4); \ + check##TYPE (g05##TYPE, 5); \ + check##TYPE (g06##TYPE, 6); \ + check##TYPE (g07##TYPE, 7); \ + check##TYPE (g08##TYPE, 8); \ + check##TYPE (g09##TYPE, 9); \ + check##TYPE (g10##TYPE, 10); \ + check##TYPE (g11##TYPE, 11); \ + check##TYPE (g12##TYPE, 12); \ + check##TYPE (g13##TYPE, 13); \ + check##TYPE (g14##TYPE, 14); \ + check##TYPE (g15##TYPE, 15); \ + check##TYPE (g16##TYPE, 16); \ +} \ + \ +TYPE \ +test0##TYPE (void) \ +{ \ + return g01##TYPE; \ +} \ + \ +TYPE \ +test1##TYPE (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +T(Scd) +T(Scsds) +T(Scssdss) diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-21_main.c b/gcc/testsuite/gcc.dg/compat/struct-return-21_main.c new file mode 100644 index 000000000..34e0ab429 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-21_main.c @@ -0,0 +1,13 @@ +/* Test function return values. This was written when correcting + a deviation from the ABI on SPARC64 between 3.3 and 3.4. */ + +extern void struct_return_21_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_return_21_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-21_x.c b/gcc/testsuite/gcc.dg/compat/struct-return-21_x.c new file mode 100644 index 000000000..721deff03 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-21_x.c @@ -0,0 +1,112 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(TYPE) \ +TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void init##TYPE (TYPE *p, int i); \ +extern void checkg##TYPE (void); \ +extern TYPE test0##TYPE (void); \ +extern TYPE test1##TYPE (TYPE); \ +extern TYPE testva##TYPE (int n, ...); \ + \ +void \ +testit##TYPE (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" init: "); \ + init##TYPE (&g01##TYPE, 1); \ + init##TYPE (&g02##TYPE, 2); \ + init##TYPE (&g03##TYPE, 3); \ + init##TYPE (&g04##TYPE, 4); \ + init##TYPE (&g05##TYPE, 5); \ + init##TYPE (&g06##TYPE, 6); \ + init##TYPE (&g07##TYPE, 7); \ + init##TYPE (&g08##TYPE, 8); \ + init##TYPE (&g09##TYPE, 9); \ + init##TYPE (&g10##TYPE, 10); \ + init##TYPE (&g11##TYPE, 11); \ + init##TYPE (&g12##TYPE, 12); \ + init##TYPE (&g13##TYPE, 13); \ + init##TYPE (&g14##TYPE, 14); \ + init##TYPE (&g15##TYPE, 15); \ + init##TYPE (&g16##TYPE, 16); \ + checkg##TYPE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##TYPE (); \ + check##TYPE (rslt, 1); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##TYPE (g01##TYPE); \ + check##TYPE (rslt, 1); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##TYPE (1, g01##TYPE); \ + check##TYPE (rslt, 1); \ + rslt = testva##TYPE (5, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE); \ + check##TYPE (rslt, 5); \ + rslt = testva##TYPE (9, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE); \ + check##TYPE (rslt, 9); \ + rslt = testva##TYPE (16, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE, g10##TYPE, \ + g11##TYPE, g12##TYPE, \ + g13##TYPE, g14##TYPE, \ + g15##TYPE, g16##TYPE); \ + check##TYPE (rslt, 16); \ + } \ + DEBUG_NL; \ +} + +#include "mixed-struct-defs.h" +#include "mixed-struct-check.h" + +T(Sfi) +T(Sfii) +T(Sfifi) +T(Sfiifii) + +#undef T + +void +struct_return_21_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Sfi) +T(Sfii) +T(Sfifi) +T(Sfiifii) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-21_y.c b/gcc/testsuite/gcc.dg/compat/struct-return-21_y.c new file mode 100644 index 000000000..b44d7f58e --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-21_y.c @@ -0,0 +1,65 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#include "mixed-struct-defs.h" +#include "mixed-struct-init.h" + +#define T(TYPE) \ +extern TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +extern TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +extern TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +extern TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void check##TYPE (TYPE x, int i); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE (g01##TYPE, 1); \ + check##TYPE (g02##TYPE, 2); \ + check##TYPE (g03##TYPE, 3); \ + check##TYPE (g04##TYPE, 4); \ + check##TYPE (g05##TYPE, 5); \ + check##TYPE (g06##TYPE, 6); \ + check##TYPE (g07##TYPE, 7); \ + check##TYPE (g08##TYPE, 8); \ + check##TYPE (g09##TYPE, 9); \ + check##TYPE (g10##TYPE, 10); \ + check##TYPE (g11##TYPE, 11); \ + check##TYPE (g12##TYPE, 12); \ + check##TYPE (g13##TYPE, 13); \ + check##TYPE (g14##TYPE, 14); \ + check##TYPE (g15##TYPE, 15); \ + check##TYPE (g16##TYPE, 16); \ +} \ + \ +TYPE \ +test0##TYPE (void) \ +{ \ + return g01##TYPE; \ +} \ + \ +TYPE \ +test1##TYPE (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +T(Sfi) +T(Sfii) +T(Sfifi) +T(Sfiifii) diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-2_main.c b/gcc/testsuite/gcc.dg/compat/struct-return-2_main.c new file mode 100644 index 000000000..22a1f6ef7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-2_main.c @@ -0,0 +1,13 @@ +/* Test function return values. This test includes structs that are + arrays of unsigned integral scalars. */ + +extern void struct_return_2_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_return_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-2_x.c b/gcc/testsuite/gcc.dg/compat/struct-return-2_x.c new file mode 100644 index 000000000..590c30aa9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-2_x.c @@ -0,0 +1,229 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#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 struct S##NAME##N test0##NAME##N (void); \ +extern struct S##NAME##N test1##NAME##N (struct S##NAME##N); \ +extern struct S##NAME##N testva##NAME##N (int n, ...); \ + \ +void \ +check##NAME##N (struct S##NAME##N *p, int i) \ +{ \ + int j; \ + DEBUG_DOT; \ + for (j = 0; j < N; j++) \ + if (p->i[j] != (TYPE) (i + j)) \ + { \ + DEBUG_FAIL; \ + } \ +} \ + \ +void \ +testit##NAME##N (void) \ +{ \ + struct S##NAME##N rslt; \ + DEBUG_FPUTS (#NAME "[" #N "]"); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#NAME "[" #N "]"); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##NAME##N (); \ + check##NAME##N (&rslt, 1*16); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME "[" #N "]"); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##NAME##N (g1s##NAME##N); \ + check##NAME##N (&rslt, 1*16); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME "[" #N "]"); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##NAME##N (1, g1s##NAME##N); \ + check##NAME##N (&rslt, 1*16); \ + rslt = testva##NAME##N (5, \ + g1s##NAME##N, g2s##NAME##N, \ + g3s##NAME##N, g4s##NAME##N, \ + g5s##NAME##N); \ + check##NAME##N (&rslt, 5*16); \ + rslt = testva##NAME##N (9, \ + 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); \ + check##NAME##N (&rslt, 9*16); \ + rslt = 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); \ + check##NAME##N (&rslt, 16*16); \ + } \ + DEBUG_NL; \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0, uc, unsigned char) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, us, unsigned short) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, ui, unsigned int) +#endif +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_return_2_x () +{ +DEBUG_INIT + +#define T(N, NAME, TYPE) testit##NAME##N (); + +#ifndef SKIP_ZERO_ARRAY +T(0, uc, unsigned char) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, us, unsigned short) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, ui, unsigned int) +#endif +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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-2_y.c b/gcc/testsuite/gcc.dg/compat/struct-return-2_y.c new file mode 100644 index 000000000..7d7df8ef6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-2_y.c @@ -0,0 +1,126 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#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); \ + \ +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); \ +} \ + \ +struct S##NAME##N \ +test0##NAME##N (void) \ +{ \ + return g1s##NAME##N; \ +} \ + \ +struct S##NAME##N \ +test1##NAME##N (struct S##NAME##N x01) \ +{ \ + return x01; \ +} \ + \ +struct S##NAME##N \ +testva##NAME##N (int n, ...) \ +{ \ + int i; \ + struct S##NAME##N rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, struct S##NAME##N); \ + va_end (ap); \ + return rslt; \ +} + +#ifndef SKIP_ZERO_ARRAY +T(0, uc, unsigned char) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, us, unsigned short) +#endif +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) +#ifndef SKIP_ZERO_ARRAY +T(0, ui, unsigned int) +#endif +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) diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-3_main.c b/gcc/testsuite/gcc.dg/compat/struct-return-3_main.c new file mode 100644 index 000000000..83f0d119a --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-3_main.c @@ -0,0 +1,14 @@ +/* Test function return values. For this test, all struct members are + scalar integral types and the structs are "small": 1, 2, 4, 8, and 12 + bytes for LP64. */ + +extern void struct_return_3_x (void); +extern void exit (int); +int fails; + +int +main () +{ + struct_return_3_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-3_x.c b/gcc/testsuite/gcc.dg/compat/struct-return-3_x.c new file mode 100644 index 000000000..e985f91e4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-3_x.c @@ -0,0 +1,134 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(TYPE) \ +TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void init##TYPE (TYPE *p, int i); \ +extern void checkg##TYPE (void); \ +extern TYPE test0##TYPE (void); \ +extern TYPE test1##TYPE (TYPE); \ +extern TYPE testva##TYPE (int n, ...); \ + \ +void \ +testit##TYPE (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" init: "); \ + init##TYPE (&g01##TYPE, 1); \ + init##TYPE (&g02##TYPE, 2); \ + init##TYPE (&g03##TYPE, 3); \ + init##TYPE (&g04##TYPE, 4); \ + init##TYPE (&g05##TYPE, 5); \ + init##TYPE (&g06##TYPE, 6); \ + init##TYPE (&g07##TYPE, 7); \ + init##TYPE (&g08##TYPE, 8); \ + init##TYPE (&g09##TYPE, 9); \ + init##TYPE (&g10##TYPE, 10); \ + init##TYPE (&g11##TYPE, 11); \ + init##TYPE (&g12##TYPE, 12); \ + init##TYPE (&g13##TYPE, 13); \ + init##TYPE (&g14##TYPE, 14); \ + init##TYPE (&g15##TYPE, 15); \ + init##TYPE (&g16##TYPE, 16); \ + checkg##TYPE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##TYPE (); \ + check##TYPE (rslt, 1); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##TYPE (g01##TYPE); \ + check##TYPE (rslt, 1); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##TYPE (1, g01##TYPE); \ + check##TYPE (rslt, 1); \ + rslt = testva##TYPE (5, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE); \ + check##TYPE (rslt, 5); \ + rslt = testva##TYPE (9, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE); \ + check##TYPE (rslt, 9); \ + rslt = testva##TYPE (16, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE, g10##TYPE, \ + g11##TYPE, g12##TYPE, \ + g13##TYPE, g14##TYPE, \ + g15##TYPE, g16##TYPE); \ + check##TYPE (rslt, 16); \ + } \ + DEBUG_NL; \ +} + +#include "small-struct-defs.h" +#include "small-struct-check.h" + +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_return_3_x () +{ +DEBUG_INIT + +#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) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/struct-return-3_y.c b/gcc/testsuite/gcc.dg/compat/struct-return-3_y.c new file mode 100644 index 000000000..dbd471351 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/struct-return-3_y.c @@ -0,0 +1,76 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#include "small-struct-defs.h" +#include "small-struct-init.h" + +#define T(TYPE) \ +extern TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +extern TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +extern TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +extern TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void check##TYPE (TYPE x, int i); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE (g01##TYPE, 1); \ + check##TYPE (g02##TYPE, 2); \ + check##TYPE (g03##TYPE, 3); \ + check##TYPE (g04##TYPE, 4); \ + check##TYPE (g05##TYPE, 5); \ + check##TYPE (g06##TYPE, 6); \ + check##TYPE (g07##TYPE, 7); \ + check##TYPE (g08##TYPE, 8); \ + check##TYPE (g09##TYPE, 9); \ + check##TYPE (g10##TYPE, 10); \ + check##TYPE (g11##TYPE, 11); \ + check##TYPE (g12##TYPE, 12); \ + check##TYPE (g13##TYPE, 13); \ + check##TYPE (g14##TYPE, 14); \ + check##TYPE (g15##TYPE, 15); \ + check##TYPE (g16##TYPE, 16); \ +} \ + \ +TYPE \ +test0##TYPE (void) \ +{ \ + return g01##TYPE; \ +} \ + \ +TYPE \ +test1##TYPE (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +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) diff --git a/gcc/testsuite/gcc.dg/compat/union-by-value-1_main.c b/gcc/testsuite/gcc.dg/compat/union-by-value-1_main.c new file mode 100644 index 000000000..cd9065920 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-by-value-1_main.c @@ -0,0 +1,13 @@ +/* Test function argument passing. This was written when correcting + a deviation from the ABI on SPARC64 between 3.3 and 3.4. */ + +extern void union_by_value_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + union_by_value_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/union-by-value-1_x.c b/gcc/testsuite/gcc.dg/compat/union-by-value-1_x.c new file mode 100644 index 000000000..a3efd4ed7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-by-value-1_x.c @@ -0,0 +1,180 @@ +#include "compat-common.h" + +#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); \ + DEBUG_FPUTS (" init: "); \ + 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_NL; \ + DEBUG_FPUTS (#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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##TYPE (1, \ + g1s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (2, \ + g1s##TYPE, g2s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (3, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (4, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (5, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (6, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (7, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (8, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (9, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE); \ + DEBUG_NL; \ + testva##TYPE (10, \ + g1s##TYPE, g2s##TYPE, g3s##TYPE, g4s##TYPE, \ + g5s##TYPE, g6s##TYPE, g7s##TYPE, g8s##TYPE, \ + g9s##TYPE, g10s##TYPE); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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); \ + DEBUG_NL; \ + 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_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test2:"); \ + test2_##TYPE (g1s##TYPE, g3s##TYPE, g5s##TYPE, g7s##TYPE, \ + g9s##TYPE, g11s##TYPE, g13s##TYPE, g15s##TYPE); \ + DEBUG_NL; \ +} + +#include "union-defs.h" +#include "union-check.h" + +T(Ucs) +T(Uci) +T(Ucl) +T(Ucll) +T(Usi) +T(Usl) +T(Usll) +T(Uil) +T(Uill) +T(Ulll) + +#undef T + +void +union_by_value_1_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Ucs) +T(Uci) +T(Ucl) +T(Ucll) +T(Usi) +T(Usl) +T(Usll) +T(Uil) +T(Uill) +T(Ulll) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/union-by-value-1_y.c b/gcc/testsuite/gcc.dg/compat/union-by-value-1_y.c new file mode 100644 index 000000000..b17613e99 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-by-value-1_y.c @@ -0,0 +1,92 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#include "union-defs.h" +#include "union-init.h" + +#define T(TYPE) \ +extern void check##TYPE (TYPE x, int i); \ +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) \ +{ \ + check##TYPE (s1, 1); \ + check##TYPE (s2, 2); \ + check##TYPE (s3, 3); \ + check##TYPE (s4, 4); \ + check##TYPE (s5, 5); \ + check##TYPE (s6, 6); \ + check##TYPE (s7, 7); \ + check##TYPE (s8, 8); \ + check##TYPE (s9, 9); \ + check##TYPE (s10, 10); \ + check##TYPE (s11, 11); \ + check##TYPE (s12, 12); \ + check##TYPE (s13, 13); \ + check##TYPE (s14, 14); \ + check##TYPE (s15, 15); \ + 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); \ + check##TYPE (t, i+1); \ + } \ + va_end (ap); \ + } \ +} + +T(Ucs) +T(Uci) +T(Ucl) +T(Ucll) +T(Usi) +T(Usl) +T(Usll) +T(Uil) +T(Uill) +T(Ulll) diff --git a/gcc/testsuite/gcc.dg/compat/union-check.h b/gcc/testsuite/gcc.dg/compat/union-check.h new file mode 100644 index 000000000..b5157814d --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-check.h @@ -0,0 +1,34 @@ +/* Function definitions that are used by multiple tests. */ + +#define CHECK_CHAR(TYPE) \ + void check##TYPE (TYPE p, int i) \ + { if (p.c != (char)i) DEBUG_CHECK } + +CHECK_CHAR(Ucs) +CHECK_CHAR(Uci) +CHECK_CHAR(Ucl) +CHECK_CHAR(Ucll) + + +#define CHECK_SHORT(TYPE) \ + void check##TYPE (TYPE p, int i) \ + { if (p.s != (short)i) DEBUG_CHECK } + +CHECK_SHORT(Usi) +CHECK_SHORT(Usl) +CHECK_SHORT(Usll) + + +#define CHECK_INT(TYPE) \ + void check##TYPE (TYPE p, int i) \ + { if (p.i != i) DEBUG_CHECK } + +CHECK_INT(Uil) +CHECK_INT(Uill) + + +#define CHECK_LONG(TYPE) \ + void check##TYPE (TYPE p, int i) \ + { if (p.l != (long)i) DEBUG_CHECK } + +CHECK_LONG(Ulll) diff --git a/gcc/testsuite/gcc.dg/compat/union-defs.h b/gcc/testsuite/gcc.dg/compat/union-defs.h new file mode 100644 index 000000000..887cd6da8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-defs.h @@ -0,0 +1,15 @@ +/* Type definitions that are used by multiple tests. */ + +typedef union { char c; short s; } Ucs; +typedef union { char c; int i; } Uci; +typedef union { char c; long l; } Ucl; +typedef union { char c; long long ll; } Ucll; + +typedef union { short s; int i; } Usi; +typedef union { short s; long l; } Usl; +typedef union { short s; long long ll; } Usll; + +typedef union { int i; long l; } Uil; +typedef union { int i; long long ll; } Uill; + +typedef union { long l; long long ll; } Ulll; diff --git a/gcc/testsuite/gcc.dg/compat/union-init.h b/gcc/testsuite/gcc.dg/compat/union-init.h new file mode 100644 index 000000000..5add7b4a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-init.h @@ -0,0 +1,34 @@ +/* Function definitions that are used by multiple tests. */ + +#define INIT_CHAR(TYPE) \ + void init##TYPE (TYPE *p, int i) \ + { p->c = (char)i; } + +INIT_CHAR(Ucs) +INIT_CHAR(Uci) +INIT_CHAR(Ucl) +INIT_CHAR(Ucll) + + +#define INIT_SHORT(TYPE) \ + void init##TYPE (TYPE *p, int i) \ + { p->s = (short)i; } + +INIT_SHORT(Usi) +INIT_SHORT(Usl) +INIT_SHORT(Usll) + + +#define INIT_INT(TYPE) \ + void init##TYPE (TYPE *p, int i) \ + { p->i = i; } + +INIT_INT(Uil) +INIT_INT(Uill) + + +#define INIT_LONG(TYPE) \ + void init##TYPE (TYPE *p, int i) \ + { p->l = (long)i; } + +INIT_LONG(Ulll) diff --git a/gcc/testsuite/gcc.dg/compat/union-m128-1.h b/gcc/testsuite/gcc.dg/compat/union-m128-1.h new file mode 100644 index 000000000..56d80cbfb --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-m128-1.h @@ -0,0 +1,17 @@ +#include <xmmintrin.h> + +typedef struct +{ + __m128 x; +} SS_struct_mi128; + +typedef union +{ + __m128 x; +} SS_union_mi128; + +typedef union +{ + __m128 x; + unsigned long long u[2]; +} union_mi128; diff --git a/gcc/testsuite/gcc.dg/compat/union-m128-1_main.c b/gcc/testsuite/gcc.dg/compat/union-m128-1_main.c new file mode 100644 index 000000000..59e68d96c --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-m128-1_main.c @@ -0,0 +1,15 @@ +/* { dg-skip-if "test SSE2 support" { ! { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O" } */ +/* { dg-require-effective-target sse2_runtime } */ + +/* Test function argument passing. PR target/15301. */ + +extern void union_m128_1_x (void); +extern void exit (int); + +int +main () +{ + union_m128_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/union-m128-1_x.c b/gcc/testsuite/gcc.dg/compat/union-m128-1_x.c new file mode 100644 index 000000000..1f92303d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-m128-1_x.c @@ -0,0 +1,24 @@ +/* { dg-options "-O -msse2" } */ + +#include "union-m128-1.h" + +SS_union_mi128 un; +SS_struct_mi128 st; + +extern void bar (); +extern void foo (); + +void +union_m128_1_x () +{ + union_mi128 x; + + x.u [0] = 0x123456789abcedf0LL; + x.u [1] = 0xfedcba9876543210LL; + un.x = x.x; + st.x = x.x; + bar(un); + bar(st); + foo(un); + foo(st); +} diff --git a/gcc/testsuite/gcc.dg/compat/union-m128-1_y.c b/gcc/testsuite/gcc.dg/compat/union-m128-1_y.c new file mode 100644 index 000000000..be9d6e8f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-m128-1_y.c @@ -0,0 +1,27 @@ +/* { dg-options "-O -msse2" } */ + +#include <stdlib.h> + +#include "union-m128-1.h" + +void +bar (SS_union_mi128 un) +{ + union_mi128 x; + + x.x = un.x; + if (x.u [0] != 0x123456789abcedf0LL + || x.u [1] != 0xfedcba9876543210LL) + abort (); +} + +void +foo (SS_struct_mi128 st) +{ + union_mi128 x; + + x.x = st.x; + if (x.u [0] != 0x123456789abcedf0LL + || x.u [1] != 0xfedcba9876543210LL) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/compat/union-return-1_main.c b/gcc/testsuite/gcc.dg/compat/union-return-1_main.c new file mode 100644 index 000000000..edf15166b --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-return-1_main.c @@ -0,0 +1,13 @@ +/* Test function return values. This was written when correcting + a deviation from the ABI on SPARC64 between 3.3 and 3.4. */ + +extern void union_return_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + union_return_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/union-return-1_x.c b/gcc/testsuite/gcc.dg/compat/union-return-1_x.c new file mode 100644 index 000000000..761f000aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-return-1_x.c @@ -0,0 +1,124 @@ +#include "compat-common.h" + +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + +#define T(TYPE) \ +TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void init##TYPE (TYPE *p, int i); \ +extern void checkg##TYPE (void); \ +extern TYPE test0##TYPE (void); \ +extern TYPE test1##TYPE (TYPE); \ +extern TYPE testva##TYPE (int n, ...); \ + \ +void \ +testit##TYPE (void) \ +{ \ + TYPE rslt; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" init: "); \ + init##TYPE (&g01##TYPE, 1); \ + init##TYPE (&g02##TYPE, 2); \ + init##TYPE (&g03##TYPE, 3); \ + init##TYPE (&g04##TYPE, 4); \ + init##TYPE (&g05##TYPE, 5); \ + init##TYPE (&g06##TYPE, 6); \ + init##TYPE (&g07##TYPE, 7); \ + init##TYPE (&g08##TYPE, 8); \ + init##TYPE (&g09##TYPE, 9); \ + init##TYPE (&g10##TYPE, 10); \ + init##TYPE (&g11##TYPE, 11); \ + init##TYPE (&g12##TYPE, 12); \ + init##TYPE (&g13##TYPE, 13); \ + init##TYPE (&g14##TYPE, 14); \ + init##TYPE (&g15##TYPE, 15); \ + init##TYPE (&g16##TYPE, 16); \ + checkg##TYPE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test0: "); \ + rslt = test0##TYPE (); \ + check##TYPE (rslt, 1); \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" test1: "); \ + rslt = test1##TYPE (g01##TYPE); \ + check##TYPE (rslt, 1); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#TYPE); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##TYPE (1, g01##TYPE); \ + check##TYPE (rslt, 1); \ + rslt = testva##TYPE (5, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE); \ + check##TYPE (rslt, 5); \ + rslt = testva##TYPE (9, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE); \ + check##TYPE (rslt, 9); \ + rslt = testva##TYPE (16, g01##TYPE, g02##TYPE, \ + g03##TYPE, g04##TYPE, \ + g05##TYPE, g06##TYPE, \ + g07##TYPE, g08##TYPE, \ + g09##TYPE, g10##TYPE, \ + g11##TYPE, g12##TYPE, \ + g13##TYPE, g14##TYPE, \ + g15##TYPE, g16##TYPE); \ + check##TYPE (rslt, 16); \ + } \ + DEBUG_NL; \ +} + +#include "union-defs.h" +#include "union-check.h" + +T(Ucs) +T(Uci) +T(Ucl) +T(Ucll) +T(Usi) +T(Usl) +T(Usll) +T(Uil) +T(Uill) +T(Ulll) + +#undef T + +void +union_return_1_x () +{ +DEBUG_INIT + +#define T(TYPE) testit##TYPE (); + +T(Ucs) +T(Uci) +T(Ucl) +T(Ucll) +T(Usi) +T(Usl) +T(Usll) +T(Uil) +T(Uill) +T(Ulll) + +DEBUG_FINI + +if (fails != 0) + abort (); + +#undef T +} diff --git a/gcc/testsuite/gcc.dg/compat/union-return-1_y.c b/gcc/testsuite/gcc.dg/compat/union-return-1_y.c new file mode 100644 index 000000000..9eaa9777e --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/union-return-1_y.c @@ -0,0 +1,71 @@ +#include <stdarg.h> + +#include "compat-common.h" + +#include "union-defs.h" +#include "union-init.h" + +#define T(TYPE) \ +extern TYPE g01##TYPE, g02##TYPE, g03##TYPE, g04##TYPE; \ +extern TYPE g05##TYPE, g06##TYPE, g07##TYPE, g08##TYPE; \ +extern TYPE g09##TYPE, g10##TYPE, g11##TYPE, g12##TYPE; \ +extern TYPE g13##TYPE, g14##TYPE, g15##TYPE, g16##TYPE; \ + \ +extern void check##TYPE (TYPE x, int i); \ + \ +void \ +checkg##TYPE (void) \ +{ \ + check##TYPE (g01##TYPE, 1); \ + check##TYPE (g02##TYPE, 2); \ + check##TYPE (g03##TYPE, 3); \ + check##TYPE (g04##TYPE, 4); \ + check##TYPE (g05##TYPE, 5); \ + check##TYPE (g06##TYPE, 6); \ + check##TYPE (g07##TYPE, 7); \ + check##TYPE (g08##TYPE, 8); \ + check##TYPE (g09##TYPE, 9); \ + check##TYPE (g10##TYPE, 10); \ + check##TYPE (g11##TYPE, 11); \ + check##TYPE (g12##TYPE, 12); \ + check##TYPE (g13##TYPE, 13); \ + check##TYPE (g14##TYPE, 14); \ + check##TYPE (g15##TYPE, 15); \ + check##TYPE (g16##TYPE, 16); \ +} \ + \ +TYPE \ +test0##TYPE (void) \ +{ \ + return g01##TYPE; \ +} \ + \ +TYPE \ +test1##TYPE (TYPE x01) \ +{ \ + return x01; \ +} \ + \ +TYPE \ +testva##TYPE (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ +} + +T(Ucs) +T(Uci) +T(Ucl) +T(Ucll) +T(Usi) +T(Usl) +T(Usll) +T(Uil) +T(Uill) +T(Ulll) diff --git a/gcc/testsuite/gcc.dg/compat/vector-1_main.c b/gcc/testsuite/gcc.dg/compat/vector-1_main.c new file mode 100644 index 000000000..6c995e7c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1_main.c @@ -0,0 +1,14 @@ +/* Test compatibility of vector types: layout between separately-compiled + modules, parameter passing, and function return. This test uses + vectors of integer values. */ + +extern void vector_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + vector_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-1_x.c b/gcc/testsuite/gcc.dg/compat/vector-1_x.c new file mode 100644 index 000000000..29a8170d1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1_x.c @@ -0,0 +1,51 @@ +/* { dg-options "-w" } */ +/* { dg-options "-w -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */ + +#ifndef SKIP_ATTRIBUTE + +#include "compat-common.h" +#include "vector-defs.h" +#include "vector-setup.h" + +SETUP (8, qi); +SETUP (16, qi); +SETUP (32, qi); +SETUP (2, hi); +SETUP (4, hi); +SETUP (8, hi); +SETUP (16, hi); +SETUP (2, si); +SETUP (4, si); +SETUP (8, si); +SETUP (1, di); +SETUP (2, di); +SETUP (4, di); + +#endif + +void +vector_1_x (void) +{ +#ifndef SKIP_ATTRIBUTE + DEBUG_INIT + + CHECK (8, qi); + CHECK (16, qi); + CHECK (32, qi); + CHECK (2, hi); + CHECK (4, hi); + CHECK (8, hi); + CHECK (16, hi); + CHECK (2, si); + CHECK (4, si); + CHECK (8, si); + CHECK (1, di); + CHECK (2, di); + CHECK (4, di); + + DEBUG_FINI + + if (fails != 0) + abort (); +#endif +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-1_y.c b/gcc/testsuite/gcc.dg/compat/vector-1_y.c new file mode 100644 index 000000000..284b98c71 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1_y.c @@ -0,0 +1,24 @@ +/* { dg-options "-w" } */ +/* { dg-options "-w -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */ + +#ifndef SKIP_ATTRIBUTE + +#include "compat-common.h" +#include "vector-defs.h" +#include "vector-check.h" + +TEST (8, qi, 101) +TEST (16, qi, 101) +TEST (32, qi, 90) +TEST (2, hi, 201) +TEST (4, hi, 202) +TEST (8, hi, 203) +TEST (16, hi, 203) +TEST (2, si, 301) +TEST (4, si, 302) +TEST (8, si, 303) +TEST (1, di, 401) +TEST (2, di, 402) +TEST (4, di, 403) + +#endif diff --git a/gcc/testsuite/gcc.dg/compat/vector-1a_main.c b/gcc/testsuite/gcc.dg/compat/vector-1a_main.c new file mode 100644 index 000000000..608f5dd9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1a_main.c @@ -0,0 +1,17 @@ +/* { dg-skip-if "test SSE2 vector" { ! { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse2_runtime } */ + +/* Test compatibility of vector types: layout between separately-compiled + modules, parameter passing, and function return. This test uses + vectors of integer values. */ + +extern void vector_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + vector_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-1a_x.c b/gcc/testsuite/gcc.dg/compat/vector-1a_x.c new file mode 100644 index 000000000..1d39cec31 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1a_x.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -msse2" } */ + +#include "vector-1_x.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-1a_y.c b/gcc/testsuite/gcc.dg/compat/vector-1a_y.c new file mode 100644 index 000000000..53b1a7ffe --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1a_y.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -msse2" } */ + +#include "vector-1_y.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-1b_main.c b/gcc/testsuite/gcc.dg/compat/vector-1b_main.c new file mode 100644 index 000000000..427e8caf3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1b_main.c @@ -0,0 +1,17 @@ +/* { dg-skip-if "test AVX vector" { ! { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target avx_runtime } */ + +/* Test compatibility of vector types: layout between separately-compiled + modules, parameter passing, and function return. This test uses + vectors of integer values. */ + +extern void vector_1_x (void); +extern void exit (int); +int fails; + +int +main () +{ + vector_1_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-1b_x.c b/gcc/testsuite/gcc.dg/compat/vector-1b_x.c new file mode 100644 index 000000000..f3f76ec39 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1b_x.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -mavx" } */ + +#include "vector-1_x.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-1b_y.c b/gcc/testsuite/gcc.dg/compat/vector-1b_y.c new file mode 100644 index 000000000..105282cac --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-1b_y.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -mavx" } */ + +#include "vector-1_y.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-2_main.c b/gcc/testsuite/gcc.dg/compat/vector-2_main.c new file mode 100644 index 000000000..37f36fe0e --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2_main.c @@ -0,0 +1,14 @@ +/* Test compatibility of vector types: layout between separately-compiled + modules, parameter passing, and function return. This test uses + vectors of floating points values. */ + +extern void vector_2_x (void); +extern void exit (int); +int fails; + +int +main () +{ + vector_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-2_x.c b/gcc/testsuite/gcc.dg/compat/vector-2_x.c new file mode 100644 index 000000000..899a3ab11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2_x.c @@ -0,0 +1,38 @@ +/* { dg-options "-w" } */ +/* { dg-options "-w -mno-mmx -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */ + + +#ifndef SKIP_ATTRIBUTE + +#include "compat-common.h" +#include "vector-defs.h" +#include "vector-setup.h" + +SETUP (2, sf); +SETUP (4, sf); +SETUP (16, sf); +SETUP (8, sf); +SETUP (2, df); +SETUP (4, df); + +#endif + +void +vector_2_x (void) +{ +#ifndef SKIP_ATTRIBUTE + DEBUG_INIT + + CHECK (2, sf); + CHECK (4, sf); + CHECK (8, sf); + CHECK (16, sf); + CHECK (4, df); + CHECK (2, df); + + DEBUG_FINI + + if (fails != 0) + abort (); +#endif +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-2_y.c b/gcc/testsuite/gcc.dg/compat/vector-2_y.c new file mode 100644 index 000000000..a5ab241af --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2_y.c @@ -0,0 +1,17 @@ +/* { dg-options "-w" } */ +/* { dg-options "-w -mno-mmx -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */ + +#ifndef SKIP_ATTRIBUTE + +#include "compat-common.h" +#include "vector-defs.h" +#include "vector-check.h" + +TEST (2, sf, 301.0) +TEST (4, sf, 302.0) +TEST (8, sf, 303.0) +TEST (16, sf, 304.0) +TEST (2, df, 402.0) +TEST (4, df, 402.0) + +#endif diff --git a/gcc/testsuite/gcc.dg/compat/vector-2a_main.c b/gcc/testsuite/gcc.dg/compat/vector-2a_main.c new file mode 100644 index 000000000..e957faf90 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2a_main.c @@ -0,0 +1,17 @@ +/* { dg-skip-if "test SSE2 support" { ! { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target sse2_runtime } */ + +/* Test compatibility of vector types: layout between separately-compiled + modules, parameter passing, and function return. This test uses + vectors of floating points values. */ + +extern void vector_2_x (void); +extern void exit (int); +int fails; + +int +main () +{ + vector_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-2a_x.c b/gcc/testsuite/gcc.dg/compat/vector-2a_x.c new file mode 100644 index 000000000..fb62bb8c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2a_x.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -msse2" } */ + +#include "vector-2_x.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-2a_y.c b/gcc/testsuite/gcc.dg/compat/vector-2a_y.c new file mode 100644 index 000000000..7cdd195c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2a_y.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -msse2" } */ + +#include "vector-2_y.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-2b_main.c b/gcc/testsuite/gcc.dg/compat/vector-2b_main.c new file mode 100644 index 000000000..2c1957642 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2b_main.c @@ -0,0 +1,17 @@ +/* { dg-skip-if "test AVX support" { ! { i?86-*-* x86_64-*-* } } } */ +/* { dg-require-effective-target avx_runtime } */ + +/* Test compatibility of vector types: layout between separately-compiled + modules, parameter passing, and function return. This test uses + vectors of floating points values. */ + +extern void vector_2_x (void); +extern void exit (int); +int fails; + +int +main () +{ + vector_2_x (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-2b_x.c b/gcc/testsuite/gcc.dg/compat/vector-2b_x.c new file mode 100644 index 000000000..71b36bea7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2b_x.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -mavx" } */ + +#include "vector-2_x.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-2b_y.c b/gcc/testsuite/gcc.dg/compat/vector-2b_y.c new file mode 100644 index 000000000..9c114bb14 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-2b_y.c @@ -0,0 +1,3 @@ +/* { dg-options "-w -Wno-psabi -mno-mmx -mavx" } */ + +#include "vector-2_y.c" diff --git a/gcc/testsuite/gcc.dg/compat/vector-check.h b/gcc/testsuite/gcc.dg/compat/vector-check.h new file mode 100644 index 000000000..2d586d287 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-check.h @@ -0,0 +1,64 @@ +#define TEST(NUM,TMODE,VAL) \ +extern v##NUM##TMODE g_v##NUM##TMODE; \ +extern TMODE g_##TMODE; \ + \ +extern void pass_v##NUM##TMODE (v##NUM##TMODE); \ +extern v##NUM##TMODE return_v##NUM##TMODE (void); \ + \ +void \ +checkp_##NUM##TMODE (TMODE *p) \ +{ \ + int i; \ + for (i = 0; i < NUM; i++) \ + { \ + if (p[i] != g_##TMODE + i) \ + DEBUG_CHECK; \ + } \ +} \ + \ +void \ +checkg_##NUM##TMODE (void) \ +{ \ + u##NUM##TMODE u; \ + TMODE *p = u.a; \ + \ + u.v = g_v##NUM##TMODE; \ + checkp_##NUM##TMODE (p); \ +} \ + \ +void \ +init_##NUM##TMODE (void) \ +{ \ + int i; \ + u##NUM##TMODE u; \ + g_##TMODE = VAL; \ + for (i = 0; i < NUM; i++) \ + u.a[i] = VAL + i; \ + g_v##NUM##TMODE = u.v; \ +} \ + \ +void \ +test_v##NUM##TMODE (void) \ +{ \ + v##NUM##TMODE v; \ + u##NUM##TMODE u; \ + TMODE *p = u.a; \ + \ + DEBUG_FPUTS ("v" #NUM #TMODE); \ + DEBUG_NL; \ + DEBUG_FPUTS (" global variable:"); \ + init_##NUM##TMODE (); \ + checkg_##NUM##TMODE (); \ + DEBUG_NL; \ + DEBUG_FPUTS (" pass global variable:"); \ + pass_v##NUM##TMODE (g_v##NUM##TMODE); \ + DEBUG_NL; \ + DEBUG_FPUTS (" pass local variable:"); \ + v = g_v##NUM##TMODE; \ + pass_v##NUM##TMODE (v); \ + DEBUG_NL; \ + DEBUG_FPUTS (" function return:"); \ + u.v = return_v##NUM##TMODE (); \ + checkp_##NUM##TMODE (p); \ + DEBUG_NL; \ +} diff --git a/gcc/testsuite/gcc.dg/compat/vector-defs.h b/gcc/testsuite/gcc.dg/compat/vector-defs.h new file mode 100644 index 000000000..f2f050527 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-defs.h @@ -0,0 +1,90 @@ +/* This includes all of the vector modes that are recognized by + c_common_type_for_mode. */ + +typedef int __attribute__((mode(QI))) qi; +typedef int __attribute__((mode(HI))) hi; +typedef int __attribute__((mode(SI))) si; +typedef int __attribute__((mode(DI))) di; +typedef float __attribute__((mode(SF))) sf; +#if ((__SIZEOF_DOUBLE__ >= 8) || (__SIZEOF_LONG_DOUBLE__ >= 8)) +typedef float __attribute__((mode(DF))) df; +#else +typedef float __attribute__((mode(SF))) df; +#endif + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 5) + +typedef qi __attribute__((vector_size (8))) v8qi; +typedef qi __attribute__((vector_size (16))) v16qi; + +typedef hi __attribute__((vector_size (4))) v2hi; +typedef hi __attribute__((vector_size (8))) v4hi; +typedef hi __attribute__((vector_size (16))) v8hi; + +typedef si __attribute__((vector_size (8))) v2si; +typedef si __attribute__((vector_size (16))) v4si; + +typedef di __attribute__((vector_size (8))) v1di; +typedef di __attribute__((vector_size (16))) v2di; + +typedef sf __attribute__((vector_size (8))) v2sf; +typedef sf __attribute__((vector_size (16))) v4sf; +typedef sf __attribute__((vector_size (64))) v16sf; + +typedef df __attribute__((vector_size (16))) v2df; + +#else + +typedef int __attribute__((mode(V8QI))) v8qi; +typedef int __attribute__((mode(V16QI))) v16qi; + +typedef int __attribute__((mode(V2HI))) v2hi; +typedef int __attribute__((mode(V4HI))) v4hi; +typedef int __attribute__((mode(V8HI))) v8hi; + +typedef int __attribute__((mode(V2SI))) v2si; +typedef int __attribute__((mode(V4SI))) v4si; + +typedef int __attribute__((mode(V1DI))) v1di; +typedef int __attribute__((mode(V2DI))) v2di; + +typedef float __attribute__((mode(V2SF))) v2sf; +typedef float __attribute__((mode(V4SF))) v4sf; +typedef float __attribute__((mode(V16SF))) v16sf; + +typedef float __attribute__((mode(V2DF))) v2df; + +#endif + +typedef qi __attribute__((vector_size (32))) v32qi; +typedef hi __attribute__((vector_size (32))) v16hi; +typedef si __attribute__((vector_size (32))) v8si; +typedef di __attribute__((vector_size (32))) v4di; +typedef sf __attribute__((vector_size (32))) v8sf; +typedef df __attribute__((vector_size (32))) v4df; + +typedef union U32QI { v32qi v; qi a[32]; } u32qi; +typedef union U16HI { v16hi v; hi a[16]; } u16hi; +typedef union U8SI { v8si v; si a[8]; } u8si; +typedef union U4DI { v4di v; di a[4]; } u4di; +typedef union U8SF { v8sf v; sf a[8]; } u8sf; +typedef union U4DF { v4df v; df a[4]; } u4df; + +typedef union U8QI { v8qi v; qi a[8]; } u8qi; +typedef union U16QI { v16qi v; qi a[16]; } u16qi; + +typedef union U2HI { v2hi v; hi a[2]; } u2hi; +typedef union U4HI { v4hi v; hi a[4]; } u4hi; +typedef union U8HI { v8hi v; hi a[8]; } u8hi; + +typedef union U2SI { v2si v; si a[2]; } u2si; +typedef union U4SI { v4si v; si a[4]; } u4si; + +typedef union U1DI { v1di v; di a[1]; } u1di; +typedef union U2DI { v2di v; di a[2]; } u2di; + +typedef union U2SF { v2sf v; sf a[2]; } u2sf; +typedef union U4SF { v4sf v; sf a[4]; } u4sf; +typedef union U16SF { v16sf v; sf a[16]; } u16sf; + +typedef union U2DF { v2df v; df a[2]; } u2df; diff --git a/gcc/testsuite/gcc.dg/compat/vector-setup.h b/gcc/testsuite/gcc.dg/compat/vector-setup.h new file mode 100644 index 000000000..60419f851 --- /dev/null +++ b/gcc/testsuite/gcc.dg/compat/vector-setup.h @@ -0,0 +1,28 @@ +#define SETUP(NUM,TMODE) \ +v##NUM##TMODE g_v##NUM##TMODE; \ +TMODE g_##TMODE; \ + \ +extern void test_v##NUM##TMODE (void); \ +extern void checkp_##NUM##TMODE (TMODE *); \ + \ +void \ +pass_v##NUM##TMODE (v##NUM##TMODE v) \ +{ \ + u##NUM##TMODE u; \ + int j; \ + TMODE a[NUM]; \ + \ + u.v = v; \ + for (j = 0; j < NUM; j++) \ + a[j] = u.a[j]; \ + checkp_##NUM##TMODE (a); \ +} \ + \ +v##NUM##TMODE \ +return_v##NUM##TMODE (void) \ +{ \ + return g_v##NUM##TMODE; \ +} + +#define CHECK(NUM,TMODE) \ + test_v##NUM##TMODE() |