1 /* PR middle-end/83131 - c-c++/common/attr-nonstring-3 failure for strcmp
4 { dg-options "-O2 -Wstringop-overflow -ftrack-macro-expansion=0" } */
10 typedef __SIZE_TYPE__
size_t;
12 extern int strcmp (const char*, const char*);
13 extern int strncmp (const char*, const char*, size_t);
19 extern char arx
[] __attribute__ ((nonstring
));
20 extern char ar5
[5] __attribute__ ((nonstring
));
23 enum { N
= sizeof ar5
};
24 enum { X
= sizeof ar5
+ 1 };
27 int warn_strcmp_cst_1 (void)
29 return strcmp ("bar", arx
); /* { dg-warning "argument 2 declared attribute .nonstring." } */
32 int warn_strcmp_cst_2 (void)
34 return strcmp (arx
, "foo"); /* { dg-warning "argument 1 declared attribute .nonstring." } */
38 int warn_strncmp_cst_1 (void)
40 return strncmp ("bar", ar5
, X
); /* { dg-warning "argument 2 declared attribute .nonstring." } */
43 int warn_strncmp_cst_2 (void)
45 return strncmp (ar5
, "foo", X
); /* { dg-warning "argument 1 declared attribute .nonstring." } */
49 int nowarn_strncmp_cst_1 (void)
51 return strncmp ("bar", ar5
, N
);
54 int nowarn_strncmp_cst_2 (void)
56 return strncmp (ar5
, "foo", N
);
60 int warn_strncmp_var_1 (void)
62 return strncmp (str
, ar5
, X
); /* { dg-warning "argument 2 declared attribute .nonstring." } */
65 int warn_strncmp_var_2 (void)
67 return strncmp (ar5
, str
, X
); /* { dg-warning "argument 1 declared attribute .nonstring." } */
71 int nowarn_strncmp_var_1 (void)
73 return strncmp (str
, ar5
, N
);
76 int nowarn_strncmp_var_2 (void)
78 return strncmp (ar5
, str
, N
);