analyzer: enable taint state machine by default [PR103533]
[official-gcc.git] / gcc / testsuite / c-c++-common / builtins.c
blob527c77e7952e756abe7b73389bf1fb041df06b3d
1 /* Test to verify that calls to common built-in functions declared
2 with no prototype do not cause an ICE.
3 { dg-do compile }
4 { dg-options "-O2 -Wall -Wextra" }
5 { dg-additional-options "-fpermissive" { target c } }
6 { dg-prune-output "warning" }
7 { dg-require-effective-target alloca } */
9 typedef __SIZE_TYPE__ size_t;
11 #if __cplusplus
12 extern "C" {
14 #define NO_PROTO ...
15 #else
16 #define NO_PROTO /* empty */
17 #endif
19 /* Character classification built-ins from <ctype.h>. */
20 int isalpha (NO_PROTO);
21 int isalnum (NO_PROTO);
22 int isalpha (NO_PROTO);
23 int iscntrl (NO_PROTO);
24 int isdigit (NO_PROTO);
25 int isgraph (NO_PROTO);
26 int islower (NO_PROTO);
27 int isprint (NO_PROTO);
28 int ispunct (NO_PROTO);
29 int isspace (NO_PROTO);
30 int isupper (NO_PROTO);
31 int isxdigit (NO_PROTO);
32 int tolower (NO_PROTO);
33 int toupper (NO_PROTO);
35 /* Memory allocation built-ins from <stdlib.h>. */
36 void* alloca (NO_PROTO);
37 void* aligned_alloc (NO_PROTO);
38 void* calloc (NO_PROTO);
39 void* malloc (NO_PROTO);
40 void* realloc (NO_PROTO);
42 /* Raw memory built-ins from <string.h>. */
43 void* memcpy (NO_PROTO);
44 void* memchr (NO_PROTO);
45 void* memmove (NO_PROTO);
46 void* mempcpy (NO_PROTO);
47 void* memset (NO_PROTO);
49 /* String built-ins from <string.h>. */
50 char* stpcpy (NO_PROTO);
51 char* stpncpy (NO_PROTO);
53 char* strcat (NO_PROTO);
54 char* strcpy (NO_PROTO);
56 char* strdup (NO_PROTO);
57 char* strndup (NO_PROTO);
59 char* strncat (NO_PROTO);
60 char* strncpy (NO_PROTO);
62 size_t strlen (NO_PROTO);
63 size_t strnlen (NO_PROTO);
65 char* strchr (NO_PROTO);
66 int strcmp (NO_PROTO);
67 int strncmp (NO_PROTO);
69 /* Input/output functions from <stdio.h>. */
70 int puts (NO_PROTO);
71 int fputs (NO_PROTO);
73 int scanf (NO_PROTO);
74 int fscanf (NO_PROTO);
75 int sscanf (NO_PROTO);
76 int vfscanf (NO_PROTO);
77 int vsscanf (NO_PROTO);
79 int printf (NO_PROTO);
80 int fprintf (NO_PROTO);
81 int sprintf (NO_PROTO);
83 int snprintf (NO_PROTO);
85 int vprintf (NO_PROTO);
86 int vfprintf (NO_PROTO);
87 int vsprintf (NO_PROTO);
89 int vsnprintf (NO_PROTO);
91 #if __cplusplus
93 #endif
96 #define CONCAT(a, b) a ## b
97 #define UNIQ_NAME(func, id) CONCAT (test_ ## func ## _, id)
99 #define TEST_FUNC(func, arglist) \
100 __typeof__ (func arglist) \
101 UNIQ_NAME (func, __COUNTER__) (void) { \
102 return func arglist; \
105 #define T1(func) \
106 TEST_FUNC (func, ()); \
107 TEST_FUNC (func, (1)); \
108 TEST_FUNC (func, ("")); \
109 TEST_FUNC (func, ((void*)1)); \
110 TEST_FUNC (func, (iarr)); \
111 TEST_FUNC (func, (function))
113 #define T2(func) \
114 TEST_FUNC (func, (1, 1)); \
115 TEST_FUNC (func, (1, "")); \
116 TEST_FUNC (func, (1, (void*)1)); \
117 TEST_FUNC (func, (1, iarr)); \
118 TEST_FUNC (func, (1, function))
120 #define T3(func) \
121 TEST_FUNC (func, (1, 1, 1)); \
122 TEST_FUNC (func, (1, 1, "")); \
123 TEST_FUNC (func, (1, 1, (void*)1)); \
124 TEST_FUNC (func, (1, 1, iarr)); \
125 TEST_FUNC (func, (1, 1, function))
127 extern int iarr[];
128 extern void function (void);
130 T1 (isalpha);
131 T1 (isalnum);
132 T1 (isalpha);
133 T1 (iscntrl);
134 T1 (isdigit);
135 T1 (isgraph);
136 T1 (islower);
137 T1 (isprint);
138 T1 (ispunct);
139 T1 (isspace);
140 T1 (isupper);
141 T1 (isxdigit);
142 T1 (tolower);
143 T1 (toupper);
145 T1 (alloca);
146 T2 (aligned_alloc);
147 T2 (malloc);
148 T2 (calloc);
149 T2 (realloc);
151 T3 (memcpy);
152 T3 (memmove);
153 T3 (mempcpy);
154 T3 (memset);
155 T3 (memchr);
157 T2 (stpcpy);
158 T3 (stpncpy);
160 T2 (strcat);
161 T2 (strcpy);
163 T1 (strdup);
164 T2 (strndup);
166 T3 (strncat);
167 T3 (strncpy);
169 T2 (strchr);
170 T2 (strcmp);
171 T3 (strncmp);
173 T1 (strlen);
174 T2 (strnlen);
176 T1 (puts);
177 T2 (fputs);
179 T1 (scanf);
180 T2 (fscanf);
181 T2 (sscanf);
182 T2 (vfscanf);
183 T2 (vsscanf);
185 T2 (printf);
186 T3 (fprintf);
187 T3 (sprintf);
189 T3 (snprintf);
191 T2 (vprintf);
192 T2 (vfprintf);
193 T2 (vsprintf);
195 T3 (vsnprintf);