diff --git a/lang/cem/ctest/ctconv/conv.c b/lang/cem/ctest/ctconv/conv.c index 7c948db37..20dcad182 100644 --- a/lang/cem/ctest/ctconv/conv.c +++ b/lang/cem/ctest/ctconv/conv.c @@ -17,13 +17,18 @@ /* Author: E.G. Keizer */ +char rcs_id[] = "$Header$" ; + main() { t1() ; return 0 ; } t1() { - char c ; int i ; long l ; unsigned u ; float f ; + char c ; int i ; long l ; unsigned u ; +#ifndef NOFLOAT + float f ; +#endif /* test conversions */ @@ -31,8 +36,10 @@ t1() { printf("(int) '\\377' = %d\n",(int) '\377') ; printf("(long) -1 = %ld\n",(long) -1 ) ; +#ifndef NOFLOAT printf("(float) 12 = %f\n",(float) 12 ) ; printf("(int) 3.14 = %d\n",(int) 3.14 ) ; +#endif printf("(int) 32767L = %d\n",(int) 32767L ) ; printf("(int) -32768L = %d\n",(int) -32768L ) ; printf("(char) 128L = %d\n",(char) 128L) ; @@ -46,20 +53,35 @@ t1() { i=c ; l=c ; u=c ; +#ifndef NOFLOAT f=c ; - printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ; +#endif + printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ; +#ifndef NOFLOAT + printf("\t\t\t\t\tfloat %f\n",f) ; +#endif c = -1 ; i=c ; l=c ; u=c ; +#ifndef NOFLOAT f=c ; - printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ; +#endif + printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ; +#ifndef NOFLOAT + printf("\t\t\t\t\tfloat %f\n",f) ; +#endif c = 0377 ; i=c ; l=c ; u=c ; +#ifndef NOFLOAT f=c ; - printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ; +#endif + printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ; +#ifndef NOFLOAT + printf("\t\t\t\t\tfloat %f\n",f) ; +#endif /* from integer */ printf("From integer\n") ; @@ -67,18 +89,28 @@ t1() { c=i ; l=i ; u=i ; +#ifndef NOFLOAT f=i ; - printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ; - +#endif + printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ; +#ifndef NOFLOAT + printf("\t\t\t\t\tfloat %f\n",f) ; +#endif /* from long */ printf("From long\n") ; l = -3 ; c = l ; i = l ; u = l ; +#ifndef NOFLOAT f = l ; - printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ; +#endif + printf("\tchar %5d, int %6d, unsigned %6o, long %11ld\n",c,i,u,l) ; +#ifndef NOFLOAT + printf("\t\t\t\t\tfloat %f\n",f) ; +#endif +#ifndef NOFLOAT printf("From float\n") ; f = 121.5 ; c = f ; @@ -100,6 +132,7 @@ t1() { f = 1223432e3 ; l = f ; printf("\tlong %11ld, float %f\n",l,f) ; +#endif /* some special cases */ { diff --git a/lang/cem/ctest/ctdecl/decl.c b/lang/cem/ctest/ctdecl/decl.c index 024f35fb0..275931c70 100644 --- a/lang/cem/ctest/ctdecl/decl.c +++ b/lang/cem/ctest/ctdecl/decl.c @@ -17,6 +17,8 @@ /* Author: E.G. Keizer */ +char rcs_id[] = "$Header$" ; + /* Test a few declaration features */ /* Such as: forward function declarations, diff --git a/lang/cem/ctest/ctdivers/ops.c b/lang/cem/ctest/ctdivers/ops.c index b13d3712a..bfc4e7f86 100644 --- a/lang/cem/ctest/ctdivers/ops.c +++ b/lang/cem/ctest/ctdivers/ops.c @@ -17,6 +17,8 @@ /* Author: E.G. Keizer */ +char rcs_id[] = "$Header$" ; + main() { assnull() ; diff --git a/lang/cem/ctest/cterr/bugs.c b/lang/cem/ctest/cterr/bugs.c index 5d92931a0..959dbbf89 100644 --- a/lang/cem/ctest/cterr/bugs.c +++ b/lang/cem/ctest/cterr/bugs.c @@ -17,6 +17,8 @@ /* Author: E.G. Keizer */ +char rcs_id[] = "$Header$" ; + /* This programs is a collection of derived from small tests develloped for specific bugs/features in the C->EM compiler */ @@ -69,12 +71,16 @@ loc_fa(p1,p2) { con_fold() { set_err("con_fold") ; +#ifndef NOFLOAT con_flo( (1 ? 3 : 4.5), 200, 200, 200 ) ; +#endif con_lo( 4L + 3, 1 ) ; } +#ifndef NOFLOAT con_flo(d) double d ; { if ( d>3.00001 || d<2.99999 ) e(1) ; } +#endif con_lo(l) long l ; { if ( l!=7 ) e(2) ; } diff --git a/lang/cem/ctest/ctest1/test.c b/lang/cem/ctest/ctest1/test.c index f685da17d..4befc9789 100644 --- a/lang/cem/ctest/ctest1/test.c +++ b/lang/cem/ctest/ctest1/test.c @@ -15,11 +15,15 @@ * */ +char rcs_id[] = "$Header$" ; + /* C-compiler test 1 */ /* This program can be used to test C-compilers */ +#ifndef NOFLOAT # define EPSD 1e-6 # define EPSF 1e-6 +#endif /* global counters */ @@ -58,7 +62,9 @@ char *alloc(size) { return(retval) ; } +#ifndef NOFLOAT double fabs(a) double a ; { return( a<0 ? -a : a) ; } +#endif @@ -68,23 +74,29 @@ int i,j,k,l,m; long li,lj,lk,ll,lm; +#ifndef NOFLOAT float xf, yf, zf; double xd, yd, zd; +#endif struct tp2 { char c1; int i,j; +#ifndef NOFLOAT float aaa; double bbb; +#endif } r1, r2; int p, *p1, *p11, **p2, ***p3, ****p4, *****p5; struct tp2 *pp1, *pp2, *pp3; int a1[20]; +#ifndef NOFLOAT float a2[20]; double a3[20]; +#endif main() { @@ -100,7 +112,9 @@ main() test8(); test9(); test10(); +#ifndef NOFLOAT test11(); +#endif printf("End of test program, %d tests completed, %d errors detected\n", tct,ect); return 0 ; @@ -659,15 +673,518 @@ test5() /* testing local long variables */ +test6() /* global records */ +{ +#ifndef NOFLOAT + double epsd; + float epsf; + double fabs(); +#endif -test6() /* real arithmetic */ + t = 6; + tct++; +#ifndef NOFLOAT + epsd = EPSD; + epsf = EPSF; +#endif + r1.c1 = 'x'; + r1.i = 40; + r1.j = 50; +#ifndef NOFLOAT + r1.aaa = 3.0; + r1.bbb = 4.0; +#endif + r2.c1 = r1.c1; + r2.i = 50; + r2.j = 40; +#ifndef NOFLOAT + r2.aaa = 4.0; + r2.bbb = 5.0; +#endif + if ( r1.c1 != 'x' || r1.i != 40 ) e(1); +#ifndef NOFLOAT + if ( r1.aaa != 3.0 ) e(1); +#endif + if ( r1.i != 40 || r2.i != 50 ) e(2); + if ( r2.j != 40 || r1.j != 50 ) e(3); + if ( (r1.c1 + r2.c1)/2 != 'x' ) e(4); +#ifndef NOFLOAT + if ( r1.aaa * r1.aaa + r2.aaa * r2.aaa != r2.bbb * r2.bbb ) e(5); + r1.i = r1.j = r2.i = r2.j = 3.0; +#else + r1.i = r1.j = r2.i = r2.j = 3; +#endif + if ( r1.i != 3 ) e(6); + if ( r1.i * r2.j - 9 ) e(7); + r1.i++; + if ( r1.i != 4 ) e(8); + if ( --r1.i != 3 ) e(9); + if ( (++r2.i) * (--r2.j) != 8 ) e(10); + if ( (r2.i = r2.j = r1.j = r1.i = -5 ) != -5 ) e(11); + if ( r2.i * r1.j / 25 != 1 ) e(12); + r1.c1 = '\0'; + if ( r1.i * r1.j * r2.i * r1.c1 * r2.j ) e(13); + r2.c1 = 'j'; + if ( r1.c1 + r2.c1 != 'j' ) e(14); + if ( r1.c1 * r2.c1 ) e(15); + r2.j = r1.i = r2.i = r1.j = 1; + if ( (r1.i<<0) != r1.j ) e(16); + if ( (r1.i >> -0 ) != ( r1.j >> 0 ) ) e(17); + if ( (r1.i<<1) != 2 ) e(18); + if ( (r1.i<<2) != 4 ) e(19); + if ( (r1.j<<3) != (r2.j<<3) ) e(20); + if ( (r1.i | r1.i | r1.i | r1.i | r1.i) != r1.i ) e(21); + if ( (r2.j & r1.j & r2.j & r2.i) != (r1.i<<3>>3) ) e(22); + r1.j = 1; +#ifndef NOFLOAT + r1.aaa = 2.0; + if ( fabs ( r1.j * r1.aaa - 2.0 ) > epsd ) e(23); + if ( (r1.j << 4) * r1.aaa != (r1.j << 4) * r1.aaa ) e(24); + if ( ((r1.j<<6)&r1.j) * r1.aaa ) e(25); + if ((r1.j | (r1.j << 1)) * r1.aaa != ((r1.j << 1) ^ r1.j) * r1.aaa) e(26); +#endif + r1.i = r1.j = r2.i = r2.j = -2; + if ( r1.i > 0 || r1.j >= 0 ) e(27); + if ( r1.i != r2.j ) e(28); + if ( !!! ((((( r1.i == r2.j ))))) ) e(28); + if ( -(-(r1.j)) != r2.j ) e(29); + if ( r1.i % r1.j ) e(30); + if ( (r1.i % r1.j) % r1.i ) e(31); + if ( 0 % r2.j ) e(32); + if ( 03 * r1.i != -6 ) e(33); +#ifndef NOFLOAT + r1.aaa = r2.aaa = -4; + r1.bbb = r2.bbb = 4; + if ( r1.aaa > -3.5 ) e(34); + if ( fabs ( r1.aaa - r2.aaa ) > epsf ) e(35); +#endif + r1.c1 = '\03'; +#ifndef NOFLOAT + if ( fabs ( r2.aaa * r1.aaa - r1.c1 * 5 - 1.0 ) > epsf ) e(36); +#else + if ( 5*r1.c1 != 15 ) e(36) ; +#endif +} + + + + +test7() /* local records */ +{ +#ifndef NOFLOAT + double epsd; + float epsf; + double fabs(); +#endif + struct tp2 s1, s2; + + t = 7; + tct++; +#ifndef NOFLOAT + epsd = EPSD; + epsf = EPSF; +#endif + s1.c1 = 'x'; + s1.i = 40; + s1.j = 50; +#ifndef NOFLOAT + s1.aaa = 3.0; + s1.bbb = 4.0; +#endif + s2.c1 = s1.c1; + s2.i = 50; + s2.j = 40; +#ifndef NOFLOAT + s2.aaa = 4.0; + s2.bbb = 5.0; +#endif + if ( s1.c1 != 'x' || s1.i != 40 ) e(1); +#ifndef NOFLOAT + if ( s1.aaa != 3.0 ) e(1); +#endif + if ( s1.i != 40 || s2.i != 50 ) e(2); + if ( s2.j != 40 || s1.j != 50 ) e(3); + if ( (s1.c1 + s2.c1)/2 != 'x' ) e(4); +#ifndef NOFLOAT + if ( s1.aaa * s1.aaa + s2.aaa * s2.aaa != s2.bbb * s2.bbb ) e(5); + s1.i = s1.j = s2.i = s2.j = 3.0; +#else + s1.i = s1.j = s2.i = s2.j = 3; +#endif + if ( s1.i != 3 ) e(6); + if ( s1.i * s2.j - 9 ) e(7); + s1.i++; + if ( s1.i != 4 ) e(8); + if ( --s1.i != 3 ) e(9); + if ( (++s2.i) * (--s2.j) != 8 ) e(10); + if ( (s2.i = s2.j = s1.j = s1.i = -5 ) != -5 ) e(11); + if ( s2.i * s1.j / 25 != 1 ) e(12); + s1.c1 = '\0'; + if ( s1.i * s1.j * s2.i * s1.c1 * s2.j ) e(13); + s2.c1 = 'j'; + if ( s1.c1 + s2.c1 != 'j' ) e(14); + if ( s1.c1 * s2.c1 ) e(15); + s2.j = s1.i = s2.i = s1.j = 1; + if ( (s1.i<<0) != s1.j ) e(16); + if ( (s1.i >> -0 ) != ( s1.j >> 0 ) ) e(17); + if ( (s1.i<<1) != 2 ) e(18); + if ( (s1.i<<2) != 4 ) e(19); + if ( (s1.j<<3) != (s2.j<<3) ) e(20); + if ( (s1.i | s1.i | s1.i | s1.i | s1.i) != s1.i ) e(21); + if ( (s2.j & s1.j & s2.j & s2.i) != (s1.i<<3>>3) ) e(22); + s1.j = 1; +#ifndef NOFLOAT + s1.aaa = 2.0; + if ( fabs ( s1.j * s1.aaa - 2.0 ) > epsd ) e(23); + if ( (s1.j << 4) * s1.aaa != (s1.j << 4) * s1.aaa ) e(24); + if ( ((s1.j<<6)&s1.j) * s1.aaa ) e(25); + if ((s1.j | (s1.j << 1)) * s1.aaa != ((s1.j << 1) ^ s1.j) * s1.aaa) e(26); +#endif + s1.i = s1.j = s2.i = s2.j = -2; + if ( s1.i > 0 || s1.j >= 0 ) e(27); + if ( s1.i != s2.j ) e(28); + if ( !!! ((((( s1.i == s2.j ))))) ) e(28); + if ( -(-(s1.j)) != s2.j ) e(29); + if ( s1.i % s1.j ) e(30); + if ( (s1.i % s1.j) % s1.i ) e(31); + if ( 0 % s2.j ) e(32); + if ( 03 * s1.i != -6 ) e(33); +#ifndef NOFLOAT + s1.aaa = s2.aaa = -4; + s1.bbb = s2.bbb = 4; + if ( s1.aaa > -3.5 ) e(34); + if ( fabs ( s1.aaa - s2.aaa ) > epsf ) e(35); +#endif + s1.c1 = '\03'; +#ifndef NOFLOAT + if ( fabs ( s2.aaa * s1.aaa - s1.c1 * 5 - 1.0 ) > epsf ) e(36); +#else + if ( 5*r1.c1 != 15 ) e(36) ; +#endif +} + + + + +test8() /* global arrays */ +{ +#ifndef NOFLOAT + float epsf; + double epsd; + double fabs(); +#endif + + t = 8; + tct++; +#ifndef NOFLOAT + epsf = EPSF; + epsd = EPSD; +#endif + for ( i=0; i<20 ; i++ ) + a1[i] = i*i; + if ( a1[9] != 81 || a1[17] != 289 || a1[0] != 0 ) e(1); + if ( a1[1] + a1[2] + a1[3] != 14 ) e(2); + if ( ! a1[15] ) e(3); + if ( a1[8] / a1[4] != 4 ) e(4); +#ifndef NOFLOAT + for ( i=0; i<20; i++ ) + a2[i] = 10.0e-1 + i/54.324e-1; + if ( fabs(a2[4]*a2[4]-a2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5); + if ( fabs(a2[8]/a2[8]*a2[9]/a2[9]-a2[10]+a2[10]-1.0 ) > epsf ) e(6); + if ( fabs(a2[5]-a2[4]-1/54.324e-1 ) > epsf ) e(7); + for ( i=0; i<20; i++) + a3[i]= 10.0e-1 + i/54.324e-1; + if ( fabs(a3[4]*a3[4]-a3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8); + if ( fabs( a3[8]*a3[9]/a3[8]/a3[9]-a3[10]+a3[10]-1000e-3) > epsd ) e(9); + if ( fabs(a3[8]+a3[6]-2*a3[7]) > epsd ) e(10); +#endif + for ( i=0; i<20; i++ ) + a1[i] = i+1; + if ( a1[a1[a1[a1[a1[a1[0]]]]]] != 6 ) e(11); + if ( a1[a1[0]+a1[1]+a1[2]+a1[3]] != 11 ) e(12); + if ( (a1[0] << 2) != 4 ) e(13); + if ( (a1[0] >> 2) ) e(14); + if ( (a1[0] << 3 >> 3) != a1[0] ) e(15); + if ( a1[a1[0] << 1] != 3 ) e(16); + if ( a1[4<<1] != 9 ) e(17); + if ( a1[4 << 1] != 9 ) e(18); + if ( (1 << a1[0]) != 2 ) e(19); + if ( (1 & a1[0]) != 1 ) e(20); + if ( a1[4]++ != 5 ) e(21); + if ( a1[4] != 6 ) e(22); + if ( --a1[4] != 5 ) e(23); + if ( a1[ --a1[10] ] != 10 ) e(24); + a1[0] = 0; + a1[1] = 1; + a1[2] = 2; + a1[3] = 3; + i = 3; + if ( a1[--i] != 2 ) e(25); + if ( a1[ a1[--i] ] != 1 ) e(26); + if ( a1[a1[a1[a1[a1[a1[a1[a1[3]]]]]]]] != 3 ) e(27); + if ( a1[1+2] != 3 ) e(28); + if ( a1[1+2] != a1[3/3] + 2 ) e(29); + if ( a1[i=2] != 2 ) e(30); + if ( -a1[i==3] ) e(31); + if ( a1[3*2 + a1[0]*6 - 10/2 -4 + 3/1] != 0 ) e(32); + if ( a1['a' + 'c' -2*'b'] ) e(33); + if ( a1[ a1[0]==a1[1] ] ) e(34); + if ( a1[a1[1<<1]>>1] != 1 ) e(35); + a1[i=j=4] = 10; + if ( (i!=4) || (j!=4) || (i!=j) ) e(36); + if ( a1[4] != 10 ) e(37); + if ( a1[--i] != 3 ) e(38); + if ( a1[i++] != 3 ) e(39); + if ( --a1[--i] != 2 ) e(40); + a1[a1[a1[a1[a1[0]=7]=5]=8]=2]=0; + if ( a1[0] != 7) e(41); + if ((a1[7] != 5) || (a1[5]!=8) || (a1[8]!=2))e(42); + if (a1[2]) e(43); + for ( i=0 ; i<20; i++) + a1[i] = i; + a1[0] = 0; + a1[1] = 01; + a1[2] = 02; + a1[3] = 04; + a1[4] = 010; + if ((a1[0] | a1[1] | a1[2] | a1[3] | a1[4]) != 017 ) e(44); + if ( a1[0]<<4 ) e(45); + if ( (a1[4]>>3) != 1 ) e(46); + a1[4] = 04; + a1[010] = 010; + if ( a1[8] != 8 ) e(47); + if ( a1[0|1|2|4|8] != (a1[0]|a1[1]|a1[2]|a1[4]|a1[8]) ) e(48); + if ( a1[a1[0]|a1[1]|a1[2]|a1[4]|a1[8]] != a1[017] ) e(49); + if ( a1[a1[1]^a1[2]^a1[4]^a1[8]] != a1[a1[1]|a1[2]|a1[4]|a1[8]] ) e(50); + for ( i = 0; i<20; i++ ) + a1[i] = i+1; +#ifndef NOFLOAT + for ( i = 0; i<20; i++ ) + a2[i] = a3[i] = a1[i]; + if ( a2[5] != 6.0 ) e(51); + if ( a2[13] != 14.0 ) e(52); + if ( a2[a1[a1[a1[a1[a1[0]]]]]] != 6.0 ) e(53); +#endif + if ( a1[12] != 13 ) e(54); +#ifndef NOFLOAT + if ( a1[ a1[12] = a2[a1[11]] ] != 14 ) e(55); + if ( fabs( a2[13] - a2[a1[12]] ) > epsf ) e(56); + if ( a2[8] != a1[8] ) e(57); +#endif +} + + + + +test9() /* local arrays */ +{ +#ifndef NOFLOAT + float epsf; + double epsd; + double fabs(); +#endif + int b1[20]; +#ifndef NOFLOAT + float b2[20]; + double b3[20]; +#endif + + t = 9; + tct++; +#ifndef NOFLOAT + epsf = EPSF; + epsd = EPSD; +#endif + for ( i=0; i<20 ; i++ ) + b1[i] = i*i; + if ( b1[9] != 81 || b1[17] != 289 || b1[0] != 0 ) e(1); + if ( b1[1] + b1[2] + b1[3] != 14 ) e(2); + if ( ! b1[15] ) e(3); + if ( b1[8] / b1[4] != 4 ) e(4); +#ifndef NOFLOAT + for ( i=0; i<20; i++ ) + b2[i] = 10.0e-1 + i/54.324e-1; + if ( fabs(b2[4]*b2[4]-b2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5); + if ( fabs(b2[8]/b2[8]*b2[9]/b2[9]-b2[10]+b2[10]-1.0 ) > epsf ) e(6); + if ( fabs(b2[5]-b2[4]-1/54.324e-1 ) > epsf ) e(7); + for ( i=0; i<20; i++) + b3[i]= 10.0e-1 + i/54.324e-1; + if ( fabs(b3[4]*b3[4]-b3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8); + if ( fabs( b3[8]*b3[9]/b3[8]/b3[9]-b3[10]+b3[10]-1000e-3) > epsd ) e(9); + if ( fabs(b3[8]+b3[6]-2*b3[7]) > epsd ) e(10); +#endif + for ( i=0; i<20; i++ ) + b1[i] = i+1; + if ( b1[b1[b1[b1[b1[b1[0]]]]]] != 6 ) e(11); + if ( b1[b1[0]+b1[1]+b1[2]+b1[3]] != 11 ) e(12); + if ( (b1[0] << 2) != 4 ) e(13); + if ( (b1[0] >> 2) ) e(14); + if ( (b1[0] << 3 >> 3) != b1[0] ) e(15); + if ( b1[b1[0] << 1] != 3 ) e(16); + if ( b1[4<<1] != 9 ) e(17); + if ( b1[4 << 1] != 9 ) e(18); + if ( (1 << b1[0]) != 2 ) e(19); + if ( (1 & b1[0]) != 1 ) e(20); + if ( b1[4]++ != 5 ) e(21); + if ( b1[4] != 6 ) e(22); + if ( --b1[4] != 5 ) e(23); + if ( b1[ --b1[10] ] != 10 ) e(24); + b1[0] = 0; + b1[1] = 1; + b1[2] = 2; + b1[3] = 3; + i = 3; + if ( b1[--i] != 2 ) e(25); + if ( b1[ b1[--i] ] != 1 ) e(26); + if ( b1[b1[b1[b1[b1[b1[b1[b1[3]]]]]]]] != 3 ) e(27); + if ( b1[1+2] != 3 ) e(28); + if ( b1[1+2] != b1[3/3] + 2 ) e(29); + if ( b1[i=2] != 2 ) e(30); + if ( -b1[i==3] ) e(31); + if ( b1[3*2 + b1[0]*6 - 10/2 -4 + 3/1] != 0 ) e(32); + if ( b1['a' + 'c' -2*'b'] ) e(33); + if ( b1[ b1[0]==b1[1] ] ) e(34); + if ( b1[b1[1<<1]>>1] != 1 ) e(35); + b1[i=j=4] = 10; + if ( (i!=4) || (j!=4) || (i!=j) ) e(36); + if ( b1[4] != 10 ) e(37); + if ( b1[--i] != 3 ) e(38); + if ( b1[i++] != 3 ) e(39); + if ( --b1[--i] != 2 ) e(40); + b1[b1[b1[b1[b1[0]=7]=5]=8]=2]=0; + if ( b1[0] != 7) e(41); + if ((b1[7] != 5) || (b1[5]!=8) || (b1[8]!=2))e(42); + if (b1[2]) e(43); + for ( i=0 ; i<20; i++) + b1[i] = i; + b1[0] = 0; + b1[1] = 01; + b1[2] = 02; + b1[3] = 04; + b1[4] = 010; + if ((b1[0] | b1[1] | b1[2] | b1[3] | b1[4]) != 017 ) e(44); + if ( b1[0]<<4 ) e(45); + if ( (b1[4]>>3) != 1 ) e(46); + b1[4] = 04; + b1[010] = 010; + if ( b1[8] != 8 ) e(47); + if ( b1[0|1|2|4|8] != (b1[0]|b1[1]|b1[2]|b1[4]|b1[8]) ) e(48); + if ( b1[b1[0]|b1[1]|b1[2]|b1[4]|b1[8]] != b1[017] ) e(49); + if ( b1[b1[1]^b1[2]^b1[4]^b1[8]] != b1[b1[1]|b1[2]|b1[4]|b1[8]] ) e(50); + for ( i = 0; i<20; i++ ) + b1[i] = i+1; +#ifndef NOFLOAT + for ( i = 0; i<20; i++ ) + b2[i] = b3[i] = b1[i]; + if ( b2[5] != 6.0 ) e(51); + if ( b2[13] != 14.0 ) e(52); + if ( b2[b1[b1[b1[b1[b1[0]]]]]] != 6.0 ) e(53); +#endif + if ( b1[12] != 13 ) e(54); +#ifndef NOFLOAT + if ( b1[ b1[12] = b2[b1[11]] ] != 14 ) e(55); + if ( fabs( b2[13] - b2[b1[12]] ) > epsf ) e(56); + if ( b2[8] != b1[8] ) e(57); +#endif +} + + + + +test10() /* global pointers */ +{ +#ifndef NOFLOAT + float epsf; + double fabs(); +#endif + int li; + struct tp2 strp2; + +#ifndef NOFLOAT + epsf = EPSF; +#endif + t = 10; + tct++; + p1 = &li; + li = 076; + if ( p1 != &li ) e(1); + p11 = &li; + if ( p1 != p11 ) e(3); + if ( *p1 != *p11 ) e(4); + if ( &li != p11 ) e(5); + if ( *&p1 != p1 ) e(6); + if ( &*p1 != p1 ) e(7); + if ( **&p1 != *&*p1 ) e(10); + if ( *&*&*&*&*&li != li ) e(11); + p1 = &p ; + p2 = &p1; + *p1 = **p2 = 34; + if ( p1 != *p2 ) e(25); + li = 4; + p1 = &li; + p2 = &p1; + p3 = &p2; + p4 = &p3; + p5 = &p4; + if ( *p1 != **p2 ) e(26); + if ( **p2 != **p2 ) e(27); + if ( ***p3 != **p2 ) e(28); + if ( *****p5 != 4 ) e(30); + li = 3; + if ( *p1 - *p1 ) e(44); + if ( p1 != &li ) e(46); + pp1 = (struct tp2 *) alloc( sizeof *pp1 ); + pp2 = (struct tp2 *) alloc( sizeof *pp2 ); + pp3 = (struct tp2 *) alloc( sizeof *pp3 ); + pp1->i = 1325; + if ( pp1->i != 1325 ) e(47); + pp1->i = pp2->i = pp3->i = 3; + if ( pp1->i * pp1->i != 9 ) e(48); + if ( pp1->i * pp2->i * pp3->i != pp2->i * 3 * 3 ) e(49); + if ( pp1->i - pp3->i ) e(50); + if ( (*pp1).i != pp1->i ) e(51); + pp1->i++; + if ( ++pp2->i != pp1->i ) e(52); + if ( pp2->i != 4 ) e(53); +#ifndef NOFLOAT + pp1->aaa = 3.0; + pp2->aaa = -3.0; + pp3->bbb = 25.0; + if ( pp1->aaa != 3.0 ) e(54); + if ( fabs( pp1->aaa + pp2->aaa ) > epsf ) e(55); + if ( fabs( pp1->aaa * pp2->aaa + pp3->bbb - 16 ) > epsf ) e(56); + if ( fabs( pp1->aaa / pp2->aaa + 1 ) > epsf ) e(57); +#endif + pp1->c1 = 'x'; + pp1->i = pp1->j = 45; +#ifndef NOFLOAT + pp1->aaa = 100.0; + pp1->bbb = 1024.0; +#endif + strp2.c1 = pp1->c1; /* strp2 is a local struct */ + strp2.i = pp1->i = strp2.j = pp1->j; +#ifndef NOFLOAT + strp2.aaa = pp1->aaa; + strp2.bbb = pp1->bbb; +#endif + if ( strp2.c1 != 'x' ) e(58); + if ( strp2.i != strp2.j ) e(59); +#ifndef NOFLOAT + if ( strp2.aaa != pp1->aaa ) e(60); + if ( strp2.bbb != pp1->bbb ) e(61); +#endif +} + +#ifndef NOFLOAT + +test11() /* real arithmetic */ { double fabs(); double epsd; float epsf; float locxf; - t = 6; + t = 11 ; tct++; epsf = EPSF; epsd = EPSD; @@ -734,427 +1251,6 @@ test6() /* real arithmetic */ if ( locxf == 2 ) e(50); } +#endif - -test7() /* global records */ -{ - double epsd; - float epsf; - double fabs(); - - t = 7; - tct++; - epsd = EPSD; - epsf = EPSF; - r1.c1 = 'x'; - r1.i = 40; - r1.j = 50; - r1.aaa = 3.0; - r1.bbb = 4.0; - r2.c1 = r1.c1; - r2.i = 50; - r2.j = 40; - r2.aaa = 4.0; - r2.bbb = 5.0; - if ( r1.c1 != 'x' || r1.i != 40 || r1.aaa != 3.0 ) e(1); - if ( r1.i != 40 || r2.i != 50 ) e(2); - if ( r2.j != 40 || r1.j != 50 ) e(3); - if ( (r1.c1 + r2.c1)/2 != 'x' ) e(4); - if ( r1.aaa * r1.aaa + r2.aaa * r2.aaa != r2.bbb * r2.bbb ) e(5); - r1.i = r1.j = r2.i = r2.j = 3.0; - if ( r1.i != 3 ) e(6); - if ( r1.i * r2.j - 9 ) e(7); - r1.i++; - if ( r1.i != 4 ) e(8); - if ( --r1.i != 3 ) e(9); - if ( (++r2.i) * (--r2.j) != 8 ) e(10); - if ( (r2.i = r2.j = r1.j = r1.i = -5 ) != -5 ) e(11); - if ( r2.i * r1.j / 25 != 1 ) e(12); - r1.c1 = '\0'; - if ( r1.i * r1.j * r2.i * r1.c1 * r2.j ) e(13); - r2.c1 = 'j'; - if ( r1.c1 + r2.c1 != 'j' ) e(14); - if ( r1.c1 * r2.c1 ) e(15); - r2.j = r1.i = r2.i = r1.j = 1; - if ( (r1.i<<0) != r1.j ) e(16); - if ( (r1.i >> -0 ) != ( r1.j >> 0 ) ) e(17); - if ( (r1.i<<1) != 2 ) e(18); - if ( (r1.i<<2) != 4 ) e(19); - if ( (r1.j<<3) != (r2.j<<3) ) e(20); - if ( (r1.i | r1.i | r1.i | r1.i | r1.i) != r1.i ) e(21); - if ( (r2.j & r1.j & r2.j & r2.i) != (r1.i<<3>>3) ) e(22); - r1.j = 1; - r1.aaa = 2.0; - if ( fabs ( r1.j * r1.aaa - 2.0 ) > epsd ) e(23); - if ( (r1.j << 4) * r1.aaa != (r1.j << 4) * r1.aaa ) e(24); - if ( ((r1.j<<6)&r1.j) * r1.aaa ) e(25); - if ((r1.j | (r1.j << 1)) * r1.aaa != ((r1.j << 1) ^ r1.j) * r1.aaa) e(26); - r1.i = r1.j = r2.i = r2.j = -2; - if ( r1.i > 0 || r1.j >= 0 ) e(27); - if ( r1.i != r2.j ) e(28); - if ( !!! ((((( r1.i == r2.j ))))) ) e(28); - if ( -(-(r1.j)) != r2.j ) e(29); - if ( r1.i % r1.j ) e(30); - if ( (r1.i % r1.j) % r1.i ) e(31); - if ( 0 % r2.j ) e(32); - if ( 03 * r1.i != -6 ) e(33); - r1.aaa = r2.aaa = -4; - r1.bbb = r2.bbb = 4; - if ( r1.aaa > -3.5 ) e(34); - if ( fabs ( r1.aaa - r2.aaa ) > epsf ) e(35); - r1.c1 = '\03'; - if ( fabs ( r2.aaa * r1.aaa - r1.c1 * 5 - 1.0 ) > epsf ) e(36); -} - - - - -test8() /* local records */ -{ - double epsd; - float epsf; - double fabs(); - struct tp2 s1, s2; - - t = 8; - tct++; - epsd = EPSD; - epsf = EPSF; - s1.c1 = 'x'; - s1.i = 40; - s1.j = 50; - s1.aaa = 3.0; - s1.bbb = 4.0; - s2.c1 = s1.c1; - s2.i = 50; - s2.j = 40; - s2.aaa = 4.0; - s2.bbb = 5.0; - if ( s1.c1 != 'x' || s1.i != 40 || s1.aaa != 3.0 ) e(1); - if ( s1.i != 40 || s2.i != 50 ) e(2); - if ( s2.j != 40 || s1.j != 50 ) e(3); - if ( (s1.c1 + s2.c1)/2 != 'x' ) e(4); - if ( s1.aaa * s1.aaa + s2.aaa * s2.aaa != s2.bbb * s2.bbb ) e(5); - s1.i = s1.j = s2.i = s2.j = 3.0; - if ( s1.i != 3 ) e(6); - if ( s1.i * s2.j - 9 ) e(7); - s1.i++; - if ( s1.i != 4 ) e(8); - if ( --s1.i != 3 ) e(9); - if ( (++s2.i) * (--s2.j) != 8 ) e(10); - if ( (s2.i = s2.j = s1.j = s1.i = -5 ) != -5 ) e(11); - if ( s2.i * s1.j / 25 != 1 ) e(12); - s1.c1 = '\0'; - if ( s1.i * s1.j * s2.i * s1.c1 * s2.j ) e(13); - s2.c1 = 'j'; - if ( s1.c1 + s2.c1 != 'j' ) e(14); - if ( s1.c1 * s2.c1 ) e(15); - s2.j = s1.i = s2.i = s1.j = 1; - if ( (s1.i<<0) != s1.j ) e(16); - if ( (s1.i >> -0 ) != ( s1.j >> 0 ) ) e(17); - if ( (s1.i<<1) != 2 ) e(18); - if ( (s1.i<<2) != 4 ) e(19); - if ( (s1.j<<3) != (s2.j<<3) ) e(20); - if ( (s1.i | s1.i | s1.i | s1.i | s1.i) != s1.i ) e(21); - if ( (s2.j & s1.j & s2.j & s2.i) != (s1.i<<3>>3) ) e(22); - s1.j = 1; - s1.aaa = 2.0; - if ( fabs ( s1.j * s1.aaa - 2.0 ) > epsd ) e(23); - if ( (s1.j << 4) * s1.aaa != (s1.j << 4) * s1.aaa ) e(24); - if ( ((s1.j<<6)&s1.j) * s1.aaa ) e(25); - if ((s1.j | (s1.j << 1)) * s1.aaa != ((s1.j << 1) ^ s1.j) * s1.aaa) e(26); - s1.i = s1.j = s2.i = s2.j = -2; - if ( s1.i > 0 || s1.j >= 0 ) e(27); - if ( s1.i != s2.j ) e(28); - if ( !!! ((((( s1.i == s2.j ))))) ) e(28); - if ( -(-(s1.j)) != s2.j ) e(29); - if ( s1.i % s1.j ) e(30); - if ( (s1.i % s1.j) % s1.i ) e(31); - if ( 0 % s2.j ) e(32); - if ( 03 * s1.i != -6 ) e(33); - s1.aaa = s2.aaa = -4; - s1.bbb = s2.bbb = 4; - if ( s1.aaa > -3.5 ) e(34); - if ( fabs ( s1.aaa - s2.aaa ) > epsf ) e(35); - s1.c1 = '\03'; - if ( fabs ( s2.aaa * s1.aaa - s1.c1 * 5 - 1.0 ) > epsf ) e(36); -} - - - - -test9() /* global arrays */ -{ - float epsf; - double epsd; - double fabs(); - - t = 9; - tct++; - epsf = EPSF; - epsd = EPSD; - for ( i=0; i<20 ; i++ ) - a1[i] = i*i; - if ( a1[9] != 81 || a1[17] != 289 || a1[0] != 0 ) e(1); - if ( a1[1] + a1[2] + a1[3] != 14 ) e(2); - if ( ! a1[15] ) e(3); - if ( a1[8] / a1[4] != 4 ) e(4); - for ( i=0; i<20; i++ ) - a2[i] = 10.0e-1 + i/54.324e-1; - if ( fabs(a2[4]*a2[4]-a2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5); - if ( fabs(a2[8]/a2[8]*a2[9]/a2[9]-a2[10]+a2[10]-1.0 ) > epsf ) e(6); - if ( fabs(a2[5]-a2[4]-1/54.324e-1 ) > epsf ) e(7); - for ( i=0; i<20; i++) - a3[i]= 10.0e-1 + i/54.324e-1; - if ( fabs(a3[4]*a3[4]-a3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8); - if ( fabs( a3[8]*a3[9]/a3[8]/a3[9]-a3[10]+a3[10]-1000e-3) > epsd ) e(9); - if ( fabs(a3[8]+a3[6]-2*a3[7]) > epsd ) e(10); - for ( i=0; i<20; i++ ) - a1[i] = i+1; - if ( a1[a1[a1[a1[a1[a1[0]]]]]] != 6 ) e(11); - if ( a1[a1[0]+a1[1]+a1[2]+a1[3]] != 11 ) e(12); - if ( (a1[0] << 2) != 4 ) e(13); - if ( (a1[0] >> 2) ) e(14); - if ( (a1[0] << 3 >> 3) != a1[0] ) e(15); - if ( a1[a1[0] << 1] != 3 ) e(16); - if ( a1[4<<1] != 9 ) e(17); - if ( a1[4 << 1] != 9 ) e(18); - if ( (1 << a1[0]) != 2 ) e(19); - if ( (1 & a1[0]) != 1 ) e(20); - if ( a1[4]++ != 5 ) e(21); - if ( a1[4] != 6 ) e(22); - if ( --a1[4] != 5 ) e(23); - if ( a1[ --a1[10] ] != 10 ) e(24); - a1[0] = 0; - a1[1] = 1; - a1[2] = 2; - a1[3] = 3; - i = 3; - if ( a1[--i] != 2 ) e(25); - if ( a1[ a1[--i] ] != 1 ) e(26); - if ( a1[a1[a1[a1[a1[a1[a1[a1[3]]]]]]]] != 3 ) e(27); - if ( a1[1+2] != 3 ) e(28); - if ( a1[1+2] != a1[3/3] + 2 ) e(29); - if ( a1[i=2] != 2 ) e(30); - if ( -a1[i==3] ) e(31); - if ( a1[3*2 + a1[0]*6 - 10/2 -4 + 3/1] != 0 ) e(32); - if ( a1['a' + 'c' -2*'b'] ) e(33); - if ( a1[ a1[0]==a1[1] ] ) e(34); - if ( a1[a1[1<<1]>>1] != 1 ) e(35); - a1[i=j=4] = 10; - if ( (i!=4) || (j!=4) || (i!=j) ) e(36); - if ( a1[4] != 10 ) e(37); - if ( a1[--i] != 3 ) e(38); - if ( a1[i++] != 3 ) e(39); - if ( --a1[--i] != 2 ) e(40); - a1[a1[a1[a1[a1[0]=7]=5]=8]=2]=0; - if ( a1[0] != 7) e(41); - if ((a1[7] != 5) || (a1[5]!=8) || (a1[8]!=2))e(42); - if (a1[2]) e(43); - for ( i=0 ; i<20; i++) - a1[i] = i; - a1[0] = 0; - a1[1] = 01; - a1[2] = 02; - a1[3] = 04; - a1[4] = 010; - if ((a1[0] | a1[1] | a1[2] | a1[3] | a1[4]) != 017 ) e(44); - if ( a1[0]<<4 ) e(45); - if ( (a1[4]>>3) != 1 ) e(46); - a1[4] = 04; - a1[010] = 010; - if ( a1[8] != 8 ) e(47); - if ( a1[0|1|2|4|8] != (a1[0]|a1[1]|a1[2]|a1[4]|a1[8]) ) e(48); - if ( a1[a1[0]|a1[1]|a1[2]|a1[4]|a1[8]] != a1[017] ) e(49); - if ( a1[a1[1]^a1[2]^a1[4]^a1[8]] != a1[a1[1]|a1[2]|a1[4]|a1[8]] ) e(50); - for ( i = 0; i<20; i++ ) - a1[i] = i+1; - for ( i = 0; i<20; i++ ) - a2[i] = a3[i] = a1[i]; - if ( a2[5] != 6.0 ) e(51); - if ( a2[13] != 14.0 ) e(52); - if ( a2[a1[a1[a1[a1[a1[0]]]]]] != 6.0 ) e(53); - if ( a1[12] != 13 ) e(54); - if ( a1[ a1[12] = a2[a1[11]] ] != 14 ) e(55); - if ( fabs( a2[13] - a2[a1[12]] ) > epsf ) e(56); - if ( a2[8] != a1[8] ) e(57); -} - - - - -test10() /* local arrays */ -{ - float epsf; - double epsd; - double fabs(); - int b1[20]; - float b2[20]; - double b3[20]; - - t = 10; - tct++; - epsf = EPSF; - epsd = EPSD; - for ( i=0; i<20 ; i++ ) - b1[i] = i*i; - if ( b1[9] != 81 || b1[17] != 289 || b1[0] != 0 ) e(1); - if ( b1[1] + b1[2] + b1[3] != 14 ) e(2); - if ( ! b1[15] ) e(3); - if ( b1[8] / b1[4] != 4 ) e(4); - for ( i=0; i<20; i++ ) - b2[i] = 10.0e-1 + i/54.324e-1; - if ( fabs(b2[4]*b2[4]-b2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5); - if ( fabs(b2[8]/b2[8]*b2[9]/b2[9]-b2[10]+b2[10]-1.0 ) > epsf ) e(6); - if ( fabs(b2[5]-b2[4]-1/54.324e-1 ) > epsf ) e(7); - for ( i=0; i<20; i++) - b3[i]= 10.0e-1 + i/54.324e-1; - if ( fabs(b3[4]*b3[4]-b3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8); - if ( fabs( b3[8]*b3[9]/b3[8]/b3[9]-b3[10]+b3[10]-1000e-3) > epsd ) e(9); - if ( fabs(b3[8]+b3[6]-2*b3[7]) > epsd ) e(10); - for ( i=0; i<20; i++ ) - b1[i] = i+1; - if ( b1[b1[b1[b1[b1[b1[0]]]]]] != 6 ) e(11); - if ( b1[b1[0]+b1[1]+b1[2]+b1[3]] != 11 ) e(12); - if ( (b1[0] << 2) != 4 ) e(13); - if ( (b1[0] >> 2) ) e(14); - if ( (b1[0] << 3 >> 3) != b1[0] ) e(15); - if ( b1[b1[0] << 1] != 3 ) e(16); - if ( b1[4<<1] != 9 ) e(17); - if ( b1[4 << 1] != 9 ) e(18); - if ( (1 << b1[0]) != 2 ) e(19); - if ( (1 & b1[0]) != 1 ) e(20); - if ( b1[4]++ != 5 ) e(21); - if ( b1[4] != 6 ) e(22); - if ( --b1[4] != 5 ) e(23); - if ( b1[ --b1[10] ] != 10 ) e(24); - b1[0] = 0; - b1[1] = 1; - b1[2] = 2; - b1[3] = 3; - i = 3; - if ( b1[--i] != 2 ) e(25); - if ( b1[ b1[--i] ] != 1 ) e(26); - if ( b1[b1[b1[b1[b1[b1[b1[b1[3]]]]]]]] != 3 ) e(27); - if ( b1[1+2] != 3 ) e(28); - if ( b1[1+2] != b1[3/3] + 2 ) e(29); - if ( b1[i=2] != 2 ) e(30); - if ( -b1[i==3] ) e(31); - if ( b1[3*2 + b1[0]*6 - 10/2 -4 + 3/1] != 0 ) e(32); - if ( b1['a' + 'c' -2*'b'] ) e(33); - if ( b1[ b1[0]==b1[1] ] ) e(34); - if ( b1[b1[1<<1]>>1] != 1 ) e(35); - b1[i=j=4] = 10; - if ( (i!=4) || (j!=4) || (i!=j) ) e(36); - if ( b1[4] != 10 ) e(37); - if ( b1[--i] != 3 ) e(38); - if ( b1[i++] != 3 ) e(39); - if ( --b1[--i] != 2 ) e(40); - b1[b1[b1[b1[b1[0]=7]=5]=8]=2]=0; - if ( b1[0] != 7) e(41); - if ((b1[7] != 5) || (b1[5]!=8) || (b1[8]!=2))e(42); - if (b1[2]) e(43); - for ( i=0 ; i<20; i++) - b1[i] = i; - b1[0] = 0; - b1[1] = 01; - b1[2] = 02; - b1[3] = 04; - b1[4] = 010; - if ((b1[0] | b1[1] | b1[2] | b1[3] | b1[4]) != 017 ) e(44); - if ( b1[0]<<4 ) e(45); - if ( (b1[4]>>3) != 1 ) e(46); - b1[4] = 04; - b1[010] = 010; - if ( b1[8] != 8 ) e(47); - if ( b1[0|1|2|4|8] != (b1[0]|b1[1]|b1[2]|b1[4]|b1[8]) ) e(48); - if ( b1[b1[0]|b1[1]|b1[2]|b1[4]|b1[8]] != b1[017] ) e(49); - if ( b1[b1[1]^b1[2]^b1[4]^b1[8]] != b1[b1[1]|b1[2]|b1[4]|b1[8]] ) e(50); - for ( i = 0; i<20; i++ ) - b1[i] = i+1; - for ( i = 0; i<20; i++ ) - b2[i] = b3[i] = b1[i]; - if ( b2[5] != 6.0 ) e(51); - if ( b2[13] != 14.0 ) e(52); - if ( b2[b1[b1[b1[b1[b1[0]]]]]] != 6.0 ) e(53); - if ( b1[12] != 13 ) e(54); - if ( b1[ b1[12] = b2[b1[11]] ] != 14 ) e(55); - if ( fabs( b2[13] - b2[b1[12]] ) > epsf ) e(56); - if ( b2[8] != b1[8] ) e(57); -} - - - - -test11() /* global pointers */ -{ - float epsf; - double fabs(); - int li; - struct tp2 strp2; - - epsf = EPSF; - t = 11; - tct++; - p1 = &li; - li = 076; - if ( p1 != &li ) e(1); - p11 = &li; - if ( p1 != p11 ) e(3); - if ( *p1 != *p11 ) e(4); - if ( &li != p11 ) e(5); - if ( *&p1 != p1 ) e(6); - if ( &*p1 != p1 ) e(7); - if ( **&p1 != *&*p1 ) e(10); - if ( *&*&*&*&*&li != li ) e(11); - p1 = &p ; - p2 = &p1; - *p1 = **p2 = 34; - if ( p1 != *p2 ) e(25); - li = 4; - p1 = &li; - p2 = &p1; - p3 = &p2; - p4 = &p3; - p5 = &p4; - if ( *p1 != **p2 ) e(26); - if ( **p2 != **p2 ) e(27); - if ( ***p3 != **p2 ) e(28); - if ( *****p5 != 4 ) e(30); - li = 3; - if ( *p1 - *p1 ) e(44); - if ( p1 != &li ) e(46); - pp1 = (struct tp2 *) alloc( sizeof *pp1 ); - pp2 = (struct tp2 *) alloc( sizeof *pp2 ); - pp3 = (struct tp2 *) alloc( sizeof *pp3 ); - pp1->i = 1325; - if ( pp1->i != 1325 ) e(47); - pp1->i = pp2->i = pp3->i = 3; - if ( pp1->i * pp1->i != 9 ) e(48); - if ( pp1->i * pp2->i * pp3->i != pp2->i * 3 * 3 ) e(49); - if ( pp1->i - pp3->i ) e(50); - if ( (*pp1).i != pp1->i ) e(51); - pp1->i++; - if ( ++pp2->i != pp1->i ) e(52); - if ( pp2->i != 4 ) e(53); - pp1->aaa = 3.0; - pp2->aaa = -3.0; - pp3->bbb = 25.0; - if ( pp1->aaa != 3.0 ) e(54); - if ( fabs( pp1->aaa + pp2->aaa ) > epsf ) e(55); - if ( fabs( pp1->aaa * pp2->aaa + pp3->bbb - 16 ) > epsf ) e(56); - if ( fabs( pp1->aaa / pp2->aaa + 1 ) > epsf ) e(57); - pp1->c1 = 'x'; - pp1->i = pp1->j = 45; - pp1->aaa = 100.0; - pp1->bbb = 1024.0; - strp2.c1 = pp1->c1; /* strp2 is a local struct */ - strp2.i = pp1->i = strp2.j = pp1->j; - strp2.aaa = pp1->aaa; - strp2.bbb = pp1->bbb; - if ( strp2.c1 != 'x' ) e(58); - if ( strp2.i != strp2.j ) e(59); - if ( strp2.aaa != pp1->aaa ) e(60); - if ( strp2.bbb != pp1->bbb ) e(61); -} diff --git a/lang/cem/ctest/ctest2/t7.c b/lang/cem/ctest/ctest2/t7.c index f1a9dd13e..3eaa5bf28 100644 --- a/lang/cem/ctest/ctest2/t7.c +++ b/lang/cem/ctest/ctest2/t7.c @@ -16,6 +16,8 @@ * */ +char rcs_id[] = "$Header$" ; + /* #define TEST1 1 diff --git a/lang/cem/ctest/ctest3/test2.c b/lang/cem/ctest/ctest3/test2.c index 0ffb9a5ba..1a302d047 100644 --- a/lang/cem/ctest/ctest3/test2.c +++ b/lang/cem/ctest/ctest3/test2.c @@ -15,6 +15,8 @@ * */ +char rcs_id[] = "$Header$" ; + /* This program can be used to test C-compilers */ diff --git a/lang/cem/ctest/ctest5/test1.c b/lang/cem/ctest/ctest5/test1.c index 913f0f5ac..5add9a594 100644 --- a/lang/cem/ctest/ctest5/test1.c +++ b/lang/cem/ctest/ctest5/test1.c @@ -15,12 +15,16 @@ * */ +char rcs_id[] = "$Header$" ; + /* This program can be used to test C-compilers */ int i,j,k,l,m,ect,pct,t,*p1; int a1[20]; +#ifndef NOFLOAT float a2[20],xf,yf,zf; double a3[20],xd,yd,zd; +#endif char alstr[3000] ; char *alptr = alstr ; @@ -28,8 +32,10 @@ char *alptr = alstr ; struct tp2 { char c1; int i,j; +#ifndef NOFLOAT float aaa; double bbb; +#endif } r1,r2,*p3; struct node @@ -40,9 +46,12 @@ struct node main() { ect = 0; pct = 0; test1();test2();test3(); - test4();test5();test6(); - test7();test8();test9(); - test10();test11(); + test4();test5(); + test6();test7();test8(); + test9();test10(); +#ifndef NOFLOAT + test11(); +#endif printf("program test1\n"); printf("%d tests completed. Number of errors = %d\n",pct,ect); return 0 ; @@ -61,7 +70,9 @@ char *alloc(size) { } int abs(a) int a ; { return ( a<0 ? -a : a) ; } +#ifndef NOFLOAT double fabs(a) double a ; { return( a<0 ? -a : a) ; } +#endif e(n) { ect++; printf("error %d in test %d \n",n,t); @@ -98,7 +109,7 @@ test1() if ( -'z' / 01 != -'z' ) e(21); if ( 077777 >> 3 != 07777 ) e(22); if ( 077777 >> 15 ) e(23); - if ( 234 << 6 != 234 >> -6 ) e(24); + if ( 234 << 6 != 234 << 6 ) e(24); if ( 0124 & 07765 != 0124 ) e(25); if ( 34 & 31 != 2 ) e(26); if ( ( -4 | 3 ) != -1 ) e(27); @@ -168,8 +179,6 @@ test2() if ( (i > j ? k : k*j ) != 6 ) e(20); if ( (i < j ? k : k*j ) != 3 ) e(21); if ( j<> -i != l ) e(23); - if ( j<< -i != i ) e(24); if ( j>> i != i ) e(25); if ( i++ != 1 ) e(26); if ( --i != 1 ) e(27); @@ -207,8 +216,6 @@ test3() if ( (a > b ? c : c*b ) != 6 ) e(20); if ( (a < b ? c : c*b ) != 3 ) e(21); if ( b<> -a != d ) e(23); - if ( b<< -a != a ) e(24); if ( b>> a != a ) e(25); if ( a++ != 1 ) e(26); if ( --a != 1 ) e(27); @@ -221,14 +228,21 @@ test3() test4() /* global arrays */ -{ float epsf; +{ +#ifndef NOFLOAT + float epsf; double epsd; - t=4; pct++; epsf = 1e-7; epsd = 1e-17; +#endif + t=4; pct++; +#ifndef NOFLOAT + epsf = 1e-7; epsd = 1e-17; +#endif for ( i=0; i<20 ; i++ ) a1[i] = i*i; if ( a1[9] != 81 || a1[17] != 289 || a1[0] != 0 ) e(1); if ( a1[1] + a1[2] + a1[3] != 14 ) e(2); if ( ! a1[15] ) e(3); if ( a1[8] / a1[4] != 4 ) e(4); +#ifndef NOFLOAT for ( i=0; i<20; i++ ) a2[i] = 10.0e-1 + i/54.324e-1; if ( fabs(a2[4]*a2[4]-a2[4]*(10.0e-1 + 4/54.324e-1 ) ) > epsf ) e(5); if ( fabs(a2[8]/a2[8]*a2[9]/a2[9]-a2[10]+a2[10]-1.0 ) > epsf ) e(6); @@ -237,53 +251,25 @@ test4() if ( fabs(a3[4]*a3[4]-a3[4]*(1.0e0+4/54.324e-1 )) > epsd ) e(8); if ( fabs( a3[8]*a3[9]/a3[8]/a3[9]-a3[10]+a3[10]-1000e-3) > epsd ) e(9); if ( fabs(a3[8]+a3[6]-2*a3[7]) > epsd ) e(10); +#endif } -/***************************************************************/ - -test5() -/* real arithmetic */ -{ - double epsd; float epsf; - t = 5; pct++; epsf = 1e-7; epsd = 1e-17; - xf = 1.50 ; yf = 3.00 ; zf = 0.10; - xd = 1.50 ; yd = 3.00 ; zd = 0.10; - if ( fabs(1.0 + 1.0 - 2.0 ) > epsd ) e(1); - if ( fabs( 1e10-1e10 ) > epsd ) e(2); - if ( abs( 1.0e+5*1.0e+5-100e+8 ) > epsd ) e(3); - if ( fabs( 10.0/3.0*3.0/10.0-100e-2 ) > epsd ) e(4); - if ( 0.0e0 != 0 ) e(5); - if ( fabs( 32767.0 - 32767 ) > epsd ) e(6); - if ( fabs( 1.0+2+5+3.0e0+7.5e+1+140e-1-100.0 ) > epsd ) e(7); - if ( fabs(-1+(-1)+(-1.0)+(-1.0e0)+(-1.0e-0)+(-1e0)+6 ) > epsd ) e(8); - if ( fabs(5.0*yf*zf-xf) > epsf ) e(9); - if ( fabs(5.0*yd*zd-xd) > epsd ) e(10); - if ( fabs(yd*yd - (2.0*xd)*(2.0*xd) ) > epsd ) e(11); - if ( fabs(yf*yf - (2.0*xf)*(2.0*xf) ) > epsf ) e(12); - if ( fabs( yd*yd+zd*zd+2.0*yd*zd-(yd+zd)*(zd+yd) ) > epsd ) e(13); - if ( fabs( yf*yf+zf*zf+2.0*yf*zf-(yf+zf)*(zf+yf) ) > epsf ) e(14); - xf=1.10;yf=1.20; - if ( yd=yd ) e(18); - if ( yd epsd ) e(20); -} - - /****************************************************************/ -test6() +test5() /* local arrays */ -{ int b1[20]; float epsf, b2[20]; double b3[20],epsd; +{ int b1[20]; +#ifndef NOFLOAT + float epsf, b2[20]; double b3[20],epsd; epsf = 1e-7; epsd = 1e-17; - t = 6; pct++; +#endif + t = 5; pct++; for ( i=0; i<20 ; i++ ) b1[i] = i*i; if ( b1[9]-b1[8] != 17 ) e(1); if ( b1[3] + b1[4] != b1[5] ) e(2); if ( b1[1] != 1||b1[3] != 9 || b1[5] != 25 || b1[7] != 49 ) e(3); if ( b1[12] / b1[6] != 4 ) e(4); +#ifndef NOFLOAT for ( i=0; i<20; i += 1) b2[i] = 10.0e-1+i/54.324e-1; if (fabs(b2[4]*b2[4]-b2[4]*(10.0e-1+4/54.324e-1)) > epsf ) e(5); if (fabs(b2[8]/b2[8]*b2[9]/b2[9]-b2[10]+b2[10]-1.0) > epsf ) e(6); @@ -292,6 +278,7 @@ test6() if (fabs(b3[4]*b3[4]-b3[4]*(10.0e-1+4/54.324e-1)) > epsd ) e(8); if (fabs(b3[8]*b3[9]/b3[8]/b3[9]+b3[10]-b3[10]-1.0) > epsd ) e(9); if (fabs(b3[10]+b3[18]-2*b3[14]) > epsd ) e(10); +#endif } @@ -299,11 +286,16 @@ test6() -test7() +test6() /* mixed local and global */ { int li,b1[20]; +#ifndef NOFLOAT double b3[10],xxd,epsd; - t = 7; pct++;epsd = 1e-17; +#endif + t = 6; pct++; +#ifndef NOFLOAT + epsd = 1e-17; +#endif li = 6; i = li ; if ( i != 6 ) e(1); i = 6; li = i; @@ -316,27 +308,40 @@ test7() if ( b1[7]/a1[4] != a1[2] ) e(6); li = i = 121; if ( b1[10] != i && a1[11]!= li ) e(7); +#ifndef NOFLOAT for ( li=0 ; li<10; li++ ) b3[li]= 1.0e0 + li/54.324e-1; if ( fabs(b3[9]-a3[9]) > epsd ) e(8); if ( fabs(8/54.324e-1 - b3[9]+a3[1] ) > epsd ) e(9); +#endif } /***************************************************************/ -test8() +test7() /*global records */ -{ t=8; pct++; - r1.c1= 'x';r1.i=40;r1.j=50;r1.aaa=3.0;r1.bbb=4.0; +{ t=7; pct++; + r1.c1= 'x';r1.i=40;r1.j=50; +#ifndef NOFLOAT + r1.aaa=3.0;r1.bbb=4.0; +#endif r2.c1=r1.c1; r2.i= 50; - r2.j=40;r2.aaa=4.0;r2.bbb=5.0; - if (r1.c1 != 'x' || r1.i != 40 || r1.aaa != 3.0 ) e(1); + r2.j=40; +#ifndef NOFLOAT + r2.aaa=4.0;r2.bbb=5.0; +#endif + if (r1.c1 != 'x' || r1.i != 40 ) e(1); +#ifndef NOFLOAT + if ( r1.aaa != 3.0 ) e(1); +#endif i = 25;j=75; if (r1.i != 40 || r2.i != 50 ) e(2); if ( r2.j != 40 || r1.j != 50 ) e(3); if ( (r1.c1 + r2.c1)/2 != 'x' ) e(4); +#ifndef NOFLOAT if ( r1.aaa*r1.aaa+r2.aaa*r2.aaa != r2.bbb*r2.bbb) e(5); +#endif r1.i = 34; if ( i!=25 ) e(6); } @@ -344,29 +349,40 @@ test8() /****************************************************************/ -test9() +test8() /*local records */ { struct tp2 s1,s2; - t=9; pct++; - s1.c1= 'x';s1.i=40;s1.j=50;s1.aaa=3.0;s1.bbb=4.0; + t=8; pct++; + s1.c1= 'x';s1.i=40;s1.j=50; +#ifndef NOFLOAT + s1.aaa=3.0;s1.bbb=4.0; +#endif s2.c1=s1.c1; s2.i= 50; - s2.j=40;s2.aaa=4.0;s2.bbb=5.0; - if (s1.c1 != 'x' || s1.i != 40 || s1.aaa != 3.0 ) e(1); + s2.j=40; +#ifndef NOFLOAT + s2.aaa=4.0;s2.bbb=5.0; +#endif + if (s1.c1 != 'x' || s1.i != 40 ) e(1); +#ifndef NOFLOAT + if ( s1.aaa != 3.0 ) e(1); +#endif i = 25;j=75; if (s1.i != 40 || s2.i != 50 ) e(2); if ( s2.j != 40 || s1.j != 50 ) e(3); if ( (s1.c1 + s2.c1)/2 != 'x' ) e(4); +#ifndef NOFLOAT if ( s1.aaa*s1.aaa+s2.aaa*s2.aaa != s2.bbb*s2.bbb) e(5); +#endif s1.i = 34; if ( i!=25 ) e(6); } /***********************************************************************/ -test10() +test9() /*global pointers */ -{ t=10; pct++; +{ t=9; pct++; p1=alloc( sizeof *p1 ); p2=alloc( sizeof *p2); p3=alloc(sizeof *p3); @@ -397,13 +413,13 @@ test10() } /*****************************************************************/ -test11() +test10() /*local pointers */ { struct tp2 *pp3; struct node *pp2,*ingang,*uitgang; int *pp1; int b1[20]; - t=11; pct++; + t=10; pct++; pp1=alloc( sizeof *pp1 ); pp2=alloc( sizeof *p2); pp3=alloc(sizeof *pp3); @@ -428,4 +444,39 @@ test11() if ( uitgang->next->next->next->next->next->val != 1) e(8); } +/***************************************************************/ + +#ifndef NOFLOAT +test11() +/* real arithmetic */ +{ + double epsd; float epsf; + t = 11; pct++; epsf = 1e-7; epsd = 1e-16; + xf = 1.50 ; yf = 3.00 ; zf = 0.10; + xd = 1.50 ; yd = 3.00 ; zd = 0.10; + if ( fabs(1.0 + 1.0 - 2.0 ) > epsd ) e(1); + if ( fabs( 1e10-1e10 ) > epsd ) e(2); + if ( abs( 1.0e+5*1.0e+5-100e+8 ) > epsd ) e(3); + if ( fabs( 10.0/3.0*3.0/10.0-100e-2 ) > epsd ) e(4); + if ( 0.0e0 != 0 ) e(5); + if ( fabs( 32767.0 - 32767 ) > epsd ) e(6); + if ( fabs( 1.0+2+5+3.0e0+7.5e+1+140e-1-100.0 ) > epsd ) e(7); + if ( fabs(-1+(-1)+(-1.0)+(-1.0e0)+(-1.0e-0)+(-1e0)+6 ) > epsd ) e(8); + if ( fabs(5.0*yf*zf-xf) > epsf ) e(9); + if ( fabs(5.0*yd*zd-xd) > epsd ) e(10); + if ( fabs(yd*yd - (2.0*xd)*(2.0*xd) ) > epsd ) e(11); + if ( fabs(yf*yf - (2.0*xf)*(2.0*xf) ) > epsf ) e(12); + if ( fabs( yd*yd+zd*zd+2.0*yd*zd-(yd+zd)*(zd+yd) ) > epsd ) e(13); + if ( fabs( yf*yf+zf*zf+2.0*yf*zf-(yf+zf)*(zf+yf) ) > epsf ) e(14); + xf=1.10;yf=1.20; + if ( yd=yd ) e(18); + if ( yd epsd ) e(20); +} +#endif + + /*****************************************************************/ diff --git a/lang/cem/ctest/ctill/noarg.c b/lang/cem/ctest/ctill/noarg.c index 5beb6b5f9..7536b4fd5 100644 --- a/lang/cem/ctest/ctill/noarg.c +++ b/lang/cem/ctest/ctill/noarg.c @@ -1,3 +1,5 @@ +char rcs_id[] = "$Header$" ; + main() { none() ; printf("Undetected: declaration of argument not present in argument list\n") ; diff --git a/lang/cem/ctest/ctinit/init.c b/lang/cem/ctest/ctinit/init.c index 91cde4072..48b3779f9 100644 --- a/lang/cem/ctest/ctinit/init.c +++ b/lang/cem/ctest/ctinit/init.c @@ -17,6 +17,8 @@ /* Author: E.G. Keizer */ +char rcs_id[] = "$Header$" ; + /* Test initialisation of a V7 C-compiler */ /* 1 sept 1980 */ #include "../local.h" @@ -90,6 +92,7 @@ pch() { printf("mult[0],mult[1],mult[2] %s, %s, %s\n",mult[0],mult[1],mult[2]); } +#ifndef NOFLOAT /* floats */ float fl1 = 0 ; @@ -171,6 +174,7 @@ printf("dbl1\t%.20e\ndbl2\t%.20e\ndbl2\t%.20e\ndbl4\t%.20e\ndbl5\t%.20e\ndbl6\t% printf("\n") ; } +#endif /* long */ long lo1 = 14L ; @@ -193,12 +197,18 @@ struct s1 { int s_i ; char s_ca[3] ; long s_l ; +#ifndef NOFLOAT double s_f ; +#endif struct s1 *s_s1 ; } ; struct s1 st1 ; struct s1 sta[3] = { +#ifndef NOFLOAT 1 , { 'a' , 'b' , 'c' } , 10 , -10 , &sta[0] , +#else + 1 , { 'a' , 'b' , 'c' } , 10 , &sta[0] , +#endif { 2 } , 3 } ; @@ -229,8 +239,10 @@ pstruct() { st1.s_ca[2],sta[0].s_ca[2],sta[1].s_ca[2],sta[2].s_ca[2]) ; printf("s_l\t%15D%15D%15D%15D\n", st1.s_l,sta[0].s_l,sta[1].s_l,sta[2].s_l) ; +#ifndef NOFLOAT printf("s_f\t %13e %13e %13e %13e\n\n", st1.s_f,sta[0].s_f,sta[1].s_f,sta[2].s_f) ; +#endif printf("(sta[0].s_s1)->s_i = %d\n",(sta[0].s_s1)->s_i) ; printf("\nbit fields:\n\n") ; @@ -242,8 +254,10 @@ pstruct() { main() { pint() ; pch() ; +#ifndef NOFLOAT pflt() ; pdbl() ; +#endif plong() ; pstruct() ; return(0) ; diff --git a/lang/cem/ctest/ctmargt/margt.c b/lang/cem/ctest/ctmargt/margt.c index 8d50389e1..2c26296bc 100644 --- a/lang/cem/ctest/ctmargt/margt.c +++ b/lang/cem/ctest/ctmargt/margt.c @@ -1,3 +1,5 @@ +char rcs_id[] = "$Header$" ; + main(argc,argv,envp) char **argv,**envp ; { register int rargc ; diff --git a/lang/cem/ctest/ctprof/procentry.c b/lang/cem/ctest/ctprof/procentry.c index 2b59f1d4f..01e856638 100644 --- a/lang/cem/ctest/ctprof/procentry.c +++ b/lang/cem/ctest/ctprof/procentry.c @@ -15,6 +15,8 @@ * */ +char rcs_id[] = "$Header$" ; + static int level = 0 ; int procentry(name) char *name ; { register int count ; diff --git a/lang/cem/ctest/ctprof/tp.c b/lang/cem/ctest/ctprof/tp.c index 8b66dd6b3..01b54358f 100644 --- a/lang/cem/ctest/ctprof/tp.c +++ b/lang/cem/ctest/ctprof/tp.c @@ -15,6 +15,8 @@ * */ +char rcs_id2[] = "$Header$" ; + /* Author: E.G. Keizer */ int fac(n) { return ( n==0 ? 1 : n*fac(n-1)) ; } diff --git a/lang/cem/ctest/ctstruct/str.c b/lang/cem/ctest/ctstruct/str.c index 584f5ba5b..7ffb01478 100644 --- a/lang/cem/ctest/ctstruct/str.c +++ b/lang/cem/ctest/ctstruct/str.c @@ -21,9 +21,17 @@ static char rcs_id[]= "$Header$" ; /* test for structure parameters, assignment and return */ # define ASIZE 26 -struct w1 { int w1_i ; } ; -struct w2 { int w2_i ; double w2_d ; } ; -struct w3 { char w3_a[ASIZE] ; double w3_x ; } ; +struct w1 { + int w1_i ; +} ; +struct w2 { + int w2_i ; + long w2_l ; +} ; +struct w3 { + char w3_a[ASIZE] ; + unsigned w3_u ; +} ; struct w1 es1 ; struct w1 es2[3] ; @@ -70,24 +78,24 @@ asst() { printf("w2\n") ; s2t1.w2_i = 18000 ; - s2t1.w2_d = 3.1415 ; + s2t1.w2_l = 31415 ; s2t2 = s2t1 ; - printf("\ts2t2: .w2_i %d .w2_d %f\n",s2t2.w2_i,s2t2.w2_d) ; + printf("\ts2t2: .w2_i %d .w2_l %ld\n",s2t2.w2_i,s2t2.w2_l) ; s2t3 = &s2t2 ; - printf("\ts2t3->w2_d %f\n",s2t3->w2_d) ; + printf("\ts2t3->w2_l %ld\n",s2t3->w2_l) ; printf("w3\n") ; for ( i = 0 ; i + +char rcs_id[] = "$Header$" ; + foo() { printf("signal received\n"); diff --git a/lang/cem/ctest/ctsys/tfork.c b/lang/cem/ctest/ctsys/tfork.c index 5aca4fe6f..d635cadce 100644 --- a/lang/cem/ctest/ctsys/tfork.c +++ b/lang/cem/ctest/ctsys/tfork.c @@ -1,3 +1,5 @@ +char rcs_id[] = "$Header$" ; + main(argc,argv) char **argv ; { int child, waitchild ; int status ;