From ffd6080f9e1e742c73ac38354b31c6fc4e3963ba Mon Sep 17 00:00:00 2001 From: xleroy Date: Tue, 15 Mar 2011 12:41:45 +0000 Subject: Revised handling of sizeof(string-literal) git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1611 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/Makefile | 5 +++-- test/regression/Results/sizeof1 | 3 +++ test/regression/Results/sizeof2 | 2 ++ test/regression/sizeof1.c | 12 ++++++++++++ test/regression/sizeof2.c | 9 +++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 test/regression/Results/sizeof1 create mode 100644 test/regression/Results/sizeof2 create mode 100644 test/regression/sizeof2.c (limited to 'test') 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 + 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 +#include + +int main() +{ + printf("%d\n", sizeof("abcd")); + printf("%d\n", sizeof(L"abcd") / sizeof(wchar_t)); + return 0; +} -- cgit v1.2.3