From 28e0172b194956fdc4b2f4310ca1f8f3905e723a Mon Sep 17 00:00:00 2001 From: fuqun Date: Tue, 16 Mar 2021 16:36:26 +0800 Subject: [PATCH 1/2] add c_test source code --- testsuite/c_test/log | 25 ++++ .../c_test/sanity_test/SANITY0001-addr/addr.c | 54 +++++++++ .../sanity_test/SANITY0001-addr/test.cfg | 3 + .../c_test/sanity_test/SANITY0002-argc/argc.c | 26 ++++ .../sanity_test/SANITY0002-argc/test.cfg | 3 + .../SANITY0003-array_single/array_single.c | 86 ++++++++++++++ .../SANITY0003-array_single/test.cfg | 3 + .../sanity_test/SANITY0004-binop/binop.c | 73 ++++++++++++ .../sanity_test/SANITY0004-binop/test.cfg | 3 + .../c_test/sanity_test/SANITY0005-cand/cand.c | 35 ++++++ .../sanity_test/SANITY0005-cand/test.cfg | 3 + .../c_test/sanity_test/SANITY0006-goto/goto.c | 35 ++++++ .../sanity_test/SANITY0006-goto/test.cfg | 3 + .../sanity_test/SANITY0007-hello/hello.c | 27 +++++ .../sanity_test/SANITY0007-hello/test.cfg | 3 + .../if_call_return.c | 44 +++++++ .../SANITY0008-if_call_return/test.cfg | 3 + .../sanity_test/SANITY0009-if_else/if_else.c | 28 +++++ .../sanity_test/SANITY0009-if_else/test.cfg | 3 + .../SANITY0010-if_else_fp/if_else_fp.c | 108 +++++++++++++++++ .../SANITY0010-if_else_fp/test.cfg | 3 + .../SANITY0011-ind_call/ind_call.c | 31 +++++ .../sanity_test/SANITY0011-ind_call/test.cfg | 3 + .../SANITY0012-large_stack/large_stack.c | 43 +++++++ .../SANITY0012-large_stack/test.cfg | 3 + .../sanity_test/SANITY0013-memexpr/memexpr.c | 40 +++++++ .../sanity_test/SANITY0013-memexpr/test.cfg | 3 + .../sanity_test/SANITY0014-select/select.c | 28 +++++ .../sanity_test/SANITY0014-select/test.cfg | 3 + .../SANITY0015-select_fp/select_fp.c | 29 +++++ .../sanity_test/SANITY0015-select_fp/test.cfg | 3 + .../c_test/sanity_test/SANITY0016-set/set.c | 112 ++++++++++++++++++ .../sanity_test/SANITY0016-set/test.cfg | 3 + .../SANITY0017-struct_bits/struct_bits.c | 85 +++++++++++++ .../SANITY0017-struct_bits/test.cfg | 3 + .../SANITY0018-sum_array/sum_array.c | 43 +++++++ .../sanity_test/SANITY0018-sum_array/test.cfg | 3 + .../c_test/sanity_test/SANITY0019-sum/sum.c | 31 +++++ .../sanity_test/SANITY0019-sum/test.cfg | 3 + .../sanity_test/SANITY0020-vararg2/test.cfg | 3 + .../sanity_test/SANITY0020-vararg2/vararg2.c | 36 ++++++ 41 files changed, 1079 insertions(+) create mode 100644 testsuite/c_test/log create mode 100644 testsuite/c_test/sanity_test/SANITY0001-addr/addr.c create mode 100644 testsuite/c_test/sanity_test/SANITY0001-addr/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0002-argc/argc.c create mode 100644 testsuite/c_test/sanity_test/SANITY0002-argc/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0003-array_single/array_single.c create mode 100644 testsuite/c_test/sanity_test/SANITY0003-array_single/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0004-binop/binop.c create mode 100644 testsuite/c_test/sanity_test/SANITY0004-binop/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0005-cand/cand.c create mode 100644 testsuite/c_test/sanity_test/SANITY0005-cand/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0006-goto/goto.c create mode 100644 testsuite/c_test/sanity_test/SANITY0006-goto/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0007-hello/hello.c create mode 100644 testsuite/c_test/sanity_test/SANITY0007-hello/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0008-if_call_return/if_call_return.c create mode 100644 testsuite/c_test/sanity_test/SANITY0008-if_call_return/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0009-if_else/if_else.c create mode 100644 testsuite/c_test/sanity_test/SANITY0009-if_else/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0010-if_else_fp/if_else_fp.c create mode 100644 testsuite/c_test/sanity_test/SANITY0010-if_else_fp/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0011-ind_call/ind_call.c create mode 100644 testsuite/c_test/sanity_test/SANITY0011-ind_call/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0012-large_stack/large_stack.c create mode 100644 testsuite/c_test/sanity_test/SANITY0012-large_stack/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0013-memexpr/memexpr.c create mode 100644 testsuite/c_test/sanity_test/SANITY0013-memexpr/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0014-select/select.c create mode 100644 testsuite/c_test/sanity_test/SANITY0014-select/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0015-select_fp/select_fp.c create mode 100644 testsuite/c_test/sanity_test/SANITY0015-select_fp/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0016-set/set.c create mode 100644 testsuite/c_test/sanity_test/SANITY0016-set/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0017-struct_bits/struct_bits.c create mode 100644 testsuite/c_test/sanity_test/SANITY0017-struct_bits/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0018-sum_array/sum_array.c create mode 100644 testsuite/c_test/sanity_test/SANITY0018-sum_array/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0019-sum/sum.c create mode 100644 testsuite/c_test/sanity_test/SANITY0019-sum/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0020-vararg2/test.cfg create mode 100644 testsuite/c_test/sanity_test/SANITY0020-vararg2/vararg2.c diff --git a/testsuite/c_test/log b/testsuite/c_test/log new file mode 100644 index 0000000000..00584468fa --- /dev/null +++ b/testsuite/c_test/log @@ -0,0 +1,25 @@ ++ CURRDIR=/home/fuqun/OpenArkCompiler/test/c_test/sanity +++ realpath --relative-to=/home/fuqun/OpenArkCompiler /home/fuqun/OpenArkCompiler/test/c_test/sanity ++ rel=test/c_test/sanity ++ dir=. ++ src=array_single ++ opt=0 ++ '[' 4 -le 3 ']' ++ verbose=0 ++ WORKDIR=/home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl ++ mkdir -p /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl ++ cp ./array_single.c /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl ++ cd /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl +++ cd /usr/lib/gcc-cross/aarch64-linux-gnu/ +++ ls +++ head -1 ++ V=5 ++ FLAGS='-cc1 -emit-llvm -triple aarch64-linux-gnu -D__clang__ -D__BLOCKS__ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/5/include' ++ /home/fuqun/OpenArkCompiler/tools/open64_prebuilt/x86/aarch64/bin/clangfe -cc1 -emit-llvm -triple aarch64-linux-gnu -D__clang__ -D__BLOCKS__ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/5/include array_single.c ++ /home/fuqun/OpenArkCompiler/tools/open64_prebuilt/x86/aarch64/bin/whirl2mpl -a array_single.B ++ '[' 0 -eq 0 ']' ++ /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/bin/maple --run=mplcg --option=-quiet array_single.mpl ++ /usr/bin/aarch64-linux-gnu-gcc-5 -o array_single.out array_single.s ++ qemu-aarch64 -L /usr/aarch64-linux-gnu/ array_single.out ++ cat cmd.log ++ '[' 0 -eq 1 ']' diff --git a/testsuite/c_test/sanity_test/SANITY0001-addr/addr.c b/testsuite/c_test/sanity_test/SANITY0001-addr/addr.c new file mode 100644 index 0000000000..1e0281a16f --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0001-addr/addr.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int deref(int *iptr) { + return *iptr; +} + +int deref1(int *iptr) { + int j = 8; + j = *iptr + j; + return j; +} + +int addrof(int *iptr) { + int j = 8; + int *jptr = &j; + *jptr = *iptr; + return *jptr; +} + +int main() +{ + int v = 5; + int *vptr = &v; + + if (*vptr != 5) { + abort(); + } + if (deref(&v) != 5) { + abort(); + } + if (deref1(&v) != 13) { + abort(); + } + if (addrof(&v) != 5) { + abort(); + } +} + diff --git a/testsuite/c_test/sanity_test/SANITY0001-addr/test.cfg b/testsuite/c_test/sanity_test/SANITY0001-addr/test.cfg new file mode 100644 index 0000000000..67db64ba62 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0001-addr/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(addr) +run(addr) diff --git a/testsuite/c_test/sanity_test/SANITY0002-argc/argc.c b/testsuite/c_test/sanity_test/SANITY0002-argc/argc.c new file mode 100644 index 0000000000..2358a1da29 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0002-argc/argc.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main(int argc, char *argv[]) +{ + int i = 1; + if (i > argc) { + abort(); + } + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0002-argc/test.cfg b/testsuite/c_test/sanity_test/SANITY0002-argc/test.cfg new file mode 100644 index 0000000000..09597f134f --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0002-argc/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(argc) +run(argc) diff --git a/testsuite/c_test/sanity_test/SANITY0003-array_single/array_single.c b/testsuite/c_test/sanity_test/SANITY0003-array_single/array_single.c new file mode 100644 index 0000000000..22c881cdde --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0003-array_single/array_single.c @@ -0,0 +1,86 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int A[5]; +int foo(int i) { + A[3] = i + A[2]; + return A[(i >= 0 && i < 5) ? i : 0]; +} + +float B[15]; +float bar(int i) { + B[3] = i + B[2]; + return B[(i >= 0 && i < 5) ? i : 0]; +} + +// variable array type +void vararr(int sz) { + int my[sz]; + int i; + for (i = 0; i < sz; ++i) { + my[i] = i; + } + for (i = 0; i < sz; ++i) { + if (my[i] != i) { + abort(); + } + } +} + +int main() +{ + vararr(4); + + A[0] = 0; + A[2] = A[3] = 2; + if (A[3] != 2) { + abort(); + } + if (foo(2) != 2) { + abort(); + } + if (A[3] != 4) { + abort(); + } + if (foo(5) != 0) { + abort(); + } + if (A[3] != 7) { + abort(); + } + + B[0] = 0; + B[1] = B[2] = B[3] = 3; + if (B[3] != 3) { + abort(); + } + if (bar(1) != 3) { + abort(); + } + if (B[3] != 4) { + abort(); + } + if (bar(5) != 0) { + abort(); + } + if (B[3] != 8) { + abort(); + } + + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0003-array_single/test.cfg b/testsuite/c_test/sanity_test/SANITY0003-array_single/test.cfg new file mode 100644 index 0000000000..36d8622f7c --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0003-array_single/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(array_single) +run(array_single) diff --git a/testsuite/c_test/sanity_test/SANITY0004-binop/binop.c b/testsuite/c_test/sanity_test/SANITY0004-binop/binop.c new file mode 100644 index 0000000000..733be02b68 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0004-binop/binop.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int a = 0x80000001; +unsigned int ua = 0x00000002; +unsigned int val = 0xffffff84; + +int main() +{ + int c = a; + + c += a | 0; + c += a & 1; + c += a ^ 0; + c += a >> 0; + c += a << 0; + + c += a | 1; + c += a & 5; + c += a ^ 1; + c += a >> 1; + c += a << 1; + + c += a | 0x7ff; + c += a & 0x7ff; + c += a ^ 0x7ff; + c += a >> 16; + c += a << 16; + + c += a | 0xfff; + c += a & 0xfff; + c += a ^ 0xfff; + c += a >> 24; + c += a << 24; + + c += a | 0xffff; + c += a & 0xffff; + c += a ^ 0xffff; + c += a >> 31; + c += a << 31; + + unsigned int u = ua; + u += ua >> 0; + u += ua >> 1; + u += ua >> 16; + u += a >> 24; + u += a >> 31; + + if (c != 0xc102af83) { + abort(); + } + if (u != 0xffffff84) { + abort(); + } + if (u != val) { + abort(); + } +} diff --git a/testsuite/c_test/sanity_test/SANITY0004-binop/test.cfg b/testsuite/c_test/sanity_test/SANITY0004-binop/test.cfg new file mode 100644 index 0000000000..cf015b2399 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0004-binop/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(binop) +run(binop) diff --git a/testsuite/c_test/sanity_test/SANITY0005-cand/cand.c b/testsuite/c_test/sanity_test/SANITY0005-cand/cand.c new file mode 100644 index 0000000000..fa71bffcbb --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0005-cand/cand.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int i = 2; +int main() { + int v = (((i > 0) && (i < 3)) ? 1 : 2); + if ( v != 1 ) { + abort(); + } + + v = (((i > 0) && (i < 2)) ? 1 : 2); + if ( v != 2 ) { + abort(); + } + + v = (((i > 2) && (i < 3)) ? 1 : 2); + if ( v != 2 ) { + abort(); + } +} diff --git a/testsuite/c_test/sanity_test/SANITY0005-cand/test.cfg b/testsuite/c_test/sanity_test/SANITY0005-cand/test.cfg new file mode 100644 index 0000000000..cb1cefa37f --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0005-cand/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(cand) +run(cand) diff --git a/testsuite/c_test/sanity_test/SANITY0006-goto/goto.c b/testsuite/c_test/sanity_test/SANITY0006-goto/goto.c new file mode 100644 index 0000000000..a0bad57bf4 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0006-goto/goto.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int g = 5; + +int main() { + for (int i = 0; i < 10; i++) { + if (i == 1) { + goto label; + } + g = i; // 0 + } + abort(); + +label: + if (g != 0) { + abort(); + } + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0006-goto/test.cfg b/testsuite/c_test/sanity_test/SANITY0006-goto/test.cfg new file mode 100644 index 0000000000..743a50dd9f --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0006-goto/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(goto) +run(goto) diff --git a/testsuite/c_test/sanity_test/SANITY0007-hello/hello.c b/testsuite/c_test/sanity_test/SANITY0007-hello/hello.c new file mode 100644 index 0000000000..8b6d7b83d5 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0007-hello/hello.c @@ -0,0 +1,27 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main() { + char str[32]; + int v = sprintf(str,"hello world\n"); + + if (v != 12) { + abort(); + } + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0007-hello/test.cfg b/testsuite/c_test/sanity_test/SANITY0007-hello/test.cfg new file mode 100644 index 0000000000..e1ef8f6017 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0007-hello/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(hello) +run(hello) diff --git a/testsuite/c_test/sanity_test/SANITY0008-if_call_return/if_call_return.c b/testsuite/c_test/sanity_test/SANITY0008-if_call_return/if_call_return.c new file mode 100644 index 0000000000..e55533bd1f --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0008-if_call_return/if_call_return.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int i = 1; +float f = 2.2; +long long ll = 3; +double d = 4.4; + +int fi(){ return i; } +float ff(){ return f; } +long long fll(){ return ll; } +double fd(){ return d; } + +int main() { + if (fi() != 1) { + abort(); + } + if (ff() != (float)2.2) { + abort(); + } + if (fll() != 3) { + abort(); + } + if (fd() != 4.4) { + abort(); + } + return 0; +} + diff --git a/testsuite/c_test/sanity_test/SANITY0008-if_call_return/test.cfg b/testsuite/c_test/sanity_test/SANITY0008-if_call_return/test.cfg new file mode 100644 index 0000000000..e3cbc2cfac --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0008-if_call_return/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(if_call_return) +run(if_call_return) diff --git a/testsuite/c_test/sanity_test/SANITY0009-if_else/if_else.c b/testsuite/c_test/sanity_test/SANITY0009-if_else/if_else.c new file mode 100644 index 0000000000..63d19c2a83 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0009-if_else/if_else.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main() { + int i = 1; + + if (i > 1) { + abort(); + } else { + printf(""); + } + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0009-if_else/test.cfg b/testsuite/c_test/sanity_test/SANITY0009-if_else/test.cfg new file mode 100644 index 0000000000..707e431fc7 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0009-if_else/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(if_else) +run(if_else) diff --git a/testsuite/c_test/sanity_test/SANITY0010-if_else_fp/if_else_fp.c b/testsuite/c_test/sanity_test/SANITY0010-if_else_fp/if_else_fp.c new file mode 100644 index 0000000000..65d0609a14 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0010-if_else_fp/if_else_fp.c @@ -0,0 +1,108 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main() { + double d1 = 10; + double d2 = 20; + int i = 0; + + if (d1 <= d2) { + i++; + } else { + abort(); + } + + if (d2 >= d1) { + i++; + } else { + abort(); + } + + if (d2 > d1) { + i++; + } else { + abort(); + } + + if (d1 < d2 && d2 > d1) { + i++; + } else { + abort(); + } + + if (d1 != d2) { + i++; + } else { + abort(); + } + + d1 = 20; + if (d1 <= d2) { + if (d1 == d2) { + i++; + } else { + abort(); + } + } + + float f1 = 10; + float f2 = 20; + + if (f1 <= f2) { + i++; + } else { + abort(); + } + + if (f2 >= f1) { + i++; + } else { + abort(); + } + + if (f2 > f1) { + i++; + } else { + abort(); + } + + if (f1 < f2 && f2 > f1) { + i++; + } else { + abort(); + } + + if (f1 != f2) { + i++; + } else { + abort(); + } + + f1 = 20; + if (f1 <= f2) { + if (f1 == f2) { + i++; + } else { + abort(); + } + } + + if (i != 12) { + abort(); + } +} diff --git a/testsuite/c_test/sanity_test/SANITY0010-if_else_fp/test.cfg b/testsuite/c_test/sanity_test/SANITY0010-if_else_fp/test.cfg new file mode 100644 index 0000000000..09b4ec2fd0 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0010-if_else_fp/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(if_else_fp) +run(if_else_fp) diff --git a/testsuite/c_test/sanity_test/SANITY0011-ind_call/ind_call.c b/testsuite/c_test/sanity_test/SANITY0011-ind_call/ind_call.c new file mode 100644 index 0000000000..6cfda4c04c --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0011-ind_call/ind_call.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int x = 1; + +int foo(){return x;} + +int main() { + int (*fptr)() = foo; + int v = fptr(); + + if (v != 1) { + abort(); + } + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0011-ind_call/test.cfg b/testsuite/c_test/sanity_test/SANITY0011-ind_call/test.cfg new file mode 100644 index 0000000000..c6d652f30d --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0011-ind_call/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ind_call) +run(ind_call) diff --git a/testsuite/c_test/sanity_test/SANITY0012-large_stack/large_stack.c b/testsuite/c_test/sanity_test/SANITY0012-large_stack/large_stack.c new file mode 100644 index 0000000000..41bc2c2449 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0012-large_stack/large_stack.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +#define asize 500 +int sum = 0; +void vararr(int sz) { + int my[sz]; + volatile int a[asize], b[asize], c[asize]; + + for (int i = 0; i< asize; i++) { + a[i] = i; b[i] = i + 1; c[i] = i + 2; + sum = a[i] + b[i] * c[i]; + if (i < sz) { + my[i] = sum; + } + } + + if ((my[0] != 2) || + (my[1] != 7) || + (my[2] != 14) || + (my[3] != 23)) { + abort(); + } +} + +int main() { + vararr(4); +} diff --git a/testsuite/c_test/sanity_test/SANITY0012-large_stack/test.cfg b/testsuite/c_test/sanity_test/SANITY0012-large_stack/test.cfg new file mode 100644 index 0000000000..4115c08b0b --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0012-large_stack/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(large_stack) +run(large_stack) diff --git a/testsuite/c_test/sanity_test/SANITY0013-memexpr/memexpr.c b/testsuite/c_test/sanity_test/SANITY0013-memexpr/memexpr.c new file mode 100644 index 0000000000..5417248d6a --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0013-memexpr/memexpr.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main() { + struct PSas { + short a, b; + int *p; + }(*PSas0), (*PSas1); + + struct PSas pSas0, pSas1, pSasa[10]; + + int i = 5; + PSas0 = &pSas0; + PSas1 = &pSas1; + + pSasa[8].a = 2; + (*PSas0).a = 3; + (*PSas1).p = &i; + + if (pSasa[8].a != 2 || (*PSas0).a != 3 || *((*PSas1).p) != 5) { + abort(); + } + + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0013-memexpr/test.cfg b/testsuite/c_test/sanity_test/SANITY0013-memexpr/test.cfg new file mode 100644 index 0000000000..4e0e3847e7 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0013-memexpr/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(memexpr) +run(memexpr) diff --git a/testsuite/c_test/sanity_test/SANITY0014-select/select.c b/testsuite/c_test/sanity_test/SANITY0014-select/select.c new file mode 100644 index 0000000000..dfe621fe53 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0014-select/select.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main(int argc, char *argv[]) +{ + int i = (argc != 1) ? ((argc != 2) ? ((argc != 3) ? 6 : 7) : 5) : ((argc == 4) ? 8 : 9); + + if (i != 9) { + abort(); + } + + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0014-select/test.cfg b/testsuite/c_test/sanity_test/SANITY0014-select/test.cfg new file mode 100644 index 0000000000..a844d47e9b --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0014-select/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(select) +run(select) diff --git a/testsuite/c_test/sanity_test/SANITY0015-select_fp/select_fp.c b/testsuite/c_test/sanity_test/SANITY0015-select_fp/select_fp.c new file mode 100644 index 0000000000..6c3019a975 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0015-select_fp/select_fp.c @@ -0,0 +1,29 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main(int argc, char *argv[]) +{ + float f = 2000; + int i = (argc == 1) ? ((f != 200) ? ((f == 2000) ? 6 : 7) : 5) : ((argc == 4) ? 8 : 9); + + if (i != 6) { + abort(); + } + + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0015-select_fp/test.cfg b/testsuite/c_test/sanity_test/SANITY0015-select_fp/test.cfg new file mode 100644 index 0000000000..3a3cc0d575 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0015-select_fp/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(select_fp) +run(select_fp) diff --git a/testsuite/c_test/sanity_test/SANITY0016-set/set.c b/testsuite/c_test/sanity_test/SANITY0016-set/set.c new file mode 100644 index 0000000000..3eaca49ef8 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0016-set/set.c @@ -0,0 +1,112 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include + +void foo1(int x) { // x = (0, 1, -1, 1, 0, 0) + int a1 = x++ == 0; + int a2 = x-- != 0; + int a3 = --x < 0; + int a4 = x+2 > 0; + int a5 = ++x <= 0; + int a6 = x >= 0; + if (a1+a2+a3+a4+a5+a6 != 6) { + abort(); + } +} + +void foo2(int x) { // x = (1, 2, 0, 2, 1, 1) + int a1 = x == 1; + int a2 = ++x != 1; + int a3 = x-2 < 1; + int a4 = x > 1; + int a5 = --x <= 1; + int a6 = x >= 1; + if (a1+a2+a3+a4+a5+a6 != 6) { + abort(); + } +} + +void foo3(int x, int y) { // x&y = (1==1, 1!=2, 0<2, 0>-1, 0<=0, 0>=0) + int a1 = x == y; + int a2 = x != ++y; + int a3 = --x < y--; + int a4 = x > y-2; + int a5 = x <= --y; + int a6 = x >= --y; + if (a1+a2+a3+a4+a5+a6 != 6) { + abort(); + } +} + +void foo4(unsigned x) { // x = (0, 1, 0xf-f, 1, 0, 0) + unsigned a1 = x++ == 0; + unsigned a2 = x-- != 0; + unsigned a3 = (--x < 0) + 1; + unsigned a4 = x+2 > 0; + unsigned a5 = ++x <= 0; + unsigned a6 = x >= 0; + if (a1+a2+a3+a4+a5+a6 != 6) { + abort(); + } +} + +void foo5(unsigned x) { // x = (1, 2, 0, 0xf-f, 1, 1) + unsigned a1 = x == 1; + unsigned a2 = ++x != 1; + unsigned a3 = x-2 < 1; + unsigned a4 = x-3 > 1; + unsigned a5 = --x <= 1; + unsigned a6 = x >= 1; + if (a1+a2+a3+a4+a5+a6 != 6) { + abort(); + } +} + +void foo6(unsigned x, unsigned y) { // x&y = (1==1, 1!=2, 0<2, 0xf-f>1, 0<=0, 0>=0, + // 0xf-f>=0) + unsigned a1 = x == y; + unsigned a2 = x != ++y; + unsigned a3 = --x < y--; + unsigned a4 = --x > y; + unsigned a5 = ++x <= --y; + unsigned a6 = x >= y; + unsigned a7 = --x >= y; + if (a1+a2+a3+a4+a5+a6+a7 != 7) { + abort(); + } +} + +void foo7(unsigned x) { // x = (4096, 4097, 4094, 4097, 4096, 4096) + unsigned a1 = x == 4096; + unsigned a2 = ++x != 4096; + unsigned a3 = x-3 < 4095; + unsigned a4 = x > 4096; + unsigned a5 = --x <= 4096; + unsigned a6 = x >= 4096; + if (a1+a2+a3+a4+a5+a6 != 6) { + abort(); + } +} + +int main() { + foo1(0); + foo2(1); + foo3(1, 1); + foo4(0); + foo5(1); + foo6(1, 1); + foo7(4096); +} diff --git a/testsuite/c_test/sanity_test/SANITY0016-set/test.cfg b/testsuite/c_test/sanity_test/SANITY0016-set/test.cfg new file mode 100644 index 0000000000..d59002acf5 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0016-set/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(set) +run(set) diff --git a/testsuite/c_test/sanity_test/SANITY0017-struct_bits/struct_bits.c b/testsuite/c_test/sanity_test/SANITY0017-struct_bits/struct_bits.c new file mode 100644 index 0000000000..7deea9e24a --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0017-struct_bits/struct_bits.c @@ -0,0 +1,85 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +typedef struct x { + long x; + unsigned int z1:3; + unsigned int z2:12; + int z3:2; + int z4:10; + int z5:5; + int y; + char z[32]; +} x; + +typedef struct y { + long x; + long long x1 : 5; + long long x2 : 16; + unsigned long long x3 : 33; + long long x4 : 10; + int y; +} y; + +void foo() { + x xxx; + xxx.x = 1; + xxx.y = 2; + xxx.z1 = 0x7; + xxx.z2 = 0x800; + xxx.z3 = 0x3; + xxx.z4 = 0x201; + xxx.z5 = 0x11; + xxx.z[0] = 4; + xxx.z[31] = 6; + xxx.z[1] = 5; + + if (xxx.z1 != 7) { + abort(); + } + if (xxx.z2 != 0x800) { + abort(); + } + if (xxx.z3 != -1) { + abort(); + } + if (xxx.z4 != -511) { + abort(); + } + if (xxx.z5 != -15) { + abort(); + } +} + +void bar() { + y yyy; + + yyy.x = 3; + yyy.y = 4; + yyy.x1 = 7; + yyy.x2 = 0xff; + yyy.x3 = 0x800f0008; + yyy.x4 = 0x15; +} + +int main() { + foo(); + bar(); + return 0; +} + diff --git a/testsuite/c_test/sanity_test/SANITY0017-struct_bits/test.cfg b/testsuite/c_test/sanity_test/SANITY0017-struct_bits/test.cfg new file mode 100644 index 0000000000..177c412c3e --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0017-struct_bits/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(struct_bits) +run(struct_bits) diff --git a/testsuite/c_test/sanity_test/SANITY0018-sum_array/sum_array.c b/testsuite/c_test/sanity_test/SANITY0018-sum_array/sum_array.c new file mode 100644 index 0000000000..714090b691 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0018-sum_array/sum_array.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +//int main(int argc, char *argv[]) +int main() +{ + int a[10], b[10], c[10], i; + + for (i = 0; i < 10; i++) { + b[i] = i << 2; + c[i] = i << b[i]; + } + + for (i = 0; i < 10; i++) { + a[i] = b[i] + c[9-i]; + } + + int sum = 0; + for (i = 0; i < 10; i++) { + sum += a[i]; + } + + if (sum != 1985229660) { + abort(); + } + + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0018-sum_array/test.cfg b/testsuite/c_test/sanity_test/SANITY0018-sum_array/test.cfg new file mode 100644 index 0000000000..84e6ee6492 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0018-sum_array/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(sum_array) +run(sum_array) diff --git a/testsuite/c_test/sanity_test/SANITY0019-sum/sum.c b/testsuite/c_test/sanity_test/SANITY0019-sum/sum.c new file mode 100644 index 0000000000..d49699cfd2 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0019-sum/sum.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include +#include + +int main(int argc, char *argv[]) { + int sum = 0; + + for (int i = 0; i < 10; i++) { + sum += i; + } + + if (sum != 45) { + abort(); + } + + return 0; +} diff --git a/testsuite/c_test/sanity_test/SANITY0019-sum/test.cfg b/testsuite/c_test/sanity_test/SANITY0019-sum/test.cfg new file mode 100644 index 0000000000..79040ddf01 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0019-sum/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(sum) +run(sum) diff --git a/testsuite/c_test/sanity_test/SANITY0020-vararg2/test.cfg b/testsuite/c_test/sanity_test/SANITY0020-vararg2/test.cfg new file mode 100644 index 0000000000..a6dd1c5911 --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0020-vararg2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(vararg2) +run(vararg2) diff --git a/testsuite/c_test/sanity_test/SANITY0020-vararg2/vararg2.c b/testsuite/c_test/sanity_test/SANITY0020-vararg2/vararg2.c new file mode 100644 index 0000000000..eb0fcd53dd --- /dev/null +++ b/testsuite/c_test/sanity_test/SANITY0020-vararg2/vararg2.c @@ -0,0 +1,36 @@ +/* + * Copyright (C) [2020] Futurewei Technologies, Inc. All rights reverved. + * + * Licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +#include + +static double f (float a, ...); +static double (*fp) (float a, ...); + +main () { + fp = f; + if (fp ((float) 1, (double)2) != 3.0) { + abort (); + } + exit (0); +} + +static double +f (float a, ...) { + va_list ap; + + va_start(ap, a); + float i = va_arg(ap, double); + return (double)a + i; +} -- Gitee From 7b05bc3540b89a4899d7d5330380c9e2832f5ebe Mon Sep 17 00:00:00 2001 From: fuqun Date: Tue, 16 Mar 2021 16:47:56 +0800 Subject: [PATCH 2/2] delete log file --- testsuite/c_test/log | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 testsuite/c_test/log diff --git a/testsuite/c_test/log b/testsuite/c_test/log deleted file mode 100644 index 00584468fa..0000000000 --- a/testsuite/c_test/log +++ /dev/null @@ -1,25 +0,0 @@ -+ CURRDIR=/home/fuqun/OpenArkCompiler/test/c_test/sanity -++ realpath --relative-to=/home/fuqun/OpenArkCompiler /home/fuqun/OpenArkCompiler/test/c_test/sanity -+ rel=test/c_test/sanity -+ dir=. -+ src=array_single -+ opt=0 -+ '[' 4 -le 3 ']' -+ verbose=0 -+ WORKDIR=/home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl -+ mkdir -p /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl -+ cp ./array_single.c /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl -+ cd /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/test/c_test/sanity/./aarch64_with_whirl2mpl -++ cd /usr/lib/gcc-cross/aarch64-linux-gnu/ -++ ls -++ head -1 -+ V=5 -+ FLAGS='-cc1 -emit-llvm -triple aarch64-linux-gnu -D__clang__ -D__BLOCKS__ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/5/include' -+ /home/fuqun/OpenArkCompiler/tools/open64_prebuilt/x86/aarch64/bin/clangfe -cc1 -emit-llvm -triple aarch64-linux-gnu -D__clang__ -D__BLOCKS__ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/5/include array_single.c -+ /home/fuqun/OpenArkCompiler/tools/open64_prebuilt/x86/aarch64/bin/whirl2mpl -a array_single.B -+ '[' 0 -eq 0 ']' -+ /home/fuqun/OpenArkCompiler/output/aarch64-clang-release/bin/maple --run=mplcg --option=-quiet array_single.mpl -+ /usr/bin/aarch64-linux-gnu-gcc-5 -o array_single.out array_single.s -+ qemu-aarch64 -L /usr/aarch64-linux-gnu/ array_single.out -+ cat cmd.log -+ '[' 0 -eq 1 ']' -- Gitee