blob: 988d706d5cd7e2f1ed0d5c6ba4923daa9f2e578e (
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
|
// missing-return.slang
//DIAGNOSTIC_TEST:SIMPLE:
// Non-`void` function that fails to return
int bad(int a, int b)
{
int result = a + b;
// forgot `return` here
}
int alsoBad(int a, int b)
{
if(a > b)
{
return a + b;
}
// forgot `return` here
}
int okay(int a, int b)
{
int tmp = a;
for(;;)
{
if(a > b)
return tmp;
a = b;
b = tmp;
tmp = a + b;
}
// Lack of `return` here is not
// a problem, because we can never
// actually get here
}
int alsoOkay(int a, int b)
{
int tmp = a;
while(true)
{
if(a > b)
return tmp;
a = b;
b = tmp;
tmp = a + b;
}
// Lack of `return` here is not
// a problem, because we can never
// actually get here
}
|