diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-02-09 21:56:57 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-02-09 23:55:56 +0100 |
commit | b369f9225bfcf59361c986c8b7fbbacb420cb936 (patch) | |
tree | 982e29ec15ee64fc4dd4cfd9097994a4b5dce379 | |
parent | 98276e6116f3bc34839519db3a1cccc78a2f0838 (diff) | |
download | sparse-b369f9225bfcf59361c986c8b7fbbacb420cb936.tar.gz |
inline: add some tests
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | validation/expand/builtin_constant_inline0.c | 24 | ||||
-rw-r--r-- | validation/expand/builtin_constant_inline1.c | 24 | ||||
-rw-r--r-- | validation/inline_base0.c | 47 | ||||
-rw-r--r-- | validation/inline_self.c | 13 |
4 files changed, 108 insertions, 0 deletions
diff --git a/validation/expand/builtin_constant_inline0.c b/validation/expand/builtin_constant_inline0.c new file mode 100644 index 00000000..9e775d5e --- /dev/null +++ b/validation/expand/builtin_constant_inline0.c @@ -0,0 +1,24 @@ +static inline int is_const(long size) +{ + return __builtin_constant_p(size) ? size : 0; +} + +int foo(void) +{ + return is_const(42); +} + +/* + * check-name: builtin_constant_inline0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-start +foo: +.L0: + <entry-point> + ret.32 $42 + + + * check-output-end + */ diff --git a/validation/expand/builtin_constant_inline1.c b/validation/expand/builtin_constant_inline1.c new file mode 100644 index 00000000..da08f960 --- /dev/null +++ b/validation/expand/builtin_constant_inline1.c @@ -0,0 +1,24 @@ +static inline void fun(void) { } + +#define EXPR ({ fun(); 42; }) + +int bar(void) +{ + // GCC doesn't consider EXPR as a constant + return __builtin_constant_p(EXPR); +} + +/* + * check-name: builtin_constant_inline1 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-start +bar: +.L0: + <entry-point> + ret.32 $0 + + + * check-output-end + */ diff --git a/validation/inline_base0.c b/validation/inline_base0.c new file mode 100644 index 00000000..517ee972 --- /dev/null +++ b/validation/inline_base0.c @@ -0,0 +1,47 @@ +static inline int add(int a, int b) +{ + return a + b; +} + +int foo0(int x, int y) +{ + return add(x, y); +} + +int foo1(int x) +{ + return add(x, 1); +} + +int foo2(void) +{ + return add(1, 2); +} + +/* + * check-name: inline_base0 + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +foo0: +.L0: + <entry-point> + add.32 %r5 <- %arg1, %arg2 + ret.32 %r5 + + +foo1: +.L3: + <entry-point> + add.32 %r10 <- %arg1, $1 + ret.32 %r10 + + +foo2: +.L6: + <entry-point> + ret.32 $3 + + + * check-output-end + */ diff --git a/validation/inline_self.c b/validation/inline_self.c new file mode 100644 index 00000000..14c2b0b2 --- /dev/null +++ b/validation/inline_self.c @@ -0,0 +1,13 @@ +static inline void foo(void) +{ + foo(); +} + +static void baz(void) +{ + foo(); +} + +/* + * check-name: inline_self + */ |