PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / c-c++-common / attr-nonstring-1.c
blob10a66887fa2ddc78de8571723e19b660b5730994
1 /* Test to exercise attribute "nonstring" syntax.
2 { dg-do compile }
3 { dg-options "-Wattributes" } */
5 #define ATTR(list) __attribute__ (list)
6 #define NONSTR ATTR ((nonstring))
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;
13 extern NONSTR char ns1[1];
14 extern char NONSTR ns3[3];
15 extern char ns5[5] NONSTR;
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;
22 struct S
24 /* Verify it's accepted on char member pointers. */
25 NONSTR char* mpns_1;
26 char NONSTR* mpns_2;
27 char* NONSTR mpns_3;
29 /* Verify it's accepted on char member arrays. */
30 NONSTR char mns1[1];
31 char NONSTR mns3[3];
32 char mns5[5] NONSTR;
34 /* Verify it's accepted on char flexible array members. */
35 char mnsx[] NONSTR;
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." } */
41 extern NONSTR int i1; /* { dg-warning ".nonstring. attribute ignored on objects of type .int." } */
43 extern NONSTR int ia1[]; /* { dg-warning ".nonstring. attribute ignored on objects of type .int *\\\[\\\]." } */
45 extern NONSTR int* pi1; /* { dg-warning ".nonstring. attribute ignored on objects of type .int *\\*." } */
47 extern NONSTR
48 void f (void); /* { dg-warning ".nonstring. attribute does not apply to functions" } */
50 struct NONSTR
51 NonStrType { int i; }; /* { dg-warning ".nonstring. attribute does not apply to types" } */
53 typedef char NONSTR nschar_t; /* { dg-warning ".nonstring. attribute does not apply to types" } */
55 void func (NONSTR char *pns1, char NONSTR *pns2, char* NONSTR pns3)
57 (void)pns1;
58 (void)pns2;
59 (void)pns3;