From 015c64c64a5a547dcef81a75a589eeaf034654cd Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 26 Nov 2011 15:27:12 +0000 Subject: Fixed serious bug in handling of volatile arrays. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1737 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/Makefile | 4 ++-- test/regression/Results/volatile1 | 4 ++++ test/regression/volatile1.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test/regression/Results/volatile1 (limited to 'test') diff --git a/test/regression/Makefile b/test/regression/Makefile index aeba3bd..103901e 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -9,14 +9,14 @@ LIBS=$(LIBMATH) TESTS=attribs1 bitfields1 bitfields2 bitfields3 bitfields4 \ bitfields5 bitfields6 bitfields7 \ - expr1 expr6 initializers volatile2 volatile3 \ + expr1 expr6 initializers volatile1 volatile2 volatile3 \ funct3 expr5 struct7 struct8 struct11 casts1 casts2 char1 \ sizeof1 sizeof2 packedstruct1 # Other tests: should compile to .s without errors (but expect warnings) EXTRAS=annot1 commaprec expr2 expr3 expr4 extern1 funct2 funptr1 init1 \ init2 init3 init4 pragmas ptrs1 ptrs2 struct1 struct2 struct3 \ - struct4 struct5 struct6 struct9 struct10 types1 volatile1 + struct4 struct5 struct6 struct9 struct10 types1 # Test known to fail FAILURES=funct1 varargs1 diff --git a/test/regression/Results/volatile1 b/test/regression/Results/volatile1 new file mode 100644 index 0000000..2be2eb2 --- /dev/null +++ b/test/regression/Results/volatile1 @@ -0,0 +1,4 @@ +f1() = 123 +v = 42 +f3() = 44 +f5(2) = 2 diff --git a/test/regression/volatile1.c b/test/regression/volatile1.c index 850bbed..10a7abe 100644 --- a/test/regression/volatile1.c +++ b/test/regression/volatile1.c @@ -1,3 +1,5 @@ +#include + volatile int v; int f1(void) { return v; } @@ -7,3 +9,19 @@ void f2(void) { v = 42; } int f3(void) { return v / v + 1 + v; } void f4(void) { v; } + +volatile int t[2]; + +int f5(int x) { t[0] = x; return t[0]; } + +int main() +{ + v = 123; + printf("f1() = %d\n", f1()); + f2(); + printf("v = %d\n", v); + printf("f3() = %d\n", f3()); + f4(); + printf("f5(2) = %d\n", f5(2)); + return 0; +} -- cgit v1.2.3