| 1 |
/* PR middle-end/81824 - Warn for missing attributes with function aliases |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-require-ifunc "" } |
| 4 |
{ dg-options "-Wall -Wattribute-alias=2" } */ |
| 5 |
|
| 6 |
#define ATTR(...) __attribute__ ((__VA_ARGS__)) |
| 7 |
|
| 8 |
|
| 9 |
void |
| 10 |
target_no_nothrow (void) /* { dg-message ".alias_nothrow. target declared here" } */ |
| 11 |
{ } |
| 12 |
|
| 13 |
ATTR (alias ("target_no_nothrow"), nothrow) void |
| 14 |
alias_nothrow (void); /* { dg-warning ".alias_nothrow. specifies more restrictive attribute than its target .target_no_nothrow.: .nothrow." } */ |
| 15 |
|
| 16 |
|
| 17 |
#pragma GCC diagnostic push "-Wattribute-alias" |
| 18 |
#pragma GCC diagnostic ignored "-Wattribute-alias" |
| 19 |
ATTR (alias ("target_no_nothrow"), nothrow) void |
| 20 |
alias_nothrow_ignored (void); |
| 21 |
#pragma GCC diagnostic pop "-Wattribute-alias" |
| 22 |
|
| 23 |
|
| 24 |
ATTR (pure) int |
| 25 |
alias_pure (void); |
| 26 |
|
| 27 |
int |
| 28 |
target_no_pure (void) /* { dg-message ".alias_pure. target declared here" } */ |
| 29 |
{ return 0; } |
| 30 |
|
| 31 |
ATTR (alias ("target_no_pure")) int |
| 32 |
alias_pure (void); /* { dg-warning ".alias_pure. specifies more restrictive attribute than its target .target_no_pure.: .pure." } */ |
| 33 |
|
| 34 |
|
| 35 |
ATTR (const) int |
| 36 |
alias_const (void); |
| 37 |
|
| 38 |
int |
| 39 |
target_pure (void) /* { dg-message ".alias_const. target declared here" } */ |
| 40 |
{ return 0; } |
| 41 |
|
| 42 |
ATTR (alias ("target_pure")) int |
| 43 |
alias_const (void); /* { dg-warning ".alias_const. specifies more restrictive attribute than its target .target_pure.: .const." } */ |
| 44 |
|
| 45 |
|
| 46 |
/* There is no obvious relationship between the attributes on an ifunc |
| 47 |
resolver and those on its aliases. Verify that mismatches between |
| 48 |
aliases and ifunc resolvers do not trigger warnings. */ |
| 49 |
|
| 50 |
typedef int F (void); |
| 51 |
|
| 52 |
ATTR (pure, leaf) F* resolve_to_const (void) |
| 53 |
{ return alias_const; } |
| 54 |
|
| 55 |
ATTR (ifunc ("resolve_to_const")) F alias_no_const_ifunc; |
| 56 |
ATTR (const, ifunc ("resolve_to_const")) F alias_const_ifunc; |
| 57 |
ATTR (ifunc ("resolve_to_const")) int alias_no_leaf_ifunc (void); |