| 1 |
/* Test to exercise attribute "nonstring" syntax. |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-Wattributes" } */ |
| 4 |
|
| 5 |
#define ATTR(list) __attribute__ (list) |
| 6 |
#define NONSTR ATTR ((nonstring)) |
| 7 |
|
| 8 |
/* Verify it's accepted on char arrays. */ |
| 9 |
extern NONSTR char nsx_1[]; |
| 10 |
extern char NONSTR nsx_2[]; |
| 11 |
extern char nsx_3[] NONSTR; |
| 12 |
|
| 13 |
extern NONSTR char ns1[1]; |
| 14 |
extern char NONSTR ns3[3]; |
| 15 |
extern char ns5[5] NONSTR; |
| 16 |
|
| 17 |
/* Verify it's accepted on char pointers. */ |
| 18 |
extern NONSTR char* pns_1; |
| 19 |
extern char NONSTR* pns_2; |
| 20 |
extern char* NONSTR pns_3; |
| 21 |
|
| 22 |
struct S |
| 23 |
{ |
| 24 |
/* Verify it's accepted on char member pointers. */ |
| 25 |
NONSTR char* mpns_1; |
| 26 |
char NONSTR* mpns_2; |
| 27 |
char* NONSTR mpns_3; |
| 28 |
|
| 29 |
/* Verify it's accepted on char member arrays. */ |
| 30 |
NONSTR char mns1[1]; |
| 31 |
char NONSTR mns3[3]; |
| 32 |
char mns5[5] NONSTR; |
| 33 |
|
| 34 |
/* Verify it's accepted on char flexible array members. */ |
| 35 |
char mnsx[] NONSTR; |
| 36 |
}; |
| 37 |
|
| 38 |
/* Verify it's rejected on non-array and non-pointer objects. */ |
| 39 |
extern NONSTR char c1; /* { dg-warning ".nonstring. attribute ignored on objects of type .char." } */ |
| 40 |
|
| 41 |
extern NONSTR int i1; /* { dg-warning ".nonstring. attribute ignored on objects of type .int." } */ |
| 42 |
|
| 43 |
extern NONSTR int ia1[]; /* { dg-warning ".nonstring. attribute ignored on objects of type .int *\\\[\\\]." } */ |
| 44 |
|
| 45 |
extern NONSTR int* pi1; /* { dg-warning ".nonstring. attribute ignored on objects of type .int *\\*." } */ |
| 46 |
|
| 47 |
extern NONSTR |
| 48 |
void f (void); /* { dg-warning ".nonstring. attribute does not apply to functions" } */ |
| 49 |
|
| 50 |
struct NONSTR |
| 51 |
NonStrType { int i; }; /* { dg-warning ".nonstring. attribute does not apply to types" } */ |
| 52 |
|
| 53 |
typedef char NONSTR nschar_t; /* { dg-warning ".nonstring. attribute does not apply to types" } */ |
| 54 |
|
| 55 |
void func (NONSTR char *pns1, char NONSTR *pns2, char* NONSTR pns3) |
| 56 |
{ |
| 57 |
(void)pns1; |
| 58 |
(void)pns2; |
| 59 |
(void)pns3; |
| 60 |
} |