| 1 |
// Test to verify that attributes on distinct overloads of a function |
| 2 |
// with the same name are properly looked up and applied. |
| 3 |
// { dg-do compile } |
| 4 |
// { dg-options "-Wall" } |
| 5 |
|
| 6 |
int |
| 7 |
foo (int); |
| 8 |
|
| 9 |
int __attribute__ ((noreturn)) |
| 10 |
foo (int, int); |
| 11 |
|
| 12 |
int __attribute__ ((warn_unused_result)) |
| 13 |
foo (int, int, int); |
| 14 |
|
| 15 |
int call_foo_1 () |
| 16 |
{ |
| 17 |
foo (1); |
| 18 |
} // { dg-warning "\\\[-Wreturn-type]" } |
| 19 |
|
| 20 |
int call_foo_2 () |
| 21 |
{ |
| 22 |
foo (1, 2); |
| 23 |
} |
| 24 |
|
| 25 |
int call_foo_3 () |
| 26 |
{ |
| 27 |
foo (1, 2, 3); // { dg-warning "\\\[-Wunused-result]" } |
| 28 |
} // { dg-warning "\\\[-Wreturn-type]" } |
| 29 |
|
| 30 |
int call_foo_4 () |
| 31 |
{ |
| 32 |
// Make sure an error doesn't trigger bogus warnings or an ICE. |
| 33 |
foo (1, 2, 3, 4); // { dg-error "no matching function" } |
| 34 |
return 0; |
| 35 |
} |