summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2011-03-15 12:41:45 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2011-03-15 12:41:45 +0000
commitffd6080f9e1e742c73ac38354b31c6fc4e3963ba (patch)
tree48466e94e6ae8a8f7fa50c8fcf4ffb610d6dbed1 /test
parentb6a2f5a9177892fa325e35a845c593902f6f203e (diff)
Revised handling of sizeof(string-literal)
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1611 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test')
-rw-r--r--test/regression/Makefile5
-rw-r--r--test/regression/Results/sizeof13
-rw-r--r--test/regression/Results/sizeof22
-rw-r--r--test/regression/sizeof1.c12
-rw-r--r--test/regression/sizeof2.c9
5 files changed, 29 insertions, 2 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile
index eda31de..377d205 100644
--- a/test/regression/Makefile
+++ b/test/regression/Makefile
@@ -11,11 +11,12 @@ LIBS=$(LIBMATH)
TESTS=bitfields1 bitfields2 bitfields3 bitfields4 \
bitfields5 bitfields6 bitfields7 \
expr1 initializers volatile2 \
- funct3 expr5 struct7 struct8 casts1 casts2 char1
+ funct3 expr5 struct7 struct8 casts1 casts2 char1 \
+ sizeof1 sizeof2
# 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 sizeof1 struct1 struct2 struct3 \
+ init2 init3 init4 pragmas ptrs1 ptrs2 struct1 struct2 struct3 \
struct4 struct5 struct6 struct9 struct10 types1 volatile1
# Test known to fail
diff --git a/test/regression/Results/sizeof1 b/test/regression/Results/sizeof1
new file mode 100644
index 0000000..674f6da
--- /dev/null
+++ b/test/regression/Results/sizeof1
@@ -0,0 +1,3 @@
+sizeof(struct s) = 32, sizeof(tbl) = 32
+sizeof(struct bits1) = 1, sizeof(b1) = 1
+sizeof(struct bits2) = 8, sizeof(b2) = 8
diff --git a/test/regression/Results/sizeof2 b/test/regression/Results/sizeof2
new file mode 100644
index 0000000..fd3c81a
--- /dev/null
+++ b/test/regression/Results/sizeof2
@@ -0,0 +1,2 @@
+5
+5
diff --git a/test/regression/sizeof1.c b/test/regression/sizeof1.c
index e8441a2..d7d37d3 100644
--- a/test/regression/sizeof1.c
+++ b/test/regression/sizeof1.c
@@ -1,3 +1,5 @@
+#include <stdio.h>
+
struct s {
char c;
union { int i[3]; double d; } n;
@@ -29,3 +31,13 @@ struct bits2 {
char b2[sizeof(struct bits2)]; /* should be 8 */
+int main()
+{
+ printf("sizeof(struct s) = %d, sizeof(tbl) = %d\n",
+ sizeof(struct s), sizeof(tbl));
+ printf("sizeof(struct bits1) = %d, sizeof(b1) = %d\n",
+ sizeof(struct bits1), sizeof(b1));
+ printf("sizeof(struct bits2) = %d, sizeof(b2) = %d\n",
+ sizeof(struct bits2), sizeof(b2));
+ return 0;
+}
diff --git a/test/regression/sizeof2.c b/test/regression/sizeof2.c
new file mode 100644
index 0000000..66e38c0
--- /dev/null
+++ b/test/regression/sizeof2.c
@@ -0,0 +1,9 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int main()
+{
+ printf("%d\n", sizeof("abcd"));
+ printf("%d\n", sizeof(L"abcd") / sizeof(wchar_t));
+ return 0;
+}