1 /* PR c/71924 - missing -Wreturn-local-addr returning alloca result
3 { dg-options "-O2 -Wall" }
4 { dg-require-effective-target alloca } */
6 typedef __SIZE_TYPE__
size_t;
8 void* memcpy (void*, const void*, size_t);
9 void* mempcpy (void*, const void*, size_t);
10 void* memmove (void*, const void*, size_t);
12 char* stpcpy (char*, const char*);
13 char* stpncpy (char*, const char*, size_t);
15 size_t strlen (const char*);
16 size_t strnlen (const char*, size_t);
18 char* strcat (char*, const char*);
19 char* strncat (char*, const char*, size_t);
21 char* strcpy (char*, const char*);
22 char* strncpy (char*, const char*, size_t);
24 char* strdup (const char*);
26 char* strchr (const char*, int);
27 char* strrchr (const char*, int);
28 char* strstr (const char*, const char*);
30 void sink (void*, ...);
33 void* return_memcpy (const void *s
, unsigned n
)
35 char a
[n
]; /* { dg-message "declared here" } */
36 void *p
= memcpy (a
, s
, n
);
38 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
41 void* return_memcpy_cst (const void *s
, unsigned n
)
43 char a
[n
]; /* { dg-message "declared here" } */
44 void *p
= memcpy (a
+ 1, s
, n
);
46 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
49 void* return_memcpy_var (const void *s
, unsigned n
, int i
)
51 char a
[n
]; /* { dg-message "declared here" } */
52 void *p
= memcpy (a
+ i
, s
, n
);
54 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
57 void* return_mempcpy (const void *s
, unsigned n
)
59 char a
[n
]; /* { dg-message "declared here" } */
60 void *p
= mempcpy (a
, s
, n
);
62 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
65 void* return_memmove_cst (unsigned n
)
67 char a
[n
]; /* { dg-message "declared here" } */
69 void *p
= memmove (a
+ 1, a
, n
);
71 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
74 void* return_memmove_var (unsigned n
, int i
)
76 char a
[n
]; /* { dg-message "declared here" } */
78 void *p
= memmove (a
+ i
, a
, n
);
80 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
83 char* return_stpcpy (unsigned n
, const char *s
)
85 char a
[n
]; /* { dg-message "declared here" } */
86 char *p
= stpcpy (a
, s
);
88 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
91 char* return_stpncpy (unsigned n
, const char *s
)
93 char a
[n
]; /* { dg-message "declared here" } */
94 char *p
= stpncpy (a
, s
, n
);
96 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
99 char* return_strcat (unsigned n
, const char *s
)
101 char a
[n
]; /* { dg-message "declared here" } */
103 char *p
= strcat (a
, s
);
105 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
108 char* return_strncat (unsigned n
, const char *s
)
110 char a
[n
]; /* { dg-message "declared here" } */
112 char *p
= strncat (a
, s
, n
);
114 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
117 char* return_strcpy (unsigned n
, const char *s
)
119 char a
[n
]; /* { dg-message "declared here" } */
120 char *p
= strcpy (a
, s
);
122 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
125 char* return_strcpy_plus_strlen (unsigned n
, const char *s
)
127 char a
[n
]; /* { dg-message "declared here" } */
128 char *p
= strcpy (a
, s
);
131 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
134 char* return_strcpy_cst_plus_strlen (unsigned n
, const char *s
)
136 char a
[n
]; /* { dg-message "declared here" } */
138 char *p
= strcpy (a
+ 1, s
);
141 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
144 char* return_strcpy_var_plus_strlen (unsigned n
, const char *s
, int i
)
146 char a
[n
]; /* { dg-message "declared here" } */
148 char *p
= strcpy (a
+ i
, s
);
151 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
154 char* return_strncpy (unsigned n
, const char *s
)
156 char a
[n
]; /* { dg-message "declared here" } */
157 char *p
= strncpy (a
, s
, n
);
159 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
162 char* return_strncpy_plus_strnlen (unsigned n
, const char *s
)
164 char a
[n
]; /* { dg-message "declared here" } */
165 char *p
= strncpy (a
, s
, n
);
168 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
171 char* return_strdup (unsigned n
)
175 char *p
= strdup (a
);
179 char* return_strchr (unsigned n
, int c
)
181 char a
[n
]; /* { dg-message "declared here" } */
183 char *p
= strchr (a
, c
);
184 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
187 char* return_strstr (unsigned n
, const char *s
)
189 char a
[n
]; /* { dg-message "declared here" } */
191 char *p
= strstr (a
, s
);
194 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */
197 char* return_strrchr (unsigned n
, int c
)
199 char a
[n
]; /* { dg-message "declared here" } */
201 char *p
= strrchr (a
, c
);
202 return p
; /* { dg-warning "\\\[-Wreturn-local-addr]" } */