diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/regression/Makefile | 4 | ||||
-rw-r--r-- | test/regression/Results/bitfields9 | 6 | ||||
-rw-r--r-- | test/regression/Results/builtins-powerpc | 4 | ||||
-rw-r--r-- | test/regression/Results/ptrs3 | 2 | ||||
-rw-r--r-- | test/regression/Results/struct12 | 0 | ||||
-rw-r--r-- | test/regression/bitfields1.c | 4 | ||||
-rw-r--r-- | test/regression/bitfields9.c | 14 | ||||
-rw-r--r-- | test/regression/builtins-powerpc.c | 13 | ||||
-rw-r--r-- | test/regression/ptrs3.c | 10 | ||||
-rw-r--r-- | test/regression/sections.c | 6 | ||||
-rw-r--r-- | test/regression/struct12.c | 39 |
11 files changed, 81 insertions, 21 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile index 94c212d2..e2d94aa9 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -15,9 +15,9 @@ LIBS=$(LIBMATH) TESTS=int32 int64 floats floats-basics \ expr1 expr6 funptr2 initializers initializers2 initializers3 \ volatile1 volatile2 volatile3 \ - funct3 expr5 struct7 struct8 struct11 casts1 casts2 char1 \ + funct3 expr5 struct7 struct8 struct11 struct12 casts1 casts2 char1 \ sizeof1 sizeof2 binops bool for1 switch switch2 compound \ - decl1 interop1 bitfields9 + decl1 interop1 bitfields9 ptrs3 # Can run, but only in compiled mode, and have reference output in Results diff --git a/test/regression/Results/bitfields9 b/test/regression/Results/bitfields9 index ca74f1f4..a1d0e9fd 100644 --- a/test/regression/Results/bitfields9 +++ b/test/regression/Results/bitfields9 @@ -1,10 +1,10 @@ glob_s = { a = -12, b = 1 } -glob_t = { c = 123, d = 0, e = -45 } +glob_t = { c = 123, d = 1, e = -45 } loc_s = { a = 11, b = 2 } loc_t = { c = 11, d = 1, e = 2 } compound_s = { a = 2, b = 3 } -compound_t = { c = 2, d = 0, e = -11 } +compound_t = { c = 2, d = 1, e = -11 } loc_s = { a = 7, b = 2 } loc_t = { c = 7, d = 1, e = 50 } compound_s = { a = -14, b = 3 } -compound_t = { c = 50, d = 0, e = -7 } +compound_t = { c = 50, d = 1, e = -7 } diff --git a/test/regression/Results/builtins-powerpc b/test/regression/Results/builtins-powerpc index ac4240a8..0fd07f69 100644 --- a/test/regression/Results/builtins-powerpc +++ b/test/regression/Results/builtins-powerpc @@ -8,8 +8,8 @@ fmsub(3.141590, 2.718000, 1.414000) = 7.124842 fabs(3.141590) = 3.141590 fabs(-3.141590) = 3.141590 fsqrt(3.141590) = 1.772453 -frsqrte(3.141590) = 0.564198 -fres(3.141590) = 0.318311 +frsqrte(3.141590) = OK +fres(3.141590) = OK fsel(3.141590, 2.718000, 1.414000) = 2.718000 fsel(-3.141590, 2.718000, 1.414000) = 1.414000 fcti(3.141590) = 3 diff --git a/test/regression/Results/ptrs3 b/test/regression/Results/ptrs3 new file mode 100644 index 00000000..17af0459 --- /dev/null +++ b/test/regression/Results/ptrs3 @@ -0,0 +1,2 @@ +p - q = -9 +q - p = 9 diff --git a/test/regression/Results/struct12 b/test/regression/Results/struct12 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/regression/Results/struct12 diff --git a/test/regression/bitfields1.c b/test/regression/bitfields1.c index c6022dd1..5f6dfdd1 100644 --- a/test/regression/bitfields1.c +++ b/test/regression/bitfields1.c @@ -7,7 +7,7 @@ struct s { struct t { unsigned int c: 16; - unsigned int d: 1; + _Bool d: 1; short e: 8; }; @@ -29,7 +29,7 @@ int main() y.c = 12345; y.d = 0; y.e = 89; - res = f(&x, &y, 1); + res = f(&x, &y, 2); printf("x = {a = %d, b = %d }\n", x.a, x.b); printf("y = {c = %d, d = %d, e = %d }\n", y.c, y.d, y.e); diff --git a/test/regression/bitfields9.c b/test/regression/bitfields9.c index b33c4064..be87057b 100644 --- a/test/regression/bitfields9.c +++ b/test/regression/bitfields9.c @@ -9,7 +9,7 @@ struct s { struct t { unsigned int c: 16; - unsigned int d: 1; + _Bool d: 1; short e: 8; }; @@ -25,25 +25,25 @@ void print_t(char * msg, struct t p) /* Global initialization */ struct s glob_s = { -12, 1 }; -struct t glob_t = { 123, 0, -45 }; +struct t glob_t = { 123, 2, -45 }; /* Local initialization */ -void f(int x, int y) +void f(int x, int y, int z) { struct s loc_s = { x, y }; - struct t loc_t = { x, 1, y }; + struct t loc_t = { x, z, y }; print_s("loc_s", loc_s); print_t("loc_t", loc_t); print_s("compound_s", (struct s) { y, x }); - print_t("compound_t", (struct t) { y, 0, -x }); + print_t("compound_t", (struct t) { y, ~z, -x }); } int main() { print_s("glob_s", glob_s); print_t("glob_t", glob_t); - f(11, 2); - f(7, 50); + f(11, 2, 3); + f(7, 50, 2); return 0; } diff --git a/test/regression/builtins-powerpc.c b/test/regression/builtins-powerpc.c index 17d4d3c5..acffa435 100644 --- a/test/regression/builtins-powerpc.c +++ b/test/regression/builtins-powerpc.c @@ -1,6 +1,13 @@ /* Fun with builtins */ #include <stdio.h> +#include <math.h> + +char * check_relative_error(double exact, double actual, double precision) +{ + double relative_error = (actual - exact) / exact; + return fabs(relative_error) <= precision ? "OK" : "ERROR"; +} int main(int argc, char ** argv) { @@ -22,8 +29,10 @@ int main(int argc, char ** argv) printf("fabs(%f) = %f\n", a, __builtin_fabs(a)); printf("fabs(%f) = %f\n", -a, __builtin_fabs(-a)); printf("fsqrt(%f) = %f\n", a, __builtin_fsqrt(a)); - printf("frsqrte(%f) = %f\n", a, __builtin_frsqrte(a)); - printf("fres(%f) = %f\n", a, __builtin_fres(a)); + printf("frsqrte(%f) = %s\n", + a, check_relative_error(1.0 / sqrt(a), __builtin_frsqrte(a), 1./32.)); + printf("fres(%f) = %s\n", + a, check_relative_error(1.0 / a, __builtin_fres(a), 1./256.)); printf("fsel(%f, %f, %f) = %f\n", a, b, c, __builtin_fsel(a, b, c)); printf("fsel(%f, %f, %f) = %f\n", -a, b, c, __builtin_fsel(-a, b, c)); printf("fcti(%f) = %d\n", a, __builtin_fcti(a)); diff --git a/test/regression/ptrs3.c b/test/regression/ptrs3.c new file mode 100644 index 00000000..e0425af4 --- /dev/null +++ b/test/regression/ptrs3.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main() { + int a[10]; + int *p = &a[0]; + int *q = &a[9]; + printf("p - q = %d\n", (int)(p - q)); + printf("q - p = %d\n", (int)(q - p)); + return 0; +} diff --git a/test/regression/sections.c b/test/regression/sections.c index 2e0e4e75..adf94e83 100644 --- a/test/regression/sections.c +++ b/test/regression/sections.c @@ -13,14 +13,14 @@ struct s { long long ll; }; -struct s x; /* normal absolute addressing */ +struct s x = {0, }; /* normal absolute addressing */ #pragma use_section SDATA y -struct s y; /* small data area */ +struct s y = {0, }; /* small data area */ #pragma section MYDATA ".mydata" ".mydata" far-data RW #pragma use_section MYDATA z -struct s z; /* far data area, relative addressing */ +struct s z = {0, }; /* far data area, relative addressing */ #define TEST(msg,ty,x,v1,v2,v3) \ x = v1; \ diff --git a/test/regression/struct12.c b/test/regression/struct12.c new file mode 100644 index 00000000..39e62b28 --- /dev/null +++ b/test/regression/struct12.c @@ -0,0 +1,39 @@ +/* This is was originally a regression test for bug 43784 of gcc. + See ISO/IEC 9899:TC3 ยง6.8.6.4p4 and footnote 139. */ + +#include <stdio.h> + +struct s { + unsigned char a[256]; +}; +union u { + struct { struct s b; int c; } d; + struct { int c; struct s b; } e; +}; + +static union u v; +static struct s *p = &v.d.b; +static struct s *q = &v.e.b; + +static struct s __attribute__((noinline)) rp(void) +{ + return *p; +} + +static void qp(void) +{ + *q = rp(); +} + +int main() +{ + int i; + for (i = 0; i < 256; i++) + p->a[i] = i; + qp(); + for (i = 0; i < 256; i++) + if (q->a[i] != i) + printf("ERROR at %d: %d\n", i, q->a[i]); + return 0; +} + |