Wattributes-10.c: Add -fno-common option on hppa*-*-hpux*.
[official-gcc.git] / gcc / testsuite / c-c++-common / attr-nonstring-4.c
blob597bbb32c25d334d28f822943e5e11acc621e518
1 /* PR middle-end/83131 - c-c++/common/attr-nonstring-3 failure for strcmp
2 tests on PowerPC
3 { dg-do compile }
4 { dg-options "-O2 -Wstringop-overflow -ftrack-macro-expansion=0" } */
6 #if __cplusplus
7 extern "C" {
8 #endif
10 typedef __SIZE_TYPE__ size_t;
12 extern int strcmp (const char*, const char*);
13 extern int strncmp (const char*, const char*, size_t);
15 #if __cplusplus
16 } /* extern "C" */
17 #endif
19 extern char arx[] __attribute__ ((nonstring));
20 extern char ar5[5] __attribute__ ((nonstring));
21 extern char str[];
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 ("12345", ar5, X); /* { dg-warning "argument 2 declared attribute .nonstring." } */
43 int warn_strncmp_cst_2 (void)
45 return strncmp (ar5, "12345", X); /* { dg-warning "argument 1 declared attribute .nonstring." } */
49 int nowarn_strncmp_cst_1 (void)
51 return strncmp ("12345", ar5, N);
54 int nowarn_strncmp_cst_2 (void)
56 return strncmp (ar5, "12345", 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);