diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-02-16 16:55:08 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-02-17 18:38:50 +0100 |
| commit | d7529936fa7dfdff32885b3a96473883e6b70fa3 (patch) | |
| tree | 31132d586618fc2cfb9f57f723972dca883d96b0 /validation/expand | |
| parent | 3e3526ff478e9abf8feb78cac84b4a0f23b8e572 (diff) | |
| download | sparse-dev-d7529936fa7dfdff32885b3a96473883e6b70fa3.tar.gz | |
builtin: add testcases for expansion of FP classification
__builtin_isinf(), isnan() & isnormal() are all special cases
of __builtin_fpclassify().
Add a few cases testing if those are correctly expanded if
when the argument is a constant.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/expand')
| -rw-r--r-- | validation/expand/builtin_fpclassify.c | 26 | ||||
| -rw-r--r-- | validation/expand/builtin_isinf.c | 20 | ||||
| -rw-r--r-- | validation/expand/builtin_isnan.c | 20 | ||||
| -rw-r--r-- | validation/expand/builtin_isnormal.c | 20 |
4 files changed, 86 insertions, 0 deletions
diff --git a/validation/expand/builtin_fpclassify.c b/validation/expand/builtin_fpclassify.c new file mode 100644 index 00000000..506927dd --- /dev/null +++ b/validation/expand/builtin_fpclassify.c @@ -0,0 +1,26 @@ +enum { FP_NAN, FP_INF, FP_NOR, FP_SUB, FP_ZERO }; + +#define classify(X) __builtin_fpclassify(FP_NAN,FP_INF,FP_NOR,FP_SUB,FP_ZERO,X) + +int test(void) +{ + if (classify(__builtin_nan("0")) != FP_NAN) + return 0; + if (classify(__builtin_inf("0")) != FP_INF) + return 0; + if (classify(1.0) != FP_NOR) + return 0; + if (classify(0.0) != FP_ZERO) + return 0; + + return 1; +} + +/* + * check-name: builtin_fpclassify + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$1 + */ diff --git a/validation/expand/builtin_isinf.c b/validation/expand/builtin_isinf.c new file mode 100644 index 00000000..36b20a60 --- /dev/null +++ b/validation/expand/builtin_isinf.c @@ -0,0 +1,20 @@ +int test(void) +{ + if (!__builtin_isinf(__builtin_inff())) + return 0; + if (!__builtin_isinf(__builtin_inf())) + return 0; + if (!__builtin_isinf(__builtin_infl())) + return 0; + + return 1; +} + +/* + * check-name: builtin_isinf expand + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$1 + */ diff --git a/validation/expand/builtin_isnan.c b/validation/expand/builtin_isnan.c new file mode 100644 index 00000000..07c7e5e5 --- /dev/null +++ b/validation/expand/builtin_isnan.c @@ -0,0 +1,20 @@ +int test(void) +{ + if (!__builtin_isnan(__builtin_nanf("0"))) + return 0; + if (!__builtin_isnan(__builtin_nan("0"))) + return 0; + if (!__builtin_isnan(__builtin_nanl("0"))) + return 0; + + return 1; +} + +/* + * check-name: builtin_isnan expand + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$1 + */ diff --git a/validation/expand/builtin_isnormal.c b/validation/expand/builtin_isnormal.c new file mode 100644 index 00000000..0b69e273 --- /dev/null +++ b/validation/expand/builtin_isnormal.c @@ -0,0 +1,20 @@ +int test(void) +{ + if (!__builtin_isnormal(1.0F)) + return 0; + if (!__builtin_isnormal(1.0)) + return 0; + if (!__builtin_isnormal(1.0L)) + return 0; + + return 1; +} + +/* + * check-name: builtin_isnormal expand + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: ret\\..*\\$1 + */ |
