1 /* { dg-options "-fno-short-enums" } */
2 /* { dg-additional-options "-Wno-return-type" } */
3 enum
4 {
5   _sch_isdigit = 0x0004,
6   _sch_ispunct = 0x0020,
7   _sch_isxdigit = 0x0100,
8   _sch_isidst = 0x0200,
9   _sch_isvsp = 0x0400,
10   _sch_isnvsp = 0x0800,
11   _sch_isalnum = _sch_isidst | _sch_isdigit,
12   _sch_iscppsp = _sch_isvsp | _sch_isnvsp,
13 };
14 extern const unsigned short _sch_istable[256];
15 typedef union tree_node *tree;
16 typedef const union tree_node *const_tree;
17 enum opt_code
18 {
19   OPT_Warray_bounds = 240,
20   OPT_Wformat_ = 245,
21   OPT_Wintf_annotation = 368,
22   OPT_std_gnu__14 = 1311,
23 };
24 enum tree_code
25 {
26   TREE_LIST,
27   CONST_DECL,
28   ADDR_EXPR,
29   MAX_TREE_CODES
30 };
31 enum tree_code_class
32 {
33   tcc_type,
34 };
35 enum tree_node_structure_enum
36 {
37   TS_TYPED,
38   TS_COMMON,
39 };
40 enum integer_type_kind
41 {
42   itk_char,
43   itk_none
44 };
45 struct tree_base
46 {
47   enum tree_code code:16;
48 };
49 struct tree_typed
50 {
51   tree type;
52 };
53 struct tree_common
54 {
55   tree chain;
56 };
57 struct tree_list
58 {
59   tree purpose;
60 };
61 struct tree_type_common
62 {
63   tree main_variant;
64 };
65 union tree_node
66 {
67   struct tree_base base;
68   struct tree_typed typed;
69   struct tree_common common;
70   struct tree_type_common type_common;
71   struct tree_list list;
72 };
73 extern unsigned char tree_contains_struct[MAX_TREE_CODES][64];
74 extern tree integer_types[itk_none];
75 extern void tree_contains_struct_check_failed (const_tree,
76 					       tree_node_structure_enum,
77 					       const char *, int,
78 					       const char *)
79   __attribute__ ((__noreturn__));
80 inline tree
tree_check(tree __t,const char * __f,int __l,const char * __g,tree_code __c)81 tree_check (tree __t, const char *__f, int __l, const char *__g,
82 	    tree_code __c)
83 {
84 }
85 
86 inline const_tree
contains_struct_check(const_tree __t,const enum tree_node_structure_enum __s,const char * __f,int __l,const char * __g)87 contains_struct_check (const_tree __t,
88 		       const enum tree_node_structure_enum __s,
89 		       const char *__f, int __l, const char *__g)
90 {
91   if (tree_contains_struct[((enum tree_code) (__t)->base.code)][__s] != 1)
92     tree_contains_struct_check_failed (__t, __s, __f, __l, __g);
93 }
94 
95 inline const_tree
tree_class_check(const_tree __t,const enum tree_code_class __class,const char * __f,int __l,const char * __g)96 tree_class_check (const_tree __t, const enum tree_code_class __class,
97 		  const char *__f, int __l, const char *__g)
98 {
99 }
100 
101 static inline bool
is_attribute_p(const char * attr_name,const_tree ident)102 is_attribute_p (const char *attr_name, const_tree ident)
103 {
104 }
105 
106 extern int integer_zerop (const_tree);
107 extern bool warning (int, const char *, ...)
108   __attribute__ ((__nonnull__ (2)));
109 extern void
110 check_function_arguments_recurse (void (*)(void *, tree, unsigned long long),
111 				  void *, tree, unsigned long long);
112 extern bool objc_string_ref_type_p (tree);
113 enum
114 {
115   FMT_FLAG_SCANF_A_KLUDGE = 2,
116   FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256
117 };
118 typedef struct
119 {
120 }
121 format_flag_spec;
122 typedef struct
123 {
124   int flags;
125   tree *width_type;
126 }
127 format_kind_info;
128 typedef struct alloc_pool_list_def
129 {
130 }
131  *alloc_pool;
132 struct gcc_targetcm
133 {
134   bool (*string_object_ref_type_p) (const_tree stringref);
135 }
136  ;
137 extern struct gcc_targetcm targetcm;
138 enum format_type
139 {
140   gcc_objc_string_format_type,
141 };
142 typedef struct function_format_info
143 {
144   int format_type;
145 }
146 function_format_info;
147 static const format_kind_info format_types_orig[] = { };
148 struct format_check_context { };
149 
150 static const format_kind_info *format_types = format_types_orig;
151 static void check_format_info (function_format_info *, tree);
152 void check_format_arg (void *, tree, unsigned long long);
153 
154 void
check_function_format(tree attrs,int nargs,tree * argarray)155 check_function_format (tree attrs, int nargs, tree * argarray)
156 {
157   tree a;
158   for (a = attrs;
159        a;
160        ((contains_struct_check
161 	 ((a), (TS_COMMON), "../../git-master/gcc/c-family/c-format.c", 1002,
162 	  __FUNCTION__))->common.chain))
163     {
164       if (is_attribute_p
165 	  ("format",
166 	   ((tree_check
167 	     ((a), "../../git-master/gcc/c-family/c-format.c", 1004,
168 	      __FUNCTION__, (TREE_LIST)))->list.purpose)))
169 	{
170 	  function_format_info info;
171 	  {
172 	    tree params = (tree) __null;
173 	    check_format_info (&info, params);
174 	  }
175 	}
176     }
177 }
178 
179 static bool
avoid_dollar_number(const char * format)180 avoid_dollar_number (const char *format)
181 {
182   while ((_sch_istable[(*format) & 0xff] & (unsigned short) (_sch_isdigit)))
183     format++;
184   if (*format == '$')
185     {
186       warning (OPT_Wformat_,
187 	       "$ operand number used after format without operand number");
188     }
189 }
190 
191 static void
check_format_info(function_format_info * info,tree params)192 check_format_info (function_format_info * info, tree params)
193 {
194   format_check_context format_ctx;
195   unsigned long long arg_num;
196   tree format_tree;
197   check_function_arguments_recurse (check_format_arg, &format_ctx,
198 				    format_tree, arg_num);
199   const char *format_chars;
200   if (integer_zerop (format_tree))
201     {
202       {
203 	((contains_struct_check
204 	  ((params), (TS_COMMON),
205 	   "../../git-master/gcc/c-family/c-format.c", 1444,
206 	   __FUNCTION__))->common.chain);
207       }
208       return;
209     }
210   if (((enum tree_code) (format_tree)->base.code) != ADDR_EXPR)
211     {
212       return;
213     }
214   if (format_types[info->format_type].flags & (int)
215       FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL)
216     {
217       bool objc_str = (info->format_type == gcc_objc_string_format_type);
218       if (((enum tree_code) (format_tree)->base.code) != CONST_DECL
219 	  ||
220 	  !((objc_str
221 	     &&
222 	     objc_string_ref_type_p (((contains_struct_check
223 				       ((format_tree), (TS_TYPED),
224 					"../../git-master/gcc/c-family/c-format.c",
225 					1498, __FUNCTION__))->typed.type)))
226 	    ||
227 	    (*targetcm.string_object_ref_type_p) ((const_tree)
228 						  ((contains_struct_check
229 						    ((format_tree),
230 						     (TS_TYPED),
231 						     "../../git-master/gcc/c-family/c-format.c",
232 						     1500,
233 						     __FUNCTION__))->typed.
234 						   type))))
235 	{
236 	}
237     }
238   {
239   }
240   if (((tree_class_check
241 	((((contains_struct_check
242 	    ((((contains_struct_check
243 		((format_tree), (TS_TYPED),
244 		 "../../git-master/gcc/c-family/c-format.c", 1549,
245 		 __FUNCTION__))->typed.type)), (TS_TYPED),
246 	     "../../git-master/gcc/c-family/c-format.c", 1549,
247 	     __FUNCTION__))->typed.type)), (tcc_type),
248 	 "../../git-master/gcc/c-family/c-format.c", 1549,
249 	 __FUNCTION__))->type_common.main_variant) != integer_types[itk_char])
250     {
251       return;
252     }
253   {
254   }
255   const format_kind_info *fki = &format_types[info->format_type];
256   while (*format_chars != 0)
257     {
258       {
259 	if (fki->width_type != __null && *format_chars == '*')
260 	  {
261 	    {
262 	      if (avoid_dollar_number (format_chars))
263 		if (avoid_dollar_number (format_chars))
264 		  return;
265 	    }
266 	  }
267       }
268     }
269 }
270