]>
Commit | Line | Data |
---|---|---|
8d08fdba MS |
1 | /* Handle the hair of processing (but not expanding) inline functions. |
2 | Also manage function and variable name overloading. | |
8cb9cd5d | 3 | Copyright (C) 1987, 1989, 1992, 1993, 1995 Free Software Foundation, Inc. |
8d08fdba MS |
4 | Contributed by Michael Tiemann (tiemann@cygnus.com) |
5 | ||
6 | This file is part of GNU CC. | |
7 | ||
8 | GNU CC is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GNU CC is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GNU CC; see the file COPYING. If not, write to | |
e9fa0c7c RK |
20 | the Free Software Foundation, 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. */ | |
8d08fdba MS |
22 | |
23 | ||
24 | #ifndef PARM_CAN_BE_ARRAY_TYPE | |
25 | #define PARM_CAN_BE_ARRAY_TYPE 1 | |
26 | #endif | |
27 | ||
28 | /* Handle method declarations. */ | |
29 | #include <stdio.h> | |
30 | #include "config.h" | |
31 | #include "tree.h" | |
32 | #include "cp-tree.h" | |
33 | #include "class.h" | |
34 | #include "obstack.h" | |
35 | #include <ctype.h> | |
8926095f MS |
36 | #include "rtl.h" |
37 | #include "expr.h" | |
38 | #include "output.h" | |
39 | #include "hard-reg-set.h" | |
40 | #include "flags.h" | |
8d08fdba MS |
41 | |
42 | /* TREE_LIST of the current inline functions that need to be | |
43 | processed. */ | |
44 | struct pending_inline *pending_inlines; | |
45 | ||
46 | #define obstack_chunk_alloc xmalloc | |
47 | #define obstack_chunk_free free | |
48 | ||
49 | /* Obstack where we build text strings for overloading, etc. */ | |
50 | static struct obstack scratch_obstack; | |
51 | static char *scratch_firstobj; | |
52 | ||
53 | # define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0) | |
54 | # define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C))) | |
55 | # define OB_PUTC2(C1,C2) \ | |
56 | (obstack_1grow (&scratch_obstack, (C1)), obstack_1grow (&scratch_obstack, (C2))) | |
57 | # define OB_PUTS(S) (obstack_grow (&scratch_obstack, (S), sizeof (S) - 1)) | |
58 | # define OB_PUTID(ID) \ | |
59 | (obstack_grow (&scratch_obstack, IDENTIFIER_POINTER (ID), \ | |
60 | IDENTIFIER_LENGTH (ID))) | |
61 | # define OB_PUTCP(S) (obstack_grow (&scratch_obstack, (S), strlen (S))) | |
62 | # define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0')) | |
db5ae43f | 63 | # define OB_LAST() (obstack_next_free (&scratch_obstack)[-1]) |
8d08fdba MS |
64 | |
65 | #ifdef NO_AUTO_OVERLOAD | |
66 | int is_overloaded (); | |
67 | #endif | |
68 | ||
69 | void | |
70 | init_method () | |
71 | { | |
72 | gcc_obstack_init (&scratch_obstack); | |
73 | scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0); | |
74 | } | |
75 | ||
76 | /* This must be large enough to hold any printed integer or floating-point | |
77 | value. */ | |
78 | static char digit_buffer[128]; | |
79 | ||
80 | /* Move inline function definitions out of structure so that they | |
81 | can be processed normally. CNAME is the name of the class | |
82 | we are working from, METHOD_LIST is the list of method lists | |
83 | of the structure. We delete friend methods here, after | |
84 | saving away their inline function definitions (if any). */ | |
85 | ||
86 | void | |
87 | do_inline_function_hair (type, friend_list) | |
88 | tree type, friend_list; | |
89 | { | |
90 | tree method = TYPE_METHODS (type); | |
91 | ||
92 | if (method && TREE_CODE (method) == TREE_VEC) | |
93 | { | |
94 | if (TREE_VEC_ELT (method, 0)) | |
95 | method = TREE_VEC_ELT (method, 0); | |
96 | else | |
97 | method = TREE_VEC_ELT (method, 1); | |
98 | } | |
99 | ||
100 | while (method) | |
101 | { | |
102 | /* Do inline member functions. */ | |
103 | struct pending_inline *info = DECL_PENDING_INLINE_INFO (method); | |
104 | if (info) | |
105 | { | |
106 | tree args; | |
107 | ||
108 | my_friendly_assert (info->fndecl == method, 238); | |
109 | args = DECL_ARGUMENTS (method); | |
110 | while (args) | |
111 | { | |
112 | DECL_CONTEXT (args) = method; | |
113 | args = TREE_CHAIN (args); | |
114 | } | |
115 | ||
7177d104 MS |
116 | /* Allow this decl to be seen in global scope. Don't do this for |
117 | local class methods, though. */ | |
118 | if (! current_function_decl) | |
119 | IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (method)) = method; | |
8d08fdba MS |
120 | } |
121 | method = TREE_CHAIN (method); | |
122 | } | |
123 | while (friend_list) | |
124 | { | |
125 | tree fndecl = TREE_VALUE (friend_list); | |
126 | struct pending_inline *info = DECL_PENDING_INLINE_INFO (fndecl); | |
127 | if (info) | |
128 | { | |
129 | tree args; | |
130 | ||
131 | my_friendly_assert (info->fndecl == fndecl, 239); | |
132 | args = DECL_ARGUMENTS (fndecl); | |
133 | while (args) | |
134 | { | |
135 | DECL_CONTEXT (args) = fndecl; | |
136 | args = TREE_CHAIN (args); | |
137 | } | |
138 | ||
139 | /* Allow this decl to be seen in global scope */ | |
700f8a87 MS |
140 | if (! current_function_decl) |
141 | IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (fndecl)) = fndecl; | |
8d08fdba MS |
142 | } |
143 | ||
144 | friend_list = TREE_CHAIN (friend_list); | |
145 | } | |
146 | } | |
147 | \f | |
148 | /* Report an argument type mismatch between the best declared function | |
149 | we could find and the current argument list that we have. */ | |
150 | void | |
151 | report_type_mismatch (cp, parmtypes, name_kind) | |
152 | struct candidate *cp; | |
153 | tree parmtypes; | |
154 | char *name_kind; | |
155 | { | |
156 | int i = cp->u.bad_arg; | |
157 | tree ttf, tta; | |
158 | char *tmp_firstobj; | |
159 | ||
160 | switch (i) | |
161 | { | |
162 | case -4: | |
163 | my_friendly_assert (TREE_CODE (cp->function) == TEMPLATE_DECL, 240); | |
164 | cp_error ("type unification failed for function template `%#D'", | |
165 | cp->function); | |
166 | return; | |
167 | ||
168 | case -3: | |
169 | if (TYPE_READONLY (TREE_TYPE (TREE_VALUE (parmtypes)))) | |
170 | cp_error ("call to const %s `%#D' with non-const object", name_kind, | |
171 | cp->function); | |
172 | else | |
173 | cp_error ("call to non-const %s `%#D' with const object", name_kind, | |
174 | cp->function); | |
175 | return; | |
176 | case -2: | |
177 | cp_error ("too few arguments for %s `%#D'", name_kind, cp->function); | |
178 | return; | |
179 | case -1: | |
180 | cp_error ("too many arguments for %s `%#D'", name_kind, cp->function); | |
181 | return; | |
182 | case 0: | |
183 | if (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE) | |
184 | { | |
185 | /* Happens when we have an ambiguous base class. */ | |
186 | my_friendly_assert (get_binfo (DECL_CLASS_CONTEXT (cp->function), | |
187 | TREE_TYPE (TREE_TYPE (TREE_VALUE (parmtypes))), 1) == error_mark_node, | |
188 | 241); | |
189 | return; | |
190 | } | |
191 | } | |
192 | ||
193 | ttf = TYPE_ARG_TYPES (TREE_TYPE (cp->function)); | |
194 | tta = parmtypes; | |
195 | ||
196 | while (i-- > 0) | |
197 | { | |
198 | ttf = TREE_CHAIN (ttf); | |
199 | tta = TREE_CHAIN (tta); | |
200 | } | |
201 | ||
202 | OB_INIT (); | |
203 | OB_PUTS ("bad argument "); | |
204 | sprintf (digit_buffer, "%d", cp->u.bad_arg | |
205 | - (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE) | |
206 | + 1); | |
207 | OB_PUTCP (digit_buffer); | |
208 | ||
209 | OB_PUTS (" for function `"); | |
210 | OB_PUTCP (decl_as_string (cp->function, 1)); | |
211 | OB_PUTS ("' (type was "); | |
212 | ||
213 | /* Reset `i' so that type printing routines do the right thing. */ | |
214 | if (tta) | |
215 | { | |
216 | enum tree_code code = TREE_CODE (TREE_TYPE (TREE_VALUE (tta))); | |
217 | if (code == ERROR_MARK) | |
218 | OB_PUTS ("(failed type instantiation)"); | |
219 | else | |
220 | { | |
221 | i = (code == FUNCTION_TYPE || code == METHOD_TYPE); | |
222 | OB_PUTCP (type_as_string (TREE_TYPE (TREE_VALUE (tta)), 1)); | |
223 | } | |
224 | } | |
225 | else OB_PUTS ("void"); | |
226 | OB_PUTC (')'); | |
227 | OB_FINISH (); | |
228 | ||
229 | tmp_firstobj = (char *)alloca (obstack_object_size (&scratch_obstack)); | |
230 | bcopy (obstack_base (&scratch_obstack), tmp_firstobj, | |
231 | obstack_object_size (&scratch_obstack)); | |
232 | error (tmp_firstobj); | |
233 | } | |
234 | \f | |
235 | /* Here is where overload code starts. */ | |
236 | ||
237 | /* Array of types seen so far in top-level call to `build_overload_name'. | |
238 | Allocated and deallocated by caller. */ | |
239 | static tree *typevec; | |
240 | ||
241 | /* Number of types interned by `build_overload_name' so far. */ | |
242 | static int maxtype; | |
243 | ||
244 | /* Number of occurrences of last type seen. */ | |
245 | static int nrepeats; | |
246 | ||
247 | /* Nonzero if we should not try folding parameter types. */ | |
248 | static int nofold; | |
249 | ||
250 | #define ALLOCATE_TYPEVEC(PARMTYPES) \ | |
251 | do { maxtype = 0, nrepeats = 0; \ | |
252 | typevec = (tree *)alloca (list_length (PARMTYPES) * sizeof (tree)); } while (0) | |
253 | ||
254 | #define DEALLOCATE_TYPEVEC(PARMTYPES) \ | |
255 | do { tree t = (PARMTYPES); \ | |
256 | while (t) { TREE_USED (TREE_VALUE (t)) = 0; t = TREE_CHAIN (t); } \ | |
257 | } while (0) | |
258 | ||
259 | /* Code to concatenate an asciified integer to a string. */ | |
260 | static | |
261 | #ifdef __GNUC__ | |
262 | __inline | |
263 | #endif | |
264 | void | |
265 | icat (i) | |
266 | int i; | |
267 | { | |
268 | /* Handle this case first, to go really quickly. For many common values, | |
269 | the result of i/10 below is 1. */ | |
270 | if (i == 1) | |
271 | { | |
272 | OB_PUTC ('1'); | |
273 | return; | |
274 | } | |
275 | ||
276 | if (i < 0) | |
277 | { | |
278 | OB_PUTC ('m'); | |
279 | i = -i; | |
280 | } | |
281 | if (i < 10) | |
282 | OB_PUTC ('0' + i); | |
283 | else | |
284 | { | |
285 | icat (i / 10); | |
286 | OB_PUTC ('0' + (i % 10)); | |
287 | } | |
288 | } | |
289 | ||
290 | static | |
291 | #ifdef __GNUC__ | |
292 | __inline | |
293 | #endif | |
294 | void | |
295 | flush_repeats (type) | |
296 | tree type; | |
297 | { | |
298 | int tindex = 0; | |
299 | ||
300 | while (typevec[tindex] != type) | |
301 | tindex++; | |
302 | ||
303 | if (nrepeats > 1) | |
304 | { | |
305 | OB_PUTC ('N'); | |
306 | icat (nrepeats); | |
307 | if (nrepeats > 9) | |
308 | OB_PUTC ('_'); | |
309 | } | |
310 | else | |
311 | OB_PUTC ('T'); | |
312 | nrepeats = 0; | |
313 | icat (tindex); | |
314 | if (tindex > 9) | |
315 | OB_PUTC ('_'); | |
316 | } | |
317 | ||
8cb9cd5d | 318 | static int numeric_output_need_bar; |
8d08fdba MS |
319 | static void build_overload_identifier (); |
320 | ||
321 | static void | |
db5ae43f MS |
322 | build_overload_nested_name (decl) |
323 | tree decl; | |
8d08fdba | 324 | { |
db5ae43f | 325 | if (DECL_CONTEXT (decl)) |
8d08fdba | 326 | { |
db5ae43f | 327 | tree context = DECL_CONTEXT (decl); |
8d08fdba | 328 | if (TREE_CODE_CLASS (TREE_CODE (context)) == 't') |
db5ae43f | 329 | context = TYPE_MAIN_DECL (context); |
8d08fdba MS |
330 | build_overload_nested_name (context); |
331 | } | |
db5ae43f MS |
332 | |
333 | if (TREE_CODE (decl) == FUNCTION_DECL) | |
334 | { | |
335 | tree name = DECL_ASSEMBLER_NAME (decl); | |
336 | char *label; | |
337 | extern int var_labelno; | |
338 | ||
339 | ASM_FORMAT_PRIVATE_NAME (label, IDENTIFIER_POINTER (name), var_labelno); | |
340 | var_labelno++; | |
341 | ||
8cb9cd5d | 342 | if (numeric_output_need_bar) |
db5ae43f MS |
343 | { |
344 | OB_PUTC ('_'); | |
8cb9cd5d | 345 | numeric_output_need_bar = 0; |
db5ae43f MS |
346 | } |
347 | icat (strlen (label)); | |
348 | OB_PUTCP (label); | |
349 | } | |
350 | else /* TYPE_DECL */ | |
351 | { | |
352 | tree name = DECL_NAME (decl); | |
353 | build_overload_identifier (name); | |
354 | } | |
8d08fdba MS |
355 | } |
356 | ||
357 | static void | |
358 | build_overload_value (type, value) | |
359 | tree type, value; | |
360 | { | |
361 | while (TREE_CODE (value) == NON_LVALUE_EXPR | |
362 | || TREE_CODE (value) == NOP_EXPR) | |
363 | value = TREE_OPERAND (value, 0); | |
364 | my_friendly_assert (TREE_CODE (type) == PARM_DECL, 242); | |
365 | type = TREE_TYPE (type); | |
8145f082 MS |
366 | if (TREE_CODE (type) == POINTER_TYPE |
367 | && TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE) | |
368 | { | |
369 | /* Handle a pointer to member as a template instantiation | |
370 | parameter, boy, what fun! */ | |
371 | type = integer_type_node; | |
372 | if (TREE_CODE (value) != INTEGER_CST) | |
373 | { | |
374 | sorry ("unknown pointer to member constant"); | |
375 | return; | |
376 | } | |
377 | } | |
378 | ||
8d08fdba MS |
379 | switch (TREE_CODE (type)) |
380 | { | |
381 | case INTEGER_TYPE: | |
382 | case ENUMERAL_TYPE: | |
383 | { | |
384 | my_friendly_assert (TREE_CODE (value) == INTEGER_CST, 243); | |
385 | if (TYPE_PRECISION (value) == 2 * HOST_BITS_PER_WIDE_INT) | |
386 | { | |
387 | if (tree_int_cst_lt (value, integer_zero_node)) | |
388 | { | |
389 | OB_PUTC ('m'); | |
390 | value = build_int_2 (~ TREE_INT_CST_LOW (value), | |
391 | - TREE_INT_CST_HIGH (value)); | |
392 | } | |
393 | if (TREE_INT_CST_HIGH (value) | |
394 | != (TREE_INT_CST_LOW (value) >> (HOST_BITS_PER_WIDE_INT - 1))) | |
395 | { | |
396 | /* need to print a DImode value in decimal */ | |
397 | sorry ("conversion of long long as PT parameter"); | |
398 | } | |
399 | /* else fall through to print in smaller mode */ | |
400 | } | |
401 | /* Wordsize or smaller */ | |
402 | icat (TREE_INT_CST_LOW (value)); | |
403 | return; | |
404 | } | |
2986ae00 MS |
405 | case BOOLEAN_TYPE: |
406 | { | |
407 | icat (TREE_INT_CST_LOW (value)); | |
408 | return; | |
409 | } | |
8d08fdba MS |
410 | #ifndef REAL_IS_NOT_DOUBLE |
411 | case REAL_TYPE: | |
412 | { | |
413 | REAL_VALUE_TYPE val; | |
414 | char *bufp = digit_buffer; | |
415 | extern char *index (); | |
416 | ||
417 | my_friendly_assert (TREE_CODE (value) == REAL_CST, 244); | |
418 | val = TREE_REAL_CST (value); | |
419 | if (val < 0) | |
420 | { | |
421 | val = -val; | |
422 | *bufp++ = 'm'; | |
423 | } | |
424 | sprintf (bufp, "%e", val); | |
425 | bufp = (char *) index (bufp, 'e'); | |
426 | if (!bufp) | |
427 | strcat (digit_buffer, "e0"); | |
428 | else | |
429 | { | |
430 | char *p; | |
431 | bufp++; | |
432 | if (*bufp == '-') | |
433 | { | |
434 | *bufp++ = 'm'; | |
435 | } | |
436 | p = bufp; | |
437 | if (*p == '+') | |
438 | p++; | |
439 | while (*p == '0') | |
440 | p++; | |
441 | if (*p == 0) | |
442 | { | |
443 | *bufp++ = '0'; | |
444 | *bufp = 0; | |
445 | } | |
446 | else if (p != bufp) | |
447 | { | |
448 | while (*p) | |
449 | *bufp++ = *p++; | |
450 | *bufp = 0; | |
451 | } | |
452 | } | |
453 | OB_PUTCP (digit_buffer); | |
454 | return; | |
455 | } | |
456 | #endif | |
457 | case POINTER_TYPE: | |
458 | value = TREE_OPERAND (value, 0); | |
459 | if (TREE_CODE (value) == VAR_DECL) | |
460 | { | |
461 | my_friendly_assert (DECL_NAME (value) != 0, 245); | |
462 | build_overload_identifier (DECL_NAME (value)); | |
463 | return; | |
464 | } | |
465 | else if (TREE_CODE (value) == FUNCTION_DECL) | |
466 | { | |
467 | my_friendly_assert (DECL_NAME (value) != 0, 246); | |
468 | build_overload_identifier (DECL_NAME (value)); | |
469 | return; | |
470 | } | |
471 | else | |
472 | my_friendly_abort (71); | |
473 | break; /* not really needed */ | |
474 | ||
475 | default: | |
476 | sorry ("conversion of %s as template parameter", | |
477 | tree_code_name [(int) TREE_CODE (type)]); | |
478 | my_friendly_abort (72); | |
479 | } | |
480 | } | |
481 | ||
482 | static void | |
483 | build_overload_identifier (name) | |
484 | tree name; | |
485 | { | |
486 | if (IDENTIFIER_TEMPLATE (name)) | |
487 | { | |
488 | tree template, parmlist, arglist, tname; | |
489 | int i, nparms; | |
490 | template = IDENTIFIER_TEMPLATE (name); | |
491 | arglist = TREE_VALUE (template); | |
492 | template = TREE_PURPOSE (template); | |
493 | tname = DECL_NAME (template); | |
494 | parmlist = DECL_ARGUMENTS (template); | |
495 | nparms = TREE_VEC_LENGTH (parmlist); | |
496 | OB_PUTC ('t'); | |
497 | icat (IDENTIFIER_LENGTH (tname)); | |
498 | OB_PUTID (tname); | |
499 | icat (nparms); | |
500 | for (i = 0; i < nparms; i++) | |
501 | { | |
a292b002 | 502 | tree parm = TREE_VALUE (TREE_VEC_ELT (parmlist, i)); |
8d08fdba | 503 | tree arg = TREE_VEC_ELT (arglist, i); |
a292b002 | 504 | if (TREE_CODE (parm) == TYPE_DECL) |
8d08fdba MS |
505 | { |
506 | /* This parameter is a type. */ | |
507 | OB_PUTC ('Z'); | |
508 | build_overload_name (arg, 0, 0); | |
509 | } | |
510 | else | |
511 | { | |
512 | /* It's a PARM_DECL. */ | |
513 | build_overload_name (TREE_TYPE (parm), 0, 0); | |
514 | build_overload_value (parm, arg); | |
8cb9cd5d | 515 | numeric_output_need_bar = 1; |
8d08fdba MS |
516 | } |
517 | } | |
518 | } | |
519 | else | |
520 | { | |
8cb9cd5d | 521 | if (numeric_output_need_bar) |
f376e137 MS |
522 | { |
523 | OB_PUTC ('_'); | |
8cb9cd5d | 524 | numeric_output_need_bar = 0; |
f376e137 | 525 | } |
8d08fdba MS |
526 | icat (IDENTIFIER_LENGTH (name)); |
527 | OB_PUTID (name); | |
528 | } | |
529 | } | |
530 | ||
531 | /* Given a list of parameters in PARMTYPES, create an unambiguous | |
532 | overload string. Should distinguish any type that C (or C++) can | |
533 | distinguish. I.e., pointers to functions are treated correctly. | |
534 | ||
535 | Caller must deal with whether a final `e' goes on the end or not. | |
536 | ||
537 | Any default conversions must take place before this function | |
538 | is called. | |
539 | ||
540 | BEGIN and END control initialization and finalization of the | |
541 | obstack where we build the string. */ | |
542 | ||
543 | char * | |
544 | build_overload_name (parmtypes, begin, end) | |
545 | tree parmtypes; | |
546 | int begin, end; | |
547 | { | |
548 | int just_one; | |
549 | tree parmtype; | |
550 | ||
551 | if (begin) OB_INIT (); | |
8cb9cd5d | 552 | numeric_output_need_bar = 0; |
8d08fdba | 553 | |
8926095f | 554 | if ((just_one = (TREE_CODE (parmtypes) != TREE_LIST))) |
8d08fdba MS |
555 | { |
556 | parmtype = parmtypes; | |
557 | goto only_one; | |
558 | } | |
559 | ||
560 | while (parmtypes) | |
561 | { | |
562 | parmtype = TREE_VALUE (parmtypes); | |
563 | ||
564 | only_one: | |
565 | ||
a5894242 | 566 | if (! nofold && ! just_one) |
8d08fdba | 567 | { |
a5894242 MS |
568 | /* Every argument gets counted. */ |
569 | typevec[maxtype++] = parmtype; | |
8d08fdba | 570 | |
a5894242 | 571 | if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2]) |
8d08fdba | 572 | { |
a5894242 | 573 | nrepeats++; |
8d08fdba MS |
574 | goto next; |
575 | } | |
a5894242 | 576 | |
8d08fdba MS |
577 | if (nrepeats) |
578 | flush_repeats (typevec[maxtype-2]); | |
a5894242 MS |
579 | |
580 | if (TREE_USED (parmtype)) | |
581 | { | |
582 | flush_repeats (parmtype); | |
583 | goto next; | |
584 | } | |
585 | ||
586 | /* Only cache types which take more than one character. */ | |
587 | if (parmtype != TYPE_MAIN_VARIANT (parmtype) | |
588 | || (TREE_CODE (parmtype) != INTEGER_TYPE | |
589 | && TREE_CODE (parmtype) != REAL_TYPE)) | |
8d08fdba MS |
590 | TREE_USED (parmtype) = 1; |
591 | } | |
592 | ||
593 | if (TYPE_PTRMEMFUNC_P (parmtype)) | |
594 | parmtype = TYPE_PTRMEMFUNC_FN_TYPE (parmtype); | |
595 | ||
596 | if (TREE_READONLY (parmtype)) | |
597 | OB_PUTC ('C'); | |
598 | if (TREE_CODE (parmtype) == INTEGER_TYPE | |
599 | && TYPE_MAIN_VARIANT (parmtype) == unsigned_type (TYPE_MAIN_VARIANT (parmtype))) | |
600 | OB_PUTC ('U'); | |
601 | if (TYPE_VOLATILE (parmtype)) | |
602 | OB_PUTC ('V'); | |
603 | ||
604 | switch (TREE_CODE (parmtype)) | |
605 | { | |
606 | case OFFSET_TYPE: | |
607 | OB_PUTC ('O'); | |
608 | build_overload_name (TYPE_OFFSET_BASETYPE (parmtype), 0, 0); | |
609 | OB_PUTC ('_'); | |
610 | build_overload_name (TREE_TYPE (parmtype), 0, 0); | |
611 | break; | |
612 | ||
613 | case REFERENCE_TYPE: | |
614 | OB_PUTC ('R'); | |
615 | goto more; | |
616 | ||
617 | case ARRAY_TYPE: | |
618 | #if PARM_CAN_BE_ARRAY_TYPE | |
619 | { | |
620 | tree length; | |
621 | ||
622 | OB_PUTC ('A'); | |
623 | if (TYPE_DOMAIN (parmtype) == NULL_TREE) | |
2986ae00 | 624 | error ("pointer or reference to array of unknown bound in parm type"); |
8d08fdba MS |
625 | else |
626 | { | |
627 | length = array_type_nelts (parmtype); | |
628 | if (TREE_CODE (length) == INTEGER_CST) | |
629 | icat (TREE_INT_CST_LOW (length) + 1); | |
630 | } | |
631 | OB_PUTC ('_'); | |
632 | goto more; | |
633 | } | |
634 | #else | |
635 | OB_PUTC ('P'); | |
636 | goto more; | |
637 | #endif | |
638 | ||
639 | case POINTER_TYPE: | |
640 | OB_PUTC ('P'); | |
641 | more: | |
642 | build_overload_name (TREE_TYPE (parmtype), 0, 0); | |
643 | break; | |
644 | ||
645 | case FUNCTION_TYPE: | |
646 | case METHOD_TYPE: | |
647 | { | |
648 | tree firstarg = TYPE_ARG_TYPES (parmtype); | |
649 | /* Otherwise have to implement reentrant typevecs, | |
650 | unmark and remark types, etc. */ | |
651 | int old_nofold = nofold; | |
652 | nofold = 1; | |
653 | ||
654 | if (nrepeats) | |
655 | flush_repeats (typevec[maxtype-1]); | |
656 | ||
657 | /* @@ It may be possible to pass a function type in | |
658 | which is not preceded by a 'P'. */ | |
659 | if (TREE_CODE (parmtype) == FUNCTION_TYPE) | |
660 | { | |
661 | OB_PUTC ('F'); | |
662 | if (firstarg == NULL_TREE) | |
663 | OB_PUTC ('e'); | |
664 | else if (firstarg == void_list_node) | |
665 | OB_PUTC ('v'); | |
666 | else | |
667 | build_overload_name (firstarg, 0, 0); | |
668 | } | |
669 | else | |
670 | { | |
671 | int constp = TYPE_READONLY (TREE_TYPE (TREE_VALUE (firstarg))); | |
672 | int volatilep = TYPE_VOLATILE (TREE_TYPE (TREE_VALUE (firstarg))); | |
673 | OB_PUTC ('M'); | |
674 | firstarg = TREE_CHAIN (firstarg); | |
675 | ||
676 | build_overload_name (TYPE_METHOD_BASETYPE (parmtype), 0, 0); | |
677 | if (constp) | |
678 | OB_PUTC ('C'); | |
679 | if (volatilep) | |
680 | OB_PUTC ('V'); | |
681 | ||
682 | /* For cfront 2.0 compatibility. */ | |
683 | OB_PUTC ('F'); | |
684 | ||
685 | if (firstarg == NULL_TREE) | |
686 | OB_PUTC ('e'); | |
687 | else if (firstarg == void_list_node) | |
688 | OB_PUTC ('v'); | |
689 | else | |
690 | build_overload_name (firstarg, 0, 0); | |
691 | } | |
692 | ||
693 | /* Separate args from return type. */ | |
694 | OB_PUTC ('_'); | |
695 | build_overload_name (TREE_TYPE (parmtype), 0, 0); | |
696 | nofold = old_nofold; | |
697 | break; | |
698 | } | |
699 | ||
700 | case INTEGER_TYPE: | |
701 | parmtype = TYPE_MAIN_VARIANT (parmtype); | |
702 | if (parmtype == integer_type_node | |
703 | || parmtype == unsigned_type_node) | |
704 | OB_PUTC ('i'); | |
705 | else if (parmtype == long_integer_type_node | |
706 | || parmtype == long_unsigned_type_node) | |
707 | OB_PUTC ('l'); | |
708 | else if (parmtype == short_integer_type_node | |
709 | || parmtype == short_unsigned_type_node) | |
710 | OB_PUTC ('s'); | |
711 | else if (parmtype == signed_char_type_node) | |
712 | { | |
713 | OB_PUTC ('S'); | |
714 | OB_PUTC ('c'); | |
715 | } | |
716 | else if (parmtype == char_type_node | |
717 | || parmtype == unsigned_char_type_node) | |
718 | OB_PUTC ('c'); | |
719 | else if (parmtype == wchar_type_node) | |
720 | OB_PUTC ('w'); | |
721 | else if (parmtype == long_long_integer_type_node | |
722 | || parmtype == long_long_unsigned_type_node) | |
723 | OB_PUTC ('x'); | |
724 | #if 0 | |
725 | /* it would seem there is no way to enter these in source code, | |
726 | yet. (mrs) */ | |
727 | else if (parmtype == long_long_long_integer_type_node | |
728 | || parmtype == long_long_long_unsigned_type_node) | |
729 | OB_PUTC ('q'); | |
730 | #endif | |
731 | else | |
732 | my_friendly_abort (73); | |
733 | break; | |
734 | ||
2986ae00 MS |
735 | case BOOLEAN_TYPE: |
736 | OB_PUTC ('b'); | |
737 | break; | |
738 | ||
8d08fdba MS |
739 | case REAL_TYPE: |
740 | parmtype = TYPE_MAIN_VARIANT (parmtype); | |
741 | if (parmtype == long_double_type_node) | |
742 | OB_PUTC ('r'); | |
743 | else if (parmtype == double_type_node) | |
744 | OB_PUTC ('d'); | |
745 | else if (parmtype == float_type_node) | |
746 | OB_PUTC ('f'); | |
747 | else my_friendly_abort (74); | |
748 | break; | |
749 | ||
750 | case VOID_TYPE: | |
751 | if (! just_one) | |
752 | { | |
753 | #if 0 | |
754 | extern tree void_list_node; | |
755 | ||
756 | /* See if anybody is wasting memory. */ | |
757 | my_friendly_assert (parmtypes == void_list_node, 247); | |
758 | #endif | |
759 | /* This is the end of a parameter list. */ | |
760 | if (end) OB_FINISH (); | |
761 | return (char *)obstack_base (&scratch_obstack); | |
762 | } | |
763 | OB_PUTC ('v'); | |
764 | break; | |
765 | ||
766 | case ERROR_MARK: /* not right, but nothing is anyway */ | |
767 | break; | |
768 | ||
769 | /* have to do these */ | |
770 | case UNION_TYPE: | |
771 | case RECORD_TYPE: | |
772 | if (! just_one) | |
773 | /* Make this type signature look incompatible | |
774 | with AT&T. */ | |
775 | OB_PUTC ('G'); | |
776 | goto common; | |
777 | case ENUMERAL_TYPE: | |
778 | common: | |
779 | { | |
780 | tree name = TYPE_NAME (parmtype); | |
781 | int i = 1; | |
782 | ||
783 | if (TREE_CODE (name) == TYPE_DECL) | |
784 | { | |
785 | tree context = name; | |
db5ae43f MS |
786 | |
787 | /* If DECL_ASSEMBLER_NAME has been set properly, use it. */ | |
788 | if (DECL_ASSEMBLER_NAME (context) != DECL_NAME (context)) | |
789 | { | |
790 | OB_PUTID (DECL_ASSEMBLER_NAME (context)); | |
791 | break; | |
792 | } | |
8d08fdba MS |
793 | while (DECL_CONTEXT (context)) |
794 | { | |
795 | i += 1; | |
796 | context = DECL_CONTEXT (context); | |
797 | if (TREE_CODE_CLASS (TREE_CODE (context)) == 't') | |
798 | context = TYPE_NAME (context); | |
799 | } | |
800 | name = DECL_NAME (name); | |
801 | } | |
802 | my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 248); | |
803 | if (i > 1) | |
804 | { | |
805 | OB_PUTC ('Q'); | |
806 | if (i > 9) | |
807 | OB_PUTC ('_'); | |
808 | icat (i); | |
809 | if (i > 9) | |
810 | OB_PUTC ('_'); | |
8cb9cd5d | 811 | numeric_output_need_bar = 0; |
db5ae43f | 812 | build_overload_nested_name (TYPE_MAIN_DECL (parmtype)); |
8d08fdba MS |
813 | } |
814 | else | |
815 | build_overload_identifier (name); | |
816 | break; | |
817 | } | |
818 | ||
819 | case UNKNOWN_TYPE: | |
820 | /* This will take some work. */ | |
821 | OB_PUTC ('?'); | |
822 | break; | |
823 | ||
824 | case TEMPLATE_TYPE_PARM: | |
825 | case TEMPLATE_CONST_PARM: | |
826 | case UNINSTANTIATED_P_TYPE: | |
827 | /* We don't ever want this output, but it's inconvenient not to | |
828 | be able to build the string. This should cause assembler | |
829 | errors we'll notice. */ | |
830 | { | |
831 | static int n; | |
832 | sprintf (digit_buffer, " *%d", n++); | |
833 | OB_PUTCP (digit_buffer); | |
834 | } | |
835 | break; | |
836 | ||
837 | default: | |
838 | my_friendly_abort (75); | |
839 | } | |
840 | ||
841 | next: | |
842 | if (just_one) break; | |
843 | parmtypes = TREE_CHAIN (parmtypes); | |
844 | } | |
845 | if (! just_one) | |
846 | { | |
847 | if (nrepeats) | |
848 | flush_repeats (typevec[maxtype-1]); | |
849 | ||
850 | /* To get here, parms must end with `...'. */ | |
851 | OB_PUTC ('e'); | |
852 | } | |
853 | ||
854 | if (end) OB_FINISH (); | |
855 | return (char *)obstack_base (&scratch_obstack); | |
856 | } | |
f376e137 MS |
857 | |
858 | tree | |
859 | build_static_name (basetype, name) | |
860 | tree basetype, name; | |
861 | { | |
862 | char *basename = build_overload_name (basetype, 1, 1); | |
863 | char *buf = (char *) alloca (IDENTIFIER_LENGTH (name) | |
864 | + sizeof (STATIC_NAME_FORMAT) | |
865 | + strlen (basename)); | |
866 | sprintf (buf, STATIC_NAME_FORMAT, basename, IDENTIFIER_POINTER (name)); | |
867 | return get_identifier (buf); | |
868 | } | |
8d08fdba MS |
869 | \f |
870 | /* Generate an identifier that encodes the (ANSI) exception TYPE. */ | |
871 | ||
872 | /* This should be part of `ansi_opname', or at least be defined by the std. */ | |
873 | #define EXCEPTION_NAME_PREFIX "__ex" | |
874 | #define EXCEPTION_NAME_LENGTH 4 | |
875 | ||
876 | tree | |
877 | cplus_exception_name (type) | |
878 | tree type; | |
879 | { | |
880 | OB_INIT (); | |
881 | OB_PUTS (EXCEPTION_NAME_PREFIX); | |
882 | return get_identifier (build_overload_name (type, 0, 1)); | |
883 | } | |
884 | \f | |
885 | /* Change the name of a function definition so that it may be | |
886 | overloaded. NAME is the name of the function to overload, | |
887 | PARMS is the parameter list (which determines what name the | |
888 | final function obtains). | |
889 | ||
890 | FOR_METHOD is 1 if this overload is being performed | |
891 | for a method, rather than a function type. It is 2 if | |
892 | this overload is being performed for a constructor. */ | |
893 | tree | |
894 | build_decl_overload (dname, parms, for_method) | |
895 | tree dname; | |
896 | tree parms; | |
897 | int for_method; | |
898 | { | |
899 | char *name = IDENTIFIER_POINTER (dname); | |
900 | ||
a28e3c7f MS |
901 | /* member operators new and delete look like methods at this point. */ |
902 | if (! for_method && parms != NULL_TREE && TREE_CODE (parms) == TREE_LIST) | |
903 | { | |
00595019 MS |
904 | if (dname == ansi_opname[(int) DELETE_EXPR]) |
905 | return get_identifier ("__builtin_delete"); | |
906 | else if (dname == ansi_opname[(int) VEC_DELETE_EXPR]) | |
907 | return get_identifier ("__builtin_vec_delete"); | |
908 | else if (TREE_CHAIN (parms) == void_list_node) | |
a28e3c7f MS |
909 | { |
910 | if (dname == ansi_opname[(int) NEW_EXPR]) | |
911 | return get_identifier ("__builtin_new"); | |
912 | else if (dname == ansi_opname[(int) VEC_NEW_EXPR]) | |
913 | return get_identifier ("__builtin_vec_new"); | |
914 | } | |
a28e3c7f | 915 | } |
8d08fdba MS |
916 | |
917 | OB_INIT (); | |
918 | if (for_method != 2) | |
919 | OB_PUTCP (name); | |
920 | /* Otherwise, we can divine that this is a constructor, | |
921 | and figure out its name without any extra encoding. */ | |
922 | ||
923 | OB_PUTC2 ('_', '_'); | |
924 | if (for_method) | |
925 | { | |
926 | #if 0 | |
927 | /* We can get away without doing this. */ | |
928 | OB_PUTC ('M'); | |
929 | #endif | |
930 | { | |
931 | tree this_type = TREE_VALUE (parms); | |
932 | ||
933 | if (TREE_CODE (this_type) == RECORD_TYPE) /* a signature pointer */ | |
934 | parms = temp_tree_cons (NULL_TREE, SIGNATURE_TYPE (this_type), | |
935 | TREE_CHAIN (parms)); | |
936 | else | |
937 | parms = temp_tree_cons (NULL_TREE, TREE_TYPE (this_type), | |
938 | TREE_CHAIN (parms)); | |
939 | } | |
940 | } | |
941 | else | |
942 | OB_PUTC ('F'); | |
943 | ||
944 | if (parms == NULL_TREE) | |
945 | OB_PUTC2 ('e', '\0'); | |
946 | else if (parms == void_list_node) | |
947 | OB_PUTC2 ('v', '\0'); | |
948 | else | |
949 | { | |
950 | ALLOCATE_TYPEVEC (parms); | |
951 | nofold = 0; | |
952 | if (for_method) | |
953 | { | |
954 | build_overload_name (TREE_VALUE (parms), 0, 0); | |
955 | ||
956 | typevec[maxtype++] = TREE_VALUE (parms); | |
957 | TREE_USED (TREE_VALUE (parms)) = 1; | |
958 | ||
959 | if (TREE_CHAIN (parms)) | |
960 | build_overload_name (TREE_CHAIN (parms), 0, 1); | |
961 | else | |
962 | OB_PUTC2 ('e', '\0'); | |
963 | } | |
964 | else | |
965 | build_overload_name (parms, 0, 1); | |
966 | DEALLOCATE_TYPEVEC (parms); | |
967 | } | |
968 | { | |
969 | tree n = get_identifier (obstack_base (&scratch_obstack)); | |
970 | if (IDENTIFIER_OPNAME_P (dname)) | |
971 | IDENTIFIER_OPNAME_P (n) = 1; | |
972 | return n; | |
973 | } | |
974 | } | |
975 | ||
976 | /* Build an overload name for the type expression TYPE. */ | |
977 | tree | |
978 | build_typename_overload (type) | |
979 | tree type; | |
980 | { | |
981 | tree id; | |
982 | ||
983 | OB_INIT (); | |
984 | OB_PUTID (ansi_opname[(int) TYPE_EXPR]); | |
985 | nofold = 1; | |
986 | build_overload_name (type, 0, 1); | |
987 | id = get_identifier (obstack_base (&scratch_obstack)); | |
988 | IDENTIFIER_OPNAME_P (id) = 1; | |
a0a33927 | 989 | #if 0 |
51c184be | 990 | IDENTIFIER_GLOBAL_VALUE (id) = TYPE_NAME (type); |
a0a33927 | 991 | #endif |
51c184be | 992 | TREE_TYPE (id) = type; |
8d08fdba MS |
993 | return id; |
994 | } | |
995 | ||
996 | #ifndef NO_DOLLAR_IN_LABEL | |
997 | #define T_DESC_FORMAT "TD$" | |
998 | #define I_DESC_FORMAT "ID$" | |
999 | #define M_DESC_FORMAT "MD$" | |
1000 | #else | |
1001 | #if !defined(NO_DOT_IN_LABEL) | |
1002 | #define T_DESC_FORMAT "TD." | |
1003 | #define I_DESC_FORMAT "ID." | |
1004 | #define M_DESC_FORMAT "MD." | |
1005 | #else | |
1006 | #define T_DESC_FORMAT "__t_desc_" | |
1007 | #define I_DESC_FORMAT "__i_desc_" | |
1008 | #define M_DESC_FORMAT "__m_desc_" | |
1009 | #endif | |
1010 | #endif | |
1011 | ||
1012 | /* Build an overload name for the type expression TYPE. */ | |
1013 | tree | |
1014 | build_t_desc_overload (type) | |
1015 | tree type; | |
1016 | { | |
1017 | OB_INIT (); | |
1018 | OB_PUTS (T_DESC_FORMAT); | |
1019 | nofold = 1; | |
1020 | ||
1021 | #if 0 | |
1022 | /* Use a different format if the type isn't defined yet. */ | |
1023 | if (TYPE_SIZE (type) == NULL_TREE) | |
1024 | { | |
1025 | char *p; | |
1026 | int changed; | |
1027 | ||
1028 | for (p = tname; *p; p++) | |
1029 | if (isupper (*p)) | |
1030 | { | |
1031 | changed = 1; | |
1032 | *p = tolower (*p); | |
1033 | } | |
1034 | /* If there's no change, we have an inappropriate T_DESC_FORMAT. */ | |
1035 | my_friendly_assert (changed != 0, 249); | |
1036 | } | |
1037 | #endif | |
1038 | ||
1039 | build_overload_name (type, 0, 1); | |
1040 | return get_identifier (obstack_base (&scratch_obstack)); | |
1041 | } | |
1042 | ||
1043 | /* Top-level interface to explicit overload requests. Allow NAME | |
1044 | to be overloaded. Error if NAME is already declared for the current | |
1045 | scope. Warning if function is redundantly overloaded. */ | |
1046 | ||
1047 | void | |
1048 | declare_overloaded (name) | |
1049 | tree name; | |
1050 | { | |
1051 | #ifdef NO_AUTO_OVERLOAD | |
1052 | if (is_overloaded (name)) | |
1053 | warning ("function `%s' already declared overloaded", | |
1054 | IDENTIFIER_POINTER (name)); | |
1055 | else if (IDENTIFIER_GLOBAL_VALUE (name)) | |
1056 | error ("overloading function `%s' that is already defined", | |
1057 | IDENTIFIER_POINTER (name)); | |
1058 | else | |
1059 | { | |
1060 | TREE_OVERLOADED (name) = 1; | |
1061 | IDENTIFIER_GLOBAL_VALUE (name) = build_tree_list (name, NULL_TREE); | |
1062 | TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name)) = unknown_type_node; | |
1063 | } | |
1064 | #else | |
1065 | if (current_lang_name == lang_name_cplusplus) | |
1066 | { | |
1067 | if (0) | |
1068 | warning ("functions are implicitly overloaded in C++"); | |
1069 | } | |
1070 | else if (current_lang_name == lang_name_c) | |
1071 | error ("overloading function `%s' cannot be done in C language context"); | |
1072 | else | |
1073 | my_friendly_abort (76); | |
1074 | #endif | |
1075 | } | |
1076 | ||
1077 | #ifdef NO_AUTO_OVERLOAD | |
1078 | /* Check to see if NAME is overloaded. For first approximation, | |
1079 | check to see if its TREE_OVERLOADED is set. This is used on | |
1080 | IDENTIFIER nodes. */ | |
1081 | int | |
1082 | is_overloaded (name) | |
1083 | tree name; | |
1084 | { | |
1085 | /* @@ */ | |
1086 | return (TREE_OVERLOADED (name) | |
1087 | && (! IDENTIFIER_CLASS_VALUE (name) || current_class_type == 0) | |
1088 | && ! IDENTIFIER_LOCAL_VALUE (name)); | |
1089 | } | |
1090 | #endif | |
1091 | \f | |
1092 | /* Given a tree_code CODE, and some arguments (at least one), | |
1093 | attempt to use an overloaded operator on the arguments. | |
1094 | ||
1095 | For unary operators, only the first argument need be checked. | |
1096 | For binary operators, both arguments may need to be checked. | |
1097 | ||
1098 | Member functions can convert class references to class pointers, | |
1099 | for one-level deep indirection. More than that is not supported. | |
1100 | Operators [](), ()(), and ->() must be member functions. | |
1101 | ||
1102 | We call function call building calls with LOOKUP_COMPLAIN if they | |
1103 | are our only hope. This is true when we see a vanilla operator | |
1104 | applied to something of aggregate type. If this fails, we are free | |
1105 | to return `error_mark_node', because we will have reported the | |
1106 | error. | |
1107 | ||
1108 | Operators NEW and DELETE overload in funny ways: operator new takes | |
1109 | a single `size' parameter, and operator delete takes a pointer to the | |
1110 | storage being deleted. When overloading these operators, success is | |
1111 | assumed. If there is a failure, report an error message and return | |
1112 | `error_mark_node'. */ | |
1113 | ||
1114 | /* NOSTRICT */ | |
1115 | tree | |
1116 | build_opfncall (code, flags, xarg1, xarg2, arg3) | |
1117 | enum tree_code code; | |
1118 | int flags; | |
1119 | tree xarg1, xarg2, arg3; | |
1120 | { | |
1121 | tree rval = 0; | |
1122 | tree arg1, arg2; | |
1123 | tree type1, type2, fnname; | |
1124 | tree fields1 = 0, parms = 0; | |
1125 | tree global_fn; | |
1126 | int try_second; | |
1127 | int binary_is_unary; | |
1128 | ||
1129 | if (xarg1 == error_mark_node) | |
1130 | return error_mark_node; | |
1131 | ||
1132 | if (code == COND_EXPR) | |
1133 | { | |
1134 | if (TREE_CODE (xarg2) == ERROR_MARK | |
1135 | || TREE_CODE (arg3) == ERROR_MARK) | |
1136 | return error_mark_node; | |
1137 | } | |
1138 | if (code == COMPONENT_REF) | |
1139 | if (TREE_CODE (TREE_TYPE (xarg1)) == POINTER_TYPE) | |
1140 | return rval; | |
1141 | ||
1142 | /* First, see if we can work with the first argument */ | |
1143 | type1 = TREE_TYPE (xarg1); | |
1144 | ||
1145 | /* Some tree codes have length > 1, but we really only want to | |
1146 | overload them if their first argument has a user defined type. */ | |
1147 | switch (code) | |
1148 | { | |
1149 | case PREINCREMENT_EXPR: | |
1150 | case PREDECREMENT_EXPR: | |
1151 | case POSTINCREMENT_EXPR: | |
1152 | case POSTDECREMENT_EXPR: | |
1153 | case COMPONENT_REF: | |
1154 | binary_is_unary = 1; | |
1155 | try_second = 0; | |
1156 | break; | |
1157 | ||
1158 | /* ARRAY_REFs and CALL_EXPRs must overload successfully. | |
1159 | If they do not, return error_mark_node instead of NULL_TREE. */ | |
1160 | case ARRAY_REF: | |
1161 | if (xarg2 == error_mark_node) | |
1162 | return error_mark_node; | |
1163 | case CALL_EXPR: | |
1164 | rval = error_mark_node; | |
1165 | binary_is_unary = 0; | |
1166 | try_second = 0; | |
1167 | break; | |
1168 | ||
a28e3c7f | 1169 | case VEC_NEW_EXPR: |
8d08fdba MS |
1170 | case NEW_EXPR: |
1171 | { | |
a28e3c7f MS |
1172 | tree args = tree_cons (NULL_TREE, xarg2, arg3); |
1173 | fnname = ansi_opname[(int) code]; | |
8d08fdba | 1174 | if (flags & LOOKUP_GLOBAL) |
a28e3c7f | 1175 | return build_overload_call (fnname, args, flags & LOOKUP_COMPLAIN, |
8d08fdba MS |
1176 | (struct candidate *)0); |
1177 | ||
1178 | rval = build_method_call | |
1179 | (build_indirect_ref (build1 (NOP_EXPR, xarg1, error_mark_node), | |
1180 | "new"), | |
a28e3c7f | 1181 | fnname, args, NULL_TREE, flags); |
8d08fdba MS |
1182 | if (rval == error_mark_node) |
1183 | /* User might declare fancy operator new, but invoke it | |
1184 | like standard one. */ | |
1185 | return rval; | |
1186 | ||
1187 | TREE_TYPE (rval) = xarg1; | |
1188 | TREE_CALLS_NEW (rval) = 1; | |
1189 | return rval; | |
1190 | } | |
1191 | break; | |
1192 | ||
a28e3c7f | 1193 | case VEC_DELETE_EXPR: |
8d08fdba MS |
1194 | case DELETE_EXPR: |
1195 | { | |
a28e3c7f | 1196 | fnname = ansi_opname[(int) code]; |
8d08fdba MS |
1197 | if (flags & LOOKUP_GLOBAL) |
1198 | return build_overload_call (fnname, | |
a28e3c7f | 1199 | build_tree_list (NULL_TREE, xarg1), |
8d08fdba MS |
1200 | flags & LOOKUP_COMPLAIN, |
1201 | (struct candidate *)0); | |
1202 | ||
1203 | rval = build_method_call | |
1204 | (build_indirect_ref (build1 (NOP_EXPR, TREE_TYPE (xarg1), | |
1205 | error_mark_node), | |
1206 | NULL_PTR), | |
1207 | fnname, tree_cons (NULL_TREE, xarg1, | |
a28e3c7f | 1208 | build_tree_list (NULL_TREE, xarg2)), |
8d08fdba | 1209 | NULL_TREE, flags); |
d18c083e MS |
1210 | #if 0 |
1211 | /* This can happen when operator delete is protected. */ | |
8d08fdba MS |
1212 | my_friendly_assert (rval != error_mark_node, 250); |
1213 | TREE_TYPE (rval) = void_type_node; | |
d18c083e | 1214 | #endif |
8d08fdba MS |
1215 | return rval; |
1216 | } | |
1217 | break; | |
1218 | ||
1219 | default: | |
1220 | binary_is_unary = 0; | |
1221 | try_second = tree_code_length [(int) code] == 2; | |
1222 | if (try_second && xarg2 == error_mark_node) | |
1223 | return error_mark_node; | |
1224 | break; | |
1225 | } | |
1226 | ||
1227 | if (try_second && xarg2 == error_mark_node) | |
1228 | return error_mark_node; | |
1229 | ||
1230 | /* What ever it was, we do not know how to deal with it. */ | |
1231 | if (type1 == NULL_TREE) | |
1232 | return rval; | |
1233 | ||
1234 | if (TREE_CODE (type1) == OFFSET_TYPE) | |
1235 | type1 = TREE_TYPE (type1); | |
1236 | ||
1237 | if (TREE_CODE (type1) == REFERENCE_TYPE) | |
1238 | { | |
1239 | arg1 = convert_from_reference (xarg1); | |
1240 | type1 = TREE_TYPE (arg1); | |
1241 | } | |
1242 | else | |
1243 | { | |
1244 | arg1 = xarg1; | |
1245 | } | |
1246 | ||
1247 | if (!IS_AGGR_TYPE (type1) || TYPE_PTRMEMFUNC_P (type1)) | |
1248 | { | |
1249 | /* Try to fail. First, fail if unary */ | |
1250 | if (! try_second) | |
1251 | return rval; | |
1252 | /* Second, see if second argument is non-aggregate. */ | |
1253 | type2 = TREE_TYPE (xarg2); | |
1254 | if (TREE_CODE (type2) == OFFSET_TYPE) | |
1255 | type2 = TREE_TYPE (type2); | |
1256 | if (TREE_CODE (type2) == REFERENCE_TYPE) | |
1257 | { | |
1258 | arg2 = convert_from_reference (xarg2); | |
1259 | type2 = TREE_TYPE (arg2); | |
1260 | } | |
1261 | else | |
1262 | { | |
1263 | arg2 = xarg2; | |
1264 | } | |
1265 | ||
1266 | if (!IS_AGGR_TYPE (type2)) | |
1267 | return rval; | |
1268 | try_second = 0; | |
1269 | } | |
1270 | ||
1271 | if (try_second) | |
1272 | { | |
1273 | /* First arg may succeed; see whether second should. */ | |
1274 | type2 = TREE_TYPE (xarg2); | |
1275 | if (TREE_CODE (type2) == OFFSET_TYPE) | |
1276 | type2 = TREE_TYPE (type2); | |
1277 | if (TREE_CODE (type2) == REFERENCE_TYPE) | |
1278 | { | |
1279 | arg2 = convert_from_reference (xarg2); | |
1280 | type2 = TREE_TYPE (arg2); | |
1281 | } | |
1282 | else | |
1283 | { | |
1284 | arg2 = xarg2; | |
1285 | } | |
1286 | ||
1287 | if (! IS_AGGR_TYPE (type2)) | |
1288 | try_second = 0; | |
1289 | } | |
1290 | ||
1291 | if (type1 == unknown_type_node | |
1292 | || (try_second && TREE_TYPE (xarg2) == unknown_type_node)) | |
1293 | { | |
1294 | /* This will not be implemented in the foreseeable future. */ | |
1295 | return rval; | |
1296 | } | |
1297 | ||
1298 | if (code == MODIFY_EXPR) | |
1299 | fnname = ansi_assopname[(int) TREE_CODE (arg3)]; | |
1300 | else | |
1301 | fnname = ansi_opname[(int) code]; | |
1302 | ||
700f8a87 | 1303 | global_fn = lookup_name_nonclass (fnname); |
8d08fdba MS |
1304 | |
1305 | /* This is the last point where we will accept failure. This | |
1306 | may be too eager if we wish an overloaded operator not to match, | |
1307 | but would rather a normal operator be called on a type-converted | |
1308 | argument. */ | |
1309 | ||
1310 | if (IS_AGGR_TYPE (type1)) | |
1311 | { | |
1312 | fields1 = lookup_fnfields (TYPE_BINFO (type1), fnname, 0); | |
1313 | /* ARM $13.4.7, prefix/postfix ++/--. */ | |
1314 | if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR) | |
1315 | { | |
1316 | xarg2 = integer_zero_node; | |
1317 | binary_is_unary = 0; | |
1318 | ||
1319 | if (fields1) | |
1320 | { | |
1321 | tree t, t2; | |
1322 | int have_postfix = 0; | |
1323 | ||
1324 | /* Look for an `operator++ (int)'. If they didn't have | |
1325 | one, then we fall back to the old way of doing things. */ | |
1326 | for (t = TREE_VALUE (fields1); t ; t = TREE_CHAIN (t)) | |
1327 | { | |
1328 | t2 = TYPE_ARG_TYPES (TREE_TYPE (t)); | |
1329 | if (TREE_CHAIN (t2) != NULL_TREE | |
1330 | && TREE_VALUE (TREE_CHAIN (t2)) == integer_type_node) | |
1331 | { | |
1332 | have_postfix = 1; | |
1333 | break; | |
1334 | } | |
1335 | } | |
1336 | ||
1337 | if (! have_postfix) | |
1338 | { | |
1339 | char *op = POSTINCREMENT_EXPR ? "++" : "--"; | |
1340 | ||
1341 | /* There's probably a LOT of code in the world that | |
1342 | relies upon this old behavior. So we'll only give this | |
1343 | warning when we've been given -pedantic. A few | |
1344 | releases after 2.4, we'll convert this to be a pedwarn | |
1345 | or something else more appropriate. */ | |
1346 | if (pedantic) | |
1347 | warning ("no `operator%s (int)' declared for postfix `%s'", | |
1348 | op, op); | |
1349 | xarg2 = NULL_TREE; | |
1350 | binary_is_unary = 1; | |
1351 | } | |
1352 | } | |
1353 | } | |
1354 | } | |
1355 | ||
1356 | if (fields1 == NULL_TREE && global_fn == NULL_TREE) | |
1357 | return rval; | |
1358 | ||
1359 | /* If RVAL winds up being `error_mark_node', we will return | |
1360 | that... There is no way that normal semantics of these | |
1361 | operators will succeed. */ | |
1362 | ||
1363 | /* This argument may be an uncommitted OFFSET_REF. This is | |
1364 | the case for example when dealing with static class members | |
1365 | which are referenced from their class name rather than | |
1366 | from a class instance. */ | |
1367 | if (TREE_CODE (xarg1) == OFFSET_REF | |
1368 | && TREE_CODE (TREE_OPERAND (xarg1, 1)) == VAR_DECL) | |
1369 | xarg1 = TREE_OPERAND (xarg1, 1); | |
1370 | if (try_second && xarg2 && TREE_CODE (xarg2) == OFFSET_REF | |
1371 | && TREE_CODE (TREE_OPERAND (xarg2, 1)) == VAR_DECL) | |
1372 | xarg2 = TREE_OPERAND (xarg2, 1); | |
1373 | ||
1374 | if (global_fn) | |
1375 | flags |= LOOKUP_GLOBAL; | |
1376 | ||
1377 | if (code == CALL_EXPR) | |
1378 | { | |
1379 | /* This can only be a member function. */ | |
1380 | return build_method_call (xarg1, fnname, xarg2, | |
1381 | NULL_TREE, LOOKUP_NORMAL); | |
1382 | } | |
1383 | else if (tree_code_length[(int) code] == 1 || binary_is_unary) | |
1384 | { | |
1385 | parms = NULL_TREE; | |
1386 | rval = build_method_call (xarg1, fnname, NULL_TREE, NULL_TREE, flags); | |
1387 | } | |
1388 | else if (code == COND_EXPR) | |
1389 | { | |
1390 | parms = tree_cons (0, xarg2, build_tree_list (NULL_TREE, arg3)); | |
1391 | rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags); | |
1392 | } | |
1393 | else if (code == METHOD_CALL_EXPR) | |
1394 | { | |
1395 | /* must be a member function. */ | |
1396 | parms = tree_cons (NULL_TREE, xarg2, arg3); | |
1397 | return build_method_call (xarg1, fnname, parms, NULL_TREE, | |
1398 | LOOKUP_NORMAL); | |
1399 | } | |
1400 | else if (fields1) | |
1401 | { | |
1402 | parms = build_tree_list (NULL_TREE, xarg2); | |
1403 | rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags); | |
1404 | } | |
1405 | else | |
1406 | { | |
1407 | parms = tree_cons (NULL_TREE, xarg1, | |
1408 | build_tree_list (NULL_TREE, xarg2)); | |
1409 | rval = build_overload_call (fnname, parms, flags, | |
1410 | (struct candidate *)0); | |
1411 | } | |
1412 | ||
1413 | return rval; | |
1414 | } | |
1415 | \f | |
1416 | /* This function takes an identifier, ID, and attempts to figure out what | |
1417 | it means. There are a number of possible scenarios, presented in increasing | |
1418 | order of hair: | |
1419 | ||
1420 | 1) not in a class's scope | |
1421 | 2) in class's scope, member name of the class's method | |
1422 | 3) in class's scope, but not a member name of the class | |
1423 | 4) in class's scope, member name of a class's variable | |
1424 | ||
1425 | NAME is $1 from the bison rule. It is an IDENTIFIER_NODE. | |
1426 | VALUE is $$ from the bison rule. It is the value returned by lookup_name ($1) | |
1427 | yychar is the pending input character (suitably encoded :-). | |
1428 | ||
1429 | As a last ditch, try to look up the name as a label and return that | |
1430 | address. | |
1431 | ||
1432 | Values which are declared as being of REFERENCE_TYPE are | |
1433 | automatically dereferenced here (as a hack to make the | |
1434 | compiler faster). */ | |
1435 | ||
1436 | tree | |
1437 | hack_identifier (value, name, yychar) | |
1438 | tree value, name; | |
1439 | int yychar; | |
1440 | { | |
1441 | tree type; | |
1442 | ||
1443 | if (TREE_CODE (value) == ERROR_MARK) | |
1444 | { | |
1445 | if (current_class_name) | |
1446 | { | |
1447 | tree fields = lookup_fnfields (TYPE_BINFO (current_class_type), name, 1); | |
1448 | if (fields == error_mark_node) | |
1449 | return error_mark_node; | |
1450 | if (fields) | |
1451 | { | |
1452 | tree fndecl; | |
1453 | ||
1454 | fndecl = TREE_VALUE (fields); | |
1455 | my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 251); | |
1456 | if (DECL_CHAIN (fndecl) == NULL_TREE) | |
1457 | { | |
1458 | warning ("methods cannot be converted to function pointers"); | |
1459 | return fndecl; | |
1460 | } | |
1461 | else | |
1462 | { | |
1463 | error ("ambiguous request for method pointer `%s'", | |
1464 | IDENTIFIER_POINTER (name)); | |
1465 | return error_mark_node; | |
1466 | } | |
1467 | } | |
1468 | } | |
1469 | if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name)) | |
1470 | { | |
1471 | return IDENTIFIER_LABEL_VALUE (name); | |
1472 | } | |
1473 | return error_mark_node; | |
1474 | } | |
1475 | ||
1476 | type = TREE_TYPE (value); | |
1477 | if (TREE_CODE (value) == FIELD_DECL) | |
1478 | { | |
1479 | if (current_class_decl == NULL_TREE) | |
1480 | { | |
1481 | error ("request for member `%s' in static member function", | |
1482 | IDENTIFIER_POINTER (DECL_NAME (value))); | |
1483 | return error_mark_node; | |
1484 | } | |
1485 | TREE_USED (current_class_decl) = 1; | |
a5894242 | 1486 | |
8d08fdba MS |
1487 | /* Mark so that if we are in a constructor, and then find that |
1488 | this field was initialized by a base initializer, | |
1489 | we can emit an error message. */ | |
1490 | TREE_USED (value) = 1; | |
1491 | return build_component_ref (C_C_D, name, 0, 1); | |
1492 | } | |
1493 | ||
a5ef9010 | 1494 | if (really_overloaded_fn (value)) |
8d08fdba | 1495 | { |
5b605f68 | 1496 | tree t = get_first_fn (value); |
eac293a1 | 1497 | for (; t; t = DECL_CHAIN (t)) |
8d08fdba | 1498 | { |
eac293a1 MS |
1499 | if (TREE_CODE (t) == TEMPLATE_DECL) |
1500 | continue; | |
1501 | ||
5b605f68 | 1502 | assemble_external (t); |
8d08fdba | 1503 | TREE_USED (t) = 1; |
8d08fdba MS |
1504 | } |
1505 | } | |
a5ef9010 JM |
1506 | else if (TREE_CODE (value) == TREE_LIST) |
1507 | { | |
1508 | tree t = value; | |
1509 | while (t && TREE_CODE (t) == TREE_LIST) | |
1510 | { | |
1511 | assemble_external (TREE_VALUE (t)); | |
1512 | TREE_USED (t) = 1; | |
1513 | t = TREE_CHAIN (t); | |
1514 | } | |
1515 | } | |
8d08fdba MS |
1516 | else |
1517 | { | |
1518 | assemble_external (value); | |
1519 | TREE_USED (value) = 1; | |
1520 | } | |
1521 | ||
1522 | if (TREE_CODE_CLASS (TREE_CODE (value)) == 'd' && DECL_NONLOCAL (value)) | |
1523 | { | |
1524 | if (DECL_LANG_SPECIFIC (value) | |
1525 | && DECL_CLASS_CONTEXT (value) != current_class_type) | |
1526 | { | |
1527 | tree path; | |
1528 | enum access_type access; | |
1529 | register tree context | |
1530 | = (TREE_CODE (value) == FUNCTION_DECL && DECL_VIRTUAL_P (value)) | |
1531 | ? DECL_CLASS_CONTEXT (value) | |
1532 | : DECL_CONTEXT (value); | |
1533 | ||
1534 | get_base_distance (context, current_class_type, 0, &path); | |
1535 | if (path) | |
1536 | { | |
1537 | access = compute_access (path, value); | |
1538 | if (access != access_public) | |
1539 | { | |
1540 | if (TREE_CODE (value) == VAR_DECL) | |
1541 | error ("static member `%s' is %s", | |
1542 | IDENTIFIER_POINTER (name), | |
1543 | TREE_PRIVATE (value) ? "private" : | |
1544 | "from a private base class"); | |
1545 | else | |
1546 | error ("enum `%s' is from private base class", | |
1547 | IDENTIFIER_POINTER (name)); | |
1548 | return error_mark_node; | |
1549 | } | |
1550 | } | |
1551 | } | |
1552 | return value; | |
1553 | } | |
1554 | if (TREE_CODE (value) == TREE_LIST && TREE_NONLOCAL_FLAG (value)) | |
1555 | { | |
1556 | if (type == 0) | |
1557 | { | |
1558 | error ("request for member `%s' is ambiguous in multiple inheritance lattice", | |
1559 | IDENTIFIER_POINTER (name)); | |
1560 | return error_mark_node; | |
1561 | } | |
1562 | ||
1563 | return value; | |
1564 | } | |
1565 | ||
1566 | if (TREE_CODE (type) == REFERENCE_TYPE) | |
1567 | { | |
1568 | my_friendly_assert (TREE_CODE (value) == VAR_DECL | |
1569 | || TREE_CODE (value) == PARM_DECL | |
1570 | || TREE_CODE (value) == RESULT_DECL, 252); | |
878cd289 | 1571 | return convert_from_reference (value); |
8d08fdba MS |
1572 | } |
1573 | return value; | |
1574 | } | |
1575 | ||
1576 | \f | |
39211cd5 | 1577 | #if 0 |
8d08fdba MS |
1578 | /* Given an object OF, and a type conversion operator COMPONENT |
1579 | build a call to the conversion operator, if a call is requested, | |
1580 | or return the address (as a pointer to member function) if one is not. | |
1581 | ||
1582 | OF can be a TYPE_DECL or any kind of datum that would normally | |
1583 | be passed to `build_component_ref'. It may also be NULL_TREE, | |
1584 | in which case `current_class_type' and `current_class_decl' | |
1585 | provide default values. | |
1586 | ||
1587 | BASETYPE_PATH, if non-null, is the path of basetypes | |
1588 | to go through before we get the the instance of interest. | |
1589 | ||
1590 | PROTECT says whether we apply C++ scoping rules or not. */ | |
1591 | tree | |
1592 | build_component_type_expr (of, component, basetype_path, protect) | |
1593 | tree of, component, basetype_path; | |
1594 | int protect; | |
1595 | { | |
1596 | tree cname = NULL_TREE; | |
1597 | tree tmp, last; | |
1598 | tree name; | |
1599 | int flags = protect ? LOOKUP_NORMAL : LOOKUP_COMPLAIN; | |
1600 | ||
1601 | if (of) | |
1602 | my_friendly_assert (IS_AGGR_TYPE (TREE_TYPE (of)), 253); | |
1603 | my_friendly_assert (TREE_CODE (component) == TYPE_EXPR, 254); | |
1604 | ||
1605 | tmp = TREE_OPERAND (component, 0); | |
1606 | last = NULL_TREE; | |
1607 | ||
1608 | while (tmp) | |
1609 | { | |
1610 | switch (TREE_CODE (tmp)) | |
1611 | { | |
1612 | case CALL_EXPR: | |
1613 | if (last) | |
1614 | TREE_OPERAND (last, 0) = TREE_OPERAND (tmp, 0); | |
1615 | else | |
1616 | TREE_OPERAND (component, 0) = TREE_OPERAND (tmp, 0); | |
1617 | ||
1618 | last = groktypename (build_tree_list (TREE_TYPE (component), | |
1619 | TREE_OPERAND (component, 0))); | |
1620 | name = build_typename_overload (last); | |
1621 | TREE_TYPE (name) = last; | |
1622 | ||
1623 | if (TREE_OPERAND (tmp, 0) | |
1624 | && TREE_OPERAND (tmp, 0) != void_list_node) | |
1625 | { | |
1626 | cp_error ("`operator %T' requires empty parameter list", last); | |
1627 | TREE_OPERAND (tmp, 0) = NULL_TREE; | |
1628 | } | |
1629 | ||
1630 | if (of && TREE_CODE (of) != TYPE_DECL) | |
1631 | return build_method_call (of, name, NULL_TREE, NULL_TREE, flags); | |
1632 | else if (of) | |
1633 | { | |
1634 | tree this_this; | |
1635 | ||
1636 | if (current_class_decl == NULL_TREE) | |
1637 | { | |
1638 | cp_error ("object required for `operator %T' call", | |
1639 | TREE_TYPE (name)); | |
1640 | return error_mark_node; | |
1641 | } | |
1642 | ||
1643 | this_this = convert_pointer_to (TREE_TYPE (of), | |
1644 | current_class_decl); | |
1645 | this_this = build_indirect_ref (this_this, NULL_PTR); | |
1646 | return build_method_call (this_this, name, NULL_TREE, | |
1647 | NULL_TREE, flags | LOOKUP_NONVIRTUAL); | |
1648 | } | |
1649 | else if (current_class_decl) | |
1650 | return build_method_call (tmp, name, NULL_TREE, NULL_TREE, flags); | |
1651 | ||
1652 | cp_error ("object required for `operator %T' call", | |
1653 | TREE_TYPE (name)); | |
1654 | return error_mark_node; | |
1655 | ||
1656 | case INDIRECT_REF: | |
1657 | case ADDR_EXPR: | |
1658 | case ARRAY_REF: | |
1659 | break; | |
1660 | ||
1661 | case SCOPE_REF: | |
1662 | my_friendly_assert (cname == 0, 255); | |
1663 | cname = TREE_OPERAND (tmp, 0); | |
1664 | tmp = TREE_OPERAND (tmp, 1); | |
1665 | break; | |
1666 | ||
1667 | default: | |
1668 | my_friendly_abort (77); | |
1669 | } | |
1670 | last = tmp; | |
1671 | tmp = TREE_OPERAND (tmp, 0); | |
1672 | } | |
1673 | ||
1674 | last = groktypename (build_tree_list (TREE_TYPE (component), TREE_OPERAND (component, 0))); | |
1675 | name = build_typename_overload (last); | |
1676 | TREE_TYPE (name) = last; | |
1677 | if (of && TREE_CODE (of) == TYPE_DECL) | |
1678 | { | |
1679 | if (cname == NULL_TREE) | |
1680 | { | |
1681 | cname = DECL_NAME (of); | |
1682 | of = NULL_TREE; | |
1683 | } | |
1684 | else my_friendly_assert (cname == DECL_NAME (of), 256); | |
1685 | } | |
1686 | ||
1687 | if (of) | |
1688 | { | |
1689 | tree this_this; | |
1690 | ||
1691 | if (current_class_decl == NULL_TREE) | |
1692 | { | |
1693 | cp_error ("object required for `operator %T' call", | |
1694 | TREE_TYPE (name)); | |
1695 | return error_mark_node; | |
1696 | } | |
1697 | ||
1698 | this_this = convert_pointer_to (TREE_TYPE (of), current_class_decl); | |
1699 | return build_component_ref (this_this, name, 0, protect); | |
1700 | } | |
1701 | else if (cname) | |
1702 | return build_offset_ref (cname, name); | |
1703 | else if (current_class_name) | |
1704 | return build_offset_ref (current_class_name, name); | |
1705 | ||
1706 | cp_error ("object required for `operator %T' member reference", | |
1707 | TREE_TYPE (name)); | |
1708 | return error_mark_node; | |
1709 | } | |
39211cd5 | 1710 | #endif |
8926095f MS |
1711 | \f |
1712 | static char * | |
1713 | thunk_printable_name (decl) | |
1714 | tree decl; | |
1715 | { | |
1716 | return "<thunk function>"; | |
1717 | } | |
1718 | ||
1719 | tree | |
1720 | make_thunk (function, delta) | |
1721 | tree function; | |
1722 | int delta; | |
1723 | { | |
1724 | char buffer[250]; | |
a0a33927 | 1725 | tree thunk_fndecl, thunk_id; |
8926095f | 1726 | tree thunk; |
a0a33927 | 1727 | char *func_name; |
8926095f MS |
1728 | static int thunk_number = 0; |
1729 | tree func_decl; | |
1730 | if (TREE_CODE (function) != ADDR_EXPR) | |
1731 | abort (); | |
1732 | func_decl = TREE_OPERAND (function, 0); | |
1733 | if (TREE_CODE (func_decl) != FUNCTION_DECL) | |
1734 | abort (); | |
a0a33927 | 1735 | func_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func_decl)); |
5edb8b93 MS |
1736 | if (delta<=0) |
1737 | sprintf (buffer, "__thunk_%d_%s", -delta, func_name); | |
1738 | else | |
1739 | sprintf (buffer, "__thunk_n%d_%s", delta, func_name); | |
a0a33927 MS |
1740 | thunk_id = get_identifier (buffer); |
1741 | thunk = IDENTIFIER_GLOBAL_VALUE (thunk_id); | |
1742 | if (thunk && TREE_CODE (thunk) != THUNK_DECL) | |
1743 | { | |
1744 | error_with_decl ("implementation-reserved name `%s' used"); | |
1745 | IDENTIFIER_GLOBAL_VALUE (thunk_id) = thunk = NULL_TREE; | |
1746 | } | |
1747 | if (thunk == NULL_TREE) | |
1748 | { | |
1749 | thunk = build_decl (THUNK_DECL, thunk_id, TREE_TYPE (func_decl)); | |
1750 | DECL_RESULT (thunk) | |
1751 | = build_decl (RESULT_DECL, NULL_TREE, TREE_TYPE (vtable_entry_type)); | |
1752 | make_function_rtl (thunk); | |
1753 | DECL_INITIAL (thunk) = function; | |
1754 | THUNK_DELTA (thunk) = delta; | |
1755 | /* So that finish_file can write out any thunks that need to be: */ | |
1756 | pushdecl_top_level (thunk); | |
1757 | } | |
8926095f MS |
1758 | return thunk; |
1759 | } | |
1760 | ||
1761 | void | |
1762 | emit_thunk (thunk_fndecl) | |
1763 | tree thunk_fndecl; | |
1764 | { | |
1765 | rtx insns; | |
1766 | char *fnname; | |
1767 | char buffer[250]; | |
1768 | tree argp; | |
1769 | struct args_size stack_args_size; | |
1770 | tree function = TREE_OPERAND (DECL_INITIAL (thunk_fndecl), 0); | |
1771 | int delta = THUNK_DELTA (thunk_fndecl); | |
1772 | int tem; | |
1773 | int failure = 0; | |
2986ae00 | 1774 | int current_call_is_indirect = 0; /* needed for HPPA FUNCTION_ARG */ |
8926095f MS |
1775 | |
1776 | /* Used to remember which regs we need to emit a USE rtx for. */ | |
1777 | rtx need_use[FIRST_PSEUDO_REGISTER]; | |
1778 | int need_use_count = 0; | |
1779 | ||
1780 | /* rtx for the 'this' parameter. */ | |
1781 | rtx this_rtx = 0, this_reg_rtx = 0, fixed_this_rtx; | |
1782 | ||
1783 | char *(*save_decl_printable_name) () = decl_printable_name; | |
1784 | /* Data on reg parms scanned so far. */ | |
1785 | CUMULATIVE_ARGS args_so_far; | |
1786 | ||
1787 | if (TREE_ASM_WRITTEN (thunk_fndecl)) | |
1788 | return; | |
1789 | ||
a0a33927 MS |
1790 | TREE_ASM_WRITTEN (thunk_fndecl) = 1; |
1791 | ||
1792 | if (TREE_PUBLIC (function)) | |
1793 | { | |
1794 | TREE_PUBLIC (thunk_fndecl) = 1; | |
1795 | if (DECL_EXTERNAL (function)) | |
1796 | { | |
1797 | DECL_EXTERNAL (thunk_fndecl) = 1; | |
1798 | assemble_external (thunk_fndecl); | |
1799 | return; | |
1800 | } | |
1801 | } | |
1802 | ||
8926095f MS |
1803 | decl_printable_name = thunk_printable_name; |
1804 | if (current_function_decl) | |
1805 | abort (); | |
1806 | current_function_decl = thunk_fndecl; | |
1807 | init_function_start (thunk_fndecl, input_filename, lineno); | |
1808 | pushlevel (0); | |
1809 | expand_start_bindings (1); | |
1810 | ||
1811 | /* Start updating where the next arg would go. */ | |
1812 | INIT_CUMULATIVE_ARGS (args_so_far, TREE_TYPE (function), NULL_RTX); | |
1813 | stack_args_size.constant = 0; | |
1814 | stack_args_size.var = 0; | |
1815 | /* SETUP for possible structure return address FIXME */ | |
1816 | ||
1817 | /* Now look through all the parameters, make sure that we | |
1818 | don't clobber any registers used for parameters. | |
1819 | Also, pick up an rtx for the first "this" parameter. */ | |
1820 | for (argp = TYPE_ARG_TYPES (TREE_TYPE (function)); | |
1821 | argp != NULL_TREE; | |
1822 | argp = TREE_CHAIN (argp)) | |
1823 | ||
1824 | { | |
1825 | tree passed_type = TREE_VALUE (argp); | |
1826 | register rtx entry_parm; | |
1827 | int named = 1; /* FIXME */ | |
1828 | struct args_size stack_offset; | |
1829 | struct args_size arg_size; | |
1830 | ||
1831 | if (passed_type == void_type_node) | |
1832 | break; | |
1833 | ||
1834 | if ((TREE_CODE (TYPE_SIZE (passed_type)) != INTEGER_CST | |
1835 | && contains_placeholder_p (TYPE_SIZE (passed_type))) | |
1836 | #ifdef FUNCTION_ARG_PASS_BY_REFERENCE | |
1837 | || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far, | |
1838 | TYPE_MODE (passed_type), | |
1839 | passed_type, named) | |
1840 | #endif | |
1841 | ) | |
1842 | passed_type = build_pointer_type (passed_type); | |
1843 | ||
1844 | entry_parm = FUNCTION_ARG (args_so_far, | |
1845 | TYPE_MODE (passed_type), | |
1846 | passed_type, | |
1847 | named); | |
1848 | if (entry_parm != 0) | |
1849 | need_use[need_use_count++] = entry_parm; | |
1850 | ||
1851 | locate_and_pad_parm (TYPE_MODE (passed_type), passed_type, | |
1852 | #ifdef STACK_PARMS_IN_REG_PARM_AREA | |
1853 | 1, | |
1854 | #else | |
1855 | entry_parm != 0, | |
1856 | #endif | |
1857 | thunk_fndecl, | |
1858 | &stack_args_size, &stack_offset, &arg_size); | |
1859 | ||
1860 | /* REGNO (entry_parm);*/ | |
1861 | if (this_rtx == 0) | |
1862 | { | |
1863 | this_reg_rtx = entry_parm; | |
1864 | if (!entry_parm) | |
1865 | { | |
1866 | rtx offset_rtx = ARGS_SIZE_RTX (stack_offset); | |
1867 | ||
1868 | rtx internal_arg_pointer, stack_parm; | |
1869 | ||
1870 | if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM | |
1871 | || ! (fixed_regs[ARG_POINTER_REGNUM] | |
1872 | || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM))) | |
1873 | internal_arg_pointer = copy_to_reg (virtual_incoming_args_rtx); | |
1874 | else | |
1875 | internal_arg_pointer = virtual_incoming_args_rtx; | |
1876 | ||
1877 | if (offset_rtx == const0_rtx) | |
1878 | entry_parm = gen_rtx (MEM, TYPE_MODE (passed_type), | |
1879 | internal_arg_pointer); | |
1880 | else | |
1881 | entry_parm = gen_rtx (MEM, TYPE_MODE (passed_type), | |
1882 | gen_rtx (PLUS, Pmode, | |
1883 | internal_arg_pointer, | |
1884 | offset_rtx)); | |
1885 | } | |
1886 | ||
1887 | this_rtx = entry_parm; | |
1888 | } | |
1889 | ||
1890 | FUNCTION_ARG_ADVANCE (args_so_far, | |
1891 | TYPE_MODE (passed_type), | |
1892 | passed_type, | |
1893 | named); | |
1894 | } | |
1895 | ||
1896 | fixed_this_rtx = plus_constant (this_rtx, delta); | |
1897 | if (this_rtx != fixed_this_rtx) | |
1898 | emit_move_insn (this_rtx, fixed_this_rtx); | |
1899 | ||
1900 | if (this_reg_rtx) | |
1901 | emit_insn (gen_rtx (USE, VOIDmode, this_reg_rtx)); | |
1902 | ||
1903 | emit_indirect_jump (XEXP (DECL_RTL (function), 0)); | |
1904 | ||
1905 | while (need_use_count > 0) | |
1906 | emit_insn (gen_rtx (USE, VOIDmode, need_use[--need_use_count])); | |
1907 | ||
1908 | expand_end_bindings (NULL, 1, 0); | |
faae18ab | 1909 | poplevel (0, 0, 1); |
8926095f | 1910 | |
8926095f MS |
1911 | /* From now on, allocate rtl in current_obstack, not in saveable_obstack. |
1912 | Note that that may have been done above, in save_for_inline_copying. | |
1913 | The call to resume_temporary_allocation near the end of this function | |
1914 | goes back to the usual state of affairs. */ | |
1915 | ||
1916 | rtl_in_current_obstack (); | |
1917 | ||
1918 | insns = get_insns (); | |
1919 | ||
1920 | /* Copy any shared structure that should not be shared. */ | |
1921 | ||
1922 | unshare_all_rtl (insns); | |
1923 | ||
db5ae43f MS |
1924 | /* Instantiate all virtual registers. */ |
1925 | ||
1926 | instantiate_virtual_regs (current_function_decl, get_insns ()); | |
1927 | ||
8926095f MS |
1928 | /* We are no longer anticipating cse in this function, at least. */ |
1929 | ||
1930 | cse_not_expected = 1; | |
1931 | ||
1932 | /* Now we choose between stupid (pcc-like) register allocation | |
1933 | (if we got the -noreg switch and not -opt) | |
1934 | and smart register allocation. */ | |
1935 | ||
1936 | if (optimize > 0) /* Stupid allocation probably won't work */ | |
1937 | obey_regdecls = 0; /* if optimizations being done. */ | |
1938 | ||
1939 | regclass_init (); | |
1940 | ||
1941 | regclass (insns, max_reg_num ()); | |
1942 | if (obey_regdecls) | |
1943 | { | |
1944 | stupid_life_analysis (insns, max_reg_num (), NULL); | |
1945 | failure = reload (insns, 0, NULL); | |
1946 | } | |
1947 | else | |
1948 | { | |
1949 | /* Do control and data flow analysis, | |
1950 | and write some of the results to dump file. */ | |
1951 | ||
1952 | flow_analysis (insns, max_reg_num (), NULL); | |
1953 | local_alloc (); | |
1954 | failure = global_alloc (NULL); | |
1955 | } | |
1956 | ||
1957 | reload_completed = 1; | |
1958 | ||
1959 | #ifdef LEAF_REGISTERS | |
1960 | leaf_function = 0; | |
1961 | if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) | |
1962 | leaf_function = 1; | |
1963 | #endif | |
1964 | ||
1965 | /* If a machine dependent reorganization is needed, call it. */ | |
1966 | #ifdef MACHINE_DEPENDENT_REORG | |
1967 | MACHINE_DEPENDENT_REORG (insns); | |
1968 | #endif | |
1969 | ||
1970 | /* Now turn the rtl into assembler code. */ | |
1971 | ||
1972 | { | |
1973 | char *fnname = XSTR (XEXP (DECL_RTL (thunk_fndecl), 0), 0); | |
1974 | assemble_start_function (thunk_fndecl, fnname); | |
1975 | final (insns, asm_out_file, optimize, 0); | |
1976 | assemble_end_function (thunk_fndecl, fnname); | |
1977 | }; | |
1978 | ||
1979 | exit_rest_of_compilation: | |
1980 | ||
1981 | reload_completed = 0; | |
1982 | ||
1983 | /* Cancel the effect of rtl_in_current_obstack. */ | |
1984 | ||
1985 | resume_temporary_allocation (); | |
1986 | ||
1987 | decl_printable_name = save_decl_printable_name; | |
1988 | current_function_decl = 0; | |
1989 | } | |
f376e137 MS |
1990 | \f |
1991 | /* Code for synthesizing methods which have default semantics defined. */ | |
1992 | ||
0171aeab JM |
1993 | /* For the anonymous union in TYPE, return the member that is at least as |
1994 | large as the rest of the members, so we can copy it. */ | |
1995 | static tree | |
1996 | largest_union_member (type) | |
1997 | tree type; | |
1998 | { | |
1999 | tree f, type_size = TYPE_SIZE (type); | |
2000 | ||
2001 | for (f = TYPE_FIELDS (type); f; f = TREE_CHAIN (f)) | |
14ac3bfe | 2002 | if (simple_cst_equal (DECL_SIZE (f), type_size) == 1) |
0171aeab JM |
2003 | return f; |
2004 | ||
2005 | /* We should always find one. */ | |
2006 | my_friendly_abort (323); | |
2007 | return NULL_TREE; | |
2008 | } | |
2009 | ||
f376e137 MS |
2010 | /* Generate code for default X(X&) constructor. */ |
2011 | void | |
db5ae43f | 2012 | do_build_copy_constructor (fndecl) |
f376e137 MS |
2013 | tree fndecl; |
2014 | { | |
2015 | tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl)); | |
2016 | tree t; | |
2017 | ||
f376e137 MS |
2018 | clear_last_expr (); |
2019 | push_momentary (); | |
2020 | ||
2021 | if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)) | |
2022 | parm = TREE_CHAIN (parm); | |
2023 | parm = convert_from_reference (parm); | |
2024 | ||
e8abc66f | 2025 | if (TYPE_HAS_TRIVIAL_INIT_REF (current_class_type)) |
f376e137 MS |
2026 | { |
2027 | t = build (INIT_EXPR, void_type_node, C_C_D, parm); | |
2028 | TREE_SIDE_EFFECTS (t) = 1; | |
2029 | cplus_expand_expr_stmt (t); | |
2030 | } | |
2031 | else | |
2032 | { | |
2033 | tree fields = TYPE_FIELDS (current_class_type); | |
2034 | int n_bases = CLASSTYPE_N_BASECLASSES (current_class_type); | |
2035 | tree binfos = TYPE_BINFO_BASETYPES (current_class_type); | |
2036 | int i; | |
2037 | ||
2038 | for (t = CLASSTYPE_VBASECLASSES (current_class_type); t; | |
2039 | t = TREE_CHAIN (t)) | |
2040 | { | |
2041 | tree basetype = BINFO_TYPE (t); | |
8ccc31eb MS |
2042 | tree p = convert_to_reference |
2043 | (build_reference_type (basetype), parm, | |
2044 | CONV_IMPLICIT|CONV_CONST, LOOKUP_COMPLAIN, NULL_TREE); | |
f376e137 MS |
2045 | p = convert_from_reference (p); |
2046 | current_base_init_list = tree_cons (TYPE_NESTED_NAME (basetype), | |
2047 | p, current_base_init_list); | |
2048 | } | |
2049 | ||
2050 | for (i = 0; i < n_bases; ++i) | |
2051 | { | |
2052 | tree p, basetype = TREE_VEC_ELT (binfos, i); | |
2053 | if (TREE_VIA_VIRTUAL (basetype)) | |
8ccc31eb | 2054 | continue; |
f376e137 MS |
2055 | |
2056 | basetype = BINFO_TYPE (basetype); | |
8ccc31eb MS |
2057 | p = convert_to_reference |
2058 | (build_reference_type (basetype), parm, | |
2059 | CONV_IMPLICIT|CONV_CONST, LOOKUP_COMPLAIN, NULL_TREE); | |
f376e137 MS |
2060 | p = convert_from_reference (p); |
2061 | current_base_init_list = tree_cons (TYPE_NESTED_NAME (basetype), | |
2062 | p, current_base_init_list); | |
2063 | } | |
2064 | for (; fields; fields = TREE_CHAIN (fields)) | |
2065 | { | |
0171aeab | 2066 | tree name, init, t; |
a5894242 MS |
2067 | tree field = fields; |
2068 | ||
2069 | if (TREE_CODE (field) != FIELD_DECL) | |
f376e137 | 2070 | continue; |
a5894242 | 2071 | if (DECL_NAME (field)) |
f376e137 | 2072 | { |
a5894242 | 2073 | if (VFIELD_NAME_P (DECL_NAME (field))) |
f376e137 | 2074 | continue; |
a5894242 | 2075 | if (VBASE_NAME_P (DECL_NAME (field))) |
f376e137 MS |
2076 | continue; |
2077 | ||
2078 | /* True for duplicate members. */ | |
a5894242 | 2079 | if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field) |
f376e137 MS |
2080 | continue; |
2081 | } | |
a5894242 | 2082 | else if ((t = TREE_TYPE (field)) != NULL_TREE |
0171aeab JM |
2083 | && TREE_CODE (t) == UNION_TYPE |
2084 | && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)) | |
2085 | && TYPE_FIELDS (t) != NULL_TREE) | |
a5894242 | 2086 | field = largest_union_member (t); |
0171aeab JM |
2087 | else |
2088 | continue; | |
f376e137 | 2089 | |
a5894242 | 2090 | init = build (COMPONENT_REF, TREE_TYPE (field), parm, field); |
f376e137 MS |
2091 | init = build_tree_list (NULL_TREE, init); |
2092 | ||
2093 | current_member_init_list | |
a5894242 | 2094 | = tree_cons (DECL_NAME (field), init, current_member_init_list); |
f376e137 MS |
2095 | } |
2096 | current_member_init_list = nreverse (current_member_init_list); | |
faae18ab | 2097 | current_base_init_list = nreverse (current_base_init_list); |
f376e137 MS |
2098 | setup_vtbl_ptr (); |
2099 | } | |
2100 | ||
2101 | pop_momentary (); | |
f376e137 MS |
2102 | } |
2103 | ||
2104 | void | |
db5ae43f | 2105 | do_build_assign_ref (fndecl) |
f376e137 MS |
2106 | tree fndecl; |
2107 | { | |
2108 | tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl)); | |
2109 | ||
db5ae43f | 2110 | clear_last_expr (); |
f376e137 MS |
2111 | push_momentary (); |
2112 | ||
2113 | parm = convert_from_reference (parm); | |
2114 | ||
e8abc66f | 2115 | if (TYPE_HAS_TRIVIAL_ASSIGN_REF (current_class_type)) |
f376e137 MS |
2116 | { |
2117 | tree t = build (MODIFY_EXPR, void_type_node, C_C_D, parm); | |
2118 | TREE_SIDE_EFFECTS (t) = 1; | |
2119 | cplus_expand_expr_stmt (t); | |
2120 | } | |
2121 | else | |
2122 | { | |
2123 | tree fields = TYPE_FIELDS (current_class_type); | |
2124 | int n_bases = CLASSTYPE_N_BASECLASSES (current_class_type); | |
2125 | tree binfos = TYPE_BINFO_BASETYPES (current_class_type); | |
2126 | int i; | |
2127 | ||
2128 | for (i = 0; i < n_bases; ++i) | |
2129 | { | |
2130 | tree basetype = BINFO_TYPE (TREE_VEC_ELT (binfos, i)); | |
2131 | if (TYPE_HAS_ASSIGN_REF (basetype)) | |
2132 | { | |
8ccc31eb MS |
2133 | tree p = convert_to_reference |
2134 | (build_reference_type (basetype), parm, | |
2135 | CONV_IMPLICIT|CONV_CONST, LOOKUP_COMPLAIN, NULL_TREE); | |
f376e137 MS |
2136 | p = convert_from_reference (p); |
2137 | p = build_member_call (TYPE_NESTED_NAME (basetype), | |
2138 | ansi_opname [MODIFY_EXPR], | |
2139 | build_tree_list (NULL_TREE, p)); | |
2140 | expand_expr_stmt (p); | |
2141 | } | |
2142 | } | |
2143 | for (; fields; fields = TREE_CHAIN (fields)) | |
2144 | { | |
0171aeab | 2145 | tree comp, init, t; |
a5894242 MS |
2146 | tree field = fields; |
2147 | ||
2148 | if (TREE_CODE (field) != FIELD_DECL) | |
f376e137 | 2149 | continue; |
a5894242 | 2150 | if (DECL_NAME (field)) |
f376e137 | 2151 | { |
a5894242 | 2152 | if (VFIELD_NAME_P (DECL_NAME (field))) |
f376e137 | 2153 | continue; |
a5894242 | 2154 | if (VBASE_NAME_P (DECL_NAME (field))) |
f376e137 MS |
2155 | continue; |
2156 | ||
2157 | /* True for duplicate members. */ | |
a5894242 | 2158 | if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field) |
f376e137 MS |
2159 | continue; |
2160 | } | |
a5894242 | 2161 | else if ((t = TREE_TYPE (field)) != NULL_TREE |
0171aeab JM |
2162 | && TREE_CODE (t) == UNION_TYPE |
2163 | && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)) | |
2164 | && TYPE_FIELDS (t) != NULL_TREE) | |
a5894242 | 2165 | field = largest_union_member (t); |
0171aeab JM |
2166 | else |
2167 | continue; | |
f376e137 | 2168 | |
a5894242 MS |
2169 | comp = build (COMPONENT_REF, TREE_TYPE (field), C_C_D, field); |
2170 | init = build (COMPONENT_REF, TREE_TYPE (field), parm, field); | |
f376e137 MS |
2171 | |
2172 | expand_expr_stmt (build_modify_expr (comp, NOP_EXPR, init)); | |
2173 | } | |
2174 | } | |
2175 | c_expand_return (C_C_D); | |
2176 | pop_momentary (); | |
f376e137 MS |
2177 | } |
2178 | ||
db5ae43f MS |
2179 | void push_cp_function_context (); |
2180 | void pop_cp_function_context (); | |
2181 | ||
f376e137 | 2182 | void |
db5ae43f | 2183 | synthesize_method (fndecl) |
f376e137 MS |
2184 | tree fndecl; |
2185 | { | |
db5ae43f | 2186 | int nested = (current_function_decl != NULL_TREE); |
28cbf42c | 2187 | tree context = decl_function_context (fndecl); |
db5ae43f | 2188 | char *f = input_filename; |
b7484fbe | 2189 | tree base = DECL_CLASS_CONTEXT (fndecl); |
db5ae43f MS |
2190 | |
2191 | if (nested) | |
28cbf42c | 2192 | push_cp_function_context (context); |
db5ae43f MS |
2193 | |
2194 | input_filename = DECL_SOURCE_FILE (fndecl); | |
b7484fbe MS |
2195 | interface_unknown = CLASSTYPE_INTERFACE_UNKNOWN (base); |
2196 | interface_only = CLASSTYPE_INTERFACE_ONLY (base); | |
f376e137 MS |
2197 | start_function (NULL_TREE, fndecl, NULL_TREE, 1); |
2198 | store_parm_decls (); | |
db5ae43f MS |
2199 | |
2200 | if (DECL_NAME (fndecl) == ansi_opname[MODIFY_EXPR]) | |
2201 | do_build_assign_ref (fndecl); | |
2202 | else if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fndecl))) | |
2203 | ; | |
2204 | else | |
2205 | { | |
2206 | tree arg_chain = FUNCTION_ARG_CHAIN (fndecl); | |
2207 | if (DECL_CONSTRUCTOR_FOR_VBASE_P (fndecl)) | |
2208 | arg_chain = TREE_CHAIN (arg_chain); | |
2209 | if (arg_chain != void_list_node) | |
2210 | do_build_copy_constructor (fndecl); | |
2211 | else if (TYPE_NEEDS_CONSTRUCTING (current_class_type)) | |
2212 | setup_vtbl_ptr (); | |
2213 | } | |
2214 | ||
2215 | finish_function (lineno, 0, nested); | |
28cbf42c MS |
2216 | |
2217 | /* Do we really *want* to inline this function? */ | |
2218 | if (DECL_INLINE (fndecl)) | |
2219 | { | |
2220 | /* Turn off DECL_INLINE for the moment so function_cannot_inline_p | |
2221 | will check our size. */ | |
2222 | DECL_INLINE (fndecl) = 0; | |
2223 | if (function_cannot_inline_p (fndecl) == 0) | |
2224 | DECL_INLINE (fndecl) = 1; | |
2225 | } | |
2226 | ||
db5ae43f MS |
2227 | input_filename = f; |
2228 | extract_interface_info (); | |
2229 | if (nested) | |
28cbf42c | 2230 | pop_cp_function_context (context); |
f376e137 | 2231 | } |