diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-04-06 15:30:34 +0100 |
---|---|---|
committer | MartinNowack <2443641+MartinNowack@users.noreply.github.com> | 2020-06-19 18:19:53 +0100 |
commit | 623d7149dc629af9c8a85fe5d3f841d9deed2192 (patch) | |
tree | b362b409ce97c36d3d650498ff0b09a2f41d8662 | |
parent | 88b44f7bfaa028863f63de0ecd0443bcba585d30 (diff) | |
download | klee-623d7149dc629af9c8a85fe5d3f841d9deed2192.tar.gz |
Added test reported in https://github.com/klee/klee/issues/189 for byval variadic arguments
-rw-r--r-- | test/Feature/VarArgByValReported.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/Feature/VarArgByValReported.c b/test/Feature/VarArgByValReported.c new file mode 100644 index 00000000..bf2ad374 --- /dev/null +++ b/test/Feature/VarArgByValReported.c @@ -0,0 +1,42 @@ +/* This is the test reported in + https://github.com/klee/klee/issues/189, checking the correctness + of variadic arguments passed with the byval attribute */ + +// RUN: %clang %s -emit-llvm %O0opt -c -g -o %t1.bc +// RUN: rm -rf %t.klee-out +// RUN: %klee --exit-on-error --output-dir=%t.klee-out %t1.bc | FileCheck %s + +#include <stdarg.h> +#include <assert.h> +#include <stdio.h> + +struct triple { + int first, second, third; +}; + +struct mix { + long long int first; + char second; +}; + +int test(int x, ...) { + va_list ap; + va_start(ap, x); + int i1 = va_arg(ap, int); + int i2 = va_arg(ap, int); + int i3 = va_arg(ap, int); + struct triple p = va_arg(ap, struct triple); + struct mix m = va_arg(ap, struct mix); + printf("types: (%d, %d, %d, (%d,%d,%d), (%lld,%d))\n", + i1, i2, i3, p.first, p.second, p.third, m.first, m.second); + // CHECK: types: (1, 2, 3, (9,12,15), (7,8)) + va_end(ap); +} + +int main() { + struct triple p = { 9, 12, 15 }; + struct mix m = { 7, 8 }; + test(-1, 1, 2, 3, p, m); + + return 0; +} |