Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* { dg-options "-fdiagnostics-show-caret -Wreturn-local-addr" } */ | |
2 | |
3 int *address_of_local (void) | |
4 { | |
5 int some_local; | |
6 return &some_local; /* { dg-warning "function returns address of local variable" } */ | |
7 /* { dg-begin-multiline-output "" } | |
8 return &some_local; | |
9 ^~~~~~~~~~~ | |
10 { dg-end-multiline-output "" } */ | |
11 } | |
12 | |
13 void surplus_return_when_void_1 (void) | |
14 { | |
15 return 500; /* { dg-warning "'return' with a value, in function returning void" } */ | |
16 /* { dg-begin-multiline-output "" } | |
17 return 500; | |
18 ^~~ | |
19 { dg-end-multiline-output "" } */ | |
20 /* { dg-begin-multiline-output "" } | |
21 void surplus_return_when_void_1 (void) | |
22 ^~~~~~~~~~~~~~~~~~~~~~~~~~ | |
23 { dg-end-multiline-output "" } */ | |
24 } | |
25 | |
26 void surplus_return_when_void_2 (int i, int j) | |
27 { | |
28 return i * j; /* { dg-warning "'return' with a value, in function returning void" } */ | |
29 /* { dg-begin-multiline-output "" } | |
30 return i * j; | |
31 ~~^~~ | |
32 { dg-end-multiline-output "" } */ | |
33 /* { dg-begin-multiline-output "" } | |
34 void surplus_return_when_void_2 (int i, int j) | |
35 ^~~~~~~~~~~~~~~~~~~~~~~~~~ | |
36 { dg-end-multiline-output "" } */ | |
37 } | |
38 | |
39 int missing_return_value (void) | |
40 { | |
41 return; /* { dg-warning "'return' with no value, in function returning non-void" } */ | |
42 /* { dg-begin-multiline-output "" } | |
43 return; | |
44 ^~~~~~ | |
45 { dg-end-multiline-output "" } */ | |
46 /* { dg-begin-multiline-output "" } | |
47 int missing_return_value (void) | |
48 ^~~~~~~~~~~~~~~~~~~~ | |
49 { dg-end-multiline-output "" } */ | |
50 /* TODO: ideally we'd underline the return type i.e. "int", but that | |
51 location isn't captured. */ | |
52 } |