diff options
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute')
299 files changed, 9166 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/900409-1.c b/gcc/testsuite/gcc.c-torture/execute/900409-1.c new file mode 100644 index 00000000000..3112effaf2f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/900409-1.c @@ -0,0 +1,20 @@ +long f1(long a){return a&0xff000000L;} +long f2 (long a){return a&~0xff000000L;} +long f3(long a){return a&0x000000ffL;} +long f4(long a){return a&~0x000000ffL;} +long f5(long a){return a&0x0000ffffL;} +long f6(long a){return a&~0x0000ffffL;} + +main () +{ + long a = 0x89ABCDEF; + + if (f1(a)!=0x89000000L|| + f2(a)!=0x00ABCDEFL|| + f3(a)!=0x000000EFL|| + f4(a)!=0x89ABCD00L|| + f5(a)!=0x0000CDEFL|| + f6(a)!=0x89AB0000L) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920202-1.c b/gcc/testsuite/gcc.c-torture/execute/920202-1.c new file mode 100644 index 00000000000..e30ce2fd5c2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920202-1.c @@ -0,0 +1,18 @@ +static int rule_text_needs_stack_pop = 0; +static int input_stack_pos = 1; + +f (void) +{ + rule_text_needs_stack_pop = 1; + + if (input_stack_pos <= 0) + return 1; + else + return 0; +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920302-1.c b/gcc/testsuite/gcc.c-torture/execute/920302-1.c new file mode 100644 index 00000000000..5fbfd9d1b9c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920302-1.c @@ -0,0 +1,42 @@ +short optab[5]; +char buf[10]; +execute (ip) + register unsigned short *ip; +{ +#ifndef NO_LABEL_VALUES + register void *base = &&x; + char *bp = buf; + static void *tab[] = {&&x, &&y, &&z}; + if (ip == 0) + { + int i; + for (i = 0; i < 3; ++i) + optab[i] = (short)(tab[i] - base); + return; + } +x: *bp++='x'; + goto *(base + *ip++); +y: *bp++='y'; + goto *(base + *ip++); +z: *bp++='z'; + *bp=0; + return; +#else + strcpy (buf, "xyxyz"); +#endif +} + +short p[5]; + +main () +{ + execute (0); + p[0] = optab[1]; + p[1] = optab[0]; + p[2] = optab[1]; + p[3] = optab[2]; + execute (&p); + if (strcmp (buf, "xyxyz")) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920409-1.c b/gcc/testsuite/gcc.c-torture/execute/920409-1.c new file mode 100644 index 00000000000..938ce7d92d6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920409-1.c @@ -0,0 +1 @@ +x(){signed char c=-1;return c<0;}main(){if(x()!=1)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920410-1.c b/gcc/testsuite/gcc.c-torture/execute/920410-1.c new file mode 100644 index 00000000000..f5180f06a9c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920410-1.c @@ -0,0 +1,6 @@ +#define STACK_REQUIREMENT (40000 * 4 + 256) +#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT +main () { exit (0); } +#else +main(){int d[40000];d[0]=0;exit(0);} +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/920411-1.c b/gcc/testsuite/gcc.c-torture/execute/920411-1.c new file mode 100644 index 00000000000..e3e98100108 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920411-1.c @@ -0,0 +1,24 @@ +long f (w) + char *w; +{ + long k, i, c = 0, x; + char *p = (char*) &x; + for (i = 0; i < 1; i++) + { + for (k = 0; k < sizeof (long); k++) + p[k] = w[k]; + c += x; + } + return c; +} + +main () +{ + int i; + char a[sizeof (long)]; + + for (i = sizeof (long); --i >= 0;) a[i] = ' '; + if (f (a) != ~0UL / (unsigned char) ~0 * ' ') + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920415-1.c b/gcc/testsuite/gcc.c-torture/execute/920415-1.c new file mode 100644 index 00000000000..25100ad5200 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920415-1.c @@ -0,0 +1,7 @@ +/* CYGNUS LOCAL -- meissner/no label values */ +#ifndef NO_LABEL_VALUES +main(){__label__ l;void*x(){return&&l;}goto*x();abort();return;l:exit(0);} +#else +main(){ exit (0); } +#endif +/* END CYGNUS LOCAL -- meissner/no label values */ diff --git a/gcc/testsuite/gcc.c-torture/execute/920428-1.c b/gcc/testsuite/gcc.c-torture/execute/920428-1.c new file mode 100644 index 00000000000..154af763a50 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920428-1.c @@ -0,0 +1,2 @@ +x(const char*s){char a[1];const char*ss=s;a[*s++]|=1;return(int)ss+1==(int)s;} +main(){if(x("")!=1)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920428-2.c b/gcc/testsuite/gcc.c-torture/execute/920428-2.c new file mode 100644 index 00000000000..118ba968314 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920428-2.c @@ -0,0 +1,7 @@ +#ifndef NO_LABEL_VALUES +s(i){if(i>0){__label__ l1;int f(int i){if(i==2)goto l1;return 0;}return f(i);l1:;}return 1;} +x(){return s(0)==1&&s(1)==0&&s(2)==1;} +main(){if(x()!=1)abort();exit(0);} +#else +main(){ exit (0); } +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/920428-2.cexp b/gcc/testsuite/gcc.c-torture/execute/920428-2.cexp new file mode 100644 index 00000000000..c7d9f030049 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920428-2.cexp @@ -0,0 +1,6 @@ +# This doesn't work on sparc's with -mflat. + +if { [istarget "sparc-*-*"] && [string match "*mflat*" $CFLAGS] } { + set torture_execute_xfail "sparc-*-*" +} +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/920429-1.c b/gcc/testsuite/gcc.c-torture/execute/920429-1.c new file mode 100644 index 00000000000..f37bf68bdd4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920429-1.c @@ -0,0 +1,3 @@ +typedef unsigned char t;int i,j; +t*f(t*p){t c;c=*p++;i=((c&2)?1:0);j=(c&7)+1;return p;} +main(){t*p0="ab",*p1;p1=f(p0);if(p0+1!=p1)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-1.c b/gcc/testsuite/gcc.c-torture/execute/920501-1.c new file mode 100644 index 00000000000..6f757cac59c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-1.c @@ -0,0 +1,3 @@ +int s[2]; +x(){if(!s[0]){s[1+s[1]]=s[1];return 1;}} +main(){s[0]=s[1]=0;if(x(0)!=1)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-2.c b/gcc/testsuite/gcc.c-torture/execute/920501-2.c new file mode 100644 index 00000000000..d99eef289e5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-2.c @@ -0,0 +1,114 @@ +unsigned long +gcd_ll (unsigned long long x, unsigned long long y) +{ + for (;;) + { + if (y == 0) + return (unsigned long) x; + x = x % y; + if (x == 0) + return (unsigned long) y; + y = y % x; + } +} + +unsigned long long +powmod_ll (unsigned long long b, unsigned e, unsigned long long m) +{ + unsigned t; + unsigned long long pow; + int i; + + if (e == 0) + return 1; + + /* Find the most significant bit in E. */ + t = e; + for (i = 0; t != 0; i++) + t >>= 1; + + /* The most sign bit in E is handled outside of the loop, by beginning + with B in POW, and decrementing I. */ + pow = b; + i -= 2; + + for (; i >= 0; i--) + { + pow = pow * pow % m; + if ((1 << i) & e) + pow = pow * b % m; + } + + return pow; +} + +unsigned long factab[10]; + +void +facts (t, a_int, x0, p) + unsigned long long t; + int a_int; + int x0; + unsigned p; +{ + unsigned long *xp = factab; + unsigned long long x, y; + unsigned long q = 1; + unsigned long long a = a_int; + int i; + unsigned long d; + int j = 1; + unsigned long tmp; + int jj = 0; + + x = x0; + y = x0; + + for (i = 1; i < 10000; i++) + { + x = powmod_ll (x, p, t) + a; + y = powmod_ll (y, p, t) + a; + y = powmod_ll (y, p, t) + a; + + if (x > y) + tmp = x - y; + else + tmp = y - x; + q = (unsigned long long) q * tmp % t; + + if (i == j) + { + jj += 1; + j += jj; + d = gcd_ll (q, t); + if (d != 1) + { + *xp++ = d; + t /= d; + if (t == 1) + { + return; + *xp = 0; + } + } + } + } +} + +main () +{ + unsigned long long t; + unsigned x0, a; + unsigned p; + + p = 27; + t = (1ULL << p) - 1; + + a = -1; + x0 = 3; + + facts (t, a, x0, p); + if (factab[0] != 7 || factab[1] != 73 || factab[2] != 262657) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-3.c b/gcc/testsuite/gcc.c-torture/execute/920501-3.c new file mode 100644 index 00000000000..1031d7378cb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-3.c @@ -0,0 +1,35 @@ +int tab[9]; +execute(oip, ip) + unsigned short *oip, *ip; +{ +#ifndef NO_LABEL_VALUES + int x = 0; + int *xp = tab; +base: + x++; + if (x == 4) + { + *xp = 0; + return; + } + *xp++ = ip - oip; + goto *(&&base + *ip++); +#else + tab[0] = 0; + tab[1] = 1; + tab[2] = 2; + tab[3] = 0; +#endif +} + +main() +{ + unsigned short ip[10]; + int i; + for (i = 0; i < 10; i++) + ip[i] = 0; + execute(ip, ip); + if (tab[0] != 0 || tab[1] != 1 || tab[2] != 2 || tab[3] != 0) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-4.c b/gcc/testsuite/gcc.c-torture/execute/920501-4.c new file mode 100644 index 00000000000..b936c4984b6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-4.c @@ -0,0 +1,6 @@ +#ifndef NO_LABEL_VALUES +x(int i){static const void*j[]={&&x,&&y,&&z};goto*j[i];x:return 2;y:return 3;z:return 5;} +main(){if(x(0)!=2||x(1)!=3|x(2)!=5)abort();exit(0);} +#else +main(){ exit (0); } +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-5.c b/gcc/testsuite/gcc.c-torture/execute/920501-5.c new file mode 100644 index 00000000000..09740747712 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-5.c @@ -0,0 +1,19 @@ +#ifndef NO_LABEL_VALUES +x (int i) +{ + void *j[] = {&&x, &&y, &&z}; + goto *j[i]; + x:return 2; + y:return 3; + z:return 5; + +} +main () +{ + if (x (0) != 2 || x (1) != 3 | x (2) != 5) + abort(); + exit(0); +} +#else +main(){ exit (0); } +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-6.c b/gcc/testsuite/gcc.c-torture/execute/920501-6.c new file mode 100644 index 00000000000..cbb7b43243f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-6.c @@ -0,0 +1,91 @@ +#include <stdio.h> + +/* Convert a decimal string to a long long unsigned. No error check is + performed. */ + +long long unsigned +str2llu (str) + char *str; +{ + long long unsigned acc; + int d; + acc = *str++ - '0'; + for (;;) + { + d = *str++; + if (d == '\0') + break; + d -= '0'; + acc = acc * 10 + d; + } + + return acc; +} + +/* isqrt(t) - computes the square root of t. (tege 86-10-27) */ + +long unsigned +sqrtllu (long long unsigned t) +{ + long long unsigned s; + long long unsigned b; + + for (b = 0, s = t; b++, (s >>= 1) != 0; ) + ; + + s = 1 << (b >> 1); + + if (b & 1) + s += s >> 1; + + do + { + b = t / s; + s = (s + b) >> 1; + } + while (b < s); + + return s; +} + + +int plist (p0, p1, tab) + long long unsigned p0, p1; + long long unsigned *tab; +{ + long long unsigned p; + long unsigned d; + long unsigned s; + long long unsigned *xp = tab; + + for (p = p0; p <= p1; p += 2) + { + s = sqrtllu (p); + + for (d = 3; d <= s; d += 2) + { + long long unsigned q = p % d; + if (q == 0) + goto not_prime; + } + + *xp++ = p; + not_prime:; + } + *xp = 0; + return xp - tab; +} + +main (argc, argv) + int argc; + char *argv[]; +{ + long long tab[10]; + int nprimes; + nprimes = plist (str2llu ("1234111111"), str2llu ("1234111127"), tab); + + if(tab[0]!=1234111117LL||tab[1]!=1234111121LL||tab[2]!=1234111127LL||tab[3]!=0) + abort(); + + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-7.c b/gcc/testsuite/gcc.c-torture/execute/920501-7.c new file mode 100644 index 00000000000..f032bd8c690 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-7.c @@ -0,0 +1,34 @@ +/* CYGNUS LOCAL -- meissner/no label values */ +#ifdef STACK_SIZE +#define DEPTH ((STACK_SIZE) / 512 + 1) +#else +#define DEPTH 1000 +#endif + +#ifndef NO_LABEL_VALUES +x(a) +{ + __label__ xlab; + void y(a) + { + if (a==0) + goto xlab; + y (a-1); + } + y (a); + xlab:; + return a; +} +#endif + +main () +{ +#ifndef __I960__ +#ifndef NO_LABEL_VALUES + if (x (DEPTH) != DEPTH) + abort (); +#endif +#endif + exit (0); +} +/* END CYGNUS LOCAL -- meissner/no label values */ diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-7.cexp b/gcc/testsuite/gcc.c-torture/execute/920501-7.cexp new file mode 100644 index 00000000000..c7d9f030049 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-7.cexp @@ -0,0 +1,6 @@ +# This doesn't work on sparc's with -mflat. + +if { [istarget "sparc-*-*"] && [string match "*mflat*" $CFLAGS] } { + set torture_execute_xfail "sparc-*-*" +} +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-8.c b/gcc/testsuite/gcc.c-torture/execute/920501-8.c new file mode 100644 index 00000000000..04f1e132f5b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-8.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <stdarg.h> + +extern int sprintf(char *, const char *, ...); +char buf[50]; +int +va (int a, double b, int c, ...) +{ + va_list ap; + int d, e, f, g, h, i, j, k, l, m, n, o, p; + va_start (ap, c); + + d = va_arg (ap, int); + e = va_arg (ap, int); + f = va_arg (ap, int); + g = va_arg (ap, int); + h = va_arg (ap, int); + i = va_arg (ap, int); + j = va_arg (ap, int); + k = va_arg (ap, int); + l = va_arg (ap, int); + m = va_arg (ap, int); + n = va_arg (ap, int); + o = va_arg (ap, int); + p = va_arg (ap, int); + + sprintf (buf, + "%d,%f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", + a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p); + va_end (ap); +} + +main() +{ + va (1, 1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + if (strcmp ("1,1.000000,2,3,4,5,6,7,8,9,10,11,12,13,14,15", buf)) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920501-9.c b/gcc/testsuite/gcc.c-torture/execute/920501-9.c new file mode 100644 index 00000000000..f585ac6e0f4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920501-9.c @@ -0,0 +1,27 @@ +#include <stdio.h> + +long long proc1(){return 1LL;} +long long proc2(){return 0x12345678LL;} +long long proc3(){return 0xaabbccdd12345678LL;} +long long proc4(){return -1LL;} +long long proc5(){return 0xaabbccddLL;} + +print_longlong(x,buf) + long long x; + char *buf; +{ + unsigned long l; + l= (x >> 32) & 0xffffffff; + if (l != 0) + sprintf(buf,"%lx%08.lx",l,((unsigned long)x & 0xffffffff)); + else + sprintf(buf,"%lx",((unsigned long)x & 0xffffffff)); +} + +main(){char buf[100]; +print_longlong(proc1(),buf);if(strcmp("1",buf))abort(); +print_longlong(proc2(),buf);if(strcmp("12345678",buf))abort(); +print_longlong(proc3(),buf);if(strcmp("aabbccdd12345678",buf))abort(); +print_longlong(proc4(),buf);if(strcmp("ffffffffffffffff",buf))abort(); +print_longlong(proc5(),buf);if(strcmp("aabbccdd",buf))abort(); +exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920506-1.c b/gcc/testsuite/gcc.c-torture/execute/920506-1.c new file mode 100644 index 00000000000..9a646a30fc2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920506-1.c @@ -0,0 +1,2 @@ +int l[]={0,1}; +main(){int*p=l;switch(*p++){case 0:exit(0);case 1:break;case 2:break;case 3:case 4:break;}abort();} diff --git a/gcc/testsuite/gcc.c-torture/execute/920520-1.c b/gcc/testsuite/gcc.c-torture/execute/920520-1.c new file mode 100644 index 00000000000..068a12e9249 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920520-1.c @@ -0,0 +1,36 @@ +foo(int *bar) +{ + *bar = 8; +} + +bugger() +{ + int oldDepth, newDepth; + + foo(&oldDepth); + + switch (oldDepth) + { + case 8: + case 500: + newDepth = 8; + break; + + case 5000: + newDepth = 500; + break; + + default: + newDepth = 17; + break; + } + + return newDepth - oldDepth; +} + +main() +{ + if (bugger() != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920603-1.c b/gcc/testsuite/gcc.c-torture/execute/920603-1.c new file mode 100644 index 00000000000..bd27ca6196e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920603-1.c @@ -0,0 +1,2 @@ +f(got){if(got!=0xffff)abort();} +main(){signed char c=-1;unsigned u=(unsigned short)c;f(u);exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920604-1.c b/gcc/testsuite/gcc.c-torture/execute/920604-1.c new file mode 100644 index 00000000000..d7d9be13fd8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920604-1.c @@ -0,0 +1,13 @@ +long long +mod (a, b) + long long a, b; +{ + return a % b; +} + +int +main () +{ + mod (1LL, 2LL); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920612-1.c b/gcc/testsuite/gcc.c-torture/execute/920612-1.c new file mode 100644 index 00000000000..a70c0d2e078 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920612-1.c @@ -0,0 +1,2 @@ +f(j)int j;{return++j>0;} +main(){if(f((~0U)>>1))abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920612-2.c b/gcc/testsuite/gcc.c-torture/execute/920612-2.c new file mode 100644 index 00000000000..2667093491f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920612-2.c @@ -0,0 +1,12 @@ +main () +{ + int i = 0; + int a (int x) + { + while (x) + i++, x--; + return x; + } + a (2); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920618-1.c b/gcc/testsuite/gcc.c-torture/execute/920618-1.c new file mode 100644 index 00000000000..224f7208953 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920618-1.c @@ -0,0 +1 @@ +main(){if(1.17549435e-38F<=1.1)exit(0);abort();} diff --git a/gcc/testsuite/gcc.c-torture/execute/920625-1.c b/gcc/testsuite/gcc.c-torture/execute/920625-1.c new file mode 100644 index 00000000000..ae2f415dec7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920625-1.c @@ -0,0 +1,38 @@ +#include <stdarg.h> + +typedef struct{double x,y;}point; +point pts[]={{1.0,2.0},{3.0,4.0},{5.0,6.0},{7.0,8.0}}; +static int va1(int nargs,...) +{ + va_list args; + int i; + point pi; + va_start(args,nargs); + for(i=0;i<nargs;i++){ + pi=va_arg(args,point); + if(pts[i].x!=pi.x||pts[i].y!=pi.y)abort(); + } + va_end(args); +} + +typedef struct{int x,y;}ipoint; +ipoint ipts[]={{1,2},{3,4},{5,6},{7,8}}; +static int va2(int nargs,...) +{ + va_list args; + int i; + ipoint pi; + va_start(args,nargs); + for(i=0;i<nargs;i++){ + pi=va_arg(args,ipoint); + if(ipts[i].x!=pi.x||ipts[i].y!=pi.y)abort(); + } + va_end(args); +} + +main() +{ +va1(4,pts[0],pts[1],pts[2],pts[3]); +va2(4,ipts[0],ipts[1],ipts[2],ipts[3]); +exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920710-1.c b/gcc/testsuite/gcc.c-torture/execute/920710-1.c new file mode 100644 index 00000000000..7c6f871e2ac --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920710-1.c @@ -0,0 +1,11 @@ +main() +{ + if ((double) 18446744073709551615ULL < 1.84467440737095e+19 || + (double) 18446744073709551615ULL > 1.84467440737096e+19) + abort(); + + if (16777217L != (float)16777217e0) + abort(); + + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920711-1.c b/gcc/testsuite/gcc.c-torture/execute/920711-1.c new file mode 100644 index 00000000000..aa83452dafe --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920711-1.c @@ -0,0 +1,2 @@ +f(long a){return (--a > 0);} +main(){if(f(0x80000000L)==0)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920715-1.c b/gcc/testsuite/gcc.c-torture/execute/920715-1.c new file mode 100644 index 00000000000..8b0f54b081c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920715-1.c @@ -0,0 +1,67 @@ +double ran(int *idum); +main () +{ + double vp = 0.0048; + double vx; + double vy; + double vz; + + /* CYGNUS LOCAL -- meissner/32bit doubles */ + /* This test requires double precision, so for hosts that don't offer + that much precision, just ignore this test. */ + if (sizeof (double) < 8) + exit (0); + /* END CYGNUS LOCAL -- meissner/32bit doubles */ + + maxbol(vp, &vx , &vy , &vz ); + if (vx < 0.001316505673 || vx > 0.001316505674) + abort(); + if (vy < 0.002731492112 || vy > 0.002731492113) + abort(); + if (vz < 0.001561454099 || vz > 0.001561454100) + abort(); + exit(0); +} +maxbol(double vp , double *vx , double *vy , double *vz) +{ + int idum=0; + int i; + double temp; + + *vx=vp*ran( &idum ); + *vy=vp*ran( &idum ); + *vz=vp*ran( &idum ); +} + +double ran(int *idum) +{ + static long ix1,ix2,ix3; + static double r[97]; + double temp; + static int iff=0; + int j; + + if(*idum<0 || iff==0){ + iff=1; + ix1=(54773-(*idum))%259200; + ix1=(7141*ix1+54773)%259200; + ix2=ix1 %134456; + ix1=(7141*ix1+54773)%259200; + ix3=ix1 %243000; + for(j=0; j<97; j++){ + ix1=(7141*ix1+54773)%259200; + ix2=(8121*ix2+28411)%134456; + r[j]=(ix1+ix2*(1.0/134456))*(1.0/259200); + } + *idum=1; + } + ix1=(7141*ix1+54773)%259200; + ix2=(8121*ix2+28411)%134456; + ix3=(4561*ix3+51349)%243000; + j=((97*ix3)/243000); + if(j >= 97 && j < 0) + abort(); + temp=r[j]; + r[j]=(ix1+ix2*(1.0/134456))*(1.0/259200); + return temp; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920715-1.cexp b/gcc/testsuite/gcc.c-torture/execute/920715-1.cexp new file mode 100644 index 00000000000..28da30bbcd3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920715-1.cexp @@ -0,0 +1,13 @@ +# This doesn't work on h8300s +# It also doesn't work on d10v if doubles are not 64 bits + +if { [istarget "h8300*-*-*"] || [istarget "mn10200*-*-*"] } { + set torture_execute_xfail "h8300*-*-*" + set torture_execute_xfail "mn10200*-*-*" +} + +if { [istarget "d10v-*-*"] && ! [string-match "*-mdouble64*" $CFLAGS] } { + set torture_execute_xfail "d10v-*-*" +} + +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/920721-1.c b/gcc/testsuite/gcc.c-torture/execute/920721-1.c new file mode 100644 index 00000000000..086b5463f7f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920721-1.c @@ -0,0 +1,2 @@ +long f(short a,short b){return (long)a/b;} +main(){if(f(-32768,-1)!=32768L)abort();else exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920721-2.c b/gcc/testsuite/gcc.c-torture/execute/920721-2.c new file mode 100644 index 00000000000..ed4e0bf8700 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920721-2.c @@ -0,0 +1,2 @@ +f(){} +main(){int n=2;double x[n];f();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920721-3.c b/gcc/testsuite/gcc.c-torture/execute/920721-3.c new file mode 100644 index 00000000000..61f605d0ad9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920721-3.c @@ -0,0 +1,26 @@ +static inline fu (unsigned short data) +{ + return data; +} +ru(i) +{ + if(fu(i++)!=5)abort(); + if(fu(++i)!=7)abort(); +} +static inline fs (signed short data) +{ + return data; +} +rs(i) +{ + if(fs(i++)!=5)abort(); + if(fs(++i)!=7)abort(); +} + + +main() +{ + ru(5); + rs(5); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920721-4.c b/gcc/testsuite/gcc.c-torture/execute/920721-4.c new file mode 100644 index 00000000000..3cccc5b3024 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920721-4.c @@ -0,0 +1,60 @@ +#ifndef NO_LABEL_VALUES +int try (int num) { + __label__ lab1, lab2, lab3, lab4, lab5, lab6, default_lab; + + void *do_switch (int num) { + switch(num) { + case 1: + return &&lab1; + case 2: + return &&lab2; + case 3: + return &&lab3; + case 4: + return &&lab4; + case 5: + return &&lab5; + case 6: + return &&lab6; + default: + return &&default_lab; + } + } + + goto *do_switch (num); + + lab1: + return 1; + + lab2: + return 2; + + lab3: + return 3; + + lab4: + return 4; + + lab5: + return 5; + + lab6: + return 6; + + default_lab: + return -1; +} + +main() +{ + int i; + for (i = 1; i <= 6; i++) + { + if (try (i) != i) + abort(); + } + exit(0); +} +#else +main(){ exit (0); } +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/920726-1.c b/gcc/testsuite/gcc.c-torture/execute/920726-1.c new file mode 100644 index 00000000000..d6042c9f5d1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920726-1.c @@ -0,0 +1,63 @@ +#include <stdio.h> +#include <stdarg.h> + +struct spurious +{ + int anumber; +}; + +int first(char *buf, char *fmt, ...) +{ + int pos, number; + va_list args; + int dummy; + char *bp = buf; + + va_start(args, fmt); + for (pos = 0; fmt[pos]; pos++) + if (fmt[pos] == 'i') + { + number = va_arg(args, int); + sprintf(bp, "%d", number); + bp += strlen(bp); + } + else + *bp++ = fmt[pos]; + + va_end(args); + *bp = 0; + return dummy; +} + +struct spurious second(char *buf,char *fmt, ...) +{ + int pos, number; + va_list args; + struct spurious dummy; + char *bp = buf; + + va_start(args, fmt); + for (pos = 0; fmt[pos]; pos++) + if (fmt[pos] == 'i') + { + number = va_arg(args, int); + sprintf(bp, "%d", number); + bp += strlen(bp); + } + else + *bp++ = fmt[pos]; + + va_end(args); + *bp = 0; + return dummy; +} + +main() +{ + char buf1[100], buf2[100]; + first(buf1, "i i ", 5, 20); + second(buf2, "i i ", 5, 20); + if (strcmp ("5 20 ", buf1) || strcmp ("5 20 ", buf2)) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920728-1.c b/gcc/testsuite/gcc.c-torture/execute/920728-1.c new file mode 100644 index 00000000000..7a2968b71be --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920728-1.c @@ -0,0 +1,24 @@ +typedef struct {int dims[0]; } *A; + +f(unsigned long obj) +{ + unsigned char y = obj >> 24; + y &= ~4; + + if ((y==0)||(y!=251 )) + abort(); + + if(((int)obj&7)!=7)return; + + REST_OF_CODE_JUST_HERE_TO_TRIGGER_THE_BUG: + + { + unsigned char t = obj >> 24; + if (!(t==0)&&(t<=0x03)) + return 0; + return ((A)(obj&0x00FFFFFFL))->dims[1]; + } +} + +long g(){return 0xff000000L;} +main (){int x;f(g());exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920731-1.c b/gcc/testsuite/gcc.c-torture/execute/920731-1.c new file mode 100644 index 00000000000..de0fb58fcde --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920731-1.c @@ -0,0 +1,2 @@ +f(x){int i;for(i=0;i<8&&(x&1)==0;x>>=1,i++);return i;} +main(){if(f(4)!=2)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920810-1.c b/gcc/testsuite/gcc.c-torture/execute/920810-1.c new file mode 100644 index 00000000000..9565bfc1a2b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920810-1.c @@ -0,0 +1,23 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +typedef struct{void*super;int name;int size;}t; +t*f(t*clas,int size) +{ + t*child=(t*)malloc(size); + memcpy(child,clas,clas->size); + child->super=clas; + child->name=0; + child->size=size; + return child; +} +main() +{ + t foo,*bar; + memset(&foo,37,sizeof(t)); + foo.size=sizeof(t); + bar=f(&foo,sizeof(t)); + if(bar->super!=&foo||bar->name!=0||bar->size!=sizeof(t))abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920812-1.c b/gcc/testsuite/gcc.c-torture/execute/920812-1.c new file mode 100644 index 00000000000..b49ab425b21 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920812-1.c @@ -0,0 +1,3 @@ +typedef int t; +f(t y){switch(y){case 1:return 1;}return 0;} +main(){if(f((t)1)!=1)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920829-1.c b/gcc/testsuite/gcc.c-torture/execute/920829-1.c new file mode 100644 index 00000000000..ed2c2271caa --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920829-1.c @@ -0,0 +1,2 @@ +long long c=2863311530LL,c3=2863311530LL*3; +main(){if(c*3!=c3)abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920908-1.c b/gcc/testsuite/gcc.c-torture/execute/920908-1.c new file mode 100644 index 00000000000..98fbb5eaa6d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920908-1.c @@ -0,0 +1,28 @@ +/* REPRODUCED:RUN:SIGNAL MACHINE:mips OPTIONS: */ + +#include <stdarg.h> + +typedef struct{int A;}T; + +T f(int x,...) +{ +va_list ap; +T X; +va_start(ap,x); +X=va_arg(ap,T); +if(X.A!=10)abort(); +X=va_arg(ap,T); +if(X.A!=20)abort(); +va_end(ap); +return X; +} + +main() +{ +T X,Y; +int i; +X.A=10; +Y.A=20; +f(2,X,Y); +exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920908-2.c b/gcc/testsuite/gcc.c-torture/execute/920908-2.c new file mode 100644 index 00000000000..66a6d86a7e7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920908-2.c @@ -0,0 +1,23 @@ +/* +CONF:m68k-sun-sunos4.1.1 +OPTIONS:-O +*/ +struct T +{ +unsigned i:8; +unsigned c:24; +}; +f(struct T t) +{ +struct T s[1]; +s[0]=t; +return(char)s->c; +} +main() +{ +struct T t; +t.i=0xff; +t.c=0xffff11; +if(f(t)!=0x11)abort(); +exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920909-1.c b/gcc/testsuite/gcc.c-torture/execute/920909-1.c new file mode 100644 index 00000000000..c8880348c12 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920909-1.c @@ -0,0 +1,2 @@ +f(a){switch(a){case 0x402:return a+1;case 0x403:return a+2;case 0x404:return a+3;case 0x405:return a+4;case 0x406:return 1;case 0x407:return 4;}return 0;} +main(){if(f(1))abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/920922-1.c b/gcc/testsuite/gcc.c-torture/execute/920922-1.c new file mode 100644 index 00000000000..4fae192bb90 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920922-1.c @@ -0,0 +1,14 @@ +unsigned long* +f(p)unsigned long*p; +{ + unsigned long a = (*p++) >> 24; + return p + a; +} + +main () +{ + unsigned long x = 0x80000000UL; + if (f(&x) != &x + 0x81) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/920929-1.c b/gcc/testsuite/gcc.c-torture/execute/920929-1.c new file mode 100644 index 00000000000..e43444e31d7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/920929-1.c @@ -0,0 +1,13 @@ +/* REPRODUCED:RUN:SIGNAL MACHINE:sparc OPTIONS: */ +f(int n) +{ +int i; +double v[n]; +for(i=0;i<n;i++) +v[i]=0; +} +main() +{ +f(100); +exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921006-1.c b/gcc/testsuite/gcc.c-torture/execute/921006-1.c new file mode 100644 index 00000000000..50fbdb71125 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921006-1.c @@ -0,0 +1,6 @@ +/* REPRODUCED:RUN:SIGNAL MACHINE:i386 OPTIONS:-O */ +main() +{ +if(strcmp("X","")<0)abort(); +exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921007-1.c b/gcc/testsuite/gcc.c-torture/execute/921007-1.c new file mode 100644 index 00000000000..ea036519463 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921007-1.c @@ -0,0 +1,7 @@ +int strcmp(){return-1;} +#define strcmp __builtin_strcmp +main() +{ +if(strcmp("X","X\376")>=0)abort(); +exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921013-1.c b/gcc/testsuite/gcc.c-torture/execute/921013-1.c new file mode 100644 index 00000000000..d041beb257a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921013-1.c @@ -0,0 +1,20 @@ +f(d,x,y,n) +int*d; +float*x,*y; +int n; +{ + while(n--){*d++=*x++==*y++;} +} + +main() +{ + int r[4]; + float a[]={5,1,3,5}; + float b[]={2,4,3,0}; + int i; + f(r,a,b,4); + for(i=0;i<4;i++) + if((a[i]==b[i])!=r[i]) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921016-1.c b/gcc/testsuite/gcc.c-torture/execute/921016-1.c new file mode 100644 index 00000000000..46f8a838765 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921016-1.c @@ -0,0 +1,10 @@ +main() +{ +int j=1081; +struct +{ +signed int m:11; +}l; +if((l.m=j)==j)abort(); +exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921017-1.c b/gcc/testsuite/gcc.c-torture/execute/921017-1.c new file mode 100644 index 00000000000..3a0db5c4d56 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921017-1.c @@ -0,0 +1,15 @@ +f(n) +{ + int a[n]; + int g(i) + { + return a[i]; + } + a[1]=4711; + return g(1); +} +main() +{ + if(f(2)!=4711)abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921019-1.c b/gcc/testsuite/gcc.c-torture/execute/921019-1.c new file mode 100644 index 00000000000..f48613a8ba9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921019-1.c @@ -0,0 +1,8 @@ +void *foo[]={(void *)&("X"[0])}; + +main () +{ + if (((char*)foo[0])[0] != 'X') + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921019-2.c b/gcc/testsuite/gcc.c-torture/execute/921019-2.c new file mode 100644 index 00000000000..9003e7b64d5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921019-2.c @@ -0,0 +1,8 @@ +main() +{ + double x,y=0.5; + x=y/0.2; + if(x!=x) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921029-1.c b/gcc/testsuite/gcc.c-torture/execute/921029-1.c new file mode 100644 index 00000000000..76fc974c2f0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921029-1.c @@ -0,0 +1,42 @@ +typedef unsigned long long ULL; +ULL back; +ULL hpart, lpart; +ULL +build(long h, long l) +{ + hpart = h; + hpart <<= 32; + lpart = l; + lpart &= 0xFFFFFFFFLL; + back = hpart | lpart; + return back; +} + +main() +{ + if (build(0, 1) != 0x0000000000000001LL) + abort(); + if (build(0, 0) != 0x0000000000000000LL) + abort(); + if (build(0, 0xFFFFFFFF) != 0x00000000FFFFFFFFLL) + abort(); + if (build(0, 0xFFFFFFFE) != 0x00000000FFFFFFFELL) + abort(); + if (build(1, 1) != 0x0000000100000001LL) + abort(); + if (build(1, 0) != 0x0000000100000000LL) + abort(); + if (build(1, 0xFFFFFFFF) != 0x00000001FFFFFFFFLL) + abort(); + if (build(1, 0xFFFFFFFE) != 0x00000001FFFFFFFELL) + abort(); + if (build(0xFFFFFFFF, 1) != 0xFFFFFFFF00000001LL) + abort(); + if (build(0xFFFFFFFF, 0) != 0xFFFFFFFF00000000LL) + abort(); + if (build(0xFFFFFFFF, 0xFFFFFFFF) != 0xFFFFFFFFFFFFFFFFLL) + abort(); + if (build(0xFFFFFFFF, 0xFFFFFFFE) != 0xFFFFFFFFFFFFFFFELL) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921104-1.c b/gcc/testsuite/gcc.c-torture/execute/921104-1.c new file mode 100644 index 00000000000..4b6f4bcfb5b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921104-1.c @@ -0,0 +1,8 @@ +main () +{ + unsigned long val = 1; + + if (val > (unsigned long) ~0) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921110-1.c b/gcc/testsuite/gcc.c-torture/execute/921110-1.c new file mode 100644 index 00000000000..27ff96f18fb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921110-1.c @@ -0,0 +1,7 @@ +extern int abort(); +typedef int (*frob)(); +frob f[] = {abort}; +main() +{ + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921112-1.c b/gcc/testsuite/gcc.c-torture/execute/921112-1.c new file mode 100644 index 00000000000..5946398e3c0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921112-1.c @@ -0,0 +1,21 @@ +union u { + struct { int i1, i2; } t; + double d; +} x[2], v; + +f (x, v) + union u *x, v; +{ + *++x = v; +} + +main() +{ + x[1].t.i1 = x[1].t.i2 = 0; + v.t.i1 = 1; + v.t.i2 = 2; + f (x, v); + if (x[1].t.i1 != 1 || x[1].t.i2 != 2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921113-1.c b/gcc/testsuite/gcc.c-torture/execute/921113-1.c new file mode 100644 index 00000000000..78972bc975e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921113-1.c @@ -0,0 +1,63 @@ +#define STACK_REQUIREMENT (128 * 128 * 4 + 1024) +#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT +main () { exit (0); } +#else + +typedef struct { + float wsx; +} struct_list; + +typedef struct_list *list_t; + +typedef struct { + float x, y; +} vector_t; + +w(float x, float y) {} + +f1(float x, float y) +{ + if (x != 0 || y != 0) + abort(); +} +f2(float x, float y) +{ + if (x != 1 || y != 1) + abort(); +} + +gitter(int count, vector_t pos[], list_t list, int *nww, vector_t limit[2], float r) +{ + float d; + int gitt[128][128]; + + f1(limit[0].x, limit[0].y); + f2(limit[1].x, limit[1].y); + + *nww = 0; + + d = pos[0].x; + if (d <= 0.) + { + w(d, r); + if (d <= r * 0.5) + { + w(d, r); + list[0].wsx = 1; + } + } +} + +vector_t pos[1] = {{0., 0.}}; +vector_t limit[2] = {{0.,0.},{1.,1.}}; + +main() +{ + int nww; + struct_list list; + + gitter(1, pos, &list, &nww, limit, 1.); + exit(0); +} + +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/921117-1.c b/gcc/testsuite/gcc.c-torture/execute/921117-1.c new file mode 100644 index 00000000000..2ed30fbeeef --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921117-1.c @@ -0,0 +1,22 @@ +struct s { + char text[11]; + int flag; +} cell; + +int +check (struct s p) +{ + if (p.flag != 99) + return 1; + return strcmp (p.text, "0123456789"); +} + +main () +{ + cell.flag = 99; + strcpy (cell.text, "0123456789"); + + if (check (cell)) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921123-1.c b/gcc/testsuite/gcc.c-torture/execute/921123-1.c new file mode 100644 index 00000000000..d3daf120f0a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921123-1.c @@ -0,0 +1,13 @@ +f(short *p) +{ + short x = *p; + return (--x < 0); +} + +main() +{ + short x = -10; + if (!f(&x)) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921123-2.c b/gcc/testsuite/gcc.c-torture/execute/921123-2.c new file mode 100644 index 00000000000..3028717cf5a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921123-2.c @@ -0,0 +1,24 @@ +typedef struct +{ + unsigned short b0, b1, b2, b3; +} four_quarters; + +four_quarters x; +int a, b; + +void f (four_quarters j) +{ + b = j.b2; + a = j.b3; +} + +main () +{ + four_quarters x; + x.b0 = x.b1 = x.b2 = 0; + x.b3 = 38; + f(x); + if (a != 38) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921124-1.c b/gcc/testsuite/gcc.c-torture/execute/921124-1.c new file mode 100644 index 00000000000..51b090b4de1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921124-1.c @@ -0,0 +1,19 @@ +f(x, d1, d2, d3) + double d1, d2, d3; +{ + return x; +} + +g(b,s,x,y,i,j) + char *b,*s; + double x,y; +{ + if (x != 1.0 || y != 2.0 || i != 3 || j != 4) + abort(); +} + +main() +{ + g("","", 1.0, 2.0, f(3, 0.0, 0.0, 0.0), f(4, 0.0, 0.0, 0.0)); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921202-1.c b/gcc/testsuite/gcc.c-torture/execute/921202-1.c new file mode 100644 index 00000000000..d42fc74403c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921202-1.c @@ -0,0 +1,36 @@ +main () +{ + long dx[2055]; + long dy[2055]; + long s1[2055]; + int cyx, cyy; + int i; + long size; + + for (;;) + { + size = 2055; + mpn_random2 (s1, size); + + for (i = 0; i < 1; i++) + ; + + dy[size] = 0x12345678; + + for (i = 0; i < 1; i++) + cyy = mpn_mul_1 (dy, s1, size); + + if (cyx != cyy || mpn_cmp (dx, dy, size + 1) != 0 || dx[size] != 0x12345678) + { + foo ("", 8, cyy); mpn_print (dy, size); + } + exxit(); + } +} + +foo (){} +mpn_mul_1(){} +mpn_print (){} +mpn_random2(){} +mpn_cmp(){} +exxit(){exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/921202-2.c b/gcc/testsuite/gcc.c-torture/execute/921202-2.c new file mode 100644 index 00000000000..48d4a412d1b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921202-2.c @@ -0,0 +1,13 @@ +int +f(long long x) +{ + x >>= 8; + return x & 0xff; +} + +main() +{ + if (f(0x0123456789ABCDEFLL) != 0xCD) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921204-1.c b/gcc/testsuite/gcc.c-torture/execute/921204-1.c new file mode 100644 index 00000000000..9e4f4a6bae7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921204-1.c @@ -0,0 +1,36 @@ +typedef struct { + unsigned b0:1, f1:17, b18:1, b19:1, b20:1, f2:11; +} bf; + +typedef union { + bf b; + unsigned w; +} bu; + +bu +f(bu i) +{ + bu o = i; + + if (o.b.b0) + o.b.b18 = 1, + o.b.b20 = 1; + else + o.b.b18 = 0, + o.b.b20 = 0; + + return o; +} + +main() +{ + bu a; + bu r; + + a.w = 0x4000000; + a.b.b0 = 0; + r = f(a); + if (a.w != r.w) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921207-1.c b/gcc/testsuite/gcc.c-torture/execute/921207-1.c new file mode 100644 index 00000000000..5ee9d27cc2f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921207-1.c @@ -0,0 +1,15 @@ +f() +{ + unsigned b = 0; + + if (b > ~0U) + b = ~0U; + + return b; +} +main() +{ + if (f()!=0) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921208-1.c b/gcc/testsuite/gcc.c-torture/execute/921208-1.c new file mode 100644 index 00000000000..143ef63b0c9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921208-1.c @@ -0,0 +1,18 @@ +double +f(double x) +{ + return x*x; +} + +double +Int(double (*f)(double), double a) +{ + return (*f)(a); +} + +main() +{ + if (Int(&f,2.0) != 4.0) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921208-2.c b/gcc/testsuite/gcc.c-torture/execute/921208-2.c new file mode 100644 index 00000000000..d5edcf97c66 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921208-2.c @@ -0,0 +1,26 @@ +#define STACK_REQUIREMENT (100000 * 4 + 1024) +#if defined (STACK_SIZE) && STACK_SIZE < STACK_REQUIREMENT +main () { exit (0); } +#else + +g(){} + +f() +{ + int i; + float a[100000]; + + for (i = 0; i < 1; i++) + { + g(1.0, 1.0 + i / 2.0 * 3.0); + g(2.0, 1.0 + i / 2.0 * 3.0); + } +} + +main () +{ + f(); + exit(0); +} + +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/921215-1.c b/gcc/testsuite/gcc.c-torture/execute/921215-1.c new file mode 100644 index 00000000000..4fa3b7dfccc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921215-1.c @@ -0,0 +1,24 @@ +main() +{ +#ifndef NO_TRAMPOLINES + void p(void ((*f) (void ()))) + { + void r() + { + foo (); + } + + f(r); + } + + void q(void ((*f)())) + { + f(); + } + + p(q); +#endif + exit(0); +} + +foo(){} diff --git a/gcc/testsuite/gcc.c-torture/execute/921218-1.c b/gcc/testsuite/gcc.c-torture/execute/921218-1.c new file mode 100644 index 00000000000..ab7bc19cc15 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921218-1.c @@ -0,0 +1,11 @@ +f() +{ + return (unsigned char)("\377"[0]); +} + +main() +{ + if (f() != (unsigned char)(0377)) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/921218-2.c b/gcc/testsuite/gcc.c-torture/execute/921218-2.c new file mode 100644 index 00000000000..b5d57e9c3c8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/921218-2.c @@ -0,0 +1,17 @@ +f() +{ + long l2; + unsigned short us; + unsigned long ul; + short s2; + + ul = us = l2 = s2 = -1; + return ul; +} + +main() +{ + if (f()!=(unsigned short)-1) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930106-1.c b/gcc/testsuite/gcc.c-torture/execute/930106-1.c new file mode 100644 index 00000000000..8081f926013 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930106-1.c @@ -0,0 +1,27 @@ +#if defined (STACK_SIZE) +#define DUMMY_SIZE 9 +#else +#define DUMMY_SIZE 399999 +#endif + +double g() +{ + return 1.0; +} + +f() +{ + char dummy[DUMMY_SIZE]; + double f1, f2, f3; + f1 = g(); + f2 = g(); + f3 = g(); + return f1 + f2 + f3; +} + +main() +{ + if (f() != 3.0) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930111-1.c b/gcc/testsuite/gcc.c-torture/execute/930111-1.c new file mode 100644 index 00000000000..e908f14f67f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930111-1.c @@ -0,0 +1,22 @@ +main() +{ + if (wwrite((long long) 0) != 123) + abort(); + exit(0); +} + +int +wwrite(long long i) +{ + switch(i) + { + case 3: + case 10: + case 23: + case 28: + case 47: + return 0; + default: + return 123; + } +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930123-1.c b/gcc/testsuite/gcc.c-torture/execute/930123-1.c new file mode 100644 index 00000000000..7365bae5200 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930123-1.c @@ -0,0 +1,16 @@ +f(int *x) +{ + *x = 0; +} + +main() +{ + int s, c, x; + char a[] = "c"; + + f(&s); + a[c = 0] = s == 0 ? (x=1, 'a') : (x=2, 'b'); + if (a[c] != 'a') + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930126-1.c b/gcc/testsuite/gcc.c-torture/execute/930126-1.c new file mode 100644 index 00000000000..ff08e7d6131 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930126-1.c @@ -0,0 +1,20 @@ +struct s { + unsigned long long a:8, b:32; +}; + +struct s +f(struct s x) +{ + x.b = 0xcdef1234; + return x; +} + +main() +{ + static struct s i; + i.a = 12; + i = f(i); + if (i.a != 12 || i.b != 0xcdef1234) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930208-1.c b/gcc/testsuite/gcc.c-torture/execute/930208-1.c new file mode 100644 index 00000000000..464b69d437e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930208-1.c @@ -0,0 +1,23 @@ +typedef union { + long l; + struct { char b3, b2, b1, b0; } c; +} T; + +f (T u) +{ + ++u.c.b0; + ++u.c.b3; + return (u.c.b1 != 2 || u.c.b2 != 2); +} + +main () +{ + T u; + u.c.b1 = 2; + u.c.b2 = 2; + u.c.b0 = ~0; + u.c.b3 = ~0; + if (f (u)) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930406-1.c b/gcc/testsuite/gcc.c-torture/execute/930406-1.c new file mode 100644 index 00000000000..1546f5150dd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930406-1.c @@ -0,0 +1,19 @@ +f() +{ + int x = 1; + char big[0x1000]; + + ({ + __label__ mylabel; + mylabel: + x++; + if (x != 3) + goto mylabel; + }); + exit(0); +} + +main() +{ + f(); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930408-1.c b/gcc/testsuite/gcc.c-torture/execute/930408-1.c new file mode 100644 index 00000000000..42ffc098f80 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930408-1.c @@ -0,0 +1,27 @@ +typedef enum foo E; +enum foo { e0, e1 }; + +struct { + E eval; +} s; + +p() +{ + abort(); +} + +f() +{ + switch (s.eval) + { + case e0: + p(); + } +} + +main() +{ + s.eval = e1; + f(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930429-1.c b/gcc/testsuite/gcc.c-torture/execute/930429-1.c new file mode 100644 index 00000000000..656d928ebd7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930429-1.c @@ -0,0 +1,14 @@ +char * +f (char *p) +{ + short x = *p++ << 16; + return p; +} + +main () +{ + char *p = ""; + if (f (p) != p + 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930429-2.c b/gcc/testsuite/gcc.c-torture/execute/930429-2.c new file mode 100644 index 00000000000..e52c8b4d723 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930429-2.c @@ -0,0 +1,14 @@ +int +f (b) +{ + return (b >> 1) > 0; +} + +main () +{ + if (!f (9)) + abort (); + if (f (-9)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930513-1.c b/gcc/testsuite/gcc.c-torture/execute/930513-1.c new file mode 100644 index 00000000000..4544471ec7d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930513-1.c @@ -0,0 +1,16 @@ +#include <stdio.h> +char buf[2]; + +f (fp) + int (*fp)(char *, const char *, ...); +{ + (*fp)(buf, "%.0f", 5.0); +} + +main () +{ + f (&sprintf); + if (buf[0] != '5' || buf[1] != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930513-2.c b/gcc/testsuite/gcc.c-torture/execute/930513-2.c new file mode 100644 index 00000000000..3731f620497 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930513-2.c @@ -0,0 +1,27 @@ +sub3 (i) + const int *i; +{ +} + +eq (a, b) +{ + static int i = 0; + if (a != i) + abort (); + i++; +} + +main () +{ + int i; + + for (i = 0; i < 4; i++) + { + const int j = i; + int k; + sub3 (&j); + k = j; + eq (k, k); + } + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930518-1.c b/gcc/testsuite/gcc.c-torture/execute/930518-1.c new file mode 100644 index 00000000000..44bdf96afb7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930518-1.c @@ -0,0 +1,24 @@ +int bar = 0; + +f (p) + int *p; +{ + int foo = 2; + + while (foo > bar) + { + foo -= bar; + *p++ = foo; + bar = 1; + } +} + +main () +{ + int tab[2]; + tab[0] = tab[1] = 0; + f (tab); + if (tab[0] != 2 || tab[1] != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930526-1.c b/gcc/testsuite/gcc.c-torture/execute/930526-1.c new file mode 100644 index 00000000000..bbf63c6009a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930526-1.c @@ -0,0 +1,18 @@ +inline +f (x) +{ + int *(p[25]); + int m[25*7]; + int i; + + for (i = 0; i < 25; i++) + p[i] = m + x*i; + + p[1][0] = 0; +} + +main () +{ + f (7); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930527-1.c b/gcc/testsuite/gcc.c-torture/execute/930527-1.c new file mode 100644 index 00000000000..fef34bf6b7f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930527-1.c @@ -0,0 +1,11 @@ +f (unsigned char x) +{ + return (0x50 | (x >> 4)) ^ 0xff; +} + +main () +{ + if (f (0) != 0xaf) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930529-1.c b/gcc/testsuite/gcc.c-torture/execute/930529-1.c new file mode 100644 index 00000000000..906338e6e9a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930529-1.c @@ -0,0 +1,45 @@ +dd (x,d) { return x / d; } + +main () +{ + int i; + for (i = -3; i <= 3; i++) + { + if (dd (i, 1) != i / 1) + abort (); + if (dd (i, 2) != i / 2) + abort (); + if (dd (i, 3) != i / 3) + abort (); + if (dd (i, 4) != i / 4) + abort (); + if (dd (i, 5) != i / 5) + abort (); + if (dd (i, 6) != i / 6) + abort (); + if (dd (i, 7) != i / 7) + abort (); + if (dd (i, 8) != i / 8) + abort (); + } + for (i = ((unsigned) ~0 >> 1) - 3; i <= ((unsigned) ~0 >> 1) + 3; i++) + { + if (dd (i, 1) != i / 1) + abort (); + if (dd (i, 2) != i / 2) + abort (); + if (dd (i, 3) != i / 3) + abort (); + if (dd (i, 4) != i / 4) + abort (); + if (dd (i, 5) != i / 5) + abort (); + if (dd (i, 6) != i / 6) + abort (); + if (dd (i, 7) != i / 7) + abort (); + if (dd (i, 8) != i / 8) + abort (); + } + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930603-1.c b/gcc/testsuite/gcc.c-torture/execute/930603-1.c new file mode 100644 index 00000000000..6a84de03562 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930603-1.c @@ -0,0 +1,22 @@ +float fx (x) + float x; +{ + return 1.0 + 3.0 / (2.302585093 * x); +} + +main () +{ + float fx (), inita (), initc (), a, b, c; + a = inita (); + c = initc (); + f (); + b = fx (c) + a; + f (); + if (a != 3.0 || b < 4.3257 || b > 4.3258 || c != 4.0) + abort (); + exit (0); +} + +float inita () { return 3.0; } +float initc () { return 4.0; } +f () {} diff --git a/gcc/testsuite/gcc.c-torture/execute/930603-2.c b/gcc/testsuite/gcc.c-torture/execute/930603-2.c new file mode 100644 index 00000000000..8cf06a21139 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930603-2.c @@ -0,0 +1,19 @@ +int w[2][2]; + +f () +{ + int i, j; + + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + if (i == j) + w[i][j] = 1; +} + +main () +{ + f (); + if (w[0][0] != 1 || w[1][1] != 1 || w[1][0] != 0 || w[0][1] != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930603-3.c b/gcc/testsuite/gcc.c-torture/execute/930603-3.c new file mode 100644 index 00000000000..22e5aed4a8b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930603-3.c @@ -0,0 +1,30 @@ +f (b, c) + unsigned char *b; + int c; +{ + unsigned long v = 0; + switch (c) + { + case 'd': + v = ((unsigned long)b[0] << 8) + b[1]; + v >>= 9; + break; + + case 'k': + v = b[3] >> 4; + break; + + default: + abort (); + } + + return v; +} +main () +{ + char buf[4]; + buf[0] = 170; buf[1] = 5; + if (f (buf, 'd') != 85) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930608-1.c b/gcc/testsuite/gcc.c-torture/execute/930608-1.c new file mode 100644 index 00000000000..004a4400709 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930608-1.c @@ -0,0 +1,11 @@ +double f (double a) {} +double (* const a[]) (double) = {&f}; + +main () +{ + double (*p) (); + p = &f; + if (p != a[0]) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930614-1.c b/gcc/testsuite/gcc.c-torture/execute/930614-1.c new file mode 100644 index 00000000000..7b206344b3a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930614-1.c @@ -0,0 +1,19 @@ +f (double *ty) +{ + *ty = -1.0; +} + +main () +{ + double foo[6]; + double tx = 0.0, ty, d; + + f (&ty); + + if (ty < 0) + ty = -ty; + d = (tx > ty) ? tx : ty; + if (ty != d) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930614-2.c b/gcc/testsuite/gcc.c-torture/execute/930614-2.c new file mode 100644 index 00000000000..ab83a7e3bb9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930614-2.c @@ -0,0 +1,20 @@ +main () +{ + int i, j, k, l; + float x[8][2][8][2]; + + for (i = 0; i < 8; i++) + for (j = i; j < 8; j++) + for (k = 0; k < 2; k++) + for (l = 0; l < 2; l++) + { + if ((i == j) && (k == l)) + x[i][k][j][l] = 0.8; + else + x[i][k][j][l] = 0.8; + if (x[i][k][j][l] < 0.0) + abort (); + } + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930621-1.c b/gcc/testsuite/gcc.c-torture/execute/930621-1.c new file mode 100644 index 00000000000..6131301df2f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930621-1.c @@ -0,0 +1,19 @@ +f () +{ + struct { + int x : 18; + int y : 14; + } foo; + + foo.x = 10; + foo.y = 20; + + return foo.y; +} + +main () +{ + if (f () != 20) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930622-1.c b/gcc/testsuite/gcc.c-torture/execute/930622-1.c new file mode 100644 index 00000000000..d733e133d35 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930622-1.c @@ -0,0 +1,22 @@ +int a = 1, b; + +g () { return 0; } +h (x) {} + +f () +{ + if (g () == -1) + return 0; + a = g (); + if (b >= 1) + h (a); + return 0; +} + +main () +{ + f (); + if (a != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930622-2.c b/gcc/testsuite/gcc.c-torture/execute/930622-2.c new file mode 100644 index 00000000000..d049b002a19 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930622-2.c @@ -0,0 +1,24 @@ +long double +ll_to_ld (long long n) +{ + return n; +} + +long long +ld_to_ll (long double n) +{ + return n; +} + +main () +{ + long long n; + + if (ll_to_ld (10LL) != 10.0) + abort (); + + if (ld_to_ll (10.0) != 10) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930628-1.c b/gcc/testsuite/gcc.c-torture/execute/930628-1.c new file mode 100644 index 00000000000..58c612d1a1c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930628-1.c @@ -0,0 +1,27 @@ +f (double x[2], double y[2]) +{ + if (x == y) + abort (); +} + +main () +{ + struct { int f[3]; double x[1][2]; } tp[4][2]; + int i, j, ki, kj, mi, mj; + float bdm[4][2][4][2]; + + for (i = 0; i < 4; i++) + for (j = i; j < 4; j++) + for (ki = 0; ki < 2; ki++) + for (kj = 0; kj < 2; kj++) + if ((j == i) && (ki == kj)) + bdm[i][ki][j][kj] = 1000.0; + else + { + for (mi = 0; mi < 1; mi++) + for (mj = 0; mj < 1; mj++) + f (tp[i][ki].x[mi], tp[j][kj].x[mj]); + bdm[i][ki][j][kj] = 1000.0; + } + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930630-1.c b/gcc/testsuite/gcc.c-torture/execute/930630-1.c new file mode 100644 index 00000000000..4befa835d0d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930630-1.c @@ -0,0 +1,19 @@ +main () +{ + struct + { + signed int bf0:17; + signed int bf1:7; + } bf; + + bf.bf1 = 7; + f (bf.bf1); + exit (0); +} + +f (x) + int x; +{ + if (x != 7) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930702-1.c b/gcc/testsuite/gcc.c-torture/execute/930702-1.c new file mode 100644 index 00000000000..8828a701cb9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930702-1.c @@ -0,0 +1,14 @@ +fp (double a, int b) +{ + if (a != 33 || b != 11) + abort (); +} + +main () +{ + int (*f) (double, int) = fp; + + fp (33, 11); + f (33, 11); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930713-1.c b/gcc/testsuite/gcc.c-torture/execute/930713-1.c new file mode 100644 index 00000000000..6b4d5ab796a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930713-1.c @@ -0,0 +1,23 @@ +typedef struct +{ + char x; +} T; + +T +f (s1) + T s1; +{ + T s1a; + s1a.x = 17; + return s1a; +} + +main () +{ + T s1a, s1b; + s1a.x = 13; + s1b = f (s1a); + if (s1a.x != 13 || s1b.x != 17) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930718-1.c b/gcc/testsuite/gcc.c-torture/execute/930718-1.c new file mode 100644 index 00000000000..a8eacc2d222 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930718-1.c @@ -0,0 +1,34 @@ +typedef struct rtx_def +{ + int f1 :1; + int f2 :1; +} *rtx; + +static rtx +f (orig) + register rtx orig; +{ + if (orig->f1 || orig->f2) + return orig; + orig->f2 = 1; + return orig; +} + +void +f2 () +{ + abort (); +} + +main () +{ + struct rtx_def foo; + rtx bar; + + foo.f1 = 1; + foo.f2 = 0; + bar = f (&foo); + if (bar != &foo || bar->f2 != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930719-1.c b/gcc/testsuite/gcc.c-torture/execute/930719-1.c new file mode 100644 index 00000000000..c6557efc735 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930719-1.c @@ -0,0 +1,23 @@ +int +f (foo, bar, com) +{ + unsigned align; + if (foo) + return 0; + while (1) + { + switch (bar) + { + case 1: + if (com != 0) + return align; + *(char *) 0 = 0; + } + } +} + +main () +{ + f (0, 1, 1); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930725-1.c b/gcc/testsuite/gcc.c-torture/execute/930725-1.c new file mode 100644 index 00000000000..3bd738ca08a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930725-1.c @@ -0,0 +1,21 @@ +int v; + +char * +g () +{ + return ""; +} + +char * +f () +{ + return (v == 0 ? g () : "abc"); +} + +main () +{ + v = 1; + if (!strcmp (f (), "abc")) + exit (0); + abort(); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930818-1.c b/gcc/testsuite/gcc.c-torture/execute/930818-1.c new file mode 100644 index 00000000000..710e3ce2fbe --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930818-1.c @@ -0,0 +1,15 @@ +static double one = 1.0; + +f() +{ + int colinear; + colinear = (one == 0.0); + if (colinear) + abort (); + return colinear; +} +main() +{ + if (f()) abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930916-1.c b/gcc/testsuite/gcc.c-torture/execute/930916-1.c new file mode 100644 index 00000000000..6302614a8c8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930916-1.c @@ -0,0 +1,13 @@ +f (n) + unsigned n; +{ + if ((int) n >= 0) + abort (); +} + +main () +{ + unsigned x = ~0; + f (x); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930921-1.c b/gcc/testsuite/gcc.c-torture/execute/930921-1.c new file mode 100644 index 00000000000..12e04e30954 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930921-1.c @@ -0,0 +1,15 @@ +f (x) + unsigned x; +{ + return (unsigned) (((unsigned long long) x * 0xAAAAAAAB) >> 32) >> 1; +} + +main () +{ + unsigned i; + + for (i = 0; i < 10000; i++) + if (f (i) != i / 3) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930929-1.c b/gcc/testsuite/gcc.c-torture/execute/930929-1.c new file mode 100644 index 00000000000..31f695442f5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930929-1.c @@ -0,0 +1,36 @@ +sub1 (i) + int i; +{ + return i - (5 - i); +} + +sub2 (i) + int i; +{ + return i + (5 + i); +} + +sub3 (i) + int i; +{ + return i - (5 + i); +} + +sub4 (i) + int i; +{ + return i + (5 - i); +} + +main() +{ + if (sub1 (20) != 35) + abort (); + if (sub2 (20) != 45) + abort (); + if (sub3 (20) != -5) + abort (); + if (sub4 (20) != 5) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930930-1.c b/gcc/testsuite/gcc.c-torture/execute/930930-1.c new file mode 100644 index 00000000000..68fdbbfe851 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930930-1.c @@ -0,0 +1,35 @@ +long *wm_TR; +long *wm_HB; +long *wm_SPB; + +long mem[100]; + +f (mr_TR, mr_SPB, mr_HB, reg1, reg2) + long *mr_TR; + long *mr_SPB; + long *mr_HB; + long *reg1; + long *reg2; +{ + long *x = mr_TR; + + for (;;) + { + if (reg1 < reg2) + goto out; + if ((long *) *reg1 < mr_HB && (long *) *reg1 >= mr_SPB) + *--mr_TR = *reg1; + reg1--; + } + out: + + if (x != mr_TR) + abort (); +} + +main () +{ + mem[99] = (long) mem; + f (mem + 100, mem + 6, mem + 8, mem + 99, mem + 99); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/930930-2.c b/gcc/testsuite/gcc.c-torture/execute/930930-2.c new file mode 100644 index 00000000000..eb34d11fe22 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/930930-2.c @@ -0,0 +1,30 @@ +int +test_endianness() +{ + union doubleword + { + double d; + unsigned long u[2]; + } dw; + dw.d = 10; + return dw.u[0] != 0 ? 1 : 0; +} + +int +test_endianness_vol() +{ + union doubleword + { + volatile double d; + volatile long u[2]; + } dw; + dw.d = 10; + return dw.u[0] != 0 ? 1 : 0; +} + +main () +{ + if (test_endianness () != test_endianness_vol ()) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931002-1.c b/gcc/testsuite/gcc.c-torture/execute/931002-1.c new file mode 100644 index 00000000000..6a02b234394 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931002-1.c @@ -0,0 +1,28 @@ +f (void (*func) ()) +{ + func (); +} + +main () +{ +#ifndef NO_TRAMPOLINES + void t0 () + { + } + + void t1 () + { + f (t0); + } + + void t2 () + { + t1 (); + } + + t1 (); + t1 (); + t2 (); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-1.c b/gcc/testsuite/gcc.c-torture/execute/931004-1.c new file mode 100644 index 00000000000..9c89afdae35 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-1.c @@ -0,0 +1,30 @@ +struct tiny +{ + int c; +}; + +f (int n, struct tiny x, struct tiny y, struct tiny z, long l) +{ + if (x.c != 10) + abort(); + + if (y.c != 11) + abort(); + + if (z.c != 12) + abort(); + + if (l != 123) + abort (); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-10.c b/gcc/testsuite/gcc.c-torture/execute/931004-10.c new file mode 100644 index 00000000000..cf0125dba62 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-10.c @@ -0,0 +1,44 @@ +#include <stdarg.h> + +struct tiny +{ + char c; + char d; +}; + +f (int n, ...) +{ + struct tiny x; + int i; + + va_list ap; + va_start (ap,n); + for (i = 0; i < n; i++) + { + x = va_arg (ap,struct tiny); + if (x.c != i + 10) + abort(); + if (x.d != i + 20) + abort(); + } + { + long x = va_arg (ap, long); + if (x != 123) + abort(); + } + va_end (ap); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-11.c b/gcc/testsuite/gcc.c-torture/execute/931004-11.c new file mode 100644 index 00000000000..b6047025ce9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-11.c @@ -0,0 +1,50 @@ +struct tiny +{ + char c; + char d; + char e; +}; + +f (int n, struct tiny x, struct tiny y, struct tiny z, long l) +{ + if (x.c != 10) + abort(); + if (x.d != 20) + abort(); + if (x.e != 30) + abort(); + + if (y.c != 11) + abort(); + if (y.d != 21) + abort(); + if (y.e != 31) + abort(); + + if (z.c != 12) + abort(); + if (z.d != 22) + abort(); + if (z.e != 32) + abort(); + + if (l != 123) + abort (); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + x[0].e = 30; + x[1].e = 31; + x[2].e = 32; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-12.c b/gcc/testsuite/gcc.c-torture/execute/931004-12.c new file mode 100644 index 00000000000..d3fc71e0cb0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-12.c @@ -0,0 +1,50 @@ +#include <stdarg.h> + +struct tiny +{ + char c; + char d; + char e; +}; + +f (int n, ...) +{ + struct tiny x; + int i; + + va_list ap; + va_start (ap,n); + for (i = 0; i < n; i++) + { + x = va_arg (ap,struct tiny); + if (x.c != i + 10) + abort(); + if (x.d != i + 20) + abort(); + if (x.e != i + 30) + abort(); + } + { + long x = va_arg (ap, long); + if (x != 123) + abort(); + } + va_end (ap); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + x[0].e = 30; + x[1].e = 31; + x[2].e = 32; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-13.c b/gcc/testsuite/gcc.c-torture/execute/931004-13.c new file mode 100644 index 00000000000..60422af8eb7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-13.c @@ -0,0 +1,60 @@ +struct tiny +{ + char c; + char d; + char e; + char f; +}; + +f (int n, struct tiny x, struct tiny y, struct tiny z, long l) +{ + if (x.c != 10) + abort(); + if (x.d != 20) + abort(); + if (x.e != 30) + abort(); + if (x.f != 40) + abort(); + + if (y.c != 11) + abort(); + if (y.d != 21) + abort(); + if (y.e != 31) + abort(); + if (y.f != 41) + abort(); + + if (z.c != 12) + abort(); + if (z.d != 22) + abort(); + if (z.e != 32) + abort(); + if (z.f != 42) + abort(); + + if (l != 123) + abort (); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + x[0].e = 30; + x[1].e = 31; + x[2].e = 32; + x[0].f = 40; + x[1].f = 41; + x[2].f = 42; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-14.c b/gcc/testsuite/gcc.c-torture/execute/931004-14.c new file mode 100644 index 00000000000..55c71bbc42a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-14.c @@ -0,0 +1,56 @@ +#include <stdarg.h> + +struct tiny +{ + char c; + char d; + char e; + char f; +}; + +f (int n, ...) +{ + struct tiny x; + int i; + + va_list ap; + va_start (ap,n); + for (i = 0; i < n; i++) + { + x = va_arg (ap,struct tiny); + if (x.c != i + 10) + abort(); + if (x.d != i + 20) + abort(); + if (x.e != i + 30) + abort(); + if (x.f != i + 40) + abort(); + } + { + long x = va_arg (ap, long); + if (x != 123) + abort(); + } + va_end (ap); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + x[0].e = 30; + x[1].e = 31; + x[2].e = 32; + x[0].f = 40; + x[1].f = 41; + x[2].f = 42; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-2.c b/gcc/testsuite/gcc.c-torture/execute/931004-2.c new file mode 100644 index 00000000000..83bdea67b0c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-2.c @@ -0,0 +1,38 @@ +#include <stdarg.h> + +struct tiny +{ + int c; +}; + +f (int n, ...) +{ + struct tiny x; + int i; + + va_list ap; + va_start (ap,n); + for (i = 0; i < n; i++) + { + x = va_arg (ap,struct tiny); + if (x.c != i + 10) + abort(); + } + { + long x = va_arg (ap, long); + if (x != 123) + abort(); + } + va_end (ap); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-3.c b/gcc/testsuite/gcc.c-torture/execute/931004-3.c new file mode 100644 index 00000000000..1e7a0fdcd53 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-3.c @@ -0,0 +1,30 @@ +struct tiny +{ + short c; +}; + +f (int n, struct tiny x, struct tiny y, struct tiny z, long l) +{ + if (x.c != 10) + abort(); + + if (y.c != 11) + abort(); + + if (z.c != 12) + abort(); + + if (l != 123) + abort (); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-4.c b/gcc/testsuite/gcc.c-torture/execute/931004-4.c new file mode 100644 index 00000000000..f0d2331e5cc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-4.c @@ -0,0 +1,38 @@ +#include <stdarg.h> + +struct tiny +{ + short c; +}; + +f (int n, ...) +{ + struct tiny x; + int i; + + va_list ap; + va_start (ap,n); + for (i = 0; i < n; i++) + { + x = va_arg (ap,struct tiny); + if (x.c != i + 10) + abort(); + } + { + long x = va_arg (ap, long); + if (x != 123) + abort(); + } + va_end (ap); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-5.c b/gcc/testsuite/gcc.c-torture/execute/931004-5.c new file mode 100644 index 00000000000..9bef779e6ed --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-5.c @@ -0,0 +1,40 @@ +struct tiny +{ + short c; + short d; +}; + +f (int n, struct tiny x, struct tiny y, struct tiny z, long l) +{ + if (x.c != 10) + abort(); + if (x.d != 20) + abort(); + + if (y.c != 11) + abort(); + if (y.d != 21) + abort(); + + if (z.c != 12) + abort(); + if (z.d != 22) + abort(); + + if (l != 123) + abort (); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-6.c b/gcc/testsuite/gcc.c-torture/execute/931004-6.c new file mode 100644 index 00000000000..6dca48f38ef --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-6.c @@ -0,0 +1,44 @@ +#include <stdarg.h> + +struct tiny +{ + short c; + short d; +}; + +f (int n, ...) +{ + struct tiny x; + int i; + + va_list ap; + va_start (ap,n); + for (i = 0; i < n; i++) + { + x = va_arg (ap,struct tiny); + if (x.c != i + 10) + abort(); + if (x.d != i + 20) + abort(); + } + { + long x = va_arg (ap, long); + if (x != 123) + abort(); + } + va_end (ap); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-7.c b/gcc/testsuite/gcc.c-torture/execute/931004-7.c new file mode 100644 index 00000000000..8ab2fcb2ab2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-7.c @@ -0,0 +1,30 @@ +struct tiny +{ + char c; +}; + +f (int n, struct tiny x, struct tiny y, struct tiny z, long l) +{ + if (x.c != 10) + abort(); + + if (y.c != 11) + abort(); + + if (z.c != 12) + abort(); + + if (l != 123) + abort (); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-8.c b/gcc/testsuite/gcc.c-torture/execute/931004-8.c new file mode 100644 index 00000000000..5fb97f64a6b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-8.c @@ -0,0 +1,38 @@ +#include <stdarg.h> + +struct tiny +{ + char c; +}; + +f (int n, ...) +{ + struct tiny x; + int i; + + va_list ap; + va_start (ap,n); + for (i = 0; i < n; i++) + { + x = va_arg (ap,struct tiny); + if (x.c != i + 10) + abort(); + } + { + long x = va_arg (ap, long); + if (x != 123) + abort(); + } + va_end (ap); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931004-9.c b/gcc/testsuite/gcc.c-torture/execute/931004-9.c new file mode 100644 index 00000000000..07247f7adfa --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931004-9.c @@ -0,0 +1,40 @@ +struct tiny +{ + char c; + char d; +}; + +f (int n, struct tiny x, struct tiny y, struct tiny z, long l) +{ + if (x.c != 10) + abort(); + if (x.d != 20) + abort(); + + if (y.c != 11) + abort(); + if (y.d != 21) + abort(); + + if (z.c != 12) + abort(); + if (z.d != 22) + abort(); + + if (l != 123) + abort (); +} + +main () +{ + struct tiny x[3]; + x[0].c = 10; + x[1].c = 11; + x[2].c = 12; + x[0].d = 20; + x[1].d = 21; + x[2].d = 22; + f (3, x[0], x[1], x[2], (long) 123); + exit(0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931005-1.c b/gcc/testsuite/gcc.c-torture/execute/931005-1.c new file mode 100644 index 00000000000..5a7e031cbfe --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931005-1.c @@ -0,0 +1,23 @@ +typedef struct +{ + char x; +} T; + +T +f (s1) + T s1; +{ + T s1a; + s1a.x = s1.x; + return s1a; +} + +main () +{ + T s1a, s1b; + s1a.x = 100; + s1b = f (s1a); + if (s1b.x != 100) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931009-1.c b/gcc/testsuite/gcc.c-torture/execute/931009-1.c new file mode 100644 index 00000000000..292228014e7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931009-1.c @@ -0,0 +1,26 @@ +main () +{ + f (); + exit (0); +} + +static +g (out, size, lo, hi) + int *out, size, lo, hi; +{ + int j; + + for (j = 0; j < size; j++) + out[j] = j * (hi - lo); +} + + +f () +{ + int a[2]; + + g (a, 2, 0, 1); + + if (a[0] != 0 || a[1] != 1) + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931012-1.c b/gcc/testsuite/gcc.c-torture/execute/931012-1.c new file mode 100644 index 00000000000..d9c958ddb90 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931012-1.c @@ -0,0 +1,13 @@ +f (int b, int c) +{ + if (b != 0 && b != 1 && c != 0) + b = 0; + return b; +} + +main () +{ + if (!f (1, 2)) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931017-1.c b/gcc/testsuite/gcc.c-torture/execute/931017-1.c new file mode 100644 index 00000000000..5917bd95b76 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931017-1.c @@ -0,0 +1,54 @@ +int v; + +main () +{ + f (); + exit (0); +} + +h1 () +{ + return 0; +} + +h2 (e) + int *e; +{ + if (e != &v) + abort (); + return 0; +} + +g (c) + char *c; +{ + int i; + int b; + + do + { + i = h1 (); + if (i == -1) + return 0; + else if (i == 1) + h1 (); + } + while (i == 1); + + do + b = h2 (&v); + while (i == 5); + + if (i != 2) + return b; + *c = 'a'; + + return 0; +} + + +f () +{ + char c; + g (&c); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931018-1.c b/gcc/testsuite/gcc.c-torture/execute/931018-1.c new file mode 100644 index 00000000000..d3814e699b8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931018-1.c @@ -0,0 +1,18 @@ +unsigned int a[0x1000]; +extern unsigned long v; + +main () +{ + f (v); + f (v); + exit (0); +} + +f (a) + unsigned long a; +{ + if (a != 0xdeadbeefL) + abort(); +} + +const unsigned long v = 0xdeadbeefL; diff --git a/gcc/testsuite/gcc.c-torture/execute/931031-1.c b/gcc/testsuite/gcc.c-torture/execute/931031-1.c new file mode 100644 index 00000000000..761989040f4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931031-1.c @@ -0,0 +1,24 @@ +struct foo +{ + unsigned y:1; + unsigned x:32; +}; + +int +f (x) + struct foo x; +{ + int t = x.x; + if (t < 0) + return 1; + return t+1; +} + +main () +{ + struct foo x; + x.x = -1; + if (f (x) == 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931102-1.c b/gcc/testsuite/gcc.c-torture/execute/931102-1.c new file mode 100644 index 00000000000..489e7ebda8d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931102-1.c @@ -0,0 +1,30 @@ +typedef union +{ + struct + { + char h, l; + } b; +} T; + +f (x) + int x; +{ + int num = 0; + T reg; + + reg.b.l = x; + while ((reg.b.l & 1) == 0) + { + num++; + reg.b.l >>= 1; + } + return num; +} + +main () +{ + if (f (2) != 1) + abort (); + exit (0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931102-2.c b/gcc/testsuite/gcc.c-torture/execute/931102-2.c new file mode 100644 index 00000000000..6fc735c8bc1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931102-2.c @@ -0,0 +1,31 @@ +typedef union +{ + long align; + struct + { + short h, l; + } b; +} T; + +f (x) + int x; +{ + int num = 0; + T reg; + + reg.b.l = x; + while ((reg.b.l & 1) == 0) + { + num++; + reg.b.l >>= 1; + } + return num; +} + +main () +{ + if (f (2) != 1) + abort (); + exit (0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/931110-1.c b/gcc/testsuite/gcc.c-torture/execute/931110-1.c new file mode 100644 index 00000000000..5b33b269a2d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931110-1.c @@ -0,0 +1,18 @@ +typedef struct +{ + short f:3, g:3, h:10; +} small; + +struct +{ + int i; + small s[10]; +} x; + +main () +{ + int i; + for (i = 0; i < 10; i++) + x.s[i].f = 0; + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931110-2.c b/gcc/testsuite/gcc.c-torture/execute/931110-2.c new file mode 100644 index 00000000000..586615b180c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931110-2.c @@ -0,0 +1,12 @@ +main () +{ + static int a[] = {3, 4}; + register int *b; + int c; + + b = a; + c = *b++ % 8; + if (c != 3) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931208-1.c b/gcc/testsuite/gcc.c-torture/execute/931208-1.c new file mode 100644 index 00000000000..ee2bc9f1e04 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931208-1.c @@ -0,0 +1,14 @@ +f () +{ + unsigned long x, y = 1; + + x = ((y * 8192) - 216) / 16; + return x; +} + +main () +{ + if (f () != 498) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/931228-1.c b/gcc/testsuite/gcc.c-torture/execute/931228-1.c new file mode 100644 index 00000000000..dcd3b65ff3b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/931228-1.c @@ -0,0 +1,15 @@ +f (x) +{ + x &= 010000; + x &= 007777; + x ^= 017777; + x &= 017770; + return x; +} + +main () +{ + if (f (-1) != 017770) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/940115-1.c b/gcc/testsuite/gcc.c-torture/execute/940115-1.c new file mode 100644 index 00000000000..d0fac9077a1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/940115-1.c @@ -0,0 +1,13 @@ +f (cp, end) + char *cp; + char *end; +{ + return (cp < end); +} + +main () +{ + if (! f ((char *) 0, (char *) 1)) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/940122-1.c b/gcc/testsuite/gcc.c-torture/execute/940122-1.c new file mode 100644 index 00000000000..9dbf6ae185b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/940122-1.c @@ -0,0 +1,21 @@ +char *a = 0; +char *b = 0; + +g (x) + int x; +{ + if ((!!a) != (!!b)) + abort (); +} + +f (x) + int x; +{ + g (x * x); +} + +main () +{ + f (100); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941014-1.c b/gcc/testsuite/gcc.c-torture/execute/941014-1.c new file mode 100644 index 00000000000..98db917428f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941014-1.c @@ -0,0 +1,15 @@ +int f (int a, int b) { } + +main () +{ + unsigned long addr1; + unsigned long addr2; + + addr1 = (unsigned long) &f; + addr1 += 5; + addr2 = 5 + (unsigned long) &f; + + if (addr1 != addr2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941014-2.c b/gcc/testsuite/gcc.c-torture/execute/941014-2.c new file mode 100644 index 00000000000..3932a34ce92 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941014-2.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> + +typedef struct { + unsigned short a; + unsigned short b; +} foo_t; + +void a1 (unsigned long offset) {} + +volatile foo_t * +f () +{ + volatile foo_t *foo_p = (volatile foo_t *)malloc (sizeof (foo_t)); + + a1((unsigned long)foo_p-30); + if (foo_p->a & 0xf000) + printf("%d\n", foo_p->a); + foo_p->b = 0x0100; + a1 ((unsigned long)foo_p + 2); + a1 ((unsigned long)foo_p - 30); + return foo_p; +} + +main () +{ + volatile foo_t *foo_p; + + foo_p = f (); + if (foo_p->b != 0x0100) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941015-1.c b/gcc/testsuite/gcc.c-torture/execute/941015-1.c new file mode 100644 index 00000000000..38d4796645f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941015-1.c @@ -0,0 +1,35 @@ +int +foo1 (value) + long long value; +{ + register const long long constant = 0xc000000080000000LL; + + if (value < constant) + return 1; + else + return 2; +} + +int +foo2 (value) + unsigned long long value; +{ + register const unsigned long long constant = 0xc000000080000000LL; + + if (value < constant) + return 1; + else + return 2; +} + +main () +{ + unsigned long long value = 0xc000000000000001LL; + int x, y; + + x = foo1 (value); + y = foo2 (value); + if (x != y || x != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941021-1.c b/gcc/testsuite/gcc.c-torture/execute/941021-1.c new file mode 100644 index 00000000000..9fc1cfadf97 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941021-1.c @@ -0,0 +1,20 @@ +double glob_dbl; + +f (pdbl, value) + double *pdbl; + double value; +{ + if (pdbl == 0) + pdbl = &glob_dbl; + + *pdbl = value; +} + +main () +{ + f ((void *) 0, 55.1); + + if (glob_dbl != 55.1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941025-1.c b/gcc/testsuite/gcc.c-torture/execute/941025-1.c new file mode 100644 index 00000000000..2daf0ad25cc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941025-1.c @@ -0,0 +1,12 @@ +long f (x, y) + long x,y; +{ + return (x > 1) ? y : (y & 1); +} + +main () +{ + if (f (2L, 0xdecadeL) != 0xdecadeL) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941031-1.c b/gcc/testsuite/gcc.c-torture/execute/941031-1.c new file mode 100644 index 00000000000..134f966c6f3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941031-1.c @@ -0,0 +1,27 @@ +typedef long mpt; + +int +f (mpt us, mpt vs) +{ + long aus; + long avs; + + aus = us >= 0 ? us : -us; + avs = vs >= 0 ? vs : -vs; + + if (aus < avs) + { + long t = aus; + aus = avs; + avs = aus; + } + + return avs; +} + +main () +{ + if (f ((mpt) 3, (mpt) 17) != 17) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941101-1.c b/gcc/testsuite/gcc.c-torture/execute/941101-1.c new file mode 100644 index 00000000000..66b5f384a80 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941101-1.c @@ -0,0 +1,15 @@ +f () +{ + int var = 7; + + if ((var/7) == 1) + return var/7; + return 0; +} + +main () +{ + if (f () != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941110-1.c b/gcc/testsuite/gcc.c-torture/execute/941110-1.c new file mode 100644 index 00000000000..b78256d3c3f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941110-1.c @@ -0,0 +1,16 @@ +f (const int x) +{ + int y = 0; + y = x ? y : -y; + { + const int *p = &x; + } + return y; +} + +main () +{ + if (f (0)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/941202-1.c b/gcc/testsuite/gcc.c-torture/execute/941202-1.c new file mode 100644 index 00000000000..72d0b33e924 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/941202-1.c @@ -0,0 +1,21 @@ +g (x, y) +{ + if (x != 3) + abort (); +} + +static inline +f (int i) +{ + int *tmp; + + tmp = (int *) alloca (sizeof (i)); + *tmp = i; + g (*tmp, 0); +} + +main () +{ + f (3); + exit (0); +}; diff --git a/gcc/testsuite/gcc.c-torture/execute/950221-1.c b/gcc/testsuite/gcc.c-torture/execute/950221-1.c new file mode 100644 index 00000000000..d45fb5aeef0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950221-1.c @@ -0,0 +1,51 @@ +struct parsefile +{ + long fd; + char *buf; +}; +struct parsefile basepf; +struct parsefile *parsefile = &basepf; +int filler[0x3000]; +int el; + +char * +g1 (a, b) + int a; + int *b; +{ +} + +g2 (a) + long a; +{ + if (a != 0xdeadbeefL) + abort (); + exit (0); +} + +f () +{ + register char *p, *q; + register int i; + register int something; + + if (parsefile->fd == 0L && el) + { + const char *rl_cp; + int len; + rl_cp = g1 (el, &len); + strcpy (p, rl_cp); + } + else + { + alabel: + i = g2 (parsefile->fd); + } +} + +main () +{ + el = 0; + parsefile->fd = 0xdeadbeefL; + f (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950322-1.c b/gcc/testsuite/gcc.c-torture/execute/950322-1.c new file mode 100644 index 00000000000..28a1469fea0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950322-1.c @@ -0,0 +1,30 @@ +f (unsigned char *a) +{ + int i, j; + int x, y; + + j = a[1]; + i = a[0] - j; + if (i < 0) + { + x = 1; + y = -i; + } + else + { + x = 0; + y = i; + } + return x + y; +} + + +main () +{ + unsigned char a[2]; + a[0] = 8; + a[1] = 9; + if (f (a) != 2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950426-1.c b/gcc/testsuite/gcc.c-torture/execute/950426-1.c new file mode 100644 index 00000000000..076032c7220 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950426-1.c @@ -0,0 +1,32 @@ + +struct tag { + int m1; + char *m2[5]; +} s1, *p1; + +int i; + +main() +{ + s1.m1 = -1; + p1 = &s1; + + if ( func1( &p1->m1 ) == -1 ) + foo ("ok"); + else + abort (); + + i = 3; + s1.m2[3]= "123"; + + if ( strlen( (p1->m2[i])++ ) == 3 ) + foo ("ok"); + else + abort (); + + exit (0); +} + +func1(int *p) { return(*p); } + +foo (char *s) {} diff --git a/gcc/testsuite/gcc.c-torture/execute/950426-2.c b/gcc/testsuite/gcc.c-torture/execute/950426-2.c new file mode 100644 index 00000000000..a1a690469d1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950426-2.c @@ -0,0 +1,13 @@ +main() +{ + long int i = -2147483647L - 1L; /* 0x80000000 */ + char ca = 1; + + if (i >> ca != -1073741824L) + abort (); + + if (i >> i / -2000000000L != -1073741824L) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950503-1.c b/gcc/testsuite/gcc.c-torture/execute/950503-1.c new file mode 100644 index 00000000000..1c95b369c50 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950503-1.c @@ -0,0 +1,15 @@ +main () +{ + int tmp; + unsigned long long utmp1, utmp2; + + tmp = 16; + + utmp1 = (~((unsigned long long) 0)) >> tmp; + utmp2 = (~((unsigned long long) 0)) >> 16; + + if (utmp1 != utmp2) + abort (); + exit (0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/950511-1.c b/gcc/testsuite/gcc.c-torture/execute/950511-1.c new file mode 100644 index 00000000000..6584b0c86b6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950511-1.c @@ -0,0 +1,11 @@ +main () +{ + unsigned long long xx; + unsigned long long *x = (unsigned long long *) &xx; + + *x = -3; + *x = *x * *x; + if (*x != 9) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950512-1.c b/gcc/testsuite/gcc.c-torture/execute/950512-1.c new file mode 100644 index 00000000000..8aa116d27ca --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950512-1.c @@ -0,0 +1,24 @@ +unsigned +f1 (x) +{ + return ((unsigned) (x != 0) - 3) / 2; +} + +unsigned long long +f2 (x) +{ + return ((unsigned long long) (x != 0) - 3) / 2; +} + +main () +{ + if (f1 (1) != (~(unsigned) 0) >> 1) + abort (); + if (f1 (0) != ((~(unsigned) 0) >> 1) - 1) + abort (); + if (f2 (1) != (~(unsigned long long) 0) >> 1) + abort (); + if (f2 (0) != ((~(unsigned long long) 0) >> 1) - 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950605-1.c b/gcc/testsuite/gcc.c-torture/execute/950605-1.c new file mode 100644 index 00000000000..d89a42e49c6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950605-1.c @@ -0,0 +1,12 @@ +f (c) + unsigned char c; +{ + if (c != 0xFF) + abort (); +} + +main () +{ + f (-1); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950607-1.c b/gcc/testsuite/gcc.c-torture/execute/950607-1.c new file mode 100644 index 00000000000..7b1503ad11d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950607-1.c @@ -0,0 +1,9 @@ +main () +{ + struct { long status; } h; + + h.status = 0; + if (((h.status & 128) == 1) && ((h.status & 32) == 0)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950607-2.c b/gcc/testsuite/gcc.c-torture/execute/950607-2.c new file mode 100644 index 00000000000..da18f7373f4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950607-2.c @@ -0,0 +1,41 @@ +typedef struct { + long int p_x, p_y; +} Point; + +int +f (Point basePt, Point pt1, Point pt2) +{ + long long vector; + + vector = + (long long) (pt1.p_x - basePt.p_x) * (long long) (pt2.p_y - basePt.p_y) - + (long long) (pt1.p_y - basePt.p_y) * (long long) (pt2.p_x - basePt.p_x); + + if (vector > (long long) 0) + return 0; + else if (vector < (long long) 0) + return 1; + else + return 2; +} + +main () +{ + Point b, p1, p2; + int answer; + + b.p_x = -23250; + b.p_y = 23250; + + p1.p_x = 23250; + p1.p_y = -23250; + + p2.p_x = -23250; + p2.p_y = -23250; + + answer = f (b, p1, p2); + + if (answer != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950612-1.c b/gcc/testsuite/gcc.c-torture/execute/950612-1.c new file mode 100644 index 00000000000..f9885279c33 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950612-1.c @@ -0,0 +1,48 @@ +unsigned int +f1 (int diff) +{ + return ((unsigned int) (diff < 0 ? -diff : diff)); +} + +unsigned int +f2 (unsigned int diff) +{ + return ((unsigned int) ((signed int) diff < 0 ? -diff : diff)); +} + +unsigned long long +f3 (long long diff) +{ + return ((unsigned long long) (diff < 0 ? -diff : diff)); +} + +unsigned long long +f4 (unsigned long long diff) +{ + return ((unsigned long long) ((signed long long) diff < 0 ? -diff : diff)); +} + +main () +{ + int i; + for (i = 0; i <= 10; i++) + { + if (f1 (i) != i) + abort (); + if (f1 (-i) != i) + abort (); + if (f2 (i) != i) + abort (); + if (f2 (-i) != i) + abort (); + if (f3 ((long long) i) != i) + abort (); + if (f3 ((long long) -i) != i) + abort (); + if (f4 ((long long) i) != i) + abort (); + if (f4 ((long long) -i) != i) + abort (); + } + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950621-1.c b/gcc/testsuite/gcc.c-torture/execute/950621-1.c new file mode 100644 index 00000000000..5fc5a902874 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950621-1.c @@ -0,0 +1,20 @@ +struct s +{ + int a; + int b; + struct s *dummy; +}; + +f (struct s *sp) +{ + return sp && sp->a == -1 && sp->b == -1; +} + +main () +{ + struct s x; + x.a = x.b = -1; + if (f (&x) == 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950628-1.c b/gcc/testsuite/gcc.c-torture/execute/950628-1.c new file mode 100644 index 00000000000..e330ff56971 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950628-1.c @@ -0,0 +1,31 @@ +typedef struct +{ + char hours, day, month; + short year; +} T; + +T g (void) +{ + T now; + + now.hours = 1; + now.day = 2; + now.month = 3; + now.year = 4; + return now; +} + +T f (void) +{ + T virk; + + virk = g (); + return virk; +} + +main () +{ + if (f ().hours != 1 || f ().day != 2 || f ().month != 3 || f ().year != 4) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950704-1.c b/gcc/testsuite/gcc.c-torture/execute/950704-1.c new file mode 100644 index 00000000000..f11aff8cabc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950704-1.c @@ -0,0 +1,59 @@ +int errflag; + +long long +f (long long x, long long y) +{ + long long r; + + errflag = 0; + r = x + y; + if (x >= 0) + { + if ((y < 0) || (r >= 0)) + return r; + } + else + { + if ((y > 0) || (r < 0)) + return r; + } + errflag = 1; + return 0; +} + +main () +{ + f (0, 0); + if (errflag) + abort (); + + f (1, -1); + if (errflag) + abort (); + + f (-1, 1); + if (errflag) + abort (); + + f (0x8000000000000000LL, 0x8000000000000000LL); + if (!errflag) + abort (); + + f (0x8000000000000000LL, -1LL); + if (!errflag) + abort (); + + f (0x7fffffffffffffffLL, 0x7fffffffffffffffLL); + if (!errflag) + abort (); + + f (0x7fffffffffffffffLL, 1LL); + if (!errflag) + abort (); + + f (0x7fffffffffffffffLL, 0x8000000000000000LL); + if (errflag) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950706-1.c b/gcc/testsuite/gcc.c-torture/execute/950706-1.c new file mode 100644 index 00000000000..2db1915411c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950706-1.c @@ -0,0 +1,16 @@ +int +f (int n) +{ + return (n > 0) - (n < 0); +} + +main () +{ + if (f (-1) != -1) + abort (); + if (f (1) != 1) + abort (); + if (f (0) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950710-1.c b/gcc/testsuite/gcc.c-torture/execute/950710-1.c new file mode 100644 index 00000000000..26ff9b2a8a0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950710-1.c @@ -0,0 +1,54 @@ +struct twelve +{ + int a; + int b; + int c; +}; + +struct pair +{ + int first; + int second; +}; + +struct pair +g () +{ + struct pair p; + return p; +} + +static void +f () +{ + int i; + for (i = 0; i < 1; i++) + { + int j; + for (j = 0; j < 1; j++) + { + if (0) + { + int k; + for (k = 0; k < 1; k++) + { + struct pair e = g (); + } + } + else + { + struct twelve a, b; + if ((((char *) &b - (char *) &a) < 0 + ? (-((char *) &b - (char *) &a)) + : ((char *) &b - (char *) &a)) < sizeof (a)) + abort (); + } + } + } +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950714-1.c b/gcc/testsuite/gcc.c-torture/execute/950714-1.c new file mode 100644 index 00000000000..5dc44a906e2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950714-1.c @@ -0,0 +1,17 @@ +int array[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + +main () +{ + int i, j; + int *p; + + for (i = 0; i < 10; i++) + for (p = &array[0]; p != &array[9]; p++) + if (*p == i) + goto label; + + label: + if (i != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950809-1.c b/gcc/testsuite/gcc.c-torture/execute/950809-1.c new file mode 100644 index 00000000000..a33d42bd7cd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950809-1.c @@ -0,0 +1,33 @@ +struct S +{ + int *sp, fc, *sc, a[2]; +}; + +f (struct S *x) +{ + int *t = x->sc; + int t1 = t[0]; + int t2 = t[1]; + int t3 = t[2]; + int a0 = x->a[0]; + int a1 = x->a[1]; + t[2] = t1; + t[0] = a1; + x->a[1] = a0; + x->a[0] = t3; + x->fc = t2; + x->sp = t; +} + +main () +{ + struct S s; + static int sc[3] = {2, 3, 4}; + s.sc = sc; + s.a[0] = 10; + s.a[1] = 11; + f (&s); + if (s.sp[2] != 2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950906-1.c b/gcc/testsuite/gcc.c-torture/execute/950906-1.c new file mode 100644 index 00000000000..31997d5c257 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950906-1.c @@ -0,0 +1,16 @@ +g (int i) +{ +} + +f (int i) +{ + g (0); + while ( ({ i--; }) ) + g (0); +} + +main () +{ + f (10); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950915-1.c b/gcc/testsuite/gcc.c-torture/execute/950915-1.c new file mode 100644 index 00000000000..cfa044757b8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950915-1.c @@ -0,0 +1,15 @@ +long int a = 100000; +long int b = 21475; + +long +f () +{ + return ((long long) a * (long long) b) >> 16; +} + +main () +{ + if (f () < 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/950929-1.c b/gcc/testsuite/gcc.c-torture/execute/950929-1.c new file mode 100644 index 00000000000..a35cd6a153e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/950929-1.c @@ -0,0 +1,21 @@ +int f (char *p) { } + +main () +{ + char c; + char c2; + int i = 0; + char *pc = &c; + char *pc2 = &c2; + int *pi = &i; + + *pc2 = 1; + *pi = 1; + *pc2 &= *pi; + f (pc2); + *pc2 = 1; + *pc2 &= *pi; + if (*pc2 != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/951003-1.c b/gcc/testsuite/gcc.c-torture/execute/951003-1.c new file mode 100644 index 00000000000..269bf135386 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/951003-1.c @@ -0,0 +1,21 @@ +int f (i) { return 12; } +int g () { return 0; } + +main () +{ + int i, s; + + for (i = 0; i < 32; i++) + { + s = f (i); + + if (i == g ()) + s = 42; + if (i == 0 || s == 12) + ; + else + abort (); + } + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/951115-1.c b/gcc/testsuite/gcc.c-torture/execute/951115-1.c new file mode 100644 index 00000000000..03520c99ca2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/951115-1.c @@ -0,0 +1,24 @@ +int var = 0; + +g () +{ + var = 1; +} + +f () +{ + int f2 = 0; + + if (f2 == 0) + ; + + g (); +} + +main () +{ + f (); + if (var != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/951204-1.c b/gcc/testsuite/gcc.c-torture/execute/951204-1.c new file mode 100644 index 00000000000..c4d585b6b9e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/951204-1.c @@ -0,0 +1,18 @@ +f (char *x) +{ + *x = 'x'; +} + +main () +{ + int i; + char x = '\0'; + + for (i = 0; i < 100; ++i) + { + f (&x); + if (*(const char *) &x != 'x') + abort (); + } + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960116-1.c b/gcc/testsuite/gcc.c-torture/execute/960116-1.c new file mode 100644 index 00000000000..6d7624ca1a1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960116-1.c @@ -0,0 +1,20 @@ +static inline +p (int *p) +{ + return !((long) p & 1); +} + +int +f (int *q) +{ + if (p (q) && *q) + return 1; + return 0; +} + +main () +{ + if (f ((int*) 0xffffffff) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960117-1.c b/gcc/testsuite/gcc.c-torture/execute/960117-1.c new file mode 100644 index 00000000000..741455b08b9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960117-1.c @@ -0,0 +1,46 @@ +static char id_space[2] [32 +1]; +typedef short COUNT; + +typedef char TEXT; + +union T_VALS +{ + TEXT *id __attribute__ ((aligned (2), packed)) ; +}; +typedef union T_VALS VALS; + +struct T_VAL +{ + COUNT pos __attribute__ ((aligned (2), packed)) ; + VALS vals __attribute__ ((aligned (2), packed)) ; +}; +typedef struct T_VAL VAL; + +VAL curval = {0}; + +static short idc = 0; +static int cur_line; +static int char_pos; + +typedef unsigned short WORD; + +WORD +get_id (char c) +{ + curval.vals.id[0] = c; +} + +WORD +get_tok () +{ + char c = 'c'; + curval.vals.id = id_space[idc]; + curval.pos = (cur_line << 10) | char_pos; + return get_id (c); +} + +main () +{ + get_tok (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960209-1.c b/gcc/testsuite/gcc.c-torture/execute/960209-1.c new file mode 100644 index 00000000000..decd2af2aab --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960209-1.c @@ -0,0 +1,43 @@ +struct a_struct +{ + unsigned char a_character; +}; + +struct a_struct an_array[5]; +struct a_struct *a_ptr; +int yabba = 1; + +int +f (a, b) + unsigned char a; + unsigned long b; +{ + long i, j, p, q, r, s; + + if (b != (unsigned long) 0) + { + if (yabba) + return -1; + s = 4000000 / b; + for (i = 0; i < 11; i++) + { + for (j = 0; j < 256; j++) + { + if (((p - s < 0) ? -s : 0) < (( q - s < 0) ? -s : q)) + r = i; + } + } + } + + if (yabba) + return 0; + a_ptr = &an_array[a]; + a_ptr->a_character = (unsigned char) r; +} + +main () +{ + if (f (1, 0UL) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960215-1.c b/gcc/testsuite/gcc.c-torture/execute/960215-1.c new file mode 100644 index 00000000000..9502b4b2de4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960215-1.c @@ -0,0 +1,25 @@ +long double C = 2; +long double U = 1; +long double Y2 = 3; +long double Y1 = 1; +long double X, Y, Z, T, R, S; +main () +{ + X = (C + U) * Y2; + Y = C - U - U; + Z = C + U + U; + T = (C - U) * Y1; + X = X - (Z + U); + R = Y * Y1; + S = Z * Y2; + T = T - Y; + Y = (U - Y) + R; + Z = S - (Z + U + U); + R = (Y2 + U) * Y1; + Y1 = Y2 * Y1; + R = R - Y2; + Y1 = Y1 - 0.5L; + if (Z != 6) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960218-1.c b/gcc/testsuite/gcc.c-torture/execute/960218-1.c new file mode 100644 index 00000000000..7301a17b00d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960218-1.c @@ -0,0 +1,22 @@ +int glob; + +g (x) +{ + glob = x; + return 0; +} + +f (x) +{ + int a = ~x; + while (a) + a = g (a); +} + +main () +{ + f (3); + if (glob != -4) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960219-1.c b/gcc/testsuite/gcc.c-torture/execute/960219-1.c new file mode 100644 index 00000000000..d21bcfcad24 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960219-1.c @@ -0,0 +1,11 @@ +f (int i) +{ + if (((1 << i) & 1) == 0) + abort (); +} + +main () +{ + f (0); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960301-1.c b/gcc/testsuite/gcc.c-torture/execute/960301-1.c new file mode 100644 index 00000000000..d75efea9844 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960301-1.c @@ -0,0 +1,22 @@ +struct foo { + unsigned : 12; + unsigned field : 4; +} foo; +unsigned oldfoo; + +int +bar (unsigned k) +{ + oldfoo = foo.field; + foo.field = k; + if (k) + return 1; + return 2; +} + +main () +{ + if (bar (1U) != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960302-1.c b/gcc/testsuite/gcc.c-torture/execute/960302-1.c new file mode 100644 index 00000000000..7a9426a4635 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960302-1.c @@ -0,0 +1,21 @@ +long a = 1; + +foo () +{ + switch (a % 2 % 2 % 2 % 2 % 2 % 2 % 2 % 2) + { + case 0: + return 0; + case 1: + return 1; + default: + return -1; + } +} + +main () +{ + if (foo () != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960311-1.c b/gcc/testsuite/gcc.c-torture/execute/960311-1.c new file mode 100644 index 00000000000..16579d0bbd1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960311-1.c @@ -0,0 +1,69 @@ +#include <stdio.h> + +#ifdef DEBUG +#define abort() printf ("error, line %d\n", __LINE__) +#endif + +int count; + +void a1() { ++count; } + +void +b (unsigned char data) +{ + if (data & 0x80) a1(); + data <<= 1; + + if (data & 0x80) a1(); + data <<= 1; + + if (data & 0x80) a1(); +} + +main () +{ + count = 0; + b (0); + if (count != 0) + abort (); + + count = 0; + b (0x80); + if (count != 1) + abort (); + + count = 0; + b (0x40); + if (count != 1) + abort (); + + count = 0; + b (0x20); + if (count != 1) + abort (); + + count = 0; + b (0xc0); + if (count != 2) + abort (); + + count = 0; + b (0xa0); + if (count != 2) + abort (); + + count = 0; + b (0x60); + if (count != 2) + abort (); + + count = 0; + b (0xe0); + if (count != 3) + abort (); + +#ifdef DEBUG + printf ("Done.\n"); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960311-2.c b/gcc/testsuite/gcc.c-torture/execute/960311-2.c new file mode 100644 index 00000000000..d5c2d07a336 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960311-2.c @@ -0,0 +1,69 @@ +#include <stdio.h> + +#ifdef DEBUG +#define abort() printf ("error, line %d\n", __LINE__) +#endif + +int count; + +void a1() { ++count; } + +void +b (unsigned short data) +{ + if (data & 0x8000) a1(); + data <<= 1; + + if (data & 0x8000) a1(); + data <<= 1; + + if (data & 0x8000) a1(); +} + +main () +{ + count = 0; + b (0); + if (count != 0) + abort (); + + count = 0; + b (0x8000); + if (count != 1) + abort (); + + count = 0; + b (0x4000); + if (count != 1) + abort (); + + count = 0; + b (0x2000); + if (count != 1) + abort (); + + count = 0; + b (0xc000); + if (count != 2) + abort (); + + count = 0; + b (0xa000); + if (count != 2) + abort (); + + count = 0; + b (0x6000); + if (count != 2) + abort (); + + count = 0; + b (0xe000); + if (count != 3) + abort (); + +#ifdef DEBUG + printf ("Done.\n"); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960311-3.c b/gcc/testsuite/gcc.c-torture/execute/960311-3.c new file mode 100644 index 00000000000..755fc723f85 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960311-3.c @@ -0,0 +1,69 @@ +#include <stdio.h> + +#ifdef DEBUG +#define abort() printf ("error, line %d\n", __LINE__) +#endif + +int count; + +void a1() { ++count; } + +void +b (unsigned long data) +{ + if (data & 0x80000000) a1(); + data <<= 1; + + if (data & 0x80000000) a1(); + data <<= 1; + + if (data & 0x80000000) a1(); +} + +main () +{ + count = 0; + b (0); + if (count != 0) + abort (); + + count = 0; + b (0x80000000); + if (count != 1) + abort (); + + count = 0; + b (0x40000000); + if (count != 1) + abort (); + + count = 0; + b (0x20000000); + if (count != 1) + abort (); + + count = 0; + b (0xc0000000); + if (count != 2) + abort (); + + count = 0; + b (0xa0000000); + if (count != 2) + abort (); + + count = 0; + b (0x60000000); + if (count != 2) + abort (); + + count = 0; + b (0xe0000000); + if (count != 3) + abort (); + +#ifdef DEBUG + printf ("Done.\n"); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960312-1.c b/gcc/testsuite/gcc.c-torture/execute/960312-1.c new file mode 100644 index 00000000000..94e67df23bd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960312-1.c @@ -0,0 +1,34 @@ +struct S +{ + int *sp, fc, *sc, a[2]; +}; + +f (struct S *x) +{ + int *t = x->sc; + int t1 = t[0]; + int t2 = t[1]; + int t3 = t[2]; + int a0 = x->a[0]; + int a1 = x->a[1]; + asm("": :"r" (t2), "r" (t3)); + t[2] = t1; + t[0] = a1; + x->a[1] = a0; + x->a[0] = t3; + x->fc = t2; + x->sp = t; +} + +main () +{ + struct S s; + static int sc[3] = {2, 3, 4}; + s.sc = sc; + s.a[0] = 10; + s.a[1] = 11; + f (&s); + if (s.sp[2] != 2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960317-1.c b/gcc/testsuite/gcc.c-torture/execute/960317-1.c new file mode 100644 index 00000000000..8d7907d751c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960317-1.c @@ -0,0 +1,22 @@ +int +f (unsigned bitcount, int mant) +{ + int mask = -1 << bitcount; + { + if (! (mant & -mask)) + goto ab; + if (mant & ~mask) + goto auf; + } +ab: + return 0; +auf: + return 1; +} + +main () +{ + if (f (0, -1)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960321-1.c b/gcc/testsuite/gcc.c-torture/execute/960321-1.c new file mode 100644 index 00000000000..eafe48ff753 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960321-1.c @@ -0,0 +1,14 @@ +char a[10] = "deadbeef"; + +char +acc_a (long i) +{ + return a[i-2000000000L]; +} + +main () +{ + if (acc_a (2000000000L) != 'd') + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960326-1.c b/gcc/testsuite/gcc.c-torture/execute/960326-1.c new file mode 100644 index 00000000000..f2013737022 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960326-1.c @@ -0,0 +1,16 @@ +struct s +{ + int a; + int b; + short c; + int d[3]; +}; + +struct s s = { .b = 3, .d = {2,0,0} }; + +main () +{ + if (s.b != 3) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960327-1.c b/gcc/testsuite/gcc.c-torture/execute/960327-1.c new file mode 100644 index 00000000000..d630a7b572c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960327-1.c @@ -0,0 +1,30 @@ +#include <stdio.h> +g () +{ + return '\n'; +} + +f () +{ + char s[] = "abcedfg01234"; + char *sp = s + 12; + + switch (g ()) + { + case '\n': + break; + } + + while (*--sp == '0') + ; + sprintf (sp + 1, "X"); + + if (s[12] != 'X') + abort (); +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960402-1.c b/gcc/testsuite/gcc.c-torture/execute/960402-1.c new file mode 100644 index 00000000000..601a9a3b091 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960402-1.c @@ -0,0 +1,11 @@ +f (signed long long int x) +{ + return x > 0xFFFFFFFFLL || x < -0x80000000LL; +} + +main () +{ + if (f (0) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960405-1.c b/gcc/testsuite/gcc.c-torture/execute/960405-1.c new file mode 100644 index 00000000000..d8480cc2c05 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960405-1.c @@ -0,0 +1,13 @@ +#define X 5.9486574767861588254287966331400356538172e4931L + +long double x = X + X; +long double y = 2.0L * X; + +main () +{ +#if ! defined (__vax__) && ! defined (_CRAY) + if (x != y) + abort (); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960416-1.c b/gcc/testsuite/gcc.c-torture/execute/960416-1.c new file mode 100644 index 00000000000..f7cb056802c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960416-1.c @@ -0,0 +1,63 @@ +typedef unsigned long int st; +typedef unsigned long long dt; +typedef union +{ + dt d; + struct + { + st h, l; + } + s; +} t_be; + +typedef union +{ + dt d; + struct + { + st l, h; + } + s; +} t_le; + +#define df(f, t) \ +int \ +f (t afh, t bfh) \ +{ \ + t hh; \ + t hp, lp, dp, m; \ + st ad, bd; \ + int s; \ + s = 0; \ + ad = afh.s.h - afh.s.l; \ + bd = bfh.s.l - bfh.s.h; \ + if (bd > bfh.s.l) \ + { \ + bd = -bd; \ + s = ~s; \ + } \ + lp.d = (dt) afh.s.l * bfh.s.l; \ + hp.d = (dt) afh.s.h * bfh.s.h; \ + dp.d = (dt) ad *bd; \ + dp.d ^= s; \ + hh.d = hp.d + hp.s.h + lp.s.h + dp.s.h; \ + m.d = (dt) lp.s.h + hp.s.l + lp.s.l + dp.s.l; \ + return hh.s.l + m.s.l; \ +} + +df(f_le, t_le) +df(f_be, t_be) + +main () +{ + t_be x; + x.s.h = 0x10000000U; + x.s.l = 0xe0000000U; + if (x.d == 0x10000000e0000000ULL + && f_be ((t_be) 0x100000000ULL, (t_be) 0x100000000ULL) != -1) + abort (); + if (x.d == 0xe000000010000000ULL + && f_le ((t_le) 0x100000000ULL, (t_le) 0x100000000ULL) != -1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960419-1.c b/gcc/testsuite/gcc.c-torture/execute/960419-1.c new file mode 100644 index 00000000000..68bd2b97dd1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960419-1.c @@ -0,0 +1,17 @@ +static int i; + +void +check(x) + int x; +{ + if (!x) + abort(); +} + +main() +{ + int *p = &i; + + check(p != (void *)0); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960419-2.c b/gcc/testsuite/gcc.c-torture/execute/960419-2.c new file mode 100644 index 00000000000..c9526dcd779 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960419-2.c @@ -0,0 +1,13 @@ +#define SIZE 8 + +main() +{ + int a[SIZE] = {1}; + int i; + + for (i = 1; i < SIZE; i++) + if (a[i] != 0) + abort(); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960512-1.c b/gcc/testsuite/gcc.c-torture/execute/960512-1.c new file mode 100644 index 00000000000..a7c1d5fb47c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960512-1.c @@ -0,0 +1,19 @@ +__complex__ +double f () +{ + int a[40]; + __complex__ double c; + + a[9] = 0; + c = a[9]; + return c; +} + +main () +{ + __complex__ double c; + + if (c = f ()) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960513-1.c b/gcc/testsuite/gcc.c-torture/execute/960513-1.c new file mode 100644 index 00000000000..acc263ca6c8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960513-1.c @@ -0,0 +1,25 @@ +long double +f (d, i) + long double d; + int i; +{ + long double e; + + d = -d; + e = d; + if (i == 1) + d *= 2; + d -= e * d; + d -= e * d; + d -= e * d; + d -= e * d; + d -= e * d; + return d; +} + +main () +{ + if (! (int) (f (2.0L, 1))) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960521-1.c b/gcc/testsuite/gcc.c-torture/execute/960521-1.c new file mode 100644 index 00000000000..9fc5821495a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960521-1.c @@ -0,0 +1,30 @@ +#include <stdlib.h> + +int *a, *b; +int n; + +#ifdef STACK_SIZE +#define BLOCK_SIZE (STACK_SIZE / (sizeof (*a) + sizeof (*b))) +#else +#define BLOCK_SIZE 32768 +#endif +foo () +{ + int i; + for (i = 0; i < n; i++) + a[i] = -1; + for (i = 0; i < BLOCK_SIZE - 1; i++) + b[i] = -1; +} + +main () +{ + n = BLOCK_SIZE; + a = malloc (n * sizeof(*a)); + b = malloc (n * sizeof(*b)); + *b++ = 0; + foo (); + if (b[-1]) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960608-1.c b/gcc/testsuite/gcc.c-torture/execute/960608-1.c new file mode 100644 index 00000000000..1f47d02d9d5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960608-1.c @@ -0,0 +1,34 @@ +typedef struct +{ + unsigned char a : 2; + unsigned char b : 3; + unsigned char c : 1; + unsigned char d : 1; + unsigned char e : 1; +} a_struct; + +foo (flags) + a_struct *flags; +{ + return (flags->c != 0 + || flags->d != 1 + || flags->e != 1 + || flags->a != 2 + || flags->b != 3); +} + +main () +{ + a_struct flags; + + flags.c = 0; + flags.d = 1; + flags.e = 1; + flags.a = 2; + flags.b = 3; + + if (foo (&flags) != 0) + abort (); + else + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960801-1.c b/gcc/testsuite/gcc.c-torture/execute/960801-1.c new file mode 100644 index 00000000000..1707269189a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960801-1.c @@ -0,0 +1,32 @@ +unsigned +f () +{ + long long l2; + unsigned short us; + unsigned long long ul; + short s2; + + ul = us = l2 = s2 = -1; + return ul; +} + +unsigned long long +g () +{ + long long l2; + unsigned short us; + unsigned long long ul; + short s2; + + ul = us = l2 = s2 = -1; + return ul; +} + +main () +{ + if (f () != (unsigned short) -1) + abort (); + if (g () != (unsigned short) -1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960802-1.c b/gcc/testsuite/gcc.c-torture/execute/960802-1.c new file mode 100644 index 00000000000..f9ee75260be --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960802-1.c @@ -0,0 +1,36 @@ +long val = 0x5e000000; + +long +f1 (void) +{ + return 0x132; +} + +long +f2 (void) +{ + return 0x5e000000; +} + +void +f3 (long b) +{ + val = b; +} + +void +f4 () +{ + long v = f1 (); + long o = f2 (); + v = (v & 0x00ffffff) | (o & 0xff000000); + f3 (v); +} + +main () +{ + f4 (); + if (val != 0x5e000132) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/960830-1.c b/gcc/testsuite/gcc.c-torture/execute/960830-1.c new file mode 100644 index 00000000000..d87b39e2da3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960830-1.c @@ -0,0 +1,22 @@ +#ifdef __i386__ +f (rp) + unsigned int *rp; +{ + __asm__ ("mull %3" : "=a" (rp[0]), "=d" (rp[1]) : "%0" (7), "rm" (7)); +} + +main () +{ + unsigned int s[2]; + + f (s); + if (s[1] != 0 || s[0] != 49) + abort (); + exit (0); +} +#else +main () +{ + exit (0); +} +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/960909-1.c b/gcc/testsuite/gcc.c-torture/execute/960909-1.c new file mode 100644 index 00000000000..de1ed933978 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/960909-1.c @@ -0,0 +1,29 @@ +int +ffs (x) + int x; +{ + int bit, mask; + + if (x == 0) + return 0; + + for (bit = 1, mask = 1; !(x & mask); bit++, mask <<= 1) + ; + + return bit; +} + +f (x) + int x; +{ + int y; + y = ffs (x) - 1; + if (y < 0) + abort (); +} + +main () +{ + f (1); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961004-1.c b/gcc/testsuite/gcc.c-torture/execute/961004-1.c new file mode 100644 index 00000000000..7ebba2d7b1e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961004-1.c @@ -0,0 +1,22 @@ +int k = 0; + +main() +{ + int i; + int j; + + for (i = 0; i < 2; i++) + { + if (k) + { + if (j != 2) + abort (); + } + else + { + j = 2; + k++; + } + } + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961017-1.c b/gcc/testsuite/gcc.c-torture/execute/961017-1.c new file mode 100644 index 00000000000..88c9d9505a1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961017-1.c @@ -0,0 +1,8 @@ +main () +{ + unsigned char z = 0; + + do ; + while (--z > 0); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961017-2.c b/gcc/testsuite/gcc.c-torture/execute/961017-2.c new file mode 100644 index 00000000000..768ddbc6e74 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961017-2.c @@ -0,0 +1,32 @@ +main () +{ + int i = 0; + + + if (sizeof (unsigned long int) == 4) + { + unsigned long int z = 0; + + do { + z -= 0x00004000; + i++; + if (i > 0x00040000) + abort (); + } while (z > 0); + exit (0); + } + else if (sizeof (unsigned int) == 4) + { + unsigned int z = 0; + + do { + z -= 0x00004000; + i++; + if (i > 0x00040000) + abort (); + } while (z > 0); + exit (0); + } + else + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961026-1.c b/gcc/testsuite/gcc.c-torture/execute/961026-1.c new file mode 100644 index 00000000000..942a6eb131a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961026-1.c @@ -0,0 +1,17 @@ +int +test (arg) + int arg; +{ + if (arg > 0 || arg == 0) + return 0; + return -1; +} + +main () +{ + if (test (0) != 0) + abort (); + if (test (-1) != -1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961112-1.c b/gcc/testsuite/gcc.c-torture/execute/961112-1.c new file mode 100644 index 00000000000..4b1c31222ca --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961112-1.c @@ -0,0 +1,13 @@ +f (x) +{ + if (x != 0 || x == 0) + return 0; + return 1; +} + +main () +{ + if (f (3)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961122-1.c b/gcc/testsuite/gcc.c-torture/execute/961122-1.c new file mode 100644 index 00000000000..1f0a63463e1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961122-1.c @@ -0,0 +1,23 @@ +long long acc; + +addhi (short a) +{ + acc += (long long) a << 32; +} + +subhi (short a) +{ + acc -= (long long) a << 32; +} + +main () +{ + acc = 0xffff00000000ll; + addhi (1); + if (acc != 0x1000000000000ll) + abort (); + subhi (1); + if (acc != 0xffff00000000ll) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961122-2.c b/gcc/testsuite/gcc.c-torture/execute/961122-2.c new file mode 100644 index 00000000000..81e404ec4f1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961122-2.c @@ -0,0 +1,12 @@ +int +f (int a) +{ + return ((a >= 0 && a <= 10) && ! (a >= 0)); +} + +main () +{ + if (f (0)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961125-1.c b/gcc/testsuite/gcc.c-torture/execute/961125-1.c new file mode 100644 index 00000000000..7fe3dd45422 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961125-1.c @@ -0,0 +1,33 @@ +static char * +begfield (int tab, char *ptr, char *lim, int sword, int schar) +{ + if (tab) + { + while (ptr < lim && sword--) + { + while (ptr < lim && *ptr != tab) + ++ptr; + if (ptr < lim) + ++ptr; + } + } + else + { + while (1) + ; + } + + if (ptr + schar <= lim) + ptr += schar; + + return ptr; +} + +main () +{ + char *s = ":ab"; + char *lim = s + 3; + if (begfield (':', s, lim, 1, 1) != s + 2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961206-1.c b/gcc/testsuite/gcc.c-torture/execute/961206-1.c new file mode 100644 index 00000000000..943ac66804d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961206-1.c @@ -0,0 +1,52 @@ +int +sub1 (unsigned long long i) +{ + if (i < 0x80000000) + return 1; + else + return 0; +} + +int +sub2 (unsigned long long i) +{ + if (i <= 0x7FFFFFFF) + return 1; + else + return 0; +} + +int +sub3 (unsigned long long i) +{ + if (i >= 0x80000000) + return 0; + else + return 1; +} + +int +sub4 (unsigned long long i) +{ + if (i > 0x7FFFFFFF) + return 0; + else + return 1; +} + +main() +{ + if (sub1 (0x80000000ULL)) + abort (); + + if (sub2 (0x80000000ULL)) + abort (); + + if (sub3 (0x80000000ULL)) + abort (); + + if (sub4 (0x80000000ULL)) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961213-1.c b/gcc/testsuite/gcc.c-torture/execute/961213-1.c new file mode 100644 index 00000000000..12bb27f3145 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961213-1.c @@ -0,0 +1,22 @@ +int +g (unsigned long long int *v, int n, unsigned int a[], int b) +{ + int cnt; + *v = 0; + for (cnt = 0; cnt < n; ++cnt) + *v = *v * b + a[cnt]; + return n; +} + +main () +{ + int res; + unsigned int ar[] = { 10, 11, 12, 13, 14 }; + unsigned long long int v; + + res = g (&v, sizeof(ar)/sizeof(ar[0]), ar, 16); + if (v != 0xabcdeUL) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/961223-1.c b/gcc/testsuite/gcc.c-torture/execute/961223-1.c new file mode 100644 index 00000000000..9bc6cfa354d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/961223-1.c @@ -0,0 +1,19 @@ +struct s { + double d; +}; + +inline struct s +sub (struct s s) +{ + s.d += 1.0; + return s; +} + +main () +{ + struct s t = { 2.0 }; + t = sub (t); + if (t.d != 3.0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/970214-1.c b/gcc/testsuite/gcc.c-torture/execute/970214-1.c new file mode 100644 index 00000000000..4a06dfebc8d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/970214-1.c @@ -0,0 +1,5 @@ +#define L 1 +main () +{ + exit (L'1' != L'1'); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/970214-2.c b/gcc/testsuite/gcc.c-torture/execute/970214-2.c new file mode 100644 index 00000000000..cb9007625dd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/970214-2.c @@ -0,0 +1,5 @@ +#define m(L) (L'1' + (L)) +main () +{ + exit (m (0) != L'1'); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/970217-1.c b/gcc/testsuite/gcc.c-torture/execute/970217-1.c new file mode 100644 index 00000000000..09e716a330b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/970217-1.c @@ -0,0 +1,10 @@ +sub (int i, int array[i++]) +{ + return i; +} + +main() +{ + int array[10]; + exit (sub (10, array) != 11); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/970312-1.c b/gcc/testsuite/gcc.c-torture/execute/970312-1.c new file mode 100644 index 00000000000..b303c4a8e60 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/970312-1.c @@ -0,0 +1,71 @@ +#include <stdio.h> + +__inline__ static int +dummy (x) +{ + int y; + y = (long) (x * 4711.3); + return y; +} + +int getval (void); + +int +f2 (double x) +{ + unsigned short s; + int a, b, c, d, e, f, g, h, i, j; + + a = getval (); + b = getval (); + c = getval (); + d = getval (); + e = getval (); + f = getval (); + g = getval (); + h = getval (); + i = getval (); + j = getval (); + + + s = x; + + return a + b + c + d + e + f + g + h + i + j + s; +} + +int x = 1; + +int +getval (void) +{ + return x++; +} + +void +f () +{ + int a, b, c, d, e, f, g, h, i, j, k; + + a = getval (); + b = getval (); + c = getval (); + d = getval (); + e = getval (); + f = getval (); + g = getval (); + h = getval (); + i = getval (); + j = getval (); + + k = f2 (17.0); + + printf ("%d\n", a + b + c + d + e + f + g + h + i + j + k); + if (a + b + c + d + e + f + g + h + i + j + k != 227) + abort (); +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/Makefile.in b/gcc/testsuite/gcc.c-torture/execute/Makefile.in new file mode 100644 index 00000000000..e6209dbc6c2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/Makefile.in @@ -0,0 +1,12 @@ +#### host, target, and site specific Makefile frags come in here. + +srcdir = . + +# Nothing to do... +all: + +clean: + -rm -f *.o *.diff *~ *.bad core *.x + +distclean: clean + -rm -f Makefile config.status diff --git a/gcc/testsuite/gcc.c-torture/execute/arith-1.c b/gcc/testsuite/gcc.c-torture/execute/arith-1.c new file mode 100644 index 00000000000..58df322e68a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/arith-1.c @@ -0,0 +1,15 @@ +unsigned +sat_add (unsigned i) +{ + unsigned ret = i + 1; + if (ret < i) + ret = i; + return ret; +} + +main () +{ + if (sat_add (~0U) != ~0U) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/arith-rand.c b/gcc/testsuite/gcc.c-torture/execute/arith-rand.c new file mode 100644 index 00000000000..4af146a1a56 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/arith-rand.c @@ -0,0 +1,114 @@ +long +simple_rand () +{ + static unsigned long seed = 47114711; + unsigned long this = seed * 1103515245 + 12345; + seed = this; + return this >> 8; +} + +unsigned long int +random_bitstring () +{ + unsigned long int x; + int n_bits; + long ran; + int tot_bits = 0; + + x = 0; + for (;;) + { + ran = simple_rand (); + n_bits = (ran >> 1) % 16; + tot_bits += n_bits; + + if (n_bits == 0) + return x; + else + { + x <<= n_bits; + if (ran & 1) + x |= (1 << n_bits) - 1; + + if (tot_bits > 8 * sizeof (long) + 6) + return x; + } + } +} + +#define ABS(x) ((x) >= 0 ? (x) : -(x)) + +main () +{ + long int i; + + for (i = 0; i < 1000; i++) + { + unsigned long x, y; + x = random_bitstring (); + y = random_bitstring (); + + if (sizeof (int) == sizeof (long)) + goto save_time; + + { unsigned long xx = x, yy = y, r1, r2; + if (yy == 0) continue; + r1 = xx / yy; + r2 = xx % yy; + if (r2 >= yy || r1 * yy + r2 != xx) + abort (); + } + { signed long xx = x, yy = y, r1, r2; + if ((unsigned long) xx << 1 == 0 && yy == -1) + continue; + r1 = xx / yy; + r2 = xx % yy; + if (ABS (r2) >= (unsigned long) ABS (yy) || (signed long) (r1 * yy + r2) != xx) + abort (); + } + save_time: + { unsigned int xx = x, yy = y, r1, r2; + if (yy == 0) continue; + r1 = xx / yy; + r2 = xx % yy; + if (r2 >= yy || r1 * yy + r2 != xx) + abort (); + } + { signed int xx = x, yy = y, r1, r2; + if ((unsigned int) xx << 1 == 0 && yy == -1) + continue; + r1 = xx / yy; + r2 = xx % yy; + if (ABS (r2) >= (unsigned int) ABS (yy) || (signed int) (r1 * yy + r2) != xx) + abort (); + } + { unsigned short xx = x, yy = y, r1, r2; + if (yy == 0) continue; + r1 = xx / yy; + r2 = xx % yy; + if (r2 >= yy || r1 * yy + r2 != xx) + abort (); + } + { signed short xx = x, yy = y, r1, r2; + r1 = xx / yy; + r2 = xx % yy; + if (ABS (r2) >= (unsigned short) ABS (yy) || (signed short) (r1 * yy + r2) != xx) + abort (); + } + { unsigned char xx = x, yy = y, r1, r2; + if (yy == 0) continue; + r1 = xx / yy; + r2 = xx % yy; + if (r2 >= yy || r1 * yy + r2 != xx) + abort (); + } + { signed char xx = x, yy = y, r1, r2; + r1 = xx / yy; + r2 = xx % yy; + if (ABS (r2) >= (unsigned char) ABS (yy) || (signed char) (r1 * yy + r2) != xx) + abort (); + } + } + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/bf-layout-1.c b/gcc/testsuite/gcc.c-torture/execute/bf-layout-1.c new file mode 100644 index 00000000000..a82429ba208 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bf-layout-1.c @@ -0,0 +1,9 @@ +struct { long f8:8; long f24:24; } a; +struct { long f32:32; } b; + +main () +{ + if (sizeof (a) != sizeof (b)) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/bf-pack-1.c b/gcc/testsuite/gcc.c-torture/execute/bf-pack-1.c new file mode 100644 index 00000000000..ca3b1db763b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bf-pack-1.c @@ -0,0 +1,23 @@ +struct foo +{ + unsigned half:16; + unsigned long whole:32 __attribute__ ((packed)); +}; + +f (struct foo *q) +{ + if (q->half != 0x1234) + abort (); + if (q->whole != 0x56789abcL) + abort (); +} + +main () +{ + struct foo bar; + + bar.half = 0x1234; + bar.whole = 0x56789abcL; + f (&bar); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/bf-sign-1.c b/gcc/testsuite/gcc.c-torture/execute/bf-sign-1.c new file mode 100644 index 00000000000..3cc3eac15fd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bf-sign-1.c @@ -0,0 +1,18 @@ +main () +{ + struct { + signed int s:3; + unsigned int u:3; + int i:3; + } x = {-1, -1, -1}; + + if (x.u != 7) + abort (); + if (x.s != - 1) + abort (); + + if (x.i != -1 && x.i != 7) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c b/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c new file mode 100644 index 00000000000..479082217eb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bf-sign-2.c @@ -0,0 +1,52 @@ +/* + This test checks promotion of bitfields. Bitfields should be promoted + very much like chars and shorts: + + Bitfields (signed or unsigned) should be promoted to signed int if their + value will fit in a signed int, otherwise to an unsigned int if their + value will fit in an unsigned int, otherwise we don't promote them (ANSI/ISO + does not specify the behavior of bitfields larger than an unsigned int). + + We test the behavior by subtracting two from the promoted value: this will + result in a negitive value for signed types, a positive value for unsigned + types. This test (of course) assumes that the compiler is correctly + implementing signed and unsigned arithmatic. + */ + +struct X { + unsigned int u3:3; + long int s31:31; + long int s32:32; + unsigned long int u31:31; + unsigned long int u32:32; + unsigned long long ull3 :3; + unsigned long long ull35:35; +}; + +struct X x; + +main () +{ + if ((x.u3 - 2) >= 0) /* promoted value should be signed */ + abort (); + + if ((x.s31 - 2) >= 0) /* promoted value should be signed */ + abort (); + + if ((x.s32 - 2) >= 0) /* promoted value should be signed */ + abort (); + + if ((x.u31 - 2) >= 0) /* promoted value should be signed */ + abort (); + + if ((x.u32 - 2) < 0) /* promoted value should be UNsigned */ + abort (); + + if ((x.ull3 - 2) >= 0) /* promoted value should be signed */ + abort (); + + if ((x.ull35 - 2) < 0) /* promoted value should be UNsigned */ + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/bf64-1.c b/gcc/testsuite/gcc.c-torture/execute/bf64-1.c new file mode 100644 index 00000000000..60028fb1aa8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/bf64-1.c @@ -0,0 +1,40 @@ +struct tmp +{ + long long int pad : 12; + long long int field : 52; +}; + +struct tmp2 +{ + long long int field : 52; + long long int pad : 12; +}; + +struct tmp +sub (struct tmp tmp) +{ + tmp.field |= 0x0008765412345678LL; + return tmp; +} + +struct tmp2 +sub2 (struct tmp2 tmp2) +{ + tmp2.field |= 0x0008765412345678LL; + return tmp2; +} + +main() +{ + struct tmp tmp = {0x123, 0xFFF000FFF000FLL}; + struct tmp2 tmp2 = {0xFFF000FFF000FLL, 0x123}; + + tmp = sub (tmp); + tmp2 = sub2 (tmp2); + + if (tmp.pad != 0x123 || tmp.field != 0xFFFFFF541FFF567FLL) + abort (); + if (tmp2.pad != 0x123 || tmp2.field != 0xFFFFFF541FFF567FLL) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/cbrt.c b/gcc/testsuite/gcc.c-torture/execute/cbrt.c new file mode 100644 index 00000000000..8f1fe68df1d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/cbrt.c @@ -0,0 +1,91 @@ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== +*/ + +#ifndef __vax__ +static const unsigned long + B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */ + B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */ + +static const double + C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */ + D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */ + E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */ + F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */ + G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */ + +double +cbrtl (double x) +{ + long hx; + double r,s,w; + double lt; + unsigned sign; + union { + double t; + unsigned long pt[2]; + } ut, ux; + int n0; + + ut.t = 1.0; + n0 = (ut.pt[0] == 0); + + ut.t = 0.0; + ux.t = x; + + hx = ux.pt[n0]; /* high word of x */ + sign=hx&0x80000000; /* sign= sign(x) */ + hx ^=sign; + if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */ + if((hx| ux.pt[1-n0])==0) + return(ux.t); /* cbrt(0) is itself */ + + ux.pt[n0] = hx; + /* rough cbrt to 5 bits */ + if(hx<0x00100000) /* subnormal number */ + {ut.pt[n0]=0x43500000; /* set t= 2**54 */ + ut.t*=x; ut.pt[n0]=ut.pt[n0]/3+B2; + } + else + ut.pt[n0]=hx/3+B1; + + /* new cbrt to 23 bits, may be implemented in single precision */ + r=ut.t*ut.t/ux.t; + s=C+r*ut.t; + ut.t*=G+F/(s+E+D/s); + + /* chopped to 20 bits and make it larger than cbrt(x) */ + ut.pt[1-n0]=0; ut.pt[n0]+=0x00000001; + + /* one step newton iteration to 53 bits with error less than 0.667 ulps */ + s=ut.t*ut.t; /* t*t is exact */ + r=ux.t/s; + w=ut.t+ut.t; + r=(r-ut.t)/(w+r); /* r-s is exact */ + ut.t=ut.t+ut.t*r; + + /* restore the sign bit */ + ut.pt[n0] |= sign; + + lt = ut.t; + lt -= (lt - (x/(lt*lt))) * 0.333333333333333333333; + return lt; +} + +main () +{ + if ((int) (cbrtl (27.0) + 0.5) != 3) + abort (); + + exit (0); +} +#else +main () { exit (0); } +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/cmpdi-1.c b/gcc/testsuite/gcc.c-torture/execute/cmpdi-1.c new file mode 100644 index 00000000000..e3e9c860603 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/cmpdi-1.c @@ -0,0 +1,218 @@ +#define F 140 +#define T 13 + +feq (x, y) + long long int x; + long long int y; +{ + if (x == y) + return T; + else + return F; +} + +fne (x, y) + long long int x; + long long int y; +{ + if (x != y) + return T; + else + return F; +} + +flt (x, y) + long long int x; + long long int y; +{ + if (x < y) + return T; + else + return F; +} + +fge (x, y) + long long int x; + long long int y; +{ + if (x >= y) + return T; + else + return F; +} + +fgt (x, y) + long long int x; + long long int y; +{ + if (x > y) + return T; + else + return F; +} + +fle (x, y) + long long int x; + long long int y; +{ + if (x <= y) + return T; + else + return F; +} + +fltu (x, y) + unsigned long long int x; + unsigned long long int y; +{ + if (x < y) + return T; + else + return F; +} + +fgeu (x, y) + unsigned long long int x; + unsigned long long int y; +{ + if (x >= y) + return T; + else + return F; +} + +fgtu (x, y) + unsigned long long int x; + unsigned long long int y; +{ + if (x > y) + return T; + else + return F; +} + +fleu (x, y) + unsigned long long int x; + unsigned long long int y; +{ + if (x <= y) + return T; + else + return F; +} + +long long args[] = +{ + 0LL, + 1LL, + -1LL, + 0x7fffffffffffffffLL, + 0x8000000000000000LL, + 0x8000000000000001LL, + 0x1A3F237394D36C58LL, + 0x93850E92CAAC1B04LL +}; + +int correct_results[] = +{ + T, F, F, T, F, T, F, T, F, T, + F, T, T, F, F, T, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, F, T, T, F, F, T, T, F, + T, F, F, T, F, T, F, T, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, F, T, T, F, + T, F, F, T, F, T, F, T, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, T, F, F, T, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, T, F, F, T, + T, F, F, T, F, T, F, T, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + T, F, F, T, F, T, F, T, F, T, + F, T, T, F, F, T, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + T, F, F, T, F, T, F, T, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, T, F, F, T, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, F, T, T, F, T, F, F, T, + T, F, F, T, F, T, F, T, F, T, + F, T, F, T, T, F, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, F, T, T, F, + F, T, T, F, F, T, T, F, F, T, + F, T, T, F, F, T, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, F, T, T, F, F, T, T, F, + F, T, T, F, F, T, F, T, T, F, + T, F, F, T, F, T, F, T, F, T +}; + +main () +{ + int i, j, *res = correct_results; + + for (i = 0; i < 8; i++) + { + long long arg0 = args[i]; + for (j = 0; j < 8; j++) + { + long long arg1 = args[j]; + + if (feq (arg0, arg1) != *res++) + abort (); + if (fne (arg0, arg1) != *res++) + abort (); + if (flt (arg0, arg1) != *res++) + abort (); + if (fge (arg0, arg1) != *res++) + abort (); + if (fgt (arg0, arg1) != *res++) + abort (); + if (fle (arg0, arg1) != *res++) + abort (); + if (fltu (arg0, arg1) != *res++) + abort (); + if (fgeu (arg0, arg1) != *res++) + abort (); + if (fgtu (arg0, arg1) != *res++) + abort (); + if (fleu (arg0, arg1) != *res++) + abort (); + } + } + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/cmpsi-1.c b/gcc/testsuite/gcc.c-torture/execute/cmpsi-1.c new file mode 100644 index 00000000000..9fce104fefb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/cmpsi-1.c @@ -0,0 +1,32 @@ +f1 (unsigned int x, unsigned int y) +{ + if (x == 0) + dummy (); + x -= y; + /* 0xfffffff2 < 0x80000000? */ + if (x < ~(~(unsigned int) 0 >> 1)) + abort (); + return x; +} + +f2 (unsigned long int x, unsigned long int y) +{ + if (x == 0) + dummy (); + x -= y; + /* 0xfffffff2 < 0x80000000? */ + if (x < ~(~(unsigned long int) 0 >> 1)) + abort (); + return x; +} + + +dummy () {} + +main () +{ + /* 0x7ffffff3 0x80000001 */ + f1 ((~(unsigned int) 0 >> 1) - 12, ~(~(unsigned int) 0 >> 1) + 1); + f2 ((~(unsigned long int) 0 >> 1) - 12, ~(~(unsigned long int) 0 >> 1) + 1); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c b/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c new file mode 100644 index 00000000000..04c7503115d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/comp-goto-1.c @@ -0,0 +1,164 @@ +#include <stdlib.h> + +#ifndef NO_LABEL_VALUES +typedef unsigned int uint32; +typedef signed int sint32; + +typedef uint32 reg_t; + +typedef unsigned long int host_addr_t; +typedef uint32 target_addr_t; +typedef sint32 target_saddr_t; + +typedef union +{ + struct + { + unsigned int offset:18; + unsigned int ignore:4; + unsigned int s1:8; + int :2; + signed int simm:14; + unsigned int s3:8; + unsigned int s2:8; + int pad2:2; + } f1; + long long ll; + double d; +} insn_t; + +typedef struct +{ + target_addr_t vaddr_tag; + unsigned long int rigged_paddr; +} tlb_entry_t; + +typedef struct +{ + insn_t *pc; + reg_t registers[256]; + insn_t *program; + tlb_entry_t tlb_tab[0x100]; +} environment_t; + +enum operations +{ + LOAD32_RR, + METAOP_DONE +}; + +host_addr_t +f () +{ + abort (); +} + +reg_t +simulator_kernel (int what, environment_t *env) +{ + register insn_t *pc = env->pc; + register reg_t *regs = env->registers; + register insn_t insn; + register int s1; + register reg_t r2; + register void *base_addr = &&sim_base_addr; + register tlb_entry_t *tlb = env->tlb_tab; + + if (what != 0) + { + int i; + static void *op_map[] = + { + &&L_LOAD32_RR, + &&L_METAOP_DONE, + }; + insn_t *program = env->program; + for (i = 0; i < what; i++) + program[i].f1.offset = op_map[program[i].f1.offset] - base_addr; + } + + sim_base_addr:; + + insn = *pc++; + r2 = (*(reg_t *) (((char *) regs) + (insn.f1.s2 << 2))); + s1 = (insn.f1.s1 << 2); + goto *(base_addr + insn.f1.offset); + + L_LOAD32_RR: + { + target_addr_t vaddr_page = r2 / 4096; + unsigned int x = vaddr_page % 0x100; + insn = *pc++; + + for (;;) + { + target_addr_t tag = tlb[x].vaddr_tag; + host_addr_t rigged_paddr = tlb[x].rigged_paddr; + + if (tag == vaddr_page) + { + *(reg_t *) (((char *) regs) + s1) = *(uint32 *) (rigged_paddr + r2); + r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2)); + s1 = insn.f1.s1 << 2; + goto *(base_addr + insn.f1.offset); + } + + if (((target_saddr_t) tag < 0)) + { + *(reg_t *) (((char *) regs) + s1) = *(uint32 *) f (); + r2 = *(reg_t *) (((char *) regs) + (insn.f1.s2 << 2)); + s1 = insn.f1.s1 << 2; + goto *(base_addr + insn.f1.offset); + } + + x = (x - 1) % 0x100; + } + + L_METAOP_DONE: + return (*(reg_t *) (((char *) regs) + s1)); + } +} + +insn_t program[2 + 1]; + +void *malloc (); + +void +main () +{ + environment_t env; + insn_t insn; + int i, res; + host_addr_t a_page = (host_addr_t) malloc (2 * 4096); + target_addr_t a_vaddr = 0x123450; + target_addr_t vaddr_page = a_vaddr / 4096; + a_page = (a_page + 4096 - 1) & -4096; + + env.tlb_tab[((vaddr_page) % 0x100)].vaddr_tag = vaddr_page; + env.tlb_tab[((vaddr_page) % 0x100)].rigged_paddr = a_page - vaddr_page * 4096; + insn.f1.offset = LOAD32_RR; + env.registers[0] = 0; + env.registers[2] = a_vaddr; + *(int *) (a_page + a_vaddr % 4096) = 88; + insn.f1.s1 = 0; + insn.f1.s2 = 2; + + for (i = 0; i < 2; i++) + program[i] = insn; + + insn.f1.offset = METAOP_DONE; + insn.f1.s1 = 0; + program[2] = insn; + + env.pc = program; + env.program = program; + + res = simulator_kernel (2 + 1, &env); + + if (res != 88) + abort (); + exit (0); +} +#else +main(){ exit (0); } +#endif diff --git a/gcc/testsuite/gcc.c-torture/execute/complex-1.c b/gcc/testsuite/gcc.c-torture/execute/complex-1.c new file mode 100644 index 00000000000..424fa65b150 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/complex-1.c @@ -0,0 +1,40 @@ +double +g0 (double x) +{ + return 1.0; +} + +double +g1 (double x) +{ + return -1.0; +} + +double +g2 (double x) +{ + return 0.0; +} + +__complex__ double +cexp (__complex__ double x) +{ + double r; + + r = g0 (__real__ x); + __real__ x = r * g1 (__imag__ x); + __imag__ x = r * g2 (__imag__ x); + return x; +} + +main () +{ + __complex__ double x; + + x = cexp (1.0i); + if (__real__ x != -1.0) + abort (); + if (__imag__ x != 0.0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/complex-2.c b/gcc/testsuite/gcc.c-torture/execute/complex-2.c new file mode 100644 index 00000000000..9634c7943f3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/complex-2.c @@ -0,0 +1,27 @@ +__complex__ double +f (__complex__ double x, __complex__ double y) +{ + x += y; + return x; +} + +__complex__ double ag = 1.0 + 1.0i; +__complex__ double bg = -2.0 + 2.0i; + +main () +{ + __complex__ double a, b, c; + + a = ag; + b = -2.0 + 2.0i; + c = f (a, b); + + if (a != 1.0 + 1.0i) + abort (); + if (b != -2.0 + 2.0i) + abort (); + if (c != -1.0 + 3.0i) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/complex-3.c b/gcc/testsuite/gcc.c-torture/execute/complex-3.c new file mode 100644 index 00000000000..4297cf11ebd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/complex-3.c @@ -0,0 +1,25 @@ +struct complex +{ + float r; + float i; +}; + +struct complex cmplx (float, float); + +struct complex +f (float a, float b) +{ + struct complex c; + c.r = a; + c.i = b; + return c; +} + +main () +{ + struct complex z = f (1.0, 0.0); + + if (z.r != 1.0 || z.i != 0.0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/complex-4.c b/gcc/testsuite/gcc.c-torture/execute/complex-4.c new file mode 100644 index 00000000000..1c458d21fba --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/complex-4.c @@ -0,0 +1,9 @@ +main () +{ + if ((__complex__ double) 0.0 != (__complex__ double) (-0.0)) + abort (); + + if (0.0 != -0.0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/complex-5.c b/gcc/testsuite/gcc.c-torture/execute/complex-5.c new file mode 100644 index 00000000000..a3338082c46 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/complex-5.c @@ -0,0 +1,20 @@ +float __complex__ +p (float __complex__ a, float __complex__ b) +{ + return a + b; +} + +float __complex__ x = 1.0 + 14.0 * (1.0fi); +float __complex__ y = 7.0 + 5.0 * (1.0fi); +float __complex__ w = 8.0 + 19.0 * (1.0fi); +float __complex__ z; + +main () +{ + + z = p (x,y); + y = p (x, 1.0f / z); + if (z != w) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/compndlit-1.c b/gcc/testsuite/gcc.c-torture/execute/compndlit-1.c new file mode 100644 index 00000000000..4a8488d0ab4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/compndlit-1.c @@ -0,0 +1,15 @@ +struct S +{ + int a:3; + unsigned b:1, c:28; +}; + +struct S x = {1, 1, 1}; + +main () +{ + x = (struct S) {b:0, a:0, c:({ struct S o = x; o.a == 1 ? 10 : 20;})}; + if (x.c != 10) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/configure.in b/gcc/testsuite/gcc.c-torture/execute/configure.in new file mode 100644 index 00000000000..7d7078dbfd2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/configure.in @@ -0,0 +1,15 @@ +# This file is a shell script fragment that supplies the information +# necessary to tailor a template configure script into the configure +# script appropriate for this directory. For more information, check +# any existing configure script. + +srctrigger=execute.exp +srcname="DejaGnu" + +# per-host: + +# per-target: + +target_makefile_frag=../config/mt-${target_alias} + +# post-target: diff --git a/gcc/testsuite/gcc.c-torture/execute/conversion.c b/gcc/testsuite/gcc.c-torture/execute/conversion.c new file mode 100644 index 00000000000..5f358727d8f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/conversion.c @@ -0,0 +1,364 @@ +/* Test front-end conversions, optimizer conversions, and run-time + conversions between different arithmetic types. + + Constants are specified in a non-obvious way to make them work for + any word size. Their value on a 32-bit machine is indicated in the + comments. + + Note that this code is NOT intended for testing of accuracy of fp + conversions. */ + +float +u2f(u) + unsigned int u; +{ + return u; +} + +double +u2d(u) + unsigned int u; +{ + return u; +} + +float +s2f(s) + int s; +{ + return s; +} + +double +s2d(s) + int s; +{ + return s; +} + +int +fnear (float x, float y) +{ + float t = x - y; + return t == 0 || x / t > 1000000.0; +} + +int +dnear (double x, double y) +{ + double t = x - y; + return t == 0 || x / t > 100000000000000.0; +} + +test_integer_to_float() +{ + if (u2f(0U) != (float) 0U) /* 0 */ + abort(); + if (!fnear (u2f(~0U), (float) ~0U)) /* 0xffffffff */ + abort(); + if (!fnear (u2f((~0U) >> 1), (float) ((~0U) >> 1))) /* 0x7fffffff */ + abort(); + if (u2f(~((~0U) >> 1)) != (float) ~((~0U) >> 1)) /* 0x80000000 */ + abort(); + + if (u2d(0U) != (double) 0U) /* 0 */ + abort(); + if (!dnear (u2d(~0U), (double) ~0U)) /* 0xffffffff */ + abort(); + if (!dnear (u2d((~0U) >> 1),(double) ((~0U) >> 1))) /* 0x7fffffff */ + abort(); + if (u2d(~((~0U) >> 1)) != (double) ~((~0U) >> 1)) /* 0x80000000 */ + abort(); + + if (s2f(0) != (float) 0) /* 0 */ + abort(); + if (!fnear (s2f(~0), (float) ~0)) /* 0xffffffff */ + abort(); + if (!fnear (s2f((int)((~0U) >> 1)), (float)(int)((~0U) >> 1))) /* 0x7fffffff */ + abort(); + if (s2f((int)(~((~0U) >> 1))) != (float)(int)~((~0U) >> 1)) /* 0x80000000 */ + abort(); + + if (s2d(0) != (double) 0) /* 0 */ + abort(); + if (!dnear (s2d(~0), (double) ~0)) /* 0xffffffff */ + abort(); + if (!dnear (s2d((int)((~0U) >> 1)), (double)(int)((~0U) >> 1))) /* 0x7fffffff */ + abort(); + if (s2d((int)~((~0U) >> 1)) != (double)(int)~((~0U) >> 1)) /* 0x80000000 */ + abort(); +} + +#if __GNUC__ +float +ull2f(u) + unsigned long long int u; +{ + return u; +} + +double +ull2d(u) + unsigned long long int u; +{ + return u; +} + +float +sll2f(s) + long long int s; +{ + return s; +} + +double +sll2d(s) + long long int s; +{ + return s; +} + +test_longlong_integer_to_float() +{ + if (ull2f(0ULL) != (float) 0ULL) /* 0 */ + abort(); + if (ull2f(~0ULL) != (float) ~0ULL) /* 0xffffffff */ + abort(); + if (ull2f((~0ULL) >> 1) != (float) ((~0ULL) >> 1)) /* 0x7fffffff */ + abort(); + if (ull2f(~((~0ULL) >> 1)) != (float) ~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + + if (ull2d(0ULL) != (double) 0ULL) /* 0 */ + abort(); +#if __HAVE_68881__ + /* Some 68881 targets return values in fp0, with excess precision. + But the compile-time conversion to double works correctly. */ + if (! dnear (ull2d(~0ULL), (double) ~0ULL)) /* 0xffffffff */ + abort(); + if (! dnear (ull2d((~0ULL) >> 1), (double) ((~0ULL) >> 1))) /* 0x7fffffff */ + abort(); +#else + if (ull2d(~0ULL) != (double) ~0ULL) /* 0xffffffff */ + abort(); + if (ull2d((~0ULL) >> 1) != (double) ((~0ULL) >> 1)) /* 0x7fffffff */ + abort(); +#endif + if (ull2d(~((~0ULL) >> 1)) != (double) ~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + + if (sll2f(0LL) != (float) 0LL) /* 0 */ + abort(); + if (sll2f(~0LL) != (float) ~0LL) /* 0xffffffff */ + abort(); + if (! fnear (sll2f((long long int)((~0ULL) >> 1)), (float)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */ + abort(); + if (sll2f((long long int)(~((~0ULL) >> 1))) != (float)(long long int)~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + + if (sll2d(0LL) != (double) 0LL) /* 0 */ + abort(); + if (sll2d(~0LL) != (double) ~0LL) /* 0xffffffff */ + abort(); + if (!dnear (sll2d((long long int)((~0ULL) >> 1)), (double)(long long int)((~0ULL) >> 1))) /* 0x7fffffff */ + abort(); + if (! dnear (sll2d((long long int)~((~0ULL) >> 1)), (double)(long long int)~((~0ULL) >> 1))) /* 0x80000000 */ + abort(); +} +#endif + +unsigned int +f2u(float f) +{ + return (unsigned) f; +} + +unsigned int +d2u(double d) +{ + return (unsigned) d; +} + +int +f2s(float f) +{ + return (int) f; +} + +int +d2s(double d) +{ + return (int) d; +} + +test_float_to_integer() +{ + if (f2u(0.0) != 0) + abort(); + if (f2u(0.999) != 0) + abort(); + if (f2u(1.0) != 1) + abort(); + if (f2u(1.99) != 1) + abort(); + if (f2u((float) ((~0U) >> 1)) != (~0U) >> 1 && /* 0x7fffffff */ + f2u((float) ((~0U) >> 1)) != ((~0U) >> 1) + 1) + abort(); + if (f2u((float) ~((~0U) >> 1)) != ~((~0U) >> 1)) /* 0x80000000 */ + abort(); + + if (d2u(0.0) != 0) + abort(); + if (d2u(0.999) != 0) + abort(); + if (d2u(1.0) != 1) + abort(); + if (d2u(1.99) != 1) + abort(); + if (d2u((double) (~0U)) != ~0U) /* 0xffffffff */ + abort(); + if (d2u((double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */ + abort(); + if (d2u((double) ~((~0U) >> 1)) != ~((~0U) >> 1)) /* 0x80000000 */ + abort(); + + + if (f2s(0.0) != 0) + abort(); + if (f2s(0.999) != 0) + abort(); + if (f2s(1.0) != 1) + abort(); + if (f2s(1.99) != 1) + abort(); + if (f2s(-0.999) != 0) + abort(); + if (f2s(-1.0) != -1) + abort(); + if (f2s(-1.99) != -1) + abort(); + if (f2s((float)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */ + abort(); + + if (d2s(0.0) != 0) + abort(); + if (d2s(0.999) != 0) + abort(); + if (d2s(1.0) != 1) + abort(); + if (d2s(1.99) != 1) + abort(); + if (d2s(-0.999) != 0) + abort(); + if (d2s(-1.0) != -1) + abort(); + if (d2s(-1.99) != -1) + abort(); + if (d2s((double) ((~0U) >> 1)) != (~0U) >> 1) /* 0x7fffffff */ + abort(); + if (d2s((double)(int)~((~0U) >> 1)) != (int)~((~0U) >> 1)) /* 0x80000000 */ + abort(); +} + +#if __GNUC__ +unsigned long long int +f2ull(float f) +{ + return (unsigned long long int) f; +} + +unsigned long long int +d2ull(double d) +{ + return (unsigned long long int) d; +} + +long long int +f2sll(float f) +{ + return (long long int) f; +} + +long long int +d2sll(double d) +{ + return (long long int) d; +} + +test_float_to_longlong_integer() +{ + if (f2ull(0.0) != 0LL) + abort(); + if (f2ull(0.999) != 0LL) + abort(); + if (f2ull(1.0) != 1LL) + abort(); + if (f2ull(1.99) != 1LL) + abort(); + if (f2ull((float) ((~0ULL) >> 1)) != (~0ULL) >> 1 && /* 0x7fffffff */ + f2ull((float) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1) + abort(); + if (f2ull((float) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + + if (d2ull(0.0) != 0LL) + abort(); + if (d2ull(0.999) != 0LL) + abort(); + if (d2ull(1.0) != 1LL) + abort(); + if (d2ull(1.99) != 1LL) + abort(); + if (d2ull((double) ((~0ULL) >> 1)) != (~0ULL) >> 1 && /* 0x7fffffff */ + d2ull((double) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1) + abort(); + if (d2ull((double) ~((~0ULL) >> 1)) != ~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + + + if (f2sll(0.0) != 0LL) + abort(); + if (f2sll(0.999) != 0LL) + abort(); + if (f2sll(1.0) != 1LL) + abort(); + if (f2sll(1.99) != 1LL) + abort(); + if (f2sll(-0.999) != 0LL) + abort(); + if (f2sll(-1.0) != -1LL) + abort(); + if (f2sll(-1.99) != -1LL) + abort(); + if (f2sll((float)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); + + if (d2sll(0.0) != 0LL) + abort(); + if (d2sll(0.999) != 0LL) + abort(); + if (d2sll(1.0) != 1LL) + abort(); + if (d2sll(1.99) != 1LL) + abort(); + if (d2sll(-0.999) != 0LL) + abort(); + if (d2sll(-1.0) != -1LL) + abort(); + if (d2sll(-1.99) != -1LL) + abort(); + if (d2sll((double)(long long int)~((~0ULL) >> 1)) != (long long int)~((~0ULL) >> 1)) /* 0x80000000 */ + abort(); +} +#endif + +main() +{ + test_integer_to_float(); + test_float_to_integer(); +#if __GNUC__ + test_longlong_integer_to_float(); + test_float_to_longlong_integer(); +#endif + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/cvt-1.c b/gcc/testsuite/gcc.c-torture/execute/cvt-1.c new file mode 100644 index 00000000000..d7c2b33fde1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/cvt-1.c @@ -0,0 +1,30 @@ +/* CYGNUS LOCAL -- meissner/16 bit ints */ +static inline long +g1 (double x) +{ + return (double) (long) x; +} + +long +g2 (double f) +{ + return f; +} + +double +f (long i) +{ + if (g1 (i) != g2 (i)) + abort (); + return g2 (i); +} + +main () +{ + if (f (123456789L) != 123456789L) + abort (); + if (f (123456789L) != g2 (123456789L)) + abort (); + exit (0); +} +/* END CYGNUS LOCAL -- meissner/16 bit ints */ diff --git a/gcc/testsuite/gcc.c-torture/execute/cvt-1.cexp b/gcc/testsuite/gcc.c-torture/execute/cvt-1.cexp new file mode 100644 index 00000000000..997c8650c00 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/cvt-1.cexp @@ -0,0 +1,7 @@ +# This doesn't work on d10v if ints are not 32 bits + +if { [istarget "d10v-*-*"] && ! [string-match "*-mint32*" $CFLAGS] } { + set torture_execute_xfail "d10v-*-*" +} + +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/dbra-1.c b/gcc/testsuite/gcc.c-torture/execute/dbra-1.c new file mode 100644 index 00000000000..20ae8988ec8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/dbra-1.c @@ -0,0 +1,95 @@ +f1 (a) + long a; +{ + int i; + for (i = 0; i < 10; i++) + { + if (--a == -1) + return i; + } + return -1; +} + +f2 (a) + long a; +{ + int i; + for (i = 0; i < 10; i++) + { + if (--a != -1) + return i; + } + return -1; +} + +f3 (a) + long a; +{ + int i; + for (i = 0; i < 10; i++) + { + if (--a == 0) + return i; + } + return -1; +} + +f4 (a) + long a; +{ + int i; + for (i = 0; i < 10; i++) + { + if (--a != 0) + return i; + } + return -1; +} + +f5 (a) + long a; +{ + int i; + for (i = 0; i < 10; i++) + { + if (++a == 0) + return i; + } + return -1; +} + +f6 (a) + long a; +{ + int i; + for (i = 0; i < 10; i++) + { + if (++a != 0) + return i; + } + return -1; +} + + +main() +{ + if (f1 (5L) != 5) + abort (); + if (f2 (1L) != 0) + abort (); + if (f2 (0L) != 1) + abort (); + if (f3 (5L) != 4) + abort (); + if (f4 (1L) != 1) + abort (); + if (f4 (0L) != 0) + abort (); + if (f5 (-5L) != 4) + abort (); + if (f6 (-1L) != 1) + abort (); + if (f6 (0L) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/divconst-1.c b/gcc/testsuite/gcc.c-torture/execute/divconst-1.c new file mode 100644 index 00000000000..ce9dd60a8e8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/divconst-1.c @@ -0,0 +1,21 @@ +typedef struct +{ + unsigned a, b, c, d; +} t1; + +f (t1 *ps) +{ + ps->a = 10000; + ps->b = ps->a / 3; + ps->c = 10000; + ps->d = ps->c / 3; +} + +main () +{ + t1 s; + f (&s); + if (s.a != 10000 || s.b != 3333 || s.c != 10000 || s.d != 3333) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/divconst-2.c b/gcc/testsuite/gcc.c-torture/execute/divconst-2.c new file mode 100644 index 00000000000..d3adaf3a0af --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/divconst-2.c @@ -0,0 +1,12 @@ +long +f (long x) +{ + return x / (-0x7fffffffL - 1L); +} + +main () +{ + if (f (-1L) != 0L || f (0x7fffffffL) != 0L || f (-0x7fffffffL - 1L) != 1l) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/divconst-3.c b/gcc/testsuite/gcc.c-torture/execute/divconst-3.c new file mode 100644 index 00000000000..ddd687cbcfd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/divconst-3.c @@ -0,0 +1,12 @@ +long long +f (long long x) +{ + return x / 10000000000LL; +} + +main () +{ + if (f (10000000000LL) != 1 || f (100000000000LL) != 10) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/divmod-1.c b/gcc/testsuite/gcc.c-torture/execute/divmod-1.c new file mode 100644 index 00000000000..ade019c884e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/divmod-1.c @@ -0,0 +1,72 @@ +div1 (x) + signed char x; +{ + return x / -1; +} + +div2 (x) + signed short x; +{ + return x / -1; +} + +div3 (x, y) + signed char x; + signed char y; +{ + return x / y; +} + +div4 (x, y) + signed short x; + signed short y; +{ + return x / y; +} + +mod1 (x) + signed char x; +{ + return x % -1; +} + +mod2 (x) + signed short x; +{ + return x % -1; +} + +mod3 (x, y) + signed char x; + signed char y; +{ + return x % y; +} + +mod4 (x, y) + signed short x; + signed short y; +{ + return x % y; +} + +main () +{ + if (div1 (-(1 << 7)) != 1 << 7) + abort (); + if (div2 (-(1 << 15)) != 1 << 15) + abort (); + if (div3 (-(1 << 7), -1) != 1 << 7) + abort (); + if (div4 (-(1 << 15), -1) != 1 << 15) + abort (); + if (mod1 (-(1 << 7)) != 0) + abort (); + if (mod2 (-(1 << 15)) != 0) + abort (); + if (mod3 (-(1 << 7), -1) != 0) + abort (); + if (mod4 (-(1 << 15), -1) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/enum-1.c b/gcc/testsuite/gcc.c-torture/execute/enum-1.c new file mode 100644 index 00000000000..381e354918c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/enum-1.c @@ -0,0 +1,43 @@ +typedef enum +{ + END = -1, + EMPTY = (1 << 8 ) , + BACKREF, + BEGLINE, + ENDLINE, + BEGWORD, + ENDWORD, + LIMWORD, + NOTLIMWORD, + QMARK, + STAR, + PLUS, + REPMN, + CAT, + OR, + ORTOP, + LPAREN, + RPAREN, + CSET +} token; + +static token tok; + +static int +atom () +{ + if ((tok >= 0 && tok < (1 << 8 ) ) || tok >= CSET || tok == BACKREF + || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD + || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD) + return 1; + else + return 0; +} + +main () +{ + tok = 0; + if (atom () != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/execute.exp b/gcc/testsuite/gcc.c-torture/execute/execute.exp new file mode 100644 index 00000000000..8c896cb3e15 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/execute.exp @@ -0,0 +1,46 @@ +# Copyright (C) 1991, 1992, 1993, 1995, 1997 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gcc@prep.ai.mit.edu + +# This file was written by Rob Savoye. (rob@cygnus.com) +# Modified and maintained by Jeffrey Wheat (cassidy@cygnus.com) + +# +# These tests come from Torbjorn Granlund (tege@cygnus.com) +# C torture test suite. +# + +if $tracelevel then { + strace $tracelevel +} + +# load support procs +load_lib c-torture.exp + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.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 + } + + c-torture-execute $src +} diff --git a/gcc/testsuite/gcc.c-torture/execute/func-ptr-1.c b/gcc/testsuite/gcc.c-torture/execute/func-ptr-1.c new file mode 100644 index 00000000000..55f0e10660f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/func-ptr-1.c @@ -0,0 +1,16 @@ +static double f (float a); +static double (*fp) (float a); + +main () +{ + fp = f; + if (fp ((float) 1) != 1.0) + abort (); + exit (0); +} + +static double +f (float a) +{ + return a; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/gofast.c b/gcc/testsuite/gcc.c-torture/execute/gofast.c new file mode 100644 index 00000000000..f55ced22073 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/gofast.c @@ -0,0 +1,99 @@ +/* Program to test gcc's usage of the gofast library. */ + +/* The main guiding themes are to make it trivial to add test cases over time + and to make it easy for a program to parse the output to see if the right + libcalls are being made. */ + +#include <stdio.h> + +float fp_add (float a, float b) { return a + b; } +float fp_sub (float a, float b) { return a - b; } +float fp_mul (float a, float b) { return a * b; } +float fp_div (float a, float b) { return a / b; } +float fp_neg (float a) { return -a; } + +double dp_add (double a, double b) { return a + b; } +double dp_sub (double a, double b) { return a - b; } +double dp_mul (double a, double b) { return a * b; } +double dp_div (double a, double b) { return a / b; } +double dp_neg (double a) { return -a; } + +double fp_to_dp (float f) { return f; } +float dp_to_fp (double d) { return d; } + +int eqsf2 (float a, float b) { return a == b; } +int nesf2 (float a, float b) { return a != b; } +int gtsf2 (float a, float b) { return a > b; } +int gesf2 (float a, float b) { return a >= b; } +int ltsf2 (float a, float b) { return a < b; } +int lesf2 (float a, float b) { return a <= b; } + +int eqdf2 (double a, double b) { return a == b; } +int nedf2 (double a, double b) { return a != b; } +int gtdf2 (double a, double b) { return a > b; } +int gedf2 (double a, double b) { return a >= b; } +int ltdf2 (double a, double b) { return a < b; } +int ledf2 (double a, double b) { return a <= b; } + +float floatsisf (int i) { return i; } +double floatsidf (int i) { return i; } +int fixsfsi (float f) { return f; } +int fixdfsi (double d) { return d; } +unsigned int fixunssfsi (float f) { return f; } +unsigned int fixunsdfsi (double d) { return d; } + +int fail_count = 0; + +int +fail (char *msg) +{ + fail_count++; + fprintf (stderr, "Test failed: %s\n", msg); +} + +int +main() +{ + if (fp_add (1, 1) != 2) fail ("fp_add 1+1"); + if (fp_sub (3, 2) != 1) fail ("fp_sub 3-2"); + if (fp_mul (2, 3) != 6) fail ("fp_mul 2*3"); + if (fp_div (3, 2) != 1.5) fail ("fp_div 3/2"); + if (fp_neg (1) != -1) fail ("fp_neg 1"); + + if (dp_add (1, 1) != 2) fail ("dp_add 1+1"); + if (dp_sub (3, 2) != 1) fail ("dp_sub 3-2"); + if (dp_mul (2, 3) != 6) fail ("dp_mul 2*3"); + if (dp_div (3, 2) != 1.5) fail ("dp_div 3/2"); + if (dp_neg (1) != -1) fail ("dp_neg 1"); + + if (fp_to_dp (1.5) != 1.5) fail ("fp_to_dp 1.5"); + if (dp_to_fp (1.5) != 1.5) fail ("dp_to_fp 1.5"); + + if (floatsisf (1) != 1) fail ("floatsisf 1"); + if (floatsidf (1) != 1) fail ("floatsidf 1"); + if (fixsfsi (1.42) != 1) fail ("fixsfsi 1.42"); + if (fixunssfsi (1.42) != 1) fail ("fixunssfsi 1.42"); + if (fixdfsi (1.42) != 1) fail ("fixdfsi 1.42"); + if (fixunsdfsi (1.42) != 1) fail ("fixunsdfsi 1.42"); + + if (eqsf2 (1, 1) == 0) fail ("eqsf2 1==1"); + if (eqsf2 (1, 2) != 0) fail ("eqsf2 1==2"); + if (nesf2 (1, 2) == 0) fail ("nesf2 1!=1"); + if (nesf2 (1, 1) != 0) fail ("nesf2 1!=1"); + if (gtsf2 (2, 1) == 0) fail ("gtsf2 2>1"); + if (gtsf2 (1, 1) != 0) fail ("gtsf2 1>1"); + if (gtsf2 (0, 1) != 0) fail ("gtsf2 0>1"); + if (gesf2 (2, 1) == 0) fail ("gesf2 2>=1"); + if (gesf2 (1, 1) == 0) fail ("gesf2 1>=1"); + if (gesf2 (0, 1) != 0) fail ("gesf2 0>=1"); + if (ltsf2 (1, 2) == 0) fail ("ltsf2 1<2"); + if (ltsf2 (1, 1) != 0) fail ("ltsf2 1<1"); + if (ltsf2 (1, 0) != 0) fail ("ltsf2 1<0"); + if (lesf2 (1, 2) == 0) fail ("lesf2 1<=2"); + if (lesf2 (1, 1) == 0) fail ("lesf2 1<=1"); + if (lesf2 (1, 0) != 0) fail ("lesf2 1<=0"); + + if (fail_count != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/920518-1.c b/gcc/testsuite/gcc.c-torture/execute/ieee/920518-1.c new file mode 100644 index 00000000000..7f072b2981a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/920518-1.c @@ -0,0 +1,8 @@ +unsigned u=2147483839;float f0=2147483648e0,f1=2147483904e0; +main() +{ + float f=u; + if(f==f0) + abort(); + exit(0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/920810-1.c b/gcc/testsuite/gcc.c-torture/execute/ieee/920810-1.c new file mode 100644 index 00000000000..62d22940adc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/920810-1.c @@ -0,0 +1,3 @@ +#include <stdio.h> +double normalize(x)double x;{if(x==0)x=0;return x;} +main(){char b[9];sprintf(b,"%g",normalize(-0.0));if(strcmp(b,"0"))abort();exit(0);} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/930529-1.c b/gcc/testsuite/gcc.c-torture/execute/ieee/930529-1.c new file mode 100644 index 00000000000..0b5eda4ac9a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/930529-1.c @@ -0,0 +1,27 @@ +main () +{ + union { + double d; + unsigned char c[8]; + } d; + + d.d = 1.0/7.0; + + if (sizeof (char) * 8 == sizeof (double)) + { + if (d.c[0] == 0x92 && d.c[1] == 0x24 && d.c[2] == 0x49 && d.c[3] == 0x92 + && d.c[4] == 0x24 && d.c[5] == 0x49 && d.c[6] == 0xc2 && d.c[7] == 0x3f) + exit (0); + if (d.c[7] == 0x92 && d.c[6] == 0x24 && d.c[5] == 0x49 && d.c[4] == 0x92 + && d.c[3] == 0x24 && d.c[2] == 0x49 && d.c[1] == 0xc2 && d.c[0] == 0x3f) + exit (0); +#ifdef __arm__ + if (d.c[4] == 0x92 && d.c[5] == 0x24 && d.c[6] == 0x49 && d.c[7] == 0x92 + && d.c[0] == 0x24 && d.c[1] == 0x49 && d.c[2] == 0xc2 && d.c[3] == 0x3f) + exit (0); +#endif + abort (); + } + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/Makefile.in b/gcc/testsuite/gcc.c-torture/execute/ieee/Makefile.in new file mode 100644 index 00000000000..e6209dbc6c2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/Makefile.in @@ -0,0 +1,12 @@ +#### host, target, and site specific Makefile frags come in here. + +srcdir = . + +# Nothing to do... +all: + +clean: + -rm -f *.o *.diff *~ *.bad core *.x + +distclean: clean + -rm -f Makefile config.status diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/configure.in b/gcc/testsuite/gcc.c-torture/execute/ieee/configure.in new file mode 100644 index 00000000000..7d7078dbfd2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/configure.in @@ -0,0 +1,15 @@ +# This file is a shell script fragment that supplies the information +# necessary to tailor a template configure script into the configure +# script appropriate for this directory. For more information, check +# any existing configure script. + +srctrigger=execute.exp +srcname="DejaGnu" + +# per-host: + +# per-target: + +target_makefile_frag=../config/mt-${target_alias} + +# post-target: diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c new file mode 100644 index 00000000000..3c3ccb65c09 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-1.c @@ -0,0 +1,40 @@ +#include <signal.h> + +double nan = 1.0/0.0 - 1.0/0.0; +double x = 1.0; + +void leave () +{ + exit (0); +} + +main () +{ +#if ! defined (__vax__) && ! defined (_CRAY) + /* NaN is an IEEE unordered operand. All these test should be false. */ + if (nan == nan) + abort (); + if (nan != x) + x = 1.0; + else + abort (); + +#ifndef SIGNAL_SUPPRESS + /* Some machines catches a SIGFPE when a NaN is compared. + Let this test succeed o such machines. */ + signal (SIGFPE, leave); +#endif + + if (nan < x) + abort (); + if (nan > x) + abort (); + if (nan <= x) + abort (); + if (nan >= x) + abort (); + if (nan == x) + abort (); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp b/gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp new file mode 100644 index 00000000000..795dbf167c9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/ieee.exp @@ -0,0 +1,51 @@ +# +# Expect driver script for GCC Regression Tests +# Copyright (C) 1993, 1996 Free Software Foundation +# +# This file 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Written by Jeffrey Wheat (cassidy@cygnus.com) +# + +# +# These tests come from Torbjorn Granlund's (tege@cygnus.com) +# C torture test suite, and other contributors. +# + +if $tracelevel then { + strace $tracelevel +} + +# load support procs +load_lib c-torture.exp + +# initialize harness +gcc_init + +# +# main test loop +# + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.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 + } + + c-torture-execute $src +} + +# All done. +gcc_finish diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/minuszero.c b/gcc/testsuite/gcc.c-torture/execute/ieee/minuszero.c new file mode 100644 index 00000000000..85715261d61 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/minuszero.c @@ -0,0 +1,22 @@ +main () +{ + union + { + double d; + unsigned short i[sizeof (double) / sizeof (short)]; + } u; + int a = 0; + int b = -5; + int j; + + u.d = (double) a / b; + + /* Look for the right pattern, but be sloppy since + we don't know the byte order. */ + for (j = 0; j < sizeof (double) / sizeof (short); j++) + { + if (u.i[j] == 0x8000) + exit (0); + } + abort (); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.c b/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.c new file mode 100644 index 00000000000..a91a99e92e2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.c @@ -0,0 +1,41 @@ +double d (unsigned long long k) +{ + double x; + + x = (double) k; + return x; +} + +float s (unsigned long long k) +{ + float x; + + x = (float) k; + return x; +} + +main () +{ + unsigned long long int k; + double x; + + /* CYGNUS LOCAL -- meissner/32bit doubles */ + if (sizeof (double) >= 8) + { + k = 0x8693ba6d7d220401ULL; + x = d (k); + k = (unsigned long long) x; + if (k != 0x8693ba6d7d220800ULL) + abort (); + } + /* END CYGNUS LOCAL -- meissner/32bit doubles */ + + k = 0x8234508000000001ULL; + x = s (k); + k = (unsigned long long) x; + if (k != 0x8234510000000000ULL) + abort (); + + exit (0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.cexp b/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.cexp new file mode 100644 index 00000000000..0ae0a35d315 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/rbug.cexp @@ -0,0 +1,7 @@ +# This doesn't work on d10v if doubles are not 64 bits + +if { [istarget "d10v-*-*"] && ! [string-match "*-mdouble64*" $CFLAGS] } { + set torture_execute_xfail "d10v-*-*" +} + +return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/index-1.c b/gcc/testsuite/gcc.c-torture/execute/index-1.c new file mode 100644 index 00000000000..b00090d834a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/index-1.c @@ -0,0 +1,20 @@ +int a[] = +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 +}; + +int +f (long n) +{ + return a[n - 100000]; +} + +main () +{ + if (f (100030L) != 30) + abort(); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/inst-check.c b/gcc/testsuite/gcc.c-torture/execute/inst-check.c new file mode 100644 index 00000000000..ff4b00d7868 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/inst-check.c @@ -0,0 +1,14 @@ +#include <stdarg.h> + +f(m) +{ + int i,s=0; + for(i=0;i<m;i++) + s+=i; + return s; +} + +main() +{ + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/int-compare.c b/gcc/testsuite/gcc.c-torture/execute/int-compare.c new file mode 100644 index 00000000000..017a8cc3f15 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/int-compare.c @@ -0,0 +1,108 @@ +#include <limits.h> + +gt (a, b) +{ + return a > b; +} + +ge (a, b) +{ + return a >= b; +} + +lt (a, b) +{ + return a < b; +} + +le (a, b) +{ + return a <= b; +} + +void +true (c) +{ + if (!c) + abort(); +} + +void +false (c) +{ + if (c) + abort(); +} + +f () +{ + true (gt (2, 1)); + false (gt (1, 2)); + + true (gt (INT_MAX, 0)); + false (gt (0, INT_MAX)); + true (gt (INT_MAX, 1)); + false (gt (1, INT_MAX)); + + false (gt (INT_MIN, 0)); + true (gt (0, INT_MIN)); + false (gt (INT_MIN, 1)); + true (gt (1, INT_MIN)); + + true (gt (INT_MAX, INT_MIN)); + false (gt (INT_MIN, INT_MAX)); + + true (ge (2, 1)); + false (ge (1, 2)); + + true (ge (INT_MAX, 0)); + false (ge (0, INT_MAX)); + true (ge (INT_MAX, 1)); + false (ge (1, INT_MAX)); + + false (ge (INT_MIN, 0)); + true (ge (0, INT_MIN)); + false (ge (INT_MIN, 1)); + true (ge (1, INT_MIN)); + + true (ge (INT_MAX, INT_MIN)); + false (ge (INT_MIN, INT_MAX)); + + false (lt (2, 1)); + true (lt (1, 2)); + + false (lt (INT_MAX, 0)); + true (lt (0, INT_MAX)); + false (lt (INT_MAX, 1)); + true (lt (1, INT_MAX)); + + true (lt (INT_MIN, 0)); + false (lt (0, INT_MIN)); + true (lt (INT_MIN, 1)); + false (lt (1, INT_MIN)); + + false (lt (INT_MAX, INT_MIN)); + true (lt (INT_MIN, INT_MAX)); + + false (le (2, 1)); + true (le (1, 2)); + + false (le (INT_MAX, 0)); + true (le (0, INT_MAX)); + false (le (INT_MAX, 1)); + true (le (1, INT_MAX)); + + true (le (INT_MIN, 0)); + false (le (0, INT_MIN)); + true (le (INT_MIN, 1)); + false (le (1, INT_MIN)); + + false (le (INT_MAX, INT_MIN)); + true (le (INT_MIN, INT_MAX)); +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-1.c b/gcc/testsuite/gcc.c-torture/execute/loop-1.c new file mode 100644 index 00000000000..81aeeb6b392 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-1.c @@ -0,0 +1,18 @@ +main () +{ + int i, j, k[3]; + + j = 0; + for (i=0; i < 3; i++) + { + k[i] = j++; + } + + for (i=2; i >= 0; i--) + { + if (k[i] != i) + abort (); + } + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2.c b/gcc/testsuite/gcc.c-torture/execute/loop-2.c new file mode 100644 index 00000000000..3227734fbf8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-2.c @@ -0,0 +1,17 @@ +int a[2]; + +f (b) +{ + unsigned int i; + for (i = 0; i < b; i++) + a[i] = i - 2; +} + +main () +{ + a[0] = a[1] = 0; + f (2); + if (a[0] != -2 || a[1] != -1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2b.c b/gcc/testsuite/gcc.c-torture/execute/loop-2b.c new file mode 100644 index 00000000000..7f67bcd639d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-2b.c @@ -0,0 +1,22 @@ +#include <limits.h> + +int a[2]; + +f (int i) +{ + for (; i < INT_MAX; i++) + { + a[i] = -2; + if (&a[i] == &a[1]) + break; + } +} + +main () +{ + a[0] = a[1] = 0; + f (0); + if (a[0] != -2 || a[1] != -2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2c.c b/gcc/testsuite/gcc.c-torture/execute/loop-2c.c new file mode 100644 index 00000000000..9facf3bfd92 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-2c.c @@ -0,0 +1,23 @@ +int a[2]; + +__inline__ f (b, o) +{ + unsigned int i; + int *p; + for (p = &a[b], i = b; --i < ~0; ) + *--p = i * 3 + o; +} + +g(int b) +{ + f (b, (int)a); +} + +main () +{ + a[0] = a[1] = 0; + g (2); + if (a[0] != (int)a || a[1] != (int)a + 3) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2d.c b/gcc/testsuite/gcc.c-torture/execute/loop-2d.c new file mode 100644 index 00000000000..19272bf0183 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-2d.c @@ -0,0 +1,18 @@ +int a[2]; + +f (b) +{ + unsigned int i; + int *p; + for (p = &a[b], i = b; --i < ~0; ) + *--p = i * 3 + (int)a; +} + +main () +{ + a[0] = a[1] = 0; + f (2); + if (a[0] != (int)a || a[1] != (int)a + 3) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2e.c b/gcc/testsuite/gcc.c-torture/execute/loop-2e.c new file mode 100644 index 00000000000..b6ee6501501 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-2e.c @@ -0,0 +1,60 @@ +#include <limits.h> + +#ifdef __unix__ /* ??? Is that good enough? */ +#include <sys/types.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <fcntl.h> +#ifndef MAP_ANON +#ifdef MAP_ANONYMOUS +#define MAP_ANON MAP_ANONYMOUS +#else +#define MAP_ANON MAP_FILE +#endif +#endif +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif +#ifndef MAP_FIXED +#define MAP_FIXED 0 +#endif +#endif + +#define MAP_START (void *)0x7fff8000 +#define MAP_LEN 0x10000 + +#define OFFSET (MAP_LEN/2 - 2 * sizeof (int)); + +f (int *p, int **q) +{ + int i; + for (i = 0; i < 40; i++) + { + *q++ = &p[i]; + } +} + +main () +{ +#ifdef MAP_ANON + void *p; + int *q[40]; + int dev_zero; + + dev_zero = open ("/dev/zero", O_RDONLY); + /* -1 is OK when we have MAP_ANON; else mmap will flag an error. */ + if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int)) + exit (0); + p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0); + if (p != (void *)-1) + { + p = (char *)p + OFFSET; + q[39] = 0; + f (p, q); + if (q[39] != (int *)p + 39) + abort (); + } +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-2f.c b/gcc/testsuite/gcc.c-torture/execute/loop-2f.c new file mode 100644 index 00000000000..9f544b9fcbd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-2f.c @@ -0,0 +1,63 @@ +#include <limits.h> + +#ifdef __unix__ /* ??? Is that good enough? */ +#include <sys/types.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <fcntl.h> +#ifndef MAP_ANON +#ifdef MAP_ANONYMOUS +#define MAP_ANON MAP_ANONYMOUS +#else +#define MAP_ANON MAP_FILE +#endif +#endif +#ifndef MAP_FILE +#define MAP_FILE 0 +#endif +#ifndef MAP_FIXED +#define MAP_FIXED 0 +#endif +#endif + +#define MAP_START (void *)0x7fff8000 +#define MAP_LEN 0x10000 + +#define OFFSET (MAP_LEN/2 - 2 * sizeof (char)); + +f (int s, char *p) +{ + int i; + for (i = s; i >= 0 && &p[i] < &p[40]; i++) + { + p[i] = -2; + } +} + +main () +{ +#ifdef MAP_ANON + char *p; + int dev_zero; + + dev_zero = open ("/dev/zero", O_RDONLY); + /* -1 is OK when we have MAP_ANON; else mmap will flag an error. */ + if (INT_MAX != 0x7fffffffL || sizeof (char *) != sizeof (int)) + exit (0); + p = mmap (MAP_START, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_FIXED|MAP_PRIVATE, dev_zero, 0); + if (p != (char *)-1) + { + p += OFFSET; + p[39] = 0; + f (0, p); + if (p[39] != (char)-2) + abort (); + p[39] = 0; + f (-1, p); + if (p[39] != 0) + abort (); + } +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-3.c b/gcc/testsuite/gcc.c-torture/execute/loop-3.c new file mode 100644 index 00000000000..e314a01b1f1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-3.c @@ -0,0 +1,27 @@ +#include <limits.h> + +int n = 0; + +g (i) +{ + n++; +} + +f (m) +{ + int i; + i = m; + do + { + g (i * INT_MAX / 2); + } + while (--i > 0); +} + +main () +{ + f (4); + if (n != 4) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-3b.c b/gcc/testsuite/gcc.c-torture/execute/loop-3b.c new file mode 100644 index 00000000000..3de322cf146 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-3b.c @@ -0,0 +1,28 @@ +#include <limits.h> + +int n = 0; + +g (i) +{ + n++; +} + +f (m) +{ + int i; + i = m; + do + { + g (i * 4); + i -= INT_MAX / 8; + } + while (i > 0); +} + +main () +{ + f (INT_MAX/8*4); + if (n != 4) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-3c.c b/gcc/testsuite/gcc.c-torture/execute/loop-3c.c new file mode 100644 index 00000000000..bc74c2e6d9b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/loop-3c.c @@ -0,0 +1,31 @@ +#include <limits.h> + +void * a[255]; + +f (m) +{ + int i; + int sh = 0x100; + i = m; + do + { + a[sh >>= 1] = ((unsigned)i << 3) + (char*)a; + i += 4; + } + while (i < INT_MAX/2 + 1 + 4 * 4); +} + +main () +{ + a[0x10] = 0; + a[0x08] = 0; + f (INT_MAX/2 + INT_MAX/4 + 2); + if (a[0x10] || a[0x08]) + abort (); + a[0x10] = 0; + a[0x08] = 0; + f (INT_MAX/2 + 1); + if (! a[0x10] || a[0x08]) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c b/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c new file mode 100644 index 00000000000..684854b66dc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/memcpy-1.c @@ -0,0 +1,63 @@ +#include <string.h> + +#if defined (STACK_SIZE) +#define MEMCPY_SIZE (STACK_SIZE / 3) +#else +#define MEMCPY_SIZE (1 << 17) +#endif + + +void *copy (void *o, const void *i, unsigned l) +{ + return memcpy (o, i, l); +} + +main () +{ + unsigned i; + unsigned char src[MEMCPY_SIZE]; + unsigned char dst[MEMCPY_SIZE]; + + for (i = 0; i < MEMCPY_SIZE; i++) + src[i] = (unsigned char) i, dst[i] = 0; + + (void) memcpy (dst, src, MEMCPY_SIZE / 128); + + for (i = 0; i < MEMCPY_SIZE / 128; i++) + if (dst[i] != (unsigned char) i) + abort (); + + (void) memset (dst, 1, MEMCPY_SIZE / 128); + + for (i = 0; i < MEMCPY_SIZE / 128; i++) + if (dst[i] != 1) + abort (); + + (void) memcpy (dst, src, MEMCPY_SIZE); + + for (i = 0; i < MEMCPY_SIZE; i++) + if (dst[i] != (unsigned char) i) + abort (); + + (void) memset (dst, 0, MEMCPY_SIZE); + + for (i = 0; i < MEMCPY_SIZE; i++) + if (dst[i] != 0) + abort (); + + (void) copy (dst, src, MEMCPY_SIZE / 128); + + for (i = 0; i < MEMCPY_SIZE / 128; i++) + if (dst[i] != (unsigned char) i) + abort (); + + (void) memset (dst, 0, MEMCPY_SIZE); + + (void) copy (dst, src, MEMCPY_SIZE); + + for (i = 0; i < MEMCPY_SIZE; i++) + if (dst[i] != (unsigned char) i) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/mod-1.c b/gcc/testsuite/gcc.c-torture/execute/mod-1.c new file mode 100644 index 00000000000..b460df5cdb1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/mod-1.c @@ -0,0 +1,11 @@ +f (x, y) +{ + if (x % y != 0) + abort (); +} + +main () +{ + f (-5, 5); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/nest-stdar-1.c b/gcc/testsuite/gcc.c-torture/execute/nest-stdar-1.c new file mode 100644 index 00000000000..2c6108b52e6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/nest-stdar-1.c @@ -0,0 +1,19 @@ +#include <stdarg.h> + +main () +{ + static double f (int x, ...) + { + va_list args; + double a; + + va_start (args, x); + a = va_arg (args, double); + va_end (args); + return a; + } + + if (f (1, (double)1) != 1.0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/nestfunc-1.c b/gcc/testsuite/gcc.c-torture/execute/nestfunc-1.c new file mode 100644 index 00000000000..e34a56b3f57 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/nestfunc-1.c @@ -0,0 +1,28 @@ +int +g (int a, int b, int (*gi) (int, int)) +{ + if ((*gi) (a, b)) + return a; + else + return b; +} + +f () +{ +#ifndef NO_TRAMPOLINES + int i, j; + int f2 (int a, int b) + { + return a > b; + } + + if (g (1, 2, f2) != 2) + abort (); +#endif +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/packed-1.c b/gcc/testsuite/gcc.c-torture/execute/packed-1.c new file mode 100644 index 00000000000..9b226aeab9b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/packed-1.c @@ -0,0 +1,19 @@ +short x1 = 17; + +struct +{ + short i __attribute__ ((packed)); +} t; + +f () +{ + t.i = x1; + if (t.i != 17) + abort (); +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pending-4.c b/gcc/testsuite/gcc.c-torture/execute/pending-4.c new file mode 100644 index 00000000000..8000621e6b6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pending-4.c @@ -0,0 +1,33 @@ + +void dummy (x, y) + int *x; + int y; +{} + +int +main (argc, argv) + int argc; + char **argv; +{ + int number_columns=9; + int cnt0 = 0; + int cnt1 = 0; + int i,A1; + + for (i = number_columns-1; i != 0; i--) + { + if (i == 1) + { + dummy(&A1, i); + cnt0++; + } + else + { + dummy(&A1, i-1); + cnt1++; + } + } + if (cnt0 != 1 || cnt1 != 7) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ptr-arith-1.c b/gcc/testsuite/gcc.c-torture/execute/ptr-arith-1.c new file mode 100644 index 00000000000..46162b8964d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ptr-arith-1.c @@ -0,0 +1,14 @@ +char * +f (char *s, unsigned int i) +{ + return &s[i + 3 - 1]; +} + +main () +{ + char *str = "abcdefghijkl"; + char *x2 = f (str, 12); + if (str + 14 != x2) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/regstack-1.c b/gcc/testsuite/gcc.c-torture/execute/regstack-1.c new file mode 100644 index 00000000000..51fb858cf92 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/regstack-1.c @@ -0,0 +1,26 @@ +long double C = 5; +long double U = 1; +long double Y2 = 11; +long double Y1 = 17; +long double X, Y, Z, T, R, S; +main () +{ + X = (C + U) * Y2; + Y = C - U - U; + Z = C + U + U; + T = (C - U) * Y1; + X = X - (Z + U); + R = Y * Y1; + S = Z * Y2; + T = T - Y; + Y = (U - Y) + R; + Z = S - (Z + U + U); + R = (Y2 + U) * Y1; + Y1 = Y2 * Y1; + R = R - Y2; + Y1 = Y1 - 0.5L; + if (Z != 68. || Y != 49. || X != 58. || Y1 != 186.5 || R != 193. || S != 77. + || T != 65. || Y2 != 11.) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/scope-1.c b/gcc/testsuite/gcc.c-torture/execute/scope-1.c new file mode 100644 index 00000000000..cedd0b48ccb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/scope-1.c @@ -0,0 +1,17 @@ +int v = 3; + +f () +{ + int v = 4; + { + extern int v; + if (v != 3) + abort (); + } +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/scope-2.c b/gcc/testsuite/gcc.c-torture/execute/scope-2.c new file mode 100644 index 00000000000..c9a4775f6f5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/scope-2.c @@ -0,0 +1,17 @@ +static int v = 3; + +f () +{ + int v = 4; + { + extern int v; + if (v != 3) + abort (); + } +} + +main () +{ + f (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/strct-pack-1.c b/gcc/testsuite/gcc.c-torture/execute/strct-pack-1.c new file mode 100644 index 00000000000..7b702f2cd68 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/strct-pack-1.c @@ -0,0 +1,25 @@ +typedef struct +{ + short s __attribute__ ((aligned(2), packed)); + double d __attribute__ ((aligned(2), packed)); +} TRIAL; + +int +check (TRIAL *t) +{ + if (t->s != 1 || t->d != 16.0) + return 1; + return 0; +} + +main () +{ + TRIAL trial; + + trial.s = 1; + trial.d = 16.0; + + if (check (&trial) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/strct-pack-2.c b/gcc/testsuite/gcc.c-torture/execute/strct-pack-2.c new file mode 100644 index 00000000000..be76c764521 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/strct-pack-2.c @@ -0,0 +1,13 @@ +typedef struct +{ + short a __attribute__ ((aligned (2),packed)); + short *ap[2] __attribute__ ((aligned (2),packed)); +} A; + +main () +{ + short i, j = 1; + A a, *ap = &a; + ap->ap[j] = &i; + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/strct-pack-3.c b/gcc/testsuite/gcc.c-torture/execute/strct-pack-3.c new file mode 100644 index 00000000000..8f91b040ca8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/strct-pack-3.c @@ -0,0 +1,28 @@ +typedef struct +{ + short i __attribute__ ((aligned (2),packed)); + int f[2] __attribute__ ((aligned (2),packed)); +} A; + +f (ap) + A *ap; +{ + short i, j = 1; + + i = ap->f[1]; + i += ap->f[j]; + for (j = 0; j < 2; j++) + i += ap->f[j]; + + return i; +} + +main () +{ + A a; + a.f[0] = 100; + a.f[1] = 13; + if (f (&a) != 139) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/strct-pack-4.c b/gcc/testsuite/gcc.c-torture/execute/strct-pack-4.c new file mode 100644 index 00000000000..56d315f47ff --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/strct-pack-4.c @@ -0,0 +1,29 @@ +typedef struct +{ + unsigned char a __attribute__((packed)); + unsigned short b __attribute__((packed)); +} three_char_t; + +unsigned char +my_set_a (void) +{ + return 0xab; +} + +unsigned short +my_set_b (void) +{ + return 0x1234; +} + +main () +{ + three_char_t three_char; + + three_char.a = my_set_a (); + three_char.b = my_set_b (); + if (three_char.a != 0xab || three_char.b != 0x1234) + abort (); + exit (0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.c b/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.c new file mode 100644 index 00000000000..f76bb368409 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/strct-varg-1.c @@ -0,0 +1,56 @@ +#ifdef NO_VARARGS +#include <stdarg.h> +#define va_alist int x_attr, ... +#define va_dcl +#else +#include <varargs.h> +#endif + +struct s { int x, y; }; + +f (va_alist) + va_dcl +{ + struct s va_values; + va_list va; + int attr; + int i; + +#ifdef NO_VARARGS + va_start (va, x_attr); + attr = x_attr; +#else + va_start (va); + attr = va_arg (va, int); +#endif + + if (attr != 2) + abort (); + + va_values = va_arg (va, struct s); + if (va_values.x != 0xaaaa || va_values.y != 0x5555) + abort (); + + attr = va_arg (va, int); + if (attr != 3) + abort (); + + va_values = va_arg (va, struct s); + if (va_values.x != 0xffff || va_values.y != 0x1111) + abort (); + + va_end (va); +} + +main () +{ + struct s a, b; + + a.x = 0xaaaa; + a.y = 0x5555; + b.x = 0xffff; + b.y = 0x1111; + + f (2, a, 3, b); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-ini-1.c b/gcc/testsuite/gcc.c-torture/execute/struct-ini-1.c new file mode 100644 index 00000000000..ab2d178a751 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/struct-ini-1.c @@ -0,0 +1,15 @@ +struct S +{ + char f1; + int f2[2]; +}; + +struct S object = {'X', 8, 9}; + +main () +{ + if (object.f1 != 'X' || object.f2[0] != 8 || object.f2[1] != 9) + abort (); + exit (0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-ini-2.c b/gcc/testsuite/gcc.c-torture/execute/struct-ini-2.c new file mode 100644 index 00000000000..c785257ccba --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/struct-ini-2.c @@ -0,0 +1,17 @@ +struct { + int a:4; + int :4; + int b:4; + int c:4; +} x = { 2,3,4 }; + +main () +{ + if (x.a != 2) + abort (); + if (x.b != 3) + abort (); + if (x.c != 4) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-ini-3.c b/gcc/testsuite/gcc.c-torture/execute/struct-ini-3.c new file mode 100644 index 00000000000..7d282ecb8af --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/struct-ini-3.c @@ -0,0 +1,11 @@ +struct +{ + unsigned int f1:1, f2:1, f3:3, f4:3, f5:2, f6:1, f7:1; +} result = {1, 1, 7, 7, 3, 1, 1}; + +main () +{ + if ((result.f3 & ~7) != 0 || (result.f4 & ~7) != 0) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-ini-4.c b/gcc/testsuite/gcc.c-torture/execute/struct-ini-4.c new file mode 100644 index 00000000000..3342439e54d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/struct-ini-4.c @@ -0,0 +1,15 @@ +struct s { + int a[3]; + int c[3]; +}; + +struct s s = { + c: {1, 2, 3} +}; + +main() +{ + if (s.c[0] != 1) + abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c b/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c new file mode 100644 index 00000000000..e5274ec4c15 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/struct-ret-1.c @@ -0,0 +1,57 @@ +#include <stdio.h> +#include <string.h> + +char out[100]; + +typedef struct { double d; int i[3]; } B; +typedef struct { char c[33],c1; } X; + +char c1 = 'a'; +char c2 = 127; +char c3 = (char)128; +char c4 = (char)255; +char c5 = -1; + +double d1 = 0.1; +double d2 = 0.2; +double d3 = 0.3; +double d4 = 0.4; +double d5 = 0.5; +double d6 = 0.6; +double d7 = 0.7; +double d8 = 0.8; +double d9 = 0.9; + +B B1 = {0.1,{1,2,3}}; +B B2 = {0.2,{5,4,3}}; +X X1 = {"abcdefghijklmnopqrstuvwxyzABCDEF", 'G'}; +X X2 = {"123",'9'}; +X X3 = {"return-return-return",'R'}; + +X f (B a, char b, double c, B d) +{ + static X xr = {"return val", 'R'}; + X r; + r = xr; + r.c1 = b; + sprintf (out, "X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})", + a.d, a.i[0], a.i[1], a.i[2], b, c, d.d, d.i[0], d.i[1], d.i[2]); + return r; +} + +X (*fp) (B, char, double, B) = &f; + +main () +{ + X Xr; + char tmp[100]; + + Xr = f (B1, c2, d3, B2); + strcpy (tmp, out); + Xr.c[0] = Xr.c1 = '\0'; + Xr = (*fp) (B1, c2, d3, B2); + if (strcmp (tmp, out)) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/struct-ret-2.c b/gcc/testsuite/gcc.c-torture/execute/struct-ret-2.c new file mode 100644 index 00000000000..06a40a72099 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/struct-ret-2.c @@ -0,0 +1,29 @@ +typedef struct +{ + unsigned char a __attribute__ ((packed)); + unsigned short b __attribute__ ((packed)); +} three_byte_t; + +unsigned char +f (void) +{ + return 0xab; +} + +unsigned short +g (void) +{ + return 0x1234; +} + +main () +{ + three_byte_t three_byte; + + three_byte.a = f (); + three_byte.b = g (); + if (three_byte.a != 0xab || three_byte.b != 0x1234) + abort (); + exit (0); +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/tstdi-1.c b/gcc/testsuite/gcc.c-torture/execute/tstdi-1.c new file mode 100644 index 00000000000..3e31fdf5934 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/tstdi-1.c @@ -0,0 +1,139 @@ +#define FALSE 140 +#define TRUE 13 + +feq (x) + long long int x; +{ + if (x == 0) + return TRUE; + else + return FALSE; +} + +fne (x) + long long int x; +{ + if (x != 0) + return TRUE; + else + return FALSE; +} + +flt (x) + long long int x; +{ + if (x < 0) + return TRUE; + else + return FALSE; +} + +fge (x) + long long int x; +{ + if (x >= 0) + return TRUE; + else + return FALSE; +} + +fgt (x) + long long int x; +{ + if (x > 0) + return TRUE; + else + return FALSE; +} + +fle (x) + long long int x; +{ + if (x <= 0) + return TRUE; + else + return FALSE; +} + +main () +{ + if (feq (0LL) != TRUE) + abort (); + if (feq (-1LL) != FALSE) + abort (); + if (feq (0x8000000000000000LL) != FALSE) + abort (); + if (feq (0x8000000000000001LL) != FALSE) + abort (); + if (feq (1LL) != FALSE) + abort (); + if (feq (0x7fffffffffffffffLL) != FALSE) + abort (); + + if (fne (0LL) != FALSE) + abort (); + if (fne (-1LL) != TRUE) + abort (); + if (fne (0x8000000000000000LL) != TRUE) + abort (); + if (fne (0x8000000000000001LL) != TRUE) + abort (); + if (fne (1LL) != TRUE) + abort (); + if (fne (0x7fffffffffffffffLL) != TRUE) + abort (); + + if (flt (0LL) != FALSE) + abort (); + if (flt (-1LL) != TRUE) + abort (); + if (flt (0x8000000000000000LL) != TRUE) + abort (); + if (flt (0x8000000000000001LL) != TRUE) + abort (); + if (flt (1LL) != FALSE) + abort (); + if (flt (0x7fffffffffffffffLL) != FALSE) + abort (); + + if (fge (0LL) != TRUE) + abort (); + if (fge (-1LL) != FALSE) + abort (); + if (fge (0x8000000000000000LL) != FALSE) + abort (); + if (fge (0x8000000000000001LL) != FALSE) + abort (); + if (fge (1LL) != TRUE) + abort (); + if (fge (0x7fffffffffffffffLL) != TRUE) + abort (); + + if (fgt (0LL) != FALSE) + abort (); + if (fgt (-1LL) != FALSE) + abort (); + if (fgt (0x8000000000000000LL) != FALSE) + abort (); + if (fgt (0x8000000000000001LL) != FALSE) + abort (); + if (fgt (1LL) != TRUE) + abort (); + if (fgt (0x7fffffffffffffffLL) != TRUE) + abort (); + + if (fle (0LL) != TRUE) + abort (); + if (fle (-1LL) != TRUE) + abort (); + if (fle (0x8000000000000000LL) != TRUE) + abort (); + if (fle (0x8000000000000001LL) != TRUE) + abort (); + if (fle (1LL) != FALSE) + abort (); + if (fle (0x7fffffffffffffffLL) != FALSE) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/va-arg-1.c b/gcc/testsuite/gcc.c-torture/execute/va-arg-1.c new file mode 100644 index 00000000000..3f3b141a931 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/va-arg-1.c @@ -0,0 +1,24 @@ +#include <stdarg.h> + +typedef unsigned long L; +f (L p0, L p1, L p2, L p3, L p4, L p5, L p6, L p7, L p8, ...) +{ + va_list select; + + va_start (select, p8); + + if (va_arg (select, L) != 10) + abort (); + if (va_arg (select, L) != 11) + abort (); + if (va_arg (select, L) != 0) + abort (); + + va_end (select); +} + +main () +{ + f (1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 0L); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/va-arg-2.c b/gcc/testsuite/gcc.c-torture/execute/va-arg-2.c new file mode 100644 index 00000000000..7675b3f7603 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/va-arg-2.c @@ -0,0 +1,292 @@ +/* The purpose of this test is to catch edge cases when arguments are passed + in regs and on the stack. We test 16 cases, trying to catch multiple + targets (some use 3 regs for argument passing, some use 12, etc.). + We test both the arguments and the `lastarg' (the argument to va_start). */ + +#include <stdarg.h> + +extern __SIZE_TYPE__ strlen (); + +int +to_hex (unsigned int a) +{ + static char hex[] = "0123456789abcdef"; + + if (a > 15) + abort (); + return hex[a]; +} + +void +f0 (char* format, ...) +{ + va_list ap; + + va_start (ap, format); + if (strlen (format) != 16 - 0) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f1 (int a1, char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 1) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f2 (int a1, int a2, char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 2) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f3 (int a1, int a2, int a3, char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 3) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f4 (int a1, int a2, int a3, int a4, char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 4) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f5 (int a1, int a2, int a3, int a4, int a5, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 5) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f6 (int a1, int a2, int a3, int a4, int a5, + int a6, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 6) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f7 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 7) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f8 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 8) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f9 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 9) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f10 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, int a10, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 10) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f11 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, int a10, + int a11, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 11) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f12 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, int a10, + int a11, int a12, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 12) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f13 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 13) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f14 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, int a14, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 14) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f15 (int a1, int a2, int a3, int a4, int a5, + int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, int a14, int a15, + char* format, ...) +{ + va_list ap; + + va_start(ap, format); + if (strlen (format) != 16 - 15) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +main () +{ + char *f = "0123456789abcdef"; + + f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15); + f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15); + f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15); + f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15); + f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15); + f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15); + f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15); + f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15); + + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/va-arg-3.c b/gcc/testsuite/gcc.c-torture/execute/va-arg-3.c new file mode 100644 index 00000000000..7b0a0b0cf36 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/va-arg-3.c @@ -0,0 +1,339 @@ +/* Same as va-arg-2.c but using varargs.h. */ +/* The purpose of this test is to catch edge cases when arguments are passed + in regs and on the stack. We test 16 cases, trying to catch multiple + targets (some use 3 regs for argument passing, some use 12, etc.). + We test both the arguments and the `lastarg' (the argument to va_start). */ + +#ifdef NO_VARARGS +int main() +{ + exit (0); +} + +#else +#include <varargs.h> + +extern __SIZE_TYPE__ strlen (); + +int +to_hex (unsigned int a) +{ + static char hex[] = "0123456789abcdef"; + + if (a > 15) + abort (); + return hex[a]; +} + +void +f0 (va_alist) + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 0) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f1 (a1, va_alist) + int a1; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 1) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f2 (a1, a2, va_alist) + int a1, a2; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 2) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f3 (a1, a2, a3, va_alist) + int a1, a2, a3; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 3) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f4 (a1, a2, a3, a4, va_alist) + int a1, a2, a3, a4; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 4) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f5 (a1, a2, a3, a4, a5, va_alist) + int a1, a2, a3, a4, a5; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 5) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f6 (a1, a2, a3, a4, a5, a6, va_alist) + int a1, a2, a3, a4, a5, a6; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 6) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f7 (a1, a2, a3, a4, a5, a6, a7, va_alist) + int a1, a2, a3, a4, a5, a6, a7; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 7) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f8 (a1, a2, a3, a4, a5, a6, a7, a8, va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 8) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f9 (a1, a2, a3, a4, a5, a6, a7, a8, a9, va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8, a9; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 9) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f10 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 10) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f11 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, + va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 11) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f12 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 12) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f13 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 13) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f14 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 14) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +void +f15 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, va_alist) + int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15; + va_dcl +{ + va_list ap; + char *format; + + va_start (ap); + format = va_arg (ap, char *); + if (strlen (format) != 16 - 15) + abort (); + while (*format) + if (*format++ != to_hex (va_arg (ap, int))) + abort (); + va_end(ap); +} + +main () +{ + char *f = "0123456789abcdef"; + + f0 (f+0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f1 (0, f+1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f2 (0, 1, f+2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f3 (0, 1, 2, f+3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f4 (0, 1, 2, 3, f+4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f5 (0, 1, 2, 3, 4, f+5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f6 (0, 1, 2, 3, 4, 5, f+6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f7 (0, 1, 2, 3, 4, 5, 6, f+7, 7, 8, 9, 10, 11, 12, 13, 14, 15); + f8 (0, 1, 2, 3, 4, 5, 6, 7, f+8, 8, 9, 10, 11, 12, 13, 14, 15); + f9 (0, 1, 2, 3, 4, 5, 6, 7, 8, f+9, 9, 10, 11, 12, 13, 14, 15); + f10 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, f+10, 10, 11, 12, 13, 14, 15); + f11 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, f+11, 11, 12, 13, 14, 15); + f12 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, f+12, 12, 13, 14, 15); + f13 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, f+13, 13, 14, 15); + f14 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, f+14, 14, 15); + f15 (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, f+15, 15); + + exit (0); +} +#endif /* ! NO_VARARGS */ diff --git a/gcc/testsuite/gcc.c-torture/execute/va-arg-4.c b/gcc/testsuite/gcc.c-torture/execute/va-arg-4.c new file mode 100644 index 00000000000..a824f64ffa1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/va-arg-4.c @@ -0,0 +1,33 @@ +/* On the i960 any arg bigger than 16 bytes causes all subsequent args + to be passed on the stack. We test this. */ + +#include <stdarg.h> + +typedef struct { + char a[32]; +} big; + +void +f (big x, char *s, ...) +{ + va_list ap; + + if (x.a[0] != 'a' || x.a[1] != 'b' || x.a[2] != 'c') + abort (); + va_start (ap, s); + if (va_arg (ap, int) != 42) + abort (); + if (va_arg (ap, int) != 'x') + abort (); + if (va_arg (ap, int) != 0) + abort (); + va_end (ap); +} + +main () +{ + static big x = { "abc" }; + + f (x, "", 42, 'x', 0); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/va-arg-5.c b/gcc/testsuite/gcc.c-torture/execute/va-arg-5.c new file mode 100644 index 00000000000..3d8b1a79ad1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/va-arg-5.c @@ -0,0 +1,44 @@ +#include <stdarg.h> + +va_double (int n, ...) +{ + va_list args; + + va_start (args, n); + + if (va_arg (args, double) != 3.141592) + abort (); + if (va_arg (args, double) != 2.71827) + abort (); + if (va_arg (args, double) != 2.2360679) + abort (); + if (va_arg (args, double) != 2.1474836) + abort (); + + va_end (args); +} + +va_long_double (int n, ...) +{ + va_list args; + + va_start (args, n); + + if (va_arg (args, long double) != 3.141592L) + abort (); + if (va_arg (args, long double) != 2.71827L) + abort (); + if (va_arg (args, long double) != 2.2360679L) + abort (); + if (va_arg (args, long double) != 2.1474836L) + abort (); + + va_end (args); +} + +main () +{ + va_double (4, 3.141592, 2.71827, 2.2360679, 2.1474836); + va_long_double (4, 3.141592L, 2.71827L, 2.2360679L, 2.1474836L); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/va-arg-6.c b/gcc/testsuite/gcc.c-torture/execute/va-arg-6.c new file mode 100644 index 00000000000..e8d495d66e7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/va-arg-6.c @@ -0,0 +1,35 @@ +#include <stdarg.h> + +f (int n, ...) +{ + va_list args; + + va_start (args, n); + + if (va_arg (args, int) != 10) + abort (); + if (va_arg (args, long long) != 10000000000LL) + abort (); + if (va_arg (args, int) != 11) + abort (); + if (va_arg (args, long double) != 3.14L) + abort (); + if (va_arg (args, int) != 12) + abort (); + if (va_arg (args, int) != 13) + abort (); + if (va_arg (args, long long) != 20000000000LL) + abort (); + if (va_arg (args, int) != 14) + abort (); + if (va_arg (args, double) != 2.72) + abort (); + + va_end(args); +} + +main () +{ + f (4, 10, 10000000000LL, 11, 3.14L, 12, 13, 20000000000LL, 14, 2.72); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/widechar-1.c b/gcc/testsuite/gcc.c-torture/execute/widechar-1.c new file mode 100644 index 00000000000..45b9d89b4b4 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/widechar-1.c @@ -0,0 +1,14 @@ +#define C L'\400' + +#if C +#define zero (!C) +#else +#define zero C +#endif + +main() +{ + if (zero != 0) + abort (); + exit (0); +} |