From b369f9225bfcf59361c986c8b7fbbacb420cb936 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sun, 9 Feb 2020 21:56:57 +0100 Subject: inline: add some tests Signed-off-by: Luc Van Oostenryck --- validation/expand/builtin_constant_inline0.c | 24 ++++++++++++++ validation/expand/builtin_constant_inline1.c | 24 ++++++++++++++ validation/inline_base0.c | 47 ++++++++++++++++++++++++++++ validation/inline_self.c | 13 ++++++++ 4 files changed, 108 insertions(+) create mode 100644 validation/expand/builtin_constant_inline0.c create mode 100644 validation/expand/builtin_constant_inline1.c create mode 100644 validation/inline_base0.c create mode 100644 validation/inline_self.c 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: + + 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: + + 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: + + add.32 %r5 <- %arg1, %arg2 + ret.32 %r5 + + +foo1: +.L3: + + add.32 %r10 <- %arg1, $1 + ret.32 %r10 + + +foo2: +.L6: + + 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 + */ -- cgit 1.2.3-korg