diff options
| author | Xi Wang <xi.wang@gmail.com> | 2013-05-17 03:05:59 -0400 |
|---|---|---|
| committer | Pekka Enberg <penberg@kernel.org> | 2013-05-18 10:34:01 +0300 |
| commit | b17550b274916fc5a4b6f89a3f95572e6f9bce7f (patch) | |
| tree | 5a594693eb8017da2da1fc471f26b5847be02684 /validation/backend | |
| parent | 0448f78f5fae84b8a9c1358129a03ea24e593b34 (diff) | |
| download | sparse-dev-b17550b274916fc5a4b6f89a3f95572e6f9bce7f.tar.gz | |
sparse, llvm: simplify function generation
Remove repeated code, such as get_func_type() vs sym_func_type(),
pseudo_type() vs symbol_type().
Fix generating variadic functions.
Add a test case using printf().
Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'validation/backend')
| -rw-r--r-- | validation/backend/sum.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/validation/backend/sum.c b/validation/backend/sum.c new file mode 100644 index 00000000..c9451d4b --- /dev/null +++ b/validation/backend/sum.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> + +static int sum(int n) +{ + int i, result = 0; + + for (i = 1; i <= n; ++i) + result += i; + return result; +} + +int main(int argc, char **argv) +{ + printf("%d\n", sum(5)); + printf("%d\n", sum(100)); + return 0; +} + +/* + * check-name: sum from 1 to n + * check-command: ./sparsei $file + * + * check-output-start +15 +5050 + * check-output-end + */ |
