aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-28 11:23:02 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-28 11:23:02 +0000
commit939d3effd3f63e5a51d6bf0a6cf36e6ab82aac70 (patch)
tree823c67fe274343ed527e4bcc8b905e8e81096c39
parent9f95f9d59057ac914efe982aa501c6deeb241988 (diff)
downloadcompcert-939d3effd3f63e5a51d6bf0a6cf36e6ab82aac70.tar.gz
compcert-939d3effd3f63e5a51d6bf0a6cf36e6ab82aac70.zip
Extra volatile test
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1297 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
-rw-r--r--test/regression/Makefile2
-rw-r--r--test/regression/Results/volatile214
-rw-r--r--test/regression/volatile2.c30
3 files changed, 45 insertions, 1 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile
index cc8684c6..a86f7d93 100644
--- a/test/regression/Makefile
+++ b/test/regression/Makefile
@@ -7,7 +7,7 @@ CCOMPFLAGS=-stdlib ../../runtime -dparse -dclight -dasm \
LIBS=$(LIBMATH)
# Can run and have reference output in Results
-TESTS=bitfields1 expr1 initializers
+TESTS=bitfields1 expr1 initializers volatile2
# Other tests: should compile to .s without errors (but expect warnings)
EXTRAS=commaprec expr2 expr3 expr4 extern1 funct2 funptr1 init1 \
diff --git a/test/regression/Results/volatile2 b/test/regression/Results/volatile2
new file mode 100644
index 00000000..5f888741
--- /dev/null
+++ b/test/regression/Results/volatile2
@@ -0,0 +1,14 @@
+signed char 1: OK
+signed char 2: OK
+unsigned char 1: OK
+unsigned char 2: OK
+signed short 1: OK
+signed short 2: OK
+unsigned short 1: OK
+unsigned short 2: OK
+int 1: OK
+int 2: OK
+float 1: OK
+float 2: OK
+double 1: OK
+double 2: OK
diff --git a/test/regression/volatile2.c b/test/regression/volatile2.c
new file mode 100644
index 00000000..d83927b2
--- /dev/null
+++ b/test/regression/volatile2.c
@@ -0,0 +1,30 @@
+/* Checking that __builtin_volatile_xxx functions are correctly compiled */
+
+#include <stdio.h>
+
+#define TEST(msg,ty,x,v1,v2) \
+ *((volatile ty *) &x) = v1; \
+ printf("%s 1: %s\n", msg, *((ty *) &x) == v1 ? "OK" : "FAILED"); \
+ *((ty *) &x) = v2; \
+ printf("%s 2: %s\n", msg, *((volatile ty *) &x) == v2 ? "OK" : "FAILED");
+
+int main(int argc, char ** argv)
+{
+ signed char sc;
+ unsigned char uc;
+ signed short ss;
+ unsigned short us;
+ int i;
+ float f;
+ double d;
+
+ TEST("signed char", signed char, sc, 12, 34);
+ TEST("unsigned char", unsigned char, uc, 56, 78);
+ TEST("signed short", signed short, ss, 1234, 5678);
+ TEST("unsigned short", unsigned short, us, 1357, 2468);
+ TEST("int", int, i, 0x123456, 0x7890AB);
+ TEST("float", float, f, 0.5, 256.0);
+ TEST("double", double, d, 3.1415, 2.718);
+ return 0;
+}
+