Skip to content

Commit e501317

Browse files
committed
Additional regression tests for always_inline
The previous attempt of implementing support for always_inline broke each of those in different ways.
1 parent 17a50c5 commit e501317

File tree

22 files changed

+270
-0
lines changed

22 files changed

+270
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
return val;
4+
}
5+
6+
static inline int func2(int *p)
7+
{
8+
// the typecast, although redundant, is essential to show the problem
9+
return func(*(int*)p);
10+
}
11+
12+
int main()
13+
{
14+
int x;
15+
return func2(&x);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
if(val > 0)
4+
return func(val - 1);
5+
return 0;
6+
}
7+
8+
int main()
9+
{
10+
int x;
11+
return func(x);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
extern int func_alias(int val) __asm__("" "func");
2+
3+
static inline __attribute__((__always_inline__)) int func(int val)
4+
{
5+
if(val > 0)
6+
return func_alias(val - 1);
7+
return 0;
8+
}
9+
10+
int main()
11+
{
12+
int x;
13+
return func(x);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
static inline
2+
__attribute__((__section__(".init"))) __attribute__((__always_inline__))
3+
int func(int val)
4+
{
5+
return val + 1;
6+
}
7+
8+
int main()
9+
{
10+
int x;
11+
return func(x);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
static inline __attribute__((__always_inline__)) int func(int val, ...)
2+
{
3+
return val + 1;
4+
}
5+
6+
int main()
7+
{
8+
int x;
9+
return func(x, x);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
int local = val;
4+
return local;
5+
}
6+
7+
int main()
8+
{
9+
int x;
10+
return func(x);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
return (__typeof__(val))42;
4+
}
5+
6+
int main()
7+
{
8+
int x;
9+
return func(x);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
static inline __attribute__((__always_inline__)) int func(int val)
2+
{
3+
val = val + 1;
4+
return val;
5+
}
6+
7+
int main()
8+
{
9+
int x;
10+
return func(x);
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE gcc-only
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

regression/cbmc/always_inline1/main.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <assert.h>
2+
3+
#ifndef __GNUC__
4+
#define __attribute__(x)
5+
#endif
6+
7+
static inline __attribute__((__always_inline__)) void func(int *val)
8+
{
9+
*val = 1;
10+
return;
11+
}
12+
13+
static inline int func2(int *p)
14+
{
15+
func(p);
16+
return *p;
17+
}
18+
19+
int main()
20+
{
21+
int x;
22+
assert(func2(&x) == 1);
23+
return 0;
24+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/always_inline2/main.c

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <assert.h>
2+
3+
#ifndef __GNUC__
4+
#define __attribute__(x)
5+
#endif
6+
7+
static inline __attribute__((__always_inline__)) int func(int *val)
8+
{
9+
switch(*val)
10+
{
11+
case 1:
12+
return *val + 1;
13+
case 2:
14+
return *val + 2;
15+
}
16+
17+
return *val;
18+
}
19+
20+
static inline int func2(int *p)
21+
{
22+
return func(p);
23+
}
24+
25+
int main()
26+
{
27+
int x = 1;
28+
assert(func2(&x) == 2);
29+
return 0;
30+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/always_inline3/main.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <assert.h>
2+
3+
#ifndef __GNUC__
4+
#define __attribute__(x)
5+
#endif
6+
7+
static inline __attribute__((__always_inline__)) void func(int *val)
8+
{
9+
if(*val < 0)
10+
{
11+
*val = 1;
12+
return;
13+
}
14+
else
15+
{
16+
*val = 1;
17+
return;
18+
}
19+
}
20+
21+
static inline int func2(int *p)
22+
{
23+
func(p);
24+
return *p;
25+
}
26+
27+
int main()
28+
{
29+
int x;
30+
assert(func2(&x) == 1);
31+
return 0;
32+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)