blob: 4d77c55fa4015881bd1b4690a0084d27ae4ebc51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/* bug 2188
Function miscompiled when inline selected
temporal variable for function return value
is forced to int type even that type is already
resolved because variable name is hidden in
the internal scope of inline function.
*/
#include <testfwk.h>
#include <stdint.h>
volatile int32_t glob_var32_a = 0x12345678;
volatile int32_t glob_var32_b = 0x0abcdef0;
inline
int32_t inline_fnc(char sel)
{
return sel? glob_var32_b: glob_var32_a;
}
int32_t notinlined_fnc(int32_t val)
{
return val;
}
inline
int32_t *inline_ptr_fnc(char sel)
{
return sel? &glob_var32_b: &glob_var32_a;
}
int32_t notinlined_ptr_fnc(int32_t *pval)
{
return *pval;
}
void
testBug (void)
{
#ifndef __SDCC_pdk14 // Lack of memory
int32_t var32 = notinlined_fnc(inline_fnc(0));
ASSERT(var32 == glob_var32_a);
var32 = notinlined_fnc(inline_fnc(1));
ASSERT(var32 == glob_var32_b);
var32 = notinlined_ptr_fnc(inline_ptr_fnc(0));
ASSERT(var32 == glob_var32_a);
var32 = notinlined_ptr_fnc(inline_ptr_fnc(1));
ASSERT(var32 == glob_var32_b);
#endif
}
extern inline
int32_t inline_fnc(char sel);
extern inline
int32_t *inline_ptr_fnc(char sel);
|