* gcc.dg/stack-check-5.c: Skip with -fstack-protector.
[official-gcc.git] / gcc / testsuite / gcc.dg / diagnostic-range-bad-return.c
blob063fdf1f6360b38177691836e519c6fbad521be6
1 /* { dg-options "-fdiagnostics-show-caret -Wreturn-local-addr" } */
3 int *address_of_local (void)
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 "" } */
13 void surplus_return_when_void_1 (void)
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 "" } */
26 void surplus_return_when_void_2 (int i, int j)
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 "" } */
39 int missing_return_value (void)
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. */