From e7a6aff95cc37806aeb4637c40ff46a8c41a2b49 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 14 Sep 2015 10:49:12 +0200 Subject: Fix uninitialized array in do_bench (report by V. Laporte). --- test/c/aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/c/aes.c b/test/c/aes.c index abdaf6c3..88b3de4a 100644 --- a/test/c/aes.c +++ b/test/c/aes.c @@ -1423,7 +1423,7 @@ static void do_test(int keybits, u8 * key, static void do_bench(int nblocks) { u32 ckey[4 * (MAXNR + 1)]; - u8 temp[16]; + u8 temp[16] = "Plaintext"; int nr; nr = rijndaelKeySetupEnc(ckey, (u8 *)"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F", 128); -- cgit From 700e9b41253e04ac3a0a16edfa1f41a2d4084462 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 14 Sep 2015 14:53:57 +0200 Subject: Use standard headers instead of defining our own ptrdiff_t and uintptr_t. --- test/regression/alias.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/regression/alias.c b/test/regression/alias.c index a38e6dfd..9887ae2b 100644 --- a/test/regression/alias.c +++ b/test/regression/alias.c @@ -1,8 +1,8 @@ /* Testing the alias analysis on ill-defined codes where it should remain conservative. */ -typedef unsigned int uintptr_t; -typedef signed int ptrdiff_t; +#include +#include /* For testing with GCC */ #define NOINLINE __attribute__((noinline)) -- cgit From de40fce9c16ced8d23389cbcfc55ef6d99466fe8 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 15 Sep 2015 14:26:42 +0200 Subject: Issue with ignoring the result of non-void builtin functions. In RTL and beyond, the result of a builtin function that has return type different from "void" must be BR, never BR_none. Otherwise, we get compile-time fatal errors, either in Asmexpand or in Lineartyping. --- test/regression/builtins-arm.c | 5 ++++- test/regression/builtins-ia32.c | 5 ++++- test/regression/builtins-powerpc.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/regression/builtins-arm.c b/test/regression/builtins-arm.c index 91a8e890..643c8f1a 100644 --- a/test/regression/builtins-arm.c +++ b/test/regression/builtins-arm.c @@ -23,7 +23,10 @@ int main(int argc, char ** argv) y = 0; __builtin_write32_reversed(&y, 0x12345678); printf ("CSE write_32_rev: %s\n", y == 0x78563412 ? "ok" : "ERROR"); - + /* Make sure that ignoring the result of a builtin + doesn't cause an internal error */ + (void) __builtin_bswap(x); + (void) __builtin_fsqrt(a); return 0; } diff --git a/test/regression/builtins-ia32.c b/test/regression/builtins-ia32.c index 10426209..558c3153 100644 --- a/test/regression/builtins-ia32.c +++ b/test/regression/builtins-ia32.c @@ -36,7 +36,10 @@ int main(int argc, char ** argv) y = 0; __builtin_write32_reversed(&y, 0x12345678); printf ("CSE write_32_rev: %s\n", y == 0x78563412 ? "ok" : "ERROR"); - + /* Make sure that ignoring the result of a builtin + doesn't cause an internal error */ + (void) __builtin_bswap(x); + (void) __builtin_fsqrt(a); return 0; } diff --git a/test/regression/builtins-powerpc.c b/test/regression/builtins-powerpc.c index acffa435..90030737 100644 --- a/test/regression/builtins-powerpc.c +++ b/test/regression/builtins-powerpc.c @@ -50,7 +50,10 @@ int main(int argc, char ** argv) y = 0; __builtin_write32_reversed(&y, 0x12345678); printf ("CSE write_32_rev: %s\n", y == 0x78563412 ? "ok" : "ERROR"); - + /* Make sure that ignoring the result of a builtin + doesn't cause an internal error */ + (void) __builtin_bswap(x); + (void) __builtin_fsqrt(a); return 0; } -- cgit From 504228b1f7b875550eae9e3782a5f2c1033b0233 Mon Sep 17 00:00:00 2001 From: Jacques-Henri Jourdan Date: Wed, 30 Sep 2015 18:41:50 +0200 Subject: Fixed a few bugs in the pre parser. In particular, the following code was not parsed correctly: typedef int a; int f() { for(int a; ;) if(1); a * x; } Additionnaly, I tried to add some comments in the pre-parser code, especially for the different hacks used to solve various conflicts. --- test/regression/Makefile | 3 +- test/regression/Results/parsing | 0 test/regression/parsing.c | 104 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 test/regression/Results/parsing create mode 100644 test/regression/parsing.c (limited to 'test') diff --git a/test/regression/Makefile b/test/regression/Makefile index 2f70c63a..6ef44b78 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -17,7 +17,8 @@ TESTS=int32 int64 floats floats-basics \ volatile1 volatile2 volatile3 \ funct3 expr5 struct7 struct8 struct11 struct12 casts1 casts2 char1 \ sizeof1 sizeof2 binops bool for1 switch switch2 compound \ - decl1 interop1 bitfields9 ptrs3 + decl1 interop1 bitfields9 ptrs3 \ + parsing # Can run, but only in compiled mode, and have reference output in Results diff --git a/test/regression/Results/parsing b/test/regression/Results/parsing new file mode 100644 index 00000000..e69de29b diff --git a/test/regression/parsing.c b/test/regression/parsing.c new file mode 100644 index 00000000..24b954c1 --- /dev/null +++ b/test/regression/parsing.c @@ -0,0 +1,104 @@ +#include + +typedef signed int T; + +T f(T(T)); +T f(T a(T)) { + T b; + return 1; +} +int g(int x) { + T:; + T y; + T T; + T=1; + + return 1; +} + +void h() { + for(int T; ;) + if(1) + ; + T *x; + x = 0; +} + +void h2() { + for(int T; ;) + if(1) + ; + else T; +} + +struct S { + const T:3; + unsigned T:3; + const T:3; +}; + +void i() { + struct S s; + s.T = -1; + if(s.T < 0) printf("ERROR i\n"); +} + +/* These ones are parsed correctly, but rejected by the elaborator. */ +/* void j() { */ +/* typedef int I; */ +/* {sizeof(enum{I=2}); return I;} */ +/* {do sizeof(enum{I=2}); while((I)1);} */ +/* {if(1) return sizeof(enum{I=2}); */ +/* else return (I)1;} */ +/* {if(sizeof(enum{I=2})) return I; */ +/* else return I;} */ +/* {sizeof(enum{I=2})+I;} */ +/* {for(int i = sizeof(enum{I=2}); I; I) I; (I)1;} */ +/* } */ +/* int f2(enum{I=2} x) { */ +/* return I; */ +/* } */ +/* void k(A, B) */ +/* int B; */ +/* int A[B]; */ +/* { } */ +/* int l(A) */ +/* enum {T=1} A; */ +/* { return T * A; } */ + +void m() { + if(0) + if(1); + else printf("ERROR m\n"); + if(0) + for(int i; ; ) + if(1); + else printf("ERROR m\n"); + if(0) + for(1; ; ) + if(1); + else printf("ERROR m\n"); + if(0) + while(1) + if(1); + else printf("ERROR m\n"); + if(0) + L: if(1); + else printf("ERROR m\n"); + + if(0) + LL:for(1;;) + for(int i;;) + while(1) + switch(1) + case 1: + if(1); + else printf("ERROR m\n"); +} + +int main () { + f(g); + i(); + m(); + return 0; +} -- cgit