]> gcc.gnu.org Git - gcc.git/blame - gcc/cp/method.c
prevent dual double definition protection
[gcc.git] / gcc / cp / method.c
CommitLineData
8d08fdba
MS
1/* Handle the hair of processing (but not expanding) inline functions.
2 Also manage function and variable name overloading.
d6a8bdff
JL
3 Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 1999, 2000 Free Software Foundation, Inc.
8d08fdba
MS
5 Contributed by Michael Tiemann (tiemann@cygnus.com)
6
e5e809f4 7This file is part of GNU CC.
8d08fdba
MS
8
9GNU CC is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2, or (at your option)
12any later version.
13
14GNU CC is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU CC; see the file COPYING. If not, write to
e9fa0c7c
RK
21the Free Software Foundation, 59 Temple Place - Suite 330,
22Boston, MA 02111-1307, USA. */
8d08fdba
MS
23
24
8d08fdba 25/* Handle method declarations. */
8d08fdba 26#include "config.h"
e817b5e3 27#include "system.h"
8d08fdba
MS
28#include "tree.h"
29#include "cp-tree.h"
8d08fdba 30#include "obstack.h"
8926095f
MS
31#include "rtl.h"
32#include "expr.h"
33#include "output.h"
8926095f 34#include "flags.h"
54f92bfb 35#include "toplev.h"
9cd64686 36#include "ggc.h"
b1afd7f4 37#include "tm_p.h"
8d08fdba 38
669ec2b4
JM
39/* Various flags to control the mangling process. */
40
41enum mangling_flags
42{
43 /* No flags. */
44 mf_none = 0,
45 /* The thing we are presently mangling is part of a template type,
46 rather than a fully instantiated type. Therefore, we may see
47 complex expressions where we would normally expect to see a
48 simple integer constant. */
49 mf_maybe_uninstantiated = 1,
50 /* When mangling a numeric value, use the form `_XX_' (instead of
51 just `XX') if the value has more than one digit. */
52 mf_use_underscores_around_value = 2,
53};
54
55typedef enum mangling_flags mangling_flags;
56
8d08fdba
MS
57/* TREE_LIST of the current inline functions that need to be
58 processed. */
59struct pending_inline *pending_inlines;
60
669ec2b4
JM
61#define obstack_chunk_alloc xmalloc
62#define obstack_chunk_free free
63
64/* Obstack where we build text strings for overloading, etc. */
65static struct obstack scratch_obstack;
66static char *scratch_firstobj;
67
68static void icat PARAMS ((HOST_WIDE_INT));
69static void dicat PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT));
70static int old_backref_index PARAMS ((tree));
71static int flush_repeats PARAMS ((int, tree));
72static void build_overload_identifier PARAMS ((tree));
73static void build_overload_nested_name PARAMS ((tree));
74static void mangle_expression PARAMS ((tree));
75static void build_overload_int PARAMS ((tree, mangling_flags));
76static void build_overload_identifier PARAMS ((tree));
77static void build_qualified_name PARAMS ((tree));
78static void build_overload_value PARAMS ((tree, tree, mangling_flags));
79static void issue_nrepeats PARAMS ((int, tree));
80static char *build_mangled_name PARAMS ((tree,int,int));
81static void process_modifiers PARAMS ((tree));
82static void process_overload_item PARAMS ((tree,int));
158991b7
KG
83static void do_build_assign_ref PARAMS ((tree));
84static void do_build_copy_constructor PARAMS ((tree));
669ec2b4
JM
85static void build_template_template_parm_names PARAMS ((tree));
86static void build_template_parm_names PARAMS ((tree, tree));
87static void build_underscore_int PARAMS ((int));
88static void start_squangling PARAMS ((void));
89static void end_squangling PARAMS ((void));
90static int check_ktype PARAMS ((tree, int));
91static int issue_ktype PARAMS ((tree));
92static void build_overload_scope_ref PARAMS ((tree));
93static void build_mangled_template_parm_index PARAMS ((const char *, tree));
94#if HOST_BITS_PER_WIDE_INT >= 64
9399bad3 95static void build_mangled_C99_name PARAMS ((int));
669ec2b4
JM
96#endif
97static int is_back_referenceable_type PARAMS ((tree));
98static int check_btype PARAMS ((tree));
99static void build_mangled_name_for_type PARAMS ((tree));
100static void build_mangled_name_for_type_with_Gcode PARAMS ((tree, int));
101
102# define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0)
103# define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C)))
104# define OB_PUTC2(C1,C2) \
105 (obstack_1grow (&scratch_obstack, (C1)), obstack_1grow (&scratch_obstack, (C2)))
106# define OB_PUTS(S) (obstack_grow (&scratch_obstack, (S), sizeof (S) - 1))
107# define OB_PUTID(ID) \
108 (obstack_grow (&scratch_obstack, IDENTIFIER_POINTER (ID), \
109 IDENTIFIER_LENGTH (ID)))
110# define OB_PUTCP(S) (obstack_grow (&scratch_obstack, (S), strlen (S)))
111# define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0'))
112# define OB_LAST() (obstack_next_free (&scratch_obstack)[-1])
113
114/* type tables for K and B type compression */
115static varray_type btypelist;
116static varray_type ktypelist;
117
118/* number of each type seen */
119static size_t maxbtype;
120static size_t maxktype;
121
122/* Array of types seen so far in top-level call to `build_mangled_name'.
123 Allocated and deallocated by caller. */
124static varray_type typevec;
125
126/* Number of types interned by `build_mangled_name' so far. */
127static size_t maxtype;
128
129/* Called once to initialize method.c. */
130
131void
132init_method ()
133{
134 gcc_obstack_init (&scratch_obstack);
135 scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0);
136 ggc_add_tree_varray_root (&btypelist, 1);
137 ggc_add_tree_varray_root (&ktypelist, 1);
138 ggc_add_tree_varray_root (&typevec, 1);
139 if (flag_new_abi)
140 init_mangle ();
141}
142
143/* This must be large enough to hold any printed integer or floating-point
144 value. */
145static char digit_buffer[128];
146
147\f
148/* Here is where overload code starts. */
149
150/* Nonzero if we should not try folding parameter types. */
151static int nofold;
152
153/* Nonzero if an underscore is required before adding a digit to the
154 mangled name currently being built. */
155static int numeric_output_need_bar;
156
157static inline void
158start_squangling ()
159{
160 /* This function is obsoleted by the new ABI. */
161 my_friendly_assert (!flag_new_abi, 200005222);
162
163 if (flag_do_squangling)
164 {
165 nofold = 0;
166 maxbtype = 0;
167 maxktype = 0;
168 VARRAY_TREE_INIT (btypelist, 50, "btypelist");
169 VARRAY_TREE_INIT (ktypelist, 50, "ktypelist");
170 }
171}
172
173static inline void
174end_squangling ()
175{
176 if (flag_do_squangling)
177 {
178 VARRAY_FREE (ktypelist);
179 VARRAY_FREE (btypelist);
180 maxbtype = 0;
181 maxktype = 0;
182 }
183}
184
185/* Code to concatenate an asciified integer to a string. */
186
187static inline void
188icat (i)
189 HOST_WIDE_INT i;
190{
191 unsigned HOST_WIDE_INT ui;
192
193 /* Handle this case first, to go really quickly. For many common values,
194 the result of ui/10 below is 1. */
195 if (i == 1)
196 {
197 OB_PUTC ('1');
198 return;
199 }
200
201 if (i >= 0)
202 ui = i;
203 else
204 {
205 OB_PUTC ('m');
206 ui = -i;
207 }
208
209 if (ui >= 10)
210 icat (ui / 10);
211
212 OB_PUTC ('0' + (ui % 10));
213}
214
215static void
216dicat (lo, hi)
217 HOST_WIDE_INT lo, hi;
218{
219 unsigned HOST_WIDE_INT ulo, uhi, qlo, qhi;
220
221 if (hi >= 0)
222 {
223 uhi = hi;
224 ulo = lo;
225 }
226 else
227 {
228 uhi = (lo == 0 ? -hi : -hi-1);
229 ulo = -lo;
230 }
231 if (uhi == 0
232 && ulo < ((unsigned HOST_WIDE_INT)1 << (HOST_BITS_PER_WIDE_INT - 1)))
233 {
234 icat (ulo);
235 return;
236 }
237 /* Divide 2^HOST_WIDE_INT*uhi+ulo by 10. */
238 qhi = uhi / 10;
239 uhi = uhi % 10;
240 qlo = uhi * (((unsigned HOST_WIDE_INT)1 << (HOST_BITS_PER_WIDE_INT - 1)) / 5);
241 qlo += ulo / 10;
242 ulo = ulo % 10;
243 ulo += uhi * (((unsigned HOST_WIDE_INT)1 << (HOST_BITS_PER_WIDE_INT - 1)) % 5)
244 * 2;
245 qlo += ulo / 10;
246 ulo = ulo % 10;
247 /* Quotient is 2^HOST_WIDE_INT*qhi+qlo, remainder is ulo. */
248 dicat (qlo, qhi);
249 OB_PUTC ('0' + ulo);
250}
251
252/* Returns the index of TYPE in the typevec, or -1 if it's not there. */
253
254static inline int
255old_backref_index (type)
256 tree type;
257{
258 size_t tindex;
259
260 if (! is_back_referenceable_type (type))
261 return -1;
262
263 /* The entry for this parm is at maxtype-1, so don't look there for
264 something to repeat. */
265 for (tindex = 0; tindex < maxtype - 1; ++tindex)
266 if (same_type_p (VARRAY_TREE (typevec, tindex), type))
267 break;
268
269 if (tindex == maxtype - 1)
270 return -1;
271
272 return tindex;
273}
274
275/* Old mangling style: If TYPE has already been used in the parameter list,
276 emit a backward reference and return non-zero; otherwise, return 0.
277
278 NREPEATS is the number of repeats we've recorded of this type, or 0 if
279 this is the first time we've seen it and we're just looking to see if
280 it had been used before. */
281
282static inline int
283flush_repeats (nrepeats, type)
284 int nrepeats;
285 tree type;
286{
287 int tindex = old_backref_index (type);
288
289 if (tindex == -1)
290 {
291 my_friendly_assert (nrepeats == 0, 990316);
292 return 0;
293 }
294
295 if (nrepeats > 1)
296 {
297 OB_PUTC ('N');
298 icat (nrepeats);
299 if (nrepeats > 9)
300 OB_PUTC ('_');
301 }
302 else
303 OB_PUTC ('T');
304 icat (tindex);
305 if (tindex > 9)
306 OB_PUTC ('_');
307
308 return 1;
309}
310
311/* Returns nonzero iff this is a type to which we will want to make
312 back-references (using the `B' code). */
313
314static int
315is_back_referenceable_type (type)
316 tree type;
317{
318 /* For some reason, the Java folks don't want back refs on these. */
319 if (TYPE_FOR_JAVA (type))
320 return 0;
321
322 switch (TREE_CODE (type))
323 {
324 case BOOLEAN_TYPE:
325 if (!flag_do_squangling)
326 /* Even though the mangling of this is just `b', we did
327 historically generate back-references for it. */
328 return 1;
329 /* Fall through. */
330
331 case INTEGER_TYPE:
332 case REAL_TYPE:
333 case VOID_TYPE:
334 /* These types have single-character manglings, so there's no
335 point in generating back-references. */
336 return 0;
337
338 case TEMPLATE_TYPE_PARM:
339 /* It would be a bit complex to demangle signatures correctly if
340 we generated back-references to these, and the manglings of
341 type parameters are short. */
342 return 0;
343
344 default:
345 return 1;
346 }
347}
348
349/* Issue the squangling code indicating NREPEATS repetitions of TYPE,
350 which was the last parameter type output. */
351
352static void
353issue_nrepeats (nrepeats, type)
354 int nrepeats;
355 tree type;
356{
357 if (nrepeats == 1 && !is_back_referenceable_type (type))
358 /* For types whose manglings are short, don't bother using the
359 repetition code if there's only one repetition, since the
360 repetition code will be about as long as the ordinary mangling. */
361 build_mangled_name_for_type (type);
362 else
363 {
364 OB_PUTC ('n');
365 icat (nrepeats);
366 if (nrepeats > 9)
367 OB_PUTC ('_');
368 }
369}
370
371/* Check to see if a tree node has been entered into the Kcode typelist.
372 If not, add it. Returns -1 if it isn't found, otherwise returns the
373 index. */
374
375static int
376check_ktype (node, add)
377 tree node;
378 int add;
379{
380 size_t x;
381 tree localnode = node;
382
383 if (ktypelist == NULL)
384 return -1;
385
386 if (TREE_CODE (node) == TYPE_DECL)
387 localnode = TREE_TYPE (node);
388
389 for (x = 0; x < maxktype; x++)
390 {
391 if (same_type_p (localnode, VARRAY_TREE (ktypelist, x)))
392 return x;
393 }
394 /* Didn't find it, so add it here. */
395 if (add)
396 {
397 if (VARRAY_SIZE (ktypelist) <= maxktype)
398 VARRAY_GROW (ktypelist,
399 VARRAY_SIZE (ktypelist) * 3 / 2);
400 VARRAY_TREE (ktypelist, maxktype) = localnode;
401 maxktype++;
402 }
403 return -1;
404}
405
406
407static inline int
408issue_ktype (decl)
409 tree decl;
410{
411 int kindex;
412 kindex = check_ktype (decl, FALSE);
413 if (kindex != -1)
414 {
415 OB_PUTC ('K');
416 icat (kindex);
417 if (kindex > 9)
418 OB_PUTC ('_');
419 return TRUE;
420 }
421 return FALSE;
422}
423
424/* Build a representation for DECL, which may be an entity not at
425 global scope. If so, a marker indicating that the name is
426 qualified has already been output, but the qualifying context has
427 not. */
428
429static void
430build_overload_nested_name (decl)
431 tree decl;
432{
433 tree context;
434
435 if (ktypelist && issue_ktype (decl))
436 return;
437
438 if (decl == global_namespace)
439 return;
440
441 context = CP_DECL_CONTEXT (decl);
442
443 /* try to issue a K type, and if we can't continue the normal path */
444 if (!(ktypelist && issue_ktype (context)))
445 {
446 /* For a template type parameter, we want to output an 'Xn'
447 rather than 'T' or some such. */
448 if (TREE_CODE (context) == TEMPLATE_TYPE_PARM
a1281f45
KL
449 || TREE_CODE (context) == TEMPLATE_TEMPLATE_PARM
450 || TREE_CODE (context) == BOUND_TEMPLATE_TEMPLATE_PARM)
669ec2b4
JM
451 build_mangled_name_for_type (context);
452 else
453 {
454 if (TYPE_P (context))
455 context = TYPE_NAME (context);
456 build_overload_nested_name (context);
457 }
458 }
459
460 if (TREE_CODE (decl) == FUNCTION_DECL)
461 {
462 static int static_labelno;
463
464 tree name = DECL_ASSEMBLER_NAME (decl);
465 char *label;
466
467 ASM_FORMAT_PRIVATE_NAME (label, IDENTIFIER_POINTER (name), static_labelno);
468 static_labelno++;
469
470 if (numeric_output_need_bar)
471 OB_PUTC ('_');
472 icat (strlen (label));
473 OB_PUTCP (label);
474 numeric_output_need_bar = 1;
475 }
476 else if (TREE_CODE (decl) == NAMESPACE_DECL)
477 build_overload_identifier (DECL_NAME (decl));
478 else /* TYPE_DECL */
479 build_overload_identifier (decl);
480}
481
482/* Output the decimal representation of I. If I > 9, the decimal
483 representation is preceeded and followed by an underscore. */
484
485static void
486build_underscore_int (i)
487 int i;
488{
489 if (i > 9)
490 OB_PUTC ('_');
491 icat (i);
492 if (i > 9)
493 OB_PUTC ('_');
494}
495
496static void
497build_overload_scope_ref (value)
498 tree value;
499{
500 OB_PUTC2 ('Q', '2');
501 numeric_output_need_bar = 0;
502 build_mangled_name_for_type (TREE_OPERAND (value, 0));
503 build_overload_identifier (TREE_OPERAND (value, 1));
504}
505
506/* VALUE is a complex expression. Produce an appropriate mangling.
507 (We are forced to mangle complex expressions when dealing with
508 templates, and an expression involving template parameters appears
509 in the type of a function parameter.) */
510
511static void
512mangle_expression (value)
513 tree value;
514{
515 if (TREE_CODE (value) == SCOPE_REF)
516 {
517 build_overload_scope_ref (value);
518 return;
519 }
520
521 OB_PUTC ('E');
522 numeric_output_need_bar = 0;
523
524 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (value))))
525 {
526 int i;
527 int operands = TREE_CODE_LENGTH (TREE_CODE (value));
528 const char *name;
529
530 name = operator_name_info[TREE_CODE (value)].mangled_name;
531 if (name == NULL)
532 /* On some erroneous inputs, we can get here with VALUE a
533 LOOKUP_EXPR. We must survive this routine in order to issue
534 a sensible error message, so we fall through to the case
535 below. */
536 goto bad_value;
537
538 for (i = 0; i < operands; ++i)
539 {
540 tree operand;
541 enum tree_code tc;
542
543 /* We just outputted either the `E' or the name of the
544 operator. */
545 numeric_output_need_bar = 0;
546
547 if (i != 0)
548 /* Skip the leading underscores. */
549 OB_PUTCP (name + 2);
550
551 operand = TREE_OPERAND (value, i);
552 tc = TREE_CODE (operand);
553
554 if (TREE_CODE_CLASS (tc) == 't')
555 /* We can get here with sizeof, e.g.:
556
557 template <class T> void f(A<sizeof(T)>); */
558 build_mangled_name_for_type (operand);
559 else
560 build_overload_value (TREE_TYPE (operand),
561 operand,
562 mf_maybe_uninstantiated);
563 }
564 }
565 else
566 {
567 /* We don't ever want this output, but it's
568 inconvenient not to be able to build the string.
569 This should cause assembler errors we'll notice. */
570
571 static int n;
572 bad_value:
573 sprintf (digit_buffer, " *%d", n++);
574 OB_PUTCP (digit_buffer);
575 }
576
577 OB_PUTC ('W');
578 numeric_output_need_bar = 0;
579}
580
581/* Encoding for an INTEGER_CST value. */
582
583static void
584build_overload_int (value, flags)
585 tree value;
586 mangling_flags flags;
587{
588 int multiple_words_p = 0;
589 int multiple_digits_p = 0;
590
591 if ((flags & mf_maybe_uninstantiated) && TREE_CODE (value) != INTEGER_CST)
592 {
593 mangle_expression (value);
594 return;
595 }
596
597 /* Unless we were looking at an uninstantiated template, integers
598 should always be represented by constants. */
599 my_friendly_assert (TREE_CODE (value) == INTEGER_CST, 243);
600
601 /* If value doesn't fit in a single HOST_WIDE_INT, we must use a
602 special output routine that can deal with this. */
603 if (! host_integerp (value, 0))
604 {
605 multiple_words_p = 1;
606 /* And there is certainly going to be more than one digit. */
607 multiple_digits_p = 1;
608 }
609 else
610 multiple_digits_p = ((HOST_WIDE_INT) TREE_INT_CST_LOW (value) > 9
611 || (HOST_WIDE_INT) TREE_INT_CST_LOW (value) < -9);
612
613 /* If necessary, add a leading underscore. */
614 if (multiple_digits_p && (flags & mf_use_underscores_around_value))
615 OB_PUTC ('_');
616
617 /* Output the number itself. */
618 if (multiple_words_p)
619 dicat (TREE_INT_CST_LOW (value), TREE_INT_CST_HIGH (value));
620 else
621 icat (TREE_INT_CST_LOW (value));
622
623 if (flags & mf_use_underscores_around_value)
624 {
625 if (multiple_digits_p)
626 OB_PUTC ('_');
627 /* Whether or not there were multiple digits, we don't need an
628 underscore. We've either terminated the number with an
629 underscore, or else it only had one digit. */
630 numeric_output_need_bar = 0;
631 }
632 else
633 /* We just output a numeric value. */
634 numeric_output_need_bar = 1;
635}
636
637
638/* Output S followed by a representation of the TEMPLATE_PARM_INDEX
639 supplied in INDEX. */
640
641static void
642build_mangled_template_parm_index (s, index)
643 const char *s;
644 tree index;
645{
646 OB_PUTCP (s);
647 build_underscore_int (TEMPLATE_PARM_IDX (index));
648 /* We use the LEVEL, not the ORIG_LEVEL, because the mangling is a
649 representation of the function from the point of view of its
650 type. */
651 build_underscore_int (TEMPLATE_PARM_LEVEL (index));
652}
653
654
9399bad3 655/* Mangling for C99 integer types (and Cygnus extensions for 128-bit
669ec2b4
JM
656 and other types) is based on the letter "I" followed by the hex
657 representations of the bitsize for the type in question. For
658 encodings that result in larger than two digits, a leading and
659 trailing underscore is added.
660
661 Thus:
662 int1_t = 001 = I01
663 int8_t = 008 = I08
664 int16_t = 010 = I10
665 int24_t = 018 = I18
666 int32_t = 020 = I20
667 int64_t = 040 = I40
668 int80_t = 050 = I50
669 int128_t = 080 = I80
670 int256_t = 100 = I_100_
671 int512_t = 200 = I_200_
672
673 Given an integer in decimal format, mangle according to this scheme. */
674
675#if HOST_BITS_PER_WIDE_INT >= 64
676static void
9399bad3 677build_mangled_C99_name (bits)
669ec2b4
JM
678 int bits;
679{
680 char mangled[10] = "";
681
682 if (bits > 255)
683 sprintf (mangled, "I_%x_", bits);
684 else
685 sprintf (mangled, "I%.2x", bits);
686
687 OB_PUTCP (mangled);
688}
689#endif
690
691static void
692build_overload_value (type, value, flags)
693 tree type, value;
694 mangling_flags flags;
695{
696 my_friendly_assert (TYPE_P (type), 0);
697
698 while (TREE_CODE (value) == NON_LVALUE_EXPR
699 || TREE_CODE (value) == NOP_EXPR)
700 value = TREE_OPERAND (value, 0);
701
702 if (numeric_output_need_bar)
703 {
704 OB_PUTC ('_');
705 numeric_output_need_bar = 0;
706 }
707
708 if (TREE_CODE (value) == TEMPLATE_PARM_INDEX)
709 {
710 build_mangled_template_parm_index ("Y", value);
711 return;
712 }
713
714 if (TYPE_PTRMEM_P (type))
715 {
716 if (TREE_CODE (value) != PTRMEM_CST)
717 /* We should have already rejected this pointer to member,
718 since it is not a constant. */
719 my_friendly_abort (0);
720
721 /* Get the actual FIELD_DECL. */
722 value = PTRMEM_CST_MEMBER (value);
723 my_friendly_assert (TREE_CODE (value) == FIELD_DECL, 0);
724
725 /* Output the name of the field. */
726 build_overload_identifier (DECL_NAME (value));
727 return;
728 }
729 else if (INTEGRAL_TYPE_P (type))
730 {
731 build_overload_int (value, flags);
732 return;
733 }
734
735 /* The only case where we use the extra underscores here is when
736 forming the mangling for an integral non-type template argument.
737 If that didn't happen, stop now. */
738 flags &= ~mf_use_underscores_around_value;
739
740 switch (TREE_CODE (type))
741 {
742 case REAL_TYPE:
743 {
744 REAL_VALUE_TYPE val;
745 char *bufp = digit_buffer;
746
747 /* We must handle non-constants in templates. */
748 if (TREE_CODE (value) != REAL_CST)
749 {
750 mangle_expression (value);
751 break;
752 }
753
754 val = TREE_REAL_CST (value);
755 if (REAL_VALUE_ISNAN (val))
756 {
757 sprintf (bufp, "NaN");
758 }
759 else
760 {
761 if (REAL_VALUE_NEGATIVE (val))
762 {
763 val = REAL_VALUE_NEGATE (val);
764 *bufp++ = 'm';
765 }
766 if (REAL_VALUE_ISINF (val))
767 {
768 sprintf (bufp, "Infinity");
769 }
770 else
771 {
772 REAL_VALUE_TO_DECIMAL (val, "%.20e", bufp);
9473c522 773 bufp = (char *) strchr (bufp, 'e');
669ec2b4
JM
774 if (!bufp)
775 strcat (digit_buffer, "e0");
776 else
777 {
778 char *p;
779 bufp++;
780 if (*bufp == '-')
781 {
782 *bufp++ = 'm';
783 }
784 p = bufp;
785 if (*p == '+')
786 p++;
787 while (*p == '0')
788 p++;
789 if (*p == 0)
790 {
791 *bufp++ = '0';
792 *bufp = 0;
793 }
794 else if (p != bufp)
795 {
796 while (*p)
797 *bufp++ = *p++;
798 *bufp = 0;
799 }
800 }
801#ifdef NO_DOT_IN_LABEL
9473c522 802 bufp = (char *) strchr (bufp, '.');
669ec2b4
JM
803 if (bufp)
804 *bufp = '_';
805#endif
806 }
807 }
808 OB_PUTCP (digit_buffer);
809 numeric_output_need_bar = 1;
810 return;
811 }
812 case POINTER_TYPE:
813 if (TREE_CODE (value) == INTEGER_CST)
814 {
815 build_overload_int (value, flags);
816 return;
817 }
818 else if (TREE_CODE (value) == TEMPLATE_PARM_INDEX)
819 {
820 build_mangled_template_parm_index ("", value);
821 numeric_output_need_bar = 1;
822 return;
823 }
824
825 value = TREE_OPERAND (value, 0);
826
827 /* Fall through. */
828
829 case REFERENCE_TYPE:
830 if (TREE_CODE (value) == ADDR_EXPR)
831 value = TREE_OPERAND (value, 0);
832
833 if (TREE_CODE (value) == VAR_DECL)
834 {
835 my_friendly_assert (DECL_NAME (value) != 0, 245);
836 build_overload_identifier (DECL_ASSEMBLER_NAME (value));
837 return;
838 }
839 else if (TREE_CODE (value) == FUNCTION_DECL)
840 {
841 my_friendly_assert (DECL_NAME (value) != 0, 246);
842 build_overload_identifier (DECL_ASSEMBLER_NAME (value));
843 return;
844 }
845 else if (TREE_CODE (value) == SCOPE_REF)
846 build_overload_scope_ref (value);
847 else
848 my_friendly_abort (71);
849 break; /* not really needed */
850
851 case RECORD_TYPE:
852 {
853 tree delta;
854 tree idx;
855 tree pfn;
856 tree delta2;
857 tree fn;
858
859 my_friendly_assert (TYPE_PTRMEMFUNC_P (type), 0);
860
861 /* We'll get a ADDR_EXPR of a SCOPE_REF here if we're
862 mangling, an instantiation of something like:
863
864 template <class T, void (T::*fp)()> class C {};
865 template <class T> C<T, &T::f> x();
866
867 We mangle the return type of the function, and that
868 contains template parameters. */
869 if (TREE_CODE (value) == ADDR_EXPR
870 && TREE_CODE (TREE_OPERAND (value, 0)) == SCOPE_REF)
871 {
872 build_overload_scope_ref (TREE_OPERAND (value, 0));
873 break;
874 }
875
876 my_friendly_assert (TREE_CODE (value) == PTRMEM_CST, 0);
877
878 expand_ptrmemfunc_cst (value, &delta, &idx, &pfn, &delta2);
879 fn = PTRMEM_CST_MEMBER (value);
880 build_overload_int (delta, flags);
881 OB_PUTC ('_');
882 if (!flag_new_abi)
883 {
884 build_overload_int (idx, flags);
885 OB_PUTC ('_');
886 }
887 else if (DECL_VIRTUAL_P (fn))
888 {
889 build_overload_int (DECL_VINDEX (fn), flags);
890 OB_PUTC ('_');
891 }
892
893 if (!DECL_VIRTUAL_P (fn))
894 {
895 numeric_output_need_bar = 0;
896 build_overload_identifier (DECL_ASSEMBLER_NAME (fn));
897 }
898 else if (!flag_new_abi)
899 {
900 OB_PUTC ('i');
901 build_overload_int (delta2, flags);
902 }
903 }
904 break;
905
906 default:
907 sorry ("conversion of %s as template parameter",
908 tree_code_name [(int) TREE_CODE (type)]);
909 my_friendly_abort (72);
910 }
911}
912
913
914/* Add encodings for the declaration of template template parameters.
915 PARMLIST must be a TREE_VEC. */
916
917static void
918build_template_template_parm_names (parmlist)
919 tree parmlist;
920{
921 int i, nparms;
922
1899c3a4 923 my_friendly_assert (TREE_CODE (parmlist) == TREE_VEC, 990228);
669ec2b4
JM
924 nparms = TREE_VEC_LENGTH (parmlist);
925 icat (nparms);
926 for (i = 0; i < nparms; i++)
927 {
928 tree parm = TREE_VALUE (TREE_VEC_ELT (parmlist, i));
929 if (TREE_CODE (parm) == TYPE_DECL)
930 {
931 /* This parameter is a type. */
932 OB_PUTC ('Z');
933 }
934 else if (TREE_CODE (parm) == TEMPLATE_DECL)
935 {
936 /* This parameter is a template. */
937 OB_PUTC ('z');
938 build_template_template_parm_names (DECL_INNERMOST_TEMPLATE_PARMS (parm));
939 }
940 else
941 /* It's a PARM_DECL. */
942 build_mangled_name_for_type (TREE_TYPE (parm));
943 }
944}
945
946
947/* Add encodings for the vector of template parameters in PARMLIST,
948 given the vector of arguments to be substituted in ARGLIST. */
949
950static void
951build_template_parm_names (parmlist, arglist)
952 tree parmlist;
953 tree arglist;
954{
955 int i, nparms;
956 tree inner_args = INNERMOST_TEMPLATE_ARGS (arglist);
957
958 nparms = TREE_VEC_LENGTH (parmlist);
959 icat (nparms);
960 for (i = 0; i < nparms; i++)
961 {
962 tree parm = TREE_VALUE (TREE_VEC_ELT (parmlist, i));
963 tree arg = TREE_VEC_ELT (inner_args, i);
964 if (TREE_CODE (parm) == TYPE_DECL)
965 {
966 /* This parameter is a type. */
967 OB_PUTC ('Z');
968 build_mangled_name_for_type (arg);
969 }
970 else if (TREE_CODE (parm) == TEMPLATE_DECL)
971 {
972 /* This parameter is a template. */
973 if (TREE_CODE (arg) == TEMPLATE_TEMPLATE_PARM)
974 /* Output parameter declaration, argument index and level. */
975 build_mangled_name_for_type (arg);
976 else
977 {
978 /* A TEMPLATE_DECL node, output the parameter declaration
979 and template name */
980
981 OB_PUTC ('z');
982 build_template_template_parm_names
983 (DECL_INNERMOST_TEMPLATE_PARMS (parm));
984 icat (IDENTIFIER_LENGTH (DECL_NAME (arg)));
985 OB_PUTID (DECL_NAME (arg));
986 }
987 }
988 else
989 {
fd74ca0b 990 parm = tsubst (parm, inner_args, /*complain=*/1, NULL_TREE);
669ec2b4
JM
991 /* It's a PARM_DECL. */
992 build_mangled_name_for_type (TREE_TYPE (parm));
993 build_overload_value (TREE_TYPE (parm), arg,
994 ((mf_maybe_uninstantiated
995 * uses_template_parms (arglist))
996 | mf_use_underscores_around_value));
997 }
998 }
999 }
1000
1001/* Output the representation for NAME, which is either a TYPE_DECL or
1002 an IDENTIFIER. */
1003
1004static void
1005build_overload_identifier (name)
1006 tree name;
1007{
1008 if (TREE_CODE (name) == TYPE_DECL
1009 && CLASS_TYPE_P (TREE_TYPE (name))
1010 && CLASSTYPE_TEMPLATE_INFO (TREE_TYPE (name))
1011 && (PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (TREE_TYPE (name)))
1012 || (TREE_CODE (CP_DECL_CONTEXT (CLASSTYPE_TI_TEMPLATE
1013 (TREE_TYPE (name))))
1014 == FUNCTION_DECL)))
1015 {
1016 /* NAME is the TYPE_DECL for a template specialization. */
1017 tree template, parmlist, arglist, tname;
1018 template = CLASSTYPE_TI_TEMPLATE (TREE_TYPE (name));
1019 arglist = CLASSTYPE_TI_ARGS (TREE_TYPE (name));
1020 tname = DECL_NAME (template);
1021 parmlist = DECL_INNERMOST_TEMPLATE_PARMS (template);
1022 OB_PUTC ('t');
1023 icat (IDENTIFIER_LENGTH (tname));
1024 OB_PUTID (tname);
1025 build_template_parm_names (parmlist, arglist);
1026 }
1027 else
1028 {
1029 if (TREE_CODE (name) == TYPE_DECL)
1030 name = DECL_NAME (name);
1031 if (numeric_output_need_bar)
1032 {
1033 OB_PUTC ('_');
1034 numeric_output_need_bar = 0;
1035 }
1036 icat (IDENTIFIER_LENGTH (name));
1037 OB_PUTID (name);
1038 }
1039}
1040
1041/* Given DECL, either a class TYPE, TYPE_DECL or FUNCTION_DECL, produce
1042 the mangling for it. Used by build_mangled_name and build_static_name. */
1043
1044static void
1045build_qualified_name (decl)
1046 tree decl;
1047{
1048 tree context;
1049 int i = 1;
1050
1051 if (TYPE_P (decl))
1052 decl = TYPE_NAME (decl);
1053
1054 /* If DECL_ASSEMBLER_NAME has been set properly, use it. */
1055 if (TREE_CODE (decl) == TYPE_DECL
1056 && DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl) && !flag_do_squangling)
1057 {
1058 tree id = DECL_ASSEMBLER_NAME (decl);
1059 OB_PUTID (id);
1060 if (ISDIGIT (IDENTIFIER_POINTER (id) [IDENTIFIER_LENGTH (id) - 1]))
1061 numeric_output_need_bar = 1;
1062 return;
1063 }
1064
1065 context = decl;
1066 /* If we can't find a Ktype, do it the hard way. */
1067 if (check_ktype (context, FALSE) == -1)
1068 {
1069 /* Count type and namespace scopes. */
1070 while (1)
1071 {
1072 context = CP_DECL_CONTEXT (context);
1073 if (context == global_namespace)
1074 break;
1075 i += 1;
1076 if (check_ktype (context, FALSE) != -1)
1077 /* Found one! */
1078 break;
1079 if (TYPE_P (context))
1080 context = TYPE_NAME (context);
1081 }
1082 }
1083
1084 if (i > 1)
1085 {
1086 OB_PUTC ('Q');
1087 build_underscore_int (i);
1088 numeric_output_need_bar = 0;
1089 }
1090 build_overload_nested_name (decl);
1091}
1092
1093/* Output the mangled representation for TYPE. If EXTRA_GCODE is
1094 non-zero, mangled names for structure/union types are intentionally
1095 mangled differently from the method described in the ARM. */
1096
1097static void
1098build_mangled_name_for_type_with_Gcode (type, extra_Gcode)
1099 tree type;
1100 int extra_Gcode;
1101{
1102 if (TYPE_PTRMEMFUNC_P (type))
1103 type = TYPE_PTRMEMFUNC_FN_TYPE (type);
1104 process_modifiers (type);
1105 process_overload_item (type, extra_Gcode);
1106}
1107
1108/* Like build_mangled_name_for_type_with_Gcode, but never outputs the
1109 `G'. */
1110
1111static void
1112build_mangled_name_for_type (type)
1113 tree type;
1114{
1115 build_mangled_name_for_type_with_Gcode (type, 0);
1116}
1117
1118/* Given a list of parameters in PARMTYPES, create an unambiguous
1119 overload string. Should distinguish any type that C (or C++) can
1120 distinguish. I.e., pointers to functions are treated correctly.
1121
1122 Caller must deal with whether a final `e' goes on the end or not.
1123
1124 Any default conversions must take place before this function
1125 is called.
1126
1127 BEGIN and END control initialization and finalization of the
1128 obstack where we build the string. */
1129
1130char *
1131build_overload_name (parmtypes, begin, end)
1132 tree parmtypes;
1133 int begin, end;
1134{
1135 char *ret;
1136
1137 /* This function is obsoleted by the new ABI. */
1138 my_friendly_assert (!flag_new_abi, 200005221);
1139
1140 start_squangling ();
1141 ret = build_mangled_name (parmtypes, begin, end);
1142 end_squangling ();
1143 return ret ;
1144}
1145
1146/* Output the mangled representation for PARMTYPES. If PARMTYPES is a
1147 TREE_LIST, then it is a list of parameter types. Otherwise,
1148 PARMTYPES must be a single type. */
1149
1150static char *
1151build_mangled_name (parmtypes, begin, end)
1152 tree parmtypes;
1153 int begin, end;
1154{
1155 /* This function is obsoleted by the new ABI. */
1156 my_friendly_assert (!flag_new_abi, 200004105);
1157
1158 if (begin)
1159 OB_INIT ();
1160
1161 if (TREE_CODE (parmtypes) != TREE_LIST)
1162 /* There is only one type. */
1163 build_mangled_name_for_type (parmtypes);
1164 else
1165 {
1166 /* There are several types in a parameter list. */
1167 int nrepeats = 0;
1168 int old_style_repeats = !flag_do_squangling && !nofold && typevec;
1169 tree last_type = NULL_TREE;
1170
1171 for (; parmtypes && parmtypes != void_list_node;
1172 parmtypes = TREE_CHAIN (parmtypes))
1173 {
1174 /* We used to call canonical_type_variant here, but that isn't
1175 good enough; it doesn't handle pointers to typedef types. So
1176 we can't just set TREE_USED to say we've seen a type already;
1177 we have to check each of the earlier types with same_type_p. */
1178 tree parmtype = TREE_VALUE (parmtypes);
1179
1180 if (old_style_repeats)
1181 {
1182 /* Every argument gets counted. */
1183 my_friendly_assert (maxtype < VARRAY_SIZE (typevec), 387);
1184 VARRAY_TREE (typevec, maxtype) = parmtype;
1185 maxtype++;
1186 }
1187
1188 if (last_type && same_type_p (parmtype, last_type))
1189 {
1190 if (flag_do_squangling
1191 || (old_style_repeats
1192 && is_back_referenceable_type (parmtype)))
1193 {
1194 /* The next type is the same as this one. Keep
1195 track of the repetition, and output the repeat
1196 count later. */
1197 nrepeats++;
1198 continue;
1199 }
1200 }
1201 else if (nrepeats != 0)
1202 {
1203 /* Indicate how many times the previous parameter was
1204 repeated. */
1205 if (old_style_repeats)
1206 flush_repeats (nrepeats, last_type);
1207 else
1208 issue_nrepeats (nrepeats, last_type);
1209 nrepeats = 0;
1210 }
1211
1212 last_type = parmtype;
1213
1214 /* Note that for bug-compatibility with 2.7.2, we can't build up
1215 repeats of types other than the most recent one. So we call
1216 flush_repeats every round, if we get this far. */
1217 if (old_style_repeats && flush_repeats (0, parmtype))
1218 continue;
1219
1220 /* Output the PARMTYPE. */
1221 build_mangled_name_for_type_with_Gcode (parmtype, 1);
1222 }
1223
1224 /* Output the repeat count for the last parameter, if
1225 necessary. */
1226 if (nrepeats != 0)
1227 {
1228 if (old_style_repeats)
1229 flush_repeats (nrepeats, last_type);
1230 else
1231 issue_nrepeats (nrepeats, last_type);
1232 nrepeats = 0;
1233 }
1234
1235 if (!parmtypes)
1236 /* The parameter list ends in an ellipsis. */
1237 OB_PUTC ('e');
1238 }
1239
1240 if (end)
1241 OB_FINISH ();
1242 return (char *) obstack_base (&scratch_obstack);
1243}
1244
1245/* Emit modifiers such as constant, read-only, and volatile. */
1246
1247static void
1248process_modifiers (parmtype)
1249 tree parmtype;
1250{
1251 /* Note that here we do not use CP_TYPE_CONST_P and friends because
1252 we describe types recursively; we will get the `const' in
1253 `const int ()[10]' when processing the `const int' part. */
1254 if (TYPE_READONLY (parmtype))
1255 OB_PUTC ('C');
1256 if (TREE_CODE (parmtype) == INTEGER_TYPE
7def1251
JM
1257 && ! same_type_p (parmtype, char_type_node)
1258 && ! same_type_p (parmtype, wchar_type_node)
669ec2b4
JM
1259 && (TYPE_MAIN_VARIANT (parmtype)
1260 == unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
1261 && ! TYPE_FOR_JAVA (parmtype))
1262 OB_PUTC ('U');
1263 if (TYPE_VOLATILE (parmtype))
1264 OB_PUTC ('V');
1265 /* It would be better to use `R' for `restrict', but that's already
1266 used for reference types. And `r' is used for `long double'. */
1267 if (TYPE_RESTRICT (parmtype))
1268 OB_PUTC ('u');
1269}
1270
1271/* Check to see if TYPE has been entered into the Bcode typelist. If
1272 so, return 1 and emit a backreference to TYPE. Otherwise, add TYPE
1273 to the list of back-referenceable types and return 0. */
1274
1275static int
1276check_btype (type)
1277 tree type;
1278{
1279 size_t x;
1280
1281 if (btypelist == NULL)
1282 return 0;
1283
1284 if (!is_back_referenceable_type (type))
1285 return 0;
1286
1287 for (x = 0; x < maxbtype; x++)
1288 if (same_type_p (type, VARRAY_TREE (btypelist, x)))
1289 {
1290 OB_PUTC ('B');
1291 icat (x);
1292 if (x > 9)
1293 OB_PUTC ('_');
1294 return 1 ;
1295 }
1296
1297 if (VARRAY_SIZE (btypelist) <= maxbtype)
1298 /* Enlarge the table. */
1299 VARRAY_GROW (btypelist,
1300 VARRAY_SIZE (btypelist) * 3 / 2);
1301
1302 /* Register the TYPE. */
1303 VARRAY_TREE (btypelist, maxbtype) = type;
1304 maxbtype++;
1305
1306 return 0;
1307}
1308
1309/* Emit the correct code for various node types. */
1310
1311static void
1312process_overload_item (parmtype, extra_Gcode)
1313 tree parmtype;
1314 int extra_Gcode;
1315{
1316 numeric_output_need_bar = 0;
1317
1318 /* Our caller should have already handed any qualifiers, so pull out the
1319 TYPE_MAIN_VARIANT to avoid typedef confusion. Except we can't do that
1320 for arrays, because they are transparent to qualifiers. Sigh. */
1321 if (TREE_CODE (parmtype) == ARRAY_TYPE)
1322 parmtype = canonical_type_variant (parmtype);
1323 else
1324 parmtype = TYPE_MAIN_VARIANT (parmtype);
1325
1326 /* These tree types are considered modifiers for B code squangling,
1327 and therefore should not get entries in the Btypelist. They are,
1328 however, repeatable types. */
1329
1330 switch (TREE_CODE (parmtype))
1331 {
1332 case REFERENCE_TYPE:
1333 OB_PUTC ('R');
1334 goto more;
1335
1336 case ARRAY_TYPE:
1337 {
1338 OB_PUTC ('A');
1339 if (TYPE_DOMAIN (parmtype) == NULL_TREE)
1340 OB_PUTC ('_');
1341 else
1342 {
1343 tree length = array_type_nelts (parmtype);
1344 if (TREE_CODE (length) != INTEGER_CST || flag_do_squangling)
1345 {
1346 length = fold (build (PLUS_EXPR, TREE_TYPE (length),
1347 length, integer_one_node));
1348 STRIP_NOPS (length);
1349 }
1350 build_overload_value (sizetype, length, 1);
1351 }
1352 if (numeric_output_need_bar && ! flag_do_squangling)
1353 OB_PUTC ('_');
1354 goto more;
1355 }
8d08fdba 1356
669ec2b4
JM
1357 case POINTER_TYPE:
1358 OB_PUTC ('P');
1359 more:
1360 build_mangled_name_for_type (TREE_TYPE (parmtype));
1361 return;
1362 break;
1363
1364 default:
1365 break;
1366 }
1367
1368 if (flag_do_squangling && check_btype (parmtype))
1369 /* If PARMTYPE is already in the list of back-referenceable types,
1370 then check_btype will output the appropriate reference, and
1371 there's nothing more to do. */
1372 return;
1373
1374 switch (TREE_CODE (parmtype))
1375 {
1376 case OFFSET_TYPE:
1377 OB_PUTC ('O');
1378 build_mangled_name_for_type (TYPE_OFFSET_BASETYPE (parmtype));
1379 OB_PUTC ('_');
1380 build_mangled_name_for_type (TREE_TYPE (parmtype));
1381 break;
1382
1383 case FUNCTION_TYPE:
1384 case METHOD_TYPE:
1385 {
1386 tree parms = TYPE_ARG_TYPES (parmtype);
1387
1388 /* Rather than implementing a reentrant TYPEVEC, we turn off
1389 repeat codes here, unless we're squangling. Squangling
1390 doesn't make use of the TYPEVEC, so there's no reentrancy
1391 problem. */
1392 int old_nofold = nofold;
1393 if (!flag_do_squangling)
1394 nofold = 1;
1395
1396 if (TREE_CODE (parmtype) == METHOD_TYPE)
1397 {
1398 /* Mark this as a method. */
1399 OB_PUTC ('M');
1400 /* Output the class of which this method is a member. */
1401 build_mangled_name_for_type (TYPE_METHOD_BASETYPE (parmtype));
1402 /* Output any qualifiers for the `this' parameter. */
1403 process_modifiers (TREE_TYPE (TREE_VALUE (parms)));
1404 }
1405
1406 /* Output the parameter types. */
1407 OB_PUTC ('F');
1408 if (parms == NULL_TREE)
1409 OB_PUTC ('e');
1410 else if (parms == void_list_node)
1411 OB_PUTC ('v');
1412 else
1413 build_mangled_name (parms, 0, 0);
1414
1415 /* Output the return type. */
1416 OB_PUTC ('_');
1417 build_mangled_name_for_type (TREE_TYPE (parmtype));
1418
1419 nofold = old_nofold;
1420 break;
1421 }
1422
1423 case INTEGER_TYPE:
1424 if (parmtype == integer_type_node
1425 || parmtype == unsigned_type_node
1426 || parmtype == java_int_type_node)
1427 OB_PUTC ('i');
1428 else if (parmtype == long_integer_type_node
1429 || parmtype == long_unsigned_type_node)
1430 OB_PUTC ('l');
1431 else if (parmtype == short_integer_type_node
1432 || parmtype == short_unsigned_type_node
1433 || parmtype == java_short_type_node)
1434 OB_PUTC ('s');
1435 else if (parmtype == signed_char_type_node)
1436 {
1437 OB_PUTC ('S');
1438 OB_PUTC ('c');
1439 }
1440 else if (parmtype == char_type_node
1441 || parmtype == unsigned_char_type_node
1442 || parmtype == java_byte_type_node)
1443 OB_PUTC ('c');
1444 else if (parmtype == wchar_type_node
1445 || parmtype == java_char_type_node)
1446 OB_PUTC ('w');
1447 else if (parmtype == long_long_integer_type_node
1448 || parmtype == long_long_unsigned_type_node
1449 || parmtype == java_long_type_node)
1450 OB_PUTC ('x');
1451 else if (parmtype == java_boolean_type_node)
1452 OB_PUTC ('b');
1453#if HOST_BITS_PER_WIDE_INT >= 64
1454 else
1455 {
1456 int bits = TREE_INT_CST_LOW (TYPE_SIZE (parmtype));
9399bad3 1457 build_mangled_C99_name (bits);
669ec2b4
JM
1458 }
1459#else
1460 else
1461 my_friendly_abort (73);
1462#endif
1463 break;
1464
1465 case BOOLEAN_TYPE:
1466 OB_PUTC ('b');
1467 break;
1468
1469 case REAL_TYPE:
1470 if (parmtype == long_double_type_node)
1471 OB_PUTC ('r');
1472 else if (parmtype == double_type_node
1473 || parmtype == java_double_type_node)
1474 OB_PUTC ('d');
1475 else if (parmtype == float_type_node
1476 || parmtype == java_float_type_node)
1477 OB_PUTC ('f');
1478 else my_friendly_abort (74);
1479 break;
1480
1481 case COMPLEX_TYPE:
1482 OB_PUTC ('J');
1483 build_mangled_name_for_type (TREE_TYPE (parmtype));
1484 break;
1485
1486 case VOID_TYPE:
1487 OB_PUTC ('v');
1488 break;
1489
1490 case ERROR_MARK: /* not right, but nothing is anyway */
1491 break;
1492
1493 /* have to do these */
1494 case UNION_TYPE:
1495 case RECORD_TYPE:
1496 {
1497 if (extra_Gcode)
1498 OB_PUTC ('G'); /* make it look incompatible with AT&T */
1499 /* drop through into next case */
1500 }
1501 case ENUMERAL_TYPE:
1502 {
1503 tree name = TYPE_NAME (parmtype);
1504
1505 my_friendly_assert (TREE_CODE (name) == TYPE_DECL, 248);
1506
1507 build_qualified_name (name);
1508 break;
1509 }
1510
1511 case UNKNOWN_TYPE:
1512 /* This will take some work. */
1513 OB_PUTC ('?');
1514 break;
1515
a1281f45 1516 case BOUND_TEMPLATE_TEMPLATE_PARM:
669ec2b4
JM
1517 /* Find and output the original template parameter
1518 declaration. */
a1281f45
KL
1519 build_mangled_template_parm_index ("tzX",
1520 TEMPLATE_TYPE_PARM_INDEX
1521 (parmtype));
1522 build_template_parm_names
1523 (DECL_INNERMOST_TEMPLATE_PARMS (TYPE_TI_TEMPLATE (parmtype)),
1524 TYPE_TI_ARGS (parmtype));
1525 break;
1526
1527 case TEMPLATE_TEMPLATE_PARM:
1528 build_mangled_template_parm_index ("ZzX",
1529 TEMPLATE_TYPE_PARM_INDEX
1530 (parmtype));
1531 build_template_template_parm_names
1532 (DECL_INNERMOST_TEMPLATE_PARMS (TYPE_STUB_DECL (parmtype)));
669ec2b4
JM
1533 break;
1534
1535 case TEMPLATE_TYPE_PARM:
1536 build_mangled_template_parm_index ("X",
1537 TEMPLATE_TYPE_PARM_INDEX
1538 (parmtype));
1539 break;
1540
1541 case TYPENAME_TYPE:
1542 /* When mangling the type of a function template whose
1543 declaration looks like:
1544
1545 template <class T> void foo(typename T::U)
1546
1547 we have to mangle these. */
1548 build_qualified_name (parmtype);
1549 break;
1550
1551 default:
1552 my_friendly_abort (75);
1553 }
1554
1555}
1556
1557/* Produce the mangling for a variable named NAME in CONTEXT, which can
1558 be either a class TYPE or a FUNCTION_DECL. */
1559
1560tree
1561build_static_name (context, name)
1562 tree context, name;
1563{
1564 /* This function is obsoleted by the new ABI. */
1565 my_friendly_assert (!flag_new_abi, 200004106);
1566
1567 OB_INIT ();
1568 numeric_output_need_bar = 0;
1569 start_squangling ();
1570#ifdef JOINER
1571 OB_PUTC ('_');
1572 build_qualified_name (context);
1573 OB_PUTC (JOINER);
1574#else
1575 OB_PUTS ("__static_");
1576 build_qualified_name (context);
1577 OB_PUTC ('_');
1578#endif
1579 OB_PUTID (name);
1580 OB_FINISH ();
1581 end_squangling ();
1582
1583 return get_identifier ((char *)obstack_base (&scratch_obstack));
1584}
8d08fdba 1585\f
669ec2b4
JM
1586/* FOR_METHOD should be 1 if the declaration in question is for a member
1587 of a class (including a static member) and 2 if the declaration is
1588 for a constructor. */
1589tree
1590build_decl_overload_real (decl, parms, ret_type, tparms, targs,
1591 for_method)
1592 tree decl;
1593 tree parms;
1594 tree ret_type;
1595 tree tparms;
1596 tree targs;
1597 int for_method;
1598{
1599 const char *name;
1600 enum tree_code operator_code;
1601
1602 /* This function is obsoleted by the new ABI. */
1603 my_friendly_assert (!flag_new_abi, 20000410);
1604
1605 operator_code = DECL_OVERLOADED_OPERATOR_P (decl);
1606 if (!DECL_CONV_FN_P (decl) && operator_code)
1607 {
1608 /* member operators new and delete look like methods at this
1609 point. */
1610 if (! for_method && CP_DECL_CONTEXT (decl) == global_namespace
1611 && parms != NULL_TREE && TREE_CODE (parms) == TREE_LIST
1612 && TREE_CHAIN (parms) == void_list_node)
1613 switch (operator_code)
1614 {
1615 case DELETE_EXPR:
1616 return get_identifier ("__builtin_delete");
1617 case VEC_DELETE_EXPR:
1618 return get_identifier ("__builtin_vec_delete");
1619 case NEW_EXPR:
1620 return get_identifier ("__builtin_new");
1621 case VEC_NEW_EXPR:
1622 return get_identifier ("__builtin_vec_new");
1623 default:
1624 break;
1625 }
1626
1627 if (DECL_ASSIGNMENT_OPERATOR_P (decl))
1628 name = assignment_operator_name_info[(int) operator_code].mangled_name;
1629 else
1630 name = operator_name_info[(int) operator_code].mangled_name;
1631 }
1632 else
1633 name = IDENTIFIER_POINTER (DECL_NAME (decl));
1634
1635 start_squangling ();
1636 OB_INIT ();
1637 if (for_method != 2)
1638 OB_PUTCP (name);
1639 /* Otherwise, we can divine that this is a constructor,
1640 and figure out its name without any extra encoding. */
1641
1642 OB_PUTC2 ('_', '_');
1643 numeric_output_need_bar = 0;
1644
1645 if (tparms)
1646 {
1647 OB_PUTC ('H');
1648 build_template_parm_names (tparms, targs);
1649 OB_PUTC ('_');
1650 }
1651 else if (!for_method && CP_DECL_CONTEXT (decl) == global_namespace)
1652 OB_PUTC ('F');
1653
1654 if (!for_method && CP_DECL_CONTEXT (decl) != global_namespace)
1655 /* qualify with namespace */
1656 build_qualified_name (CP_DECL_CONTEXT (decl));
1657
1658 if (parms == NULL_TREE)
1659 OB_PUTC ('e');
1660 else if (parms == void_list_node)
1661 OB_PUTC ('v');
1662 else
1663 {
1664 if (!flag_do_squangling)
1665 {
1666 /* Allocate typevec array. */
1667 size_t typevec_size = list_length (parms);
1668 maxtype = 0;
1669 if (!for_method && CP_DECL_CONTEXT (decl) != global_namespace)
1670 /* The namespace of a global function needs one slot. */
1671 typevec_size++;
1672 VARRAY_TREE_INIT (typevec, typevec_size, "typevec");
1673 }
1674 nofold = 0;
1675
1676 if (for_method)
1677 {
1678 tree this_type = TREE_TYPE (TREE_VALUE (parms));
1679
1680 build_mangled_name_for_type (this_type);
1681
1682 if (!flag_do_squangling)
1683 {
1684 my_friendly_assert (maxtype < VARRAY_SIZE (typevec), 387);
1685 VARRAY_TREE (typevec, maxtype) = this_type;
1686 maxtype++;
1687 }
1688
1689 if (TREE_CHAIN (parms))
1690 build_mangled_name (TREE_CHAIN (parms), 0, 0);
1691 else
1692 OB_PUTC ('e');
1693 }
1694 else
1695 {
1696 /* the namespace qualifier for a global function
1697 will count as type */
1698 if (CP_DECL_CONTEXT (decl) != global_namespace
1699 && !flag_do_squangling)
1700 {
1701 my_friendly_assert (maxtype < VARRAY_SIZE (typevec), 387);
1702 VARRAY_TREE (typevec, maxtype) = CP_DECL_CONTEXT (decl);
1703 maxtype++;
1704 }
1705 build_mangled_name (parms, 0, 0);
1706 }
1707
1708 if (!flag_do_squangling)
1709 /* Deallocate typevec array. */
1710 VARRAY_FREE (typevec);
1711 }
1712
1713 if (ret_type != NULL_TREE && for_method != 2)
1714 {
1715 /* Add the return type. */
1716 OB_PUTC ('_');
1717 build_mangled_name_for_type (ret_type);
1718 }
1719
1720 OB_FINISH ();
1721 end_squangling ();
1722 {
1723 tree n = get_identifier (obstack_base (&scratch_obstack));
1724 return n;
1725 }
1726}
1727
36a117a5 1728/* Set the mangled name (DECL_ASSEMBLER_NAME) for DECL. */
386b8a85 1729
c1def683 1730void
36a117a5 1731set_mangled_name_for_decl (decl)
9a68c51f 1732 tree decl;
386b8a85 1733{
669ec2b4
JM
1734 tree parm_types;
1735
6b4b3deb
MM
1736 if (processing_template_decl)
1737 /* There's no need to mangle the name of a template function. */
1738 return;
1739
669ec2b4
JM
1740 if (flag_new_abi)
1741 {
1742 DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
1743 return;
1744 }
1745
1746 parm_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
1747
1748 if (DECL_STATIC_FUNCTION_P (decl))
1749 parm_types =
1750 hash_tree_chain (build_pointer_type (DECL_CONTEXT (decl)),
1751 parm_types);
1752 else
1753 /* The only member functions whose type is a FUNCTION_TYPE, rather
1754 than a METHOD_TYPE, should be static members. */
1755 my_friendly_assert (!DECL_CONTEXT (decl)
1756 || !IS_AGGR_TYPE_CODE (TREE_CODE (DECL_CONTEXT (decl)))
1757 || TREE_CODE (TREE_TYPE (decl)) != FUNCTION_TYPE,
1758 0);
1759
1760 DECL_ASSEMBLER_NAME (decl)
1761 = build_decl_overload_real (decl, parm_types, NULL_TREE,
1762 NULL_TREE, NULL_TREE,
1763 DECL_FUNCTION_MEMBER_P (decl)
1764 + DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl));
1765}
1766
1767/* Build an overload name for the type expression TYPE. */
1768
1769tree
1770build_typename_overload (type)
1771 tree type;
1772{
1773 tree id;
1774
1775 /* This function is obsoleted by the new ABI. */
1776 my_friendly_assert (!flag_new_abi, 200004108);
1777
1778 OB_INIT ();
1779 OB_PUTS (OPERATOR_TYPENAME_FORMAT);
1780 nofold = 1;
1781 start_squangling ();
1782 build_mangled_name (type, 0, 1);
1783 id = get_identifier (obstack_base (&scratch_obstack));
1784 IDENTIFIER_OPNAME_P (id) = 1;
1785 IDENTIFIER_TYPENAME_P (id) = 1;
1786 TREE_TYPE (id) = type;
1787 end_squangling ();
1788 return id;
1789}
1790
1791tree
1792build_overload_with_type (name, type)
1793 tree name, type;
1794{
1795 /* This function is obsoleted by the new ABI. */
1796 my_friendly_assert (!flag_new_abi, 200004109);
1797
1798 OB_INIT ();
1799 OB_PUTID (name);
1800 nofold = 1;
1801
1802 start_squangling ();
1803 build_mangled_name (type, 0, 1);
1804 end_squangling ();
1805 return get_identifier (obstack_base (&scratch_obstack));
1806}
1807
1808tree
1809get_id_2 (name, name2)
1810 const char *name;
1811 tree name2;
1812{
1813 /* This function is obsoleted by the new ABI. */
1814 my_friendly_assert (!flag_new_abi, 20000411);
1815
1816 OB_INIT ();
1817 OB_PUTCP (name);
1818 OB_PUTID (name2);
1819 OB_FINISH ();
1820 return get_identifier (obstack_base (&scratch_obstack));
1821}
1822
1823/* Returns the name of a construction vtable group. TYPE is the most
1824 derived class in the hierarhcy. BINFO is the most derived class in
1825 the construction vtable group. */
1826
1827tree
1828get_ctor_vtbl_name (type, binfo)
1829 tree type;
1830 tree binfo;
1831{
1832 /* This function is obsoleted by the new ABI. */
1833 my_friendly_assert (!flag_new_abi, 200005220);
1834
1835 start_squangling ();
1836 OB_INIT ();
1837 OB_PUTCP (CTOR_VTBL_NAME_PREFIX);
1838 build_mangled_name (type, 0, 0);
1839 OB_PUTC ('_');
1840 build_mangled_name (BINFO_TYPE (binfo), 0, 0);
1841 OB_PUTC ('_');
1842 build_overload_int (BINFO_OFFSET (binfo), mf_none);
1843 OB_FINISH ();
1844 end_squangling ();
1845 return get_identifier (obstack_base (&scratch_obstack));
1846}
1847
1848/* Returns a DECL_ASSEMBLER_NAME for the destructor of type TYPE. */
1849
1850tree
1851build_destructor_name (type)
1852 tree type;
1853{
1854 return build_overload_with_type (get_identifier (DESTRUCTOR_DECL_PREFIX),
1855 type);
711734a9 1856}
8d08fdba
MS
1857\f
1858/* Given a tree_code CODE, and some arguments (at least one),
1859 attempt to use an overloaded operator on the arguments.
1860
1861 For unary operators, only the first argument need be checked.
1862 For binary operators, both arguments may need to be checked.
1863
1864 Member functions can convert class references to class pointers,
1865 for one-level deep indirection. More than that is not supported.
1866 Operators [](), ()(), and ->() must be member functions.
1867
1868 We call function call building calls with LOOKUP_COMPLAIN if they
1869 are our only hope. This is true when we see a vanilla operator
1870 applied to something of aggregate type. If this fails, we are free
1871 to return `error_mark_node', because we will have reported the
1872 error.
1873
1874 Operators NEW and DELETE overload in funny ways: operator new takes
1875 a single `size' parameter, and operator delete takes a pointer to the
1876 storage being deleted. When overloading these operators, success is
1877 assumed. If there is a failure, report an error message and return
1878 `error_mark_node'. */
1879
1880/* NOSTRICT */
1881tree
1882build_opfncall (code, flags, xarg1, xarg2, arg3)
1883 enum tree_code code;
1884 int flags;
1885 tree xarg1, xarg2, arg3;
1886{
277294d7 1887 return build_new_op (code, flags, xarg1, xarg2, arg3);
8d08fdba
MS
1888}
1889\f
1890/* This function takes an identifier, ID, and attempts to figure out what
1891 it means. There are a number of possible scenarios, presented in increasing
1892 order of hair:
1893
1894 1) not in a class's scope
1895 2) in class's scope, member name of the class's method
1896 3) in class's scope, but not a member name of the class
1897 4) in class's scope, member name of a class's variable
1898
1899 NAME is $1 from the bison rule. It is an IDENTIFIER_NODE.
1900 VALUE is $$ from the bison rule. It is the value returned by lookup_name ($1)
8d08fdba
MS
1901
1902 As a last ditch, try to look up the name as a label and return that
1903 address.
1904
1905 Values which are declared as being of REFERENCE_TYPE are
1906 automatically dereferenced here (as a hack to make the
1907 compiler faster). */
1908
1909tree
5566b478 1910hack_identifier (value, name)
8d08fdba 1911 tree value, name;
8d08fdba 1912{
de22184b 1913 tree type;
8d08fdba 1914
bd6dd845 1915 if (value == error_mark_node)
8d08fdba
MS
1916 {
1917 if (current_class_name)
1918 {
1919 tree fields = lookup_fnfields (TYPE_BINFO (current_class_type), name, 1);
1920 if (fields == error_mark_node)
1921 return error_mark_node;
1922 if (fields)
1923 {
1924 tree fndecl;
1925
1926 fndecl = TREE_VALUE (fields);
1927 my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 251);
2c73f9f5
ML
1928 /* I could not trigger this code. MvL */
1929 my_friendly_abort (980325);
1930#ifdef DEAD
8d08fdba
MS
1931 if (DECL_CHAIN (fndecl) == NULL_TREE)
1932 {
8251199e 1933 warning ("methods cannot be converted to function pointers");
8d08fdba
MS
1934 return fndecl;
1935 }
1936 else
1937 {
8251199e 1938 error ("ambiguous request for method pointer `%s'",
8d08fdba
MS
1939 IDENTIFIER_POINTER (name));
1940 return error_mark_node;
1941 }
2c73f9f5 1942#endif
8d08fdba
MS
1943 }
1944 }
1945 if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name))
1946 {
1947 return IDENTIFIER_LABEL_VALUE (name);
1948 }
1949 return error_mark_node;
1950 }
1951
1952 type = TREE_TYPE (value);
1953 if (TREE_CODE (value) == FIELD_DECL)
1954 {
4ac14744 1955 if (current_class_ptr == NULL_TREE)
8d08fdba 1956 {
672476cb
MM
1957 if (current_function_decl
1958 && DECL_STATIC_FUNCTION_P (current_function_decl))
8251199e 1959 cp_error ("invalid use of member `%D' in static member function",
672476cb
MM
1960 value);
1961 else
1962 /* We can get here when processing a bad default
1963 argument, like:
1964 struct S { int a; void f(int i = a); } */
8251199e 1965 cp_error ("invalid use of member `%D'", value);
672476cb 1966
8d08fdba
MS
1967 return error_mark_node;
1968 }
4ac14744 1969 TREE_USED (current_class_ptr) = 1;
a5894242 1970
8d08fdba
MS
1971 /* Mark so that if we are in a constructor, and then find that
1972 this field was initialized by a base initializer,
1973 we can emit an error message. */
1974 TREE_USED (value) = 1;
4ac14744 1975 value = build_component_ref (current_class_ref, name, NULL_TREE, 1);
8d08fdba 1976 }
8f032717
MM
1977 else if ((TREE_CODE (value) == FUNCTION_DECL
1978 && DECL_FUNCTION_MEMBER_P (value))
1979 || (TREE_CODE (value) == OVERLOAD
1980 && DECL_FUNCTION_MEMBER_P (OVL_CURRENT (value))))
51924768
JM
1981 {
1982 tree decl;
1983
8f032717
MM
1984 if (TREE_CODE (value) == OVERLOAD)
1985 value = OVL_CURRENT (value);
1986
4f1c5b7d 1987 decl = maybe_dummy_object (DECL_CONTEXT (value), 0);
51924768
JM
1988 value = build_component_ref (decl, name, NULL_TREE, 1);
1989 }
6b5fbb55 1990 else if (really_overloaded_fn (value))
8f032717 1991 ;
2c73f9f5
ML
1992 else if (TREE_CODE (value) == OVERLOAD)
1993 /* not really overloaded function */
1994 mark_used (OVL_FUNCTION (value));
a5ef9010
JM
1995 else if (TREE_CODE (value) == TREE_LIST)
1996 {
72b7eeff 1997 /* Ambiguous reference to base members, possibly other cases?. */
a5ef9010
JM
1998 tree t = value;
1999 while (t && TREE_CODE (t) == TREE_LIST)
2000 {
72b7eeff 2001 mark_used (TREE_VALUE (t));
a5ef9010
JM
2002 t = TREE_CHAIN (t);
2003 }
2004 }
2c73f9f5 2005 else if (TREE_CODE (value) == NAMESPACE_DECL)
0e607f34 2006 {
8251199e 2007 cp_error ("use of namespace `%D' as expression", value);
0e607f34
JM
2008 return error_mark_node;
2009 }
2010 else if (DECL_CLASS_TEMPLATE_P (value))
2011 {
8251199e 2012 cp_error ("use of class template `%T' as expression", value);
0e607f34
JM
2013 return error_mark_node;
2014 }
8d08fdba 2015 else
72b7eeff 2016 mark_used (value);
8d08fdba 2017
c6882a35
JM
2018 if (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == PARM_DECL
2019 || TREE_CODE (value) == RESULT_DECL)
5566b478
MS
2020 {
2021 tree context = decl_function_context (value);
2022 if (context != NULL_TREE && context != current_function_decl
2023 && ! TREE_STATIC (value))
2024 {
8251199e 2025 cp_error ("use of %s from containing function",
5566b478
MS
2026 (TREE_CODE (value) == VAR_DECL
2027 ? "`auto' variable" : "parameter"));
8251199e 2028 cp_error_at (" `%#D' declared here", value);
e76a2646 2029 value = error_mark_node;
5566b478
MS
2030 }
2031 }
2032
2f939d94 2033 if (DECL_P (value) && DECL_NONLOCAL (value))
8d08fdba 2034 {
70adf8a9 2035 if (DECL_CLASS_SCOPE_P (value)
4f1c5b7d 2036 && DECL_CONTEXT (value) != current_class_type)
8d08fdba 2037 {
d6479fe7 2038 tree path;
4f1c5b7d 2039 path = currently_open_derived_class (DECL_CONTEXT (value));
70adf8a9 2040 enforce_access (path, value);
8d08fdba 2041 }
8d08fdba 2042 }
280f9385
MM
2043 else if (TREE_CODE (value) == TREE_LIST
2044 && TREE_TYPE (value) == error_mark_node)
8d08fdba 2045 {
0cfdd854
ML
2046 error ("request for member `%s' is ambiguous in multiple inheritance lattice",
2047 IDENTIFIER_POINTER (name));
66543169 2048 print_candidates (value);
0cfdd854 2049 return error_mark_node;
8d08fdba
MS
2050 }
2051
75d587eb 2052 if (! processing_template_decl)
6b5fbb55 2053 value = convert_from_reference (value);
8d08fdba
MS
2054 return value;
2055}
2056
8926095f 2057\f
1f6e1acc
AS
2058/* Return a thunk to FUNCTION. For a virtual thunk, DELTA is the
2059 offset to this used to locate the vptr, and VCALL_INDEX is used to
2060 look up the eventual subobject location. For a non-virtual thunk,
2061 DELTA is the offset to this and VCALL_INDEX is zero. */
2062
8926095f 2063tree
31f8e4f3 2064make_thunk (function, delta, vcall_index, generate_with_vtable_p)
8926095f 2065 tree function;
31f8e4f3
MM
2066 tree delta;
2067 tree vcall_index;
2068 int generate_with_vtable_p;
8926095f 2069{
b87692e5 2070 tree thunk_id;
8926095f 2071 tree thunk;
8926095f 2072 tree func_decl;
31f8e4f3
MM
2073 tree vcall_offset;
2074 HOST_WIDE_INT d;
2075
2076 /* Scale the VCALL_INDEX to be in terms of bytes. */
2077 if (vcall_index)
2078 vcall_offset
2079 = size_binop (MULT_EXPR,
2080 vcall_index,
2081 convert (ssizetype,
2082 TYPE_SIZE_UNIT (vtable_entry_type)));
2083 else
2084 vcall_offset = NULL_TREE;
2085
2086 d = tree_low_cst (delta, 0);
cc600f33 2087
8926095f
MS
2088 if (TREE_CODE (function) != ADDR_EXPR)
2089 abort ();
2090 func_decl = TREE_OPERAND (function, 0);
2091 if (TREE_CODE (func_decl) != FUNCTION_DECL)
2092 abort ();
cc600f33 2093
669ec2b4 2094 if (flag_new_abi)
31f8e4f3
MM
2095 thunk_id = mangle_thunk (TREE_OPERAND (function, 0),
2096 delta, vcall_offset);
669ec2b4
JM
2097 else
2098 {
2099 OB_INIT ();
2100 OB_PUTS ("__thunk_");
31f8e4f3 2101 if (d > 0)
669ec2b4
JM
2102 {
2103 OB_PUTC ('n');
31f8e4f3 2104 icat (d);
669ec2b4
JM
2105 }
2106 else
31f8e4f3 2107 icat (-d);
669ec2b4
JM
2108 OB_PUTC ('_');
2109 if (vcall_index)
2110 {
31f8e4f3 2111 icat (tree_low_cst (vcall_index, 0));
669ec2b4
JM
2112 OB_PUTC ('_');
2113 }
2114 OB_PUTID (DECL_ASSEMBLER_NAME (func_decl));
2115 OB_FINISH ();
2116 thunk_id = get_identifier (obstack_base (&scratch_obstack));
2117 }
2118
a0a33927 2119 thunk = IDENTIFIER_GLOBAL_VALUE (thunk_id);
eb68cb58 2120 if (thunk && !DECL_THUNK_P (thunk))
a0a33927 2121 {
8251199e 2122 cp_error ("implementation-reserved name `%D' used", thunk_id);
2c73f9f5
ML
2123 thunk = NULL_TREE;
2124 SET_IDENTIFIER_GLOBAL_VALUE (thunk_id, thunk);
a0a33927
MS
2125 }
2126 if (thunk == NULL_TREE)
2127 {
eb448459 2128 thunk = build_decl (FUNCTION_DECL, thunk_id, TREE_TYPE (func_decl));
6462c441
MM
2129 DECL_LANG_SPECIFIC (thunk) = DECL_LANG_SPECIFIC (func_decl);
2130 copy_lang_decl (func_decl);
2131 DECL_CONTEXT (thunk) = DECL_CONTEXT (func_decl);
eb448459
MS
2132 TREE_READONLY (thunk) = TREE_READONLY (func_decl);
2133 TREE_THIS_VOLATILE (thunk) = TREE_THIS_VOLATILE (func_decl);
7fcdf4c2 2134 comdat_linkage (thunk);
eb68cb58 2135 SET_DECL_THUNK_P (thunk);
a0a33927 2136 DECL_INITIAL (thunk) = function;
31f8e4f3 2137 THUNK_DELTA (thunk) = d;
1f6e1acc 2138 THUNK_VCALL_OFFSET (thunk) = vcall_offset;
31f8e4f3 2139 THUNK_GENERATE_WITH_VTABLE_P (thunk) = generate_with_vtable_p;
6462c441
MM
2140 /* The thunk itself is not a constructor or destructor, even if
2141 the thing it is thunking to is. */
2142 DECL_INTERFACE_KNOWN (thunk) = 1;
2143 DECL_NOT_REALLY_EXTERN (thunk) = 1;
2144 DECL_SAVED_FUNCTION_DATA (thunk) = NULL;
2145 DECL_DESTRUCTOR_P (thunk) = 0;
2146 DECL_CONSTRUCTOR_P (thunk) = 0;
72b7eeff 2147 DECL_EXTERNAL (thunk) = 1;
eb448459 2148 DECL_ARTIFICIAL (thunk) = 1;
c67dca7a 2149 DECL_VTT_PARM (thunk) = NULL_TREE;
eb68cb58
MM
2150 /* Even if this thunk is a member of a local class, we don't
2151 need a static chain. */
2152 DECL_NO_STATIC_CHAIN (thunk) = 1;
6462c441
MM
2153 /* The THUNK is not a pending inline, even if the FUNC_DECL is. */
2154 DECL_PENDING_INLINE_P (thunk) = 0;
2155 /* Nor has it been deferred. */
2156 DECL_DEFERRED_FN (thunk) = 0;
a0a33927
MS
2157 /* So that finish_file can write out any thunks that need to be: */
2158 pushdecl_top_level (thunk);
31f8e4f3
MM
2159 /* Create RTL for this thunk so that its address can be taken. */
2160 make_function_rtl (thunk);
a0a33927 2161 }
8926095f
MS
2162 return thunk;
2163}
2164
eb448459
MS
2165/* Emit the definition of a C++ multiple inheritance vtable thunk. */
2166
8926095f 2167void
31f8e4f3 2168use_thunk (thunk_fndecl, emit_p)
824b9a4c 2169 tree thunk_fndecl;
31f8e4f3
MM
2170 int emit_p;
2171
8926095f 2172{
6462c441
MM
2173 tree fnaddr;
2174 tree function;
31f8e4f3
MM
2175 tree vcall_offset;
2176 HOST_WIDE_INT delta;
8926095f
MS
2177
2178 if (TREE_ASM_WRITTEN (thunk_fndecl))
2179 return;
31f8e4f3
MM
2180
2181 fnaddr = DECL_INITIAL (thunk_fndecl);
6462c441
MM
2182 if (TREE_CODE (DECL_INITIAL (thunk_fndecl)) != ADDR_EXPR)
2183 /* We already turned this thunk into an ordinary function.
2184 There's no need to process this thunk again. (We can't just
2185 clear DECL_THUNK_P because that will confuse
2186 FNADDR_FROM_VTABLE_ENTRY and friends.) */
2187 return;
2188
31f8e4f3
MM
2189 /* Thunks are always addressable; they only appear in vtables. */
2190 TREE_ADDRESSABLE (thunk_fndecl) = 1;
a0a33927 2191
31f8e4f3
MM
2192 /* Figure out what function is being thunked to. It's referenced in
2193 this translation unit. */
2194 function = TREE_OPERAND (fnaddr, 0);
809c8c30
JM
2195 TREE_ADDRESSABLE (function) = 1;
2196 mark_used (function);
31f8e4f3
MM
2197 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (function)) = 1;
2198 if (!emit_p)
2199 return;
809c8c30 2200
31f8e4f3
MM
2201 delta = THUNK_DELTA (thunk_fndecl);
2202 vcall_offset = THUNK_VCALL_OFFSET (thunk_fndecl);
2203
2204 /* And, if we need to emit the thunk, it's used. */
2205 mark_used (thunk_fndecl);
2206 /* This thunk is actually defined. */
2207 DECL_EXTERNAL (thunk_fndecl) = 0;
a0128b67 2208
6462c441
MM
2209 if (flag_syntax_only)
2210 {
2211 TREE_ASM_WRITTEN (thunk_fndecl) = 1;
2212 return;
2213 }
2214
31f8e4f3
MM
2215 push_to_top_level ();
2216
a80e4195 2217#ifdef ASM_OUTPUT_MI_THUNK
31f8e4f3 2218 if (!vcall_offset)
3b62f224 2219 {
3cce094d 2220 const char *fnname;
3b62f224 2221 current_function_decl = thunk_fndecl;
3b62f224
MM
2222 DECL_RESULT (thunk_fndecl)
2223 = build_decl (RESULT_DECL, 0, integer_type_node);
2224 fnname = XSTR (XEXP (DECL_RTL (thunk_fndecl), 0), 0);
2225 init_function_start (thunk_fndecl, input_filename, lineno);
2226 current_function_is_thunk = 1;
2227 assemble_start_function (thunk_fndecl, fnname);
2228 ASM_OUTPUT_MI_THUNK (asm_out_file, thunk_fndecl, delta, function);
2229 assemble_end_function (thunk_fndecl, fnname);
3b62f224 2230 current_function_decl = 0;
01d939e8 2231 cfun = 0;
6462c441 2232 TREE_ASM_WRITTEN (thunk_fndecl) = 1;
3b62f224 2233 }
4e7512c9 2234 else
aa95639e 2235#endif /* ASM_OUTPUT_MI_THUNK */
3b62f224 2236 {
eb448459
MS
2237 /* If we don't have the necessary macro for efficient thunks, generate a
2238 thunk function that just makes a call to the real function.
2239 Unfortunately, this doesn't work for varargs. */
2240
eb66be0e 2241 tree a, t;
8926095f 2242
eb448459 2243 if (varargs_function_p (function))
8251199e 2244 cp_error ("generic thunk code fails for method `%#D' which uses `...'",
eb448459
MS
2245 function);
2246
eb66be0e
MS
2247 /* Set up clone argument trees for the thunk. */
2248 t = NULL_TREE;
2249 for (a = DECL_ARGUMENTS (function); a; a = TREE_CHAIN (a))
2250 {
2251 tree x = copy_node (a);
2252 TREE_CHAIN (x) = t;
2253 DECL_CONTEXT (x) = thunk_fndecl;
2254 t = x;
2255 }
2256 a = nreverse (t);
2257 DECL_ARGUMENTS (thunk_fndecl) = a;
2258 DECL_RESULT (thunk_fndecl) = NULL_TREE;
eb68cb58 2259
4e7512c9 2260 start_function (NULL_TREE, thunk_fndecl, NULL_TREE, SF_PRE_PARSED);
eb66be0e 2261
4e7512c9
MM
2262 /* Adjust the this pointer by the constant. */
2263 t = ssize_int (delta);
eb66be0e 2264 t = fold (build (PLUS_EXPR, TREE_TYPE (a), a, t));
4e7512c9
MM
2265 /* If there's a vcall offset, look up that value in the vtable and
2266 adjust the `this' pointer again. */
193833ed 2267 if (vcall_offset && !integer_zerop (vcall_offset))
4e7512c9
MM
2268 {
2269 tree orig_this;
2270
2271 t = save_expr (t);
2272 orig_this = t;
2273 /* The vptr is always at offset zero in the object. */
2274 t = build1 (NOP_EXPR,
2275 build_pointer_type (build_pointer_type
2276 (vtable_entry_type)),
2277 t);
2278 /* Form the vtable address. */
2279 t = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (t)), t);
2280 /* Find the entry with the vcall offset. */
31f8e4f3 2281 t = build (PLUS_EXPR, TREE_TYPE (t), t, vcall_offset);
4e7512c9
MM
2282 /* Calculate the offset itself. */
2283 t = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (t)), t);
2284 /* Adjust the `this' pointer. */
2285 t = fold (build (PLUS_EXPR,
2286 TREE_TYPE (orig_this),
2287 orig_this,
2288 t));
2289 }
2290
2291 /* Build up the call to the real function. */
e1b3e07d 2292 t = tree_cons (NULL_TREE, t, NULL_TREE);
eb66be0e 2293 for (a = TREE_CHAIN (a); a; a = TREE_CHAIN (a))
e1b3e07d 2294 t = tree_cons (NULL_TREE, a, t);
eb66be0e 2295 t = nreverse (t);
0c11ada6 2296 t = build_call (function, t);
b72801e2 2297 if (VOID_TYPE_P (TREE_TYPE (t)))
baf05df0 2298 finish_expr_stmt (t);
b72801e2
NS
2299 else
2300 finish_return_stmt (t);
eb66be0e 2301
4e7512c9 2302 /* The back-end expects DECL_INITIAL to contain a BLOCK, so we
6462c441 2303 create one. */
4e7512c9
MM
2304 DECL_INITIAL (thunk_fndecl) = make_node (BLOCK);
2305 BLOCK_VARS (DECL_INITIAL (thunk_fndecl))
2306 = DECL_ARGUMENTS (thunk_fndecl);
0acf7199 2307 expand_body (finish_function (0));
eb448459 2308 }
31f8e4f3
MM
2309
2310 pop_from_top_level ();
8926095f 2311}
f376e137
MS
2312\f
2313/* Code for synthesizing methods which have default semantics defined. */
2314
f376e137 2315/* Generate code for default X(X&) constructor. */
e92cc029 2316
824b9a4c 2317static void
db5ae43f 2318do_build_copy_constructor (fndecl)
f376e137
MS
2319 tree fndecl;
2320{
2321 tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
2322 tree t;
2323
454fa7a7 2324 if (DECL_HAS_IN_CHARGE_PARM_P (fndecl))
f376e137
MS
2325 parm = TREE_CHAIN (parm);
2326 parm = convert_from_reference (parm);
2327
a59ca936
JM
2328 if (TYPE_HAS_TRIVIAL_INIT_REF (current_class_type)
2329 && is_empty_class (current_class_type))
2330 /* Don't copy the padding byte; it might not have been allocated
2331 if *this is a base subobject. */;
2332 else if (TYPE_HAS_TRIVIAL_INIT_REF (current_class_type))
f376e137 2333 {
4ac14744 2334 t = build (INIT_EXPR, void_type_node, current_class_ref, parm);
f1dedc31 2335 finish_expr_stmt (t);
f376e137
MS
2336 }
2337 else
2338 {
2339 tree fields = TYPE_FIELDS (current_class_type);
2340 int n_bases = CLASSTYPE_N_BASECLASSES (current_class_type);
2341 tree binfos = TYPE_BINFO_BASETYPES (current_class_type);
fd74ca0b
MM
2342 tree member_init_list = NULL_TREE;
2343 tree base_init_list = NULL_TREE;
f376e137
MS
2344 int i;
2345
1b5f5f76 2346 /* Initialize all the base-classes. */
f376e137
MS
2347 for (t = CLASSTYPE_VBASECLASSES (current_class_type); t;
2348 t = TREE_CHAIN (t))
fd74ca0b 2349 base_init_list
a55583e9 2350 = tree_cons (BINFO_TYPE (TREE_VALUE (t)), parm,
fd74ca0b 2351 base_init_list);
f376e137
MS
2352 for (i = 0; i < n_bases; ++i)
2353 {
1b5f5f76
MM
2354 t = TREE_VEC_ELT (binfos, i);
2355 if (TREE_VIA_VIRTUAL (t))
8ccc31eb 2356 continue;
f376e137 2357
fd74ca0b
MM
2358 base_init_list
2359 = tree_cons (BINFO_TYPE (t), parm, base_init_list);
f376e137 2360 }
1b5f5f76 2361
f376e137
MS
2362 for (; fields; fields = TREE_CHAIN (fields))
2363 {
de22184b 2364 tree init, t;
a5894242
MS
2365 tree field = fields;
2366
2367 if (TREE_CODE (field) != FIELD_DECL)
f376e137 2368 continue;
8dff1027
MS
2369
2370 init = parm;
a5894242 2371 if (DECL_NAME (field))
f376e137 2372 {
a5894242 2373 if (VFIELD_NAME_P (DECL_NAME (field)))
f376e137 2374 continue;
a5894242 2375 if (VBASE_NAME_P (DECL_NAME (field)))
f376e137
MS
2376 continue;
2377
2378 /* True for duplicate members. */
a5894242 2379 if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field)
f376e137
MS
2380 continue;
2381 }
a5894242 2382 else if ((t = TREE_TYPE (field)) != NULL_TREE
6bdb8141 2383 && ANON_AGGR_TYPE_P (t)
0171aeab 2384 && TYPE_FIELDS (t) != NULL_TREE)
6bdb8141
JM
2385 /* Just use the field; anonymous types can't have
2386 nontrivial copy ctors or assignment ops. */;
0171aeab
JM
2387 else
2388 continue;
f376e137 2389
8dff1027 2390 init = build (COMPONENT_REF, TREE_TYPE (field), init, field);
f376e137
MS
2391 init = build_tree_list (NULL_TREE, init);
2392
fd74ca0b
MM
2393 member_init_list
2394 = tree_cons (field, init, member_init_list);
f376e137 2395 }
fd74ca0b
MM
2396 member_init_list = nreverse (member_init_list);
2397 base_init_list = nreverse (base_init_list);
2398 setup_vtbl_ptr (member_init_list, base_init_list);
f376e137 2399 }
f376e137
MS
2400}
2401
824b9a4c 2402static void
db5ae43f 2403do_build_assign_ref (fndecl)
f376e137
MS
2404 tree fndecl;
2405{
2406 tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
f1dedc31 2407 tree compound_stmt;
f376e137 2408
f1dedc31 2409 compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
f376e137
MS
2410 parm = convert_from_reference (parm);
2411
a59ca936
JM
2412 if (TYPE_HAS_TRIVIAL_ASSIGN_REF (current_class_type)
2413 && is_empty_class (current_class_type))
2414 /* Don't copy the padding byte; it might not have been allocated
2415 if *this is a base subobject. */;
2416 else if (TYPE_HAS_TRIVIAL_ASSIGN_REF (current_class_type))
f376e137 2417 {
4ac14744 2418 tree t = build (MODIFY_EXPR, void_type_node, current_class_ref, parm);
f1dedc31 2419 finish_expr_stmt (t);
f376e137
MS
2420 }
2421 else
2422 {
2423 tree fields = TYPE_FIELDS (current_class_type);
2424 int n_bases = CLASSTYPE_N_BASECLASSES (current_class_type);
2425 tree binfos = TYPE_BINFO_BASETYPES (current_class_type);
2426 int i;
2427
2428 for (i = 0; i < n_bases; ++i)
2429 {
2430 tree basetype = BINFO_TYPE (TREE_VEC_ELT (binfos, i));
717e3f73
NS
2431 tree p = build_qualified_type
2432 (basetype, CP_TYPE_QUALS (TREE_TYPE (parm)));
2433
2434 p = convert_to_reference
2435 (build_reference_type (p), parm,
2436 CONV_IMPLICIT, LOOKUP_COMPLAIN, NULL_TREE);
e349ee73 2437 p = convert_from_reference (p);
596ea4e5 2438 p = build_member_call (basetype, ansi_assopname (NOP_EXPR),
051e6fd7 2439 build_tree_list (NULL_TREE, p));
62409b39 2440 finish_expr_stmt (p);
f376e137
MS
2441 }
2442 for (; fields; fields = TREE_CHAIN (fields))
2443 {
0171aeab 2444 tree comp, init, t;
a5894242
MS
2445 tree field = fields;
2446
2447 if (TREE_CODE (field) != FIELD_DECL)
f376e137 2448 continue;
e349ee73 2449
1b8899d1 2450 if (CP_TYPE_CONST_P (TREE_TYPE (field)))
e349ee73
MS
2451 {
2452 if (DECL_NAME (field))
8251199e 2453 cp_error ("non-static const member `%#D', can't use default assignment operator", field);
e349ee73 2454 else
8251199e 2455 cp_error ("non-static const member in type `%T', can't use default assignment operator", current_class_type);
e349ee73
MS
2456 continue;
2457 }
2458 else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
2459 {
2460 if (DECL_NAME (field))
8251199e 2461 cp_error ("non-static reference member `%#D', can't use default assignment operator", field);
e349ee73 2462 else
8251199e 2463 cp_error ("non-static reference member in type `%T', can't use default assignment operator", current_class_type);
e349ee73
MS
2464 continue;
2465 }
2466
8dff1027
MS
2467 comp = current_class_ref;
2468 init = parm;
2469
a5894242 2470 if (DECL_NAME (field))
f376e137 2471 {
a5894242 2472 if (VFIELD_NAME_P (DECL_NAME (field)))
f376e137 2473 continue;
a5894242 2474 if (VBASE_NAME_P (DECL_NAME (field)))
f376e137
MS
2475 continue;
2476
2477 /* True for duplicate members. */
a5894242 2478 if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field)
f376e137
MS
2479 continue;
2480 }
a5894242 2481 else if ((t = TREE_TYPE (field)) != NULL_TREE
6bdb8141 2482 && ANON_AGGR_TYPE_P (t)
0171aeab 2483 && TYPE_FIELDS (t) != NULL_TREE)
6bdb8141
JM
2484 /* Just use the field; anonymous types can't have
2485 nontrivial copy ctors or assignment ops. */;
0171aeab
JM
2486 else
2487 continue;
f376e137 2488
8dff1027
MS
2489 comp = build (COMPONENT_REF, TREE_TYPE (field), comp, field);
2490 init = build (COMPONENT_REF, TREE_TYPE (field), init, field);
f376e137 2491
62409b39 2492 finish_expr_stmt (build_modify_expr (comp, NOP_EXPR, init));
f376e137
MS
2493 }
2494 }
62409b39 2495 finish_return_stmt (current_class_ref);
f1dedc31 2496 finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
f376e137
MS
2497}
2498
2499void
db5ae43f 2500synthesize_method (fndecl)
f376e137
MS
2501 tree fndecl;
2502{
db5ae43f 2503 int nested = (current_function_decl != NULL_TREE);
4f1c5b7d 2504 tree context = decl_function_context (fndecl);
62409b39 2505 int need_body = 1;
db5ae43f 2506
b7067a12
JM
2507 if (at_eof)
2508 import_export_decl (fndecl);
2509
db9b2174
MM
2510 /* If we've been asked to synthesize a clone, just synthesize the
2511 cloned function instead. Doing so will automatically fill in the
2512 body for the clone. */
2513 if (DECL_CLONED_FUNCTION_P (fndecl))
2514 {
2515 synthesize_method (DECL_CLONED_FUNCTION (fndecl));
2516 return;
2517 }
2518
9a3b49ac
MS
2519 if (! context)
2520 push_to_top_level ();
2521 else if (nested)
99dccabc 2522 push_function_context_to (context);
db5ae43f 2523
62409b39
MM
2524 /* Put the function definition at the position where it is needed,
2525 rather than within the body of the class. That way, an error
2526 during the generation of the implicit body points at the place
2527 where the attempt to generate the function occurs, giving the
2528 user a hint as to why we are attempting to generate the
2529 function. */
2530 DECL_SOURCE_LINE (fndecl) = lineno;
2531 DECL_SOURCE_FILE (fndecl) = input_filename;
2532
e76a2646 2533 interface_unknown = 1;
a8f73d4b 2534 start_function (NULL_TREE, fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
f1dedc31 2535 clear_last_expr ();
db5ae43f 2536
596ea4e5 2537 if (DECL_OVERLOADED_OPERATOR_P (fndecl) == NOP_EXPR)
62409b39
MM
2538 {
2539 do_build_assign_ref (fndecl);
2540 need_body = 0;
2541 }
9eb71d8c 2542 else if (DECL_DESTRUCTOR_P (fndecl))
fd74ca0b 2543 setup_vtbl_ptr (NULL_TREE, NULL_TREE);
db5ae43f
MS
2544 else
2545 {
2546 tree arg_chain = FUNCTION_ARG_CHAIN (fndecl);
454fa7a7 2547 if (DECL_HAS_IN_CHARGE_PARM_P (fndecl))
db5ae43f
MS
2548 arg_chain = TREE_CHAIN (arg_chain);
2549 if (arg_chain != void_list_node)
2550 do_build_copy_constructor (fndecl);
2551 else if (TYPE_NEEDS_CONSTRUCTING (current_class_type))
fd74ca0b 2552 setup_vtbl_ptr (NULL_TREE, NULL_TREE);
62409b39 2553 }
f18a14bc 2554
62409b39
MM
2555 /* If we haven't yet generated the body of the function, just
2556 generate an empty compound statement. */
2557 if (need_body)
2558 {
2559 tree compound_stmt;
2560 compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
2561 finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
db5ae43f
MS
2562 }
2563
0acf7199 2564 expand_body (finish_function (0));
28cbf42c 2565
db5ae43f 2566 extract_interface_info ();
9a3b49ac
MS
2567 if (! context)
2568 pop_from_top_level ();
2569 else if (nested)
99dccabc 2570 pop_function_context_from (context);
f376e137 2571}
9eb71d8c
MM
2572
2573/* Implicitly declare the special function indicated by KIND, as a
2574 member of TYPE. For copy constructors and assignment operators,
2575 CONST_P indicates whether these functions should take a const
2576 reference argument or a non-const reference. */
2577
2578tree
2579implicitly_declare_fn (kind, type, const_p)
2580 special_function_kind kind;
2581 tree type;
2582 int const_p;
2583{
2584 tree declspecs = NULL_TREE;
2585 tree fn, args = NULL_TREE;
2586 tree argtype;
2587 int retref = 0;
2588 tree name = constructor_name (TYPE_IDENTIFIER (type));
2589
2590 switch (kind)
2591 {
2592 /* Destructors. */
2593 case sfk_destructor:
2594 name = build_parse_node (BIT_NOT_EXPR, name);
2595 args = void_list_node;
2596 break;
2597
2598 case sfk_constructor:
2599 /* Default constructor. */
2600 args = void_list_node;
2601 break;
2602
2603 case sfk_copy_constructor:
2604 if (const_p)
2605 type = build_qualified_type (type, TYPE_QUAL_CONST);
2606 argtype = build_reference_type (type);
2607 args = tree_cons (NULL_TREE,
2608 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
2609 get_identifier ("_ctor_arg")),
2610 void_list_node);
2611 break;
2612
2613 case sfk_assignment_operator:
2614 retref = 1;
1f8f4a0b 2615 declspecs = build_tree_list (NULL_TREE, type);
9eb71d8c
MM
2616
2617 if (const_p)
2618 type = build_qualified_type (type, TYPE_QUAL_CONST);
2619
596ea4e5 2620 name = ansi_assopname (NOP_EXPR);
9eb71d8c
MM
2621
2622 argtype = build_reference_type (type);
2623 args = tree_cons (NULL_TREE,
2624 build_tree_list (hash_tree_chain (argtype, NULL_TREE),
2625 get_identifier ("_ctor_arg")),
2626 void_list_node);
2627 break;
2628
2629 default:
2630 my_friendly_abort (59);
2631 }
2632
2633 TREE_PARMLIST (args) = 1;
2634
2635 {
2636 tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE);
2637 if (retref)
2638 declarator = build_parse_node (ADDR_EXPR, declarator);
2639
2640 fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
2641 }
2642
2643 my_friendly_assert (TREE_CODE (fn) == FUNCTION_DECL, 20000408);
2644
2645 if (kind != sfk_constructor && kind != sfk_destructor)
c727aa5e
NS
2646 DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn))) = 1;
2647 DECL_ARTIFICIAL (fn) = 1;
9eb71d8c
MM
2648 DECL_NOT_REALLY_EXTERN (fn) = 1;
2649 DECL_THIS_INLINE (fn) = 1;
2650 DECL_INLINE (fn) = 1;
2651 defer_fn (fn);
2652
2653 return fn;
2654}
This page took 1.058448 seconds and 5 git commands to generate.