1 /* PR middle-end/93926 - ICE on a built-in redeclaration returning an integer
2    instead of a pointer
3    { dg-do compile }
4    { dg-options "-Wall" } */
5 
6 typedef __SIZE_TYPE__ size_t;
7 
ret_calloc(size_t n1,size_t n2)8 void* ret_calloc (size_t n1, size_t n2)
9 {
10   extern size_t calloc (size_t, size_t);    // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
11 
12   return (void *) calloc (n1, n2);
13 }
14 
ret_malloc(size_t n)15 void* ret_malloc (size_t n)
16 {
17   extern size_t malloc (size_t);            // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
18 
19   return (void *) malloc (n);
20 }
21 
ret_realloc(void * p,size_t n)22 void* ret_realloc (void *p, size_t n)
23 {
24   extern size_t realloc (void *p, size_t);  // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
25 
26   return (void *) realloc (p, n);
27 }
28 
ret_strdup(const char * s)29 void* ret_strdup (const char *s)
30 {
31   extern size_t strdup (const char*);       // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
32 
33   return (void *) strdup (s);
34 }
35 
ret_strndup(const char * s,size_t n)36 void* ret_strndup (const char *s, size_t n)
37 {
38   extern size_t
39     strndup (const char*, size_t);          // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
40 
41   return (void *) strndup (s, n);
42 }
43 
44 // For good measure also exerise strcmp return type (not part of the bug).
45 
ret_strcmp(const char * s,const char * t)46 char* ret_strcmp (const char *s, const char *t)
47 {
48   extern char*
49     strcmp (const char*, const char*);      // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
50 
51   return strcmp (s, t);
52 }
53 
54 // Exercise warnings for pointer/integer mismatches in argument types
55 // (also not part of the bug).
56 
ret_strcat(size_t s,const char * t)57 char* ret_strcat (size_t s, const char *t)
58 {
59   extern char*
60     strcat (size_t, const char*);           // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
61 
62   return strcat (s, t);
63 }
64 
ret_strcpy(char * s,size_t t)65 char* ret_strcpy (char *s, size_t t)
66 {
67   extern char* strcpy (char*, size_t);      // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
68 
69   return strcpy (s, t);
70 }
71 
ret_strncpy(char * s,const char * t,size_t n)72 char* ret_strncpy (char *s, const char *t, size_t n)
73 {
74   extern char*
75     strncpy (char*, size_t, const char*);   // { dg-warning "\\\[-Wbuiltin-declaration-mismatch" }
76 
77   return strncpy (s, n, t);
78 }
79