1 /* Handle the hair of processing (but not expanding) inline functions.
2 Also manage function and variable name overloading.
3 Copyright (C) 1987-2014 Free Software Foundation, Inc.
4 Contributed by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GCC.
8 GCC 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 3, or (at your option)
13 GCC 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.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 /* Handle method declarations. */
26 #include "coretypes.h"
29 #include "stringpool.h"
36 #include "common/common-target.h"
37 #include "diagnostic.h"
39 #include "pointer-set.h"
41 /* Various flags to control the mangling process. */
47 /* The thing we are presently mangling is part of a template type,
48 rather than a fully instantiated type. Therefore, we may see
49 complex expressions where we would normally expect to see a
50 simple integer constant. */
51 mf_maybe_uninstantiated
= 1,
52 /* When mangling a numeric value, use the form `_XX_' (instead of
53 just `XX') if the value has more than one digit. */
54 mf_use_underscores_around_value
= 2
57 typedef enum mangling_flags mangling_flags
;
59 static void do_build_copy_assign (tree
);
60 static void do_build_copy_constructor (tree
);
61 static tree
make_alias_for_thunk (tree
);
63 /* Called once to initialize method.c. */
71 /* Return a this or result adjusting thunk to FUNCTION. THIS_ADJUSTING
72 indicates whether it is a this or result adjusting thunk.
73 FIXED_OFFSET and VIRTUAL_OFFSET indicate how to do the adjustment
74 (see thunk_adjust). VIRTUAL_OFFSET can be NULL, but FIXED_OFFSET
75 never is. VIRTUAL_OFFSET is the /index/ into the vtable for this
76 adjusting thunks, we scale it to a byte offset. For covariant
77 thunks VIRTUAL_OFFSET is the virtual binfo. You must post process
78 the returned thunk with finish_thunk. */
81 make_thunk (tree function
, bool this_adjusting
,
82 tree fixed_offset
, tree virtual_offset
)
87 gcc_assert (TREE_CODE (function
) == FUNCTION_DECL
);
88 /* We can have this thunks to covariant thunks, but not vice versa. */
89 gcc_assert (!DECL_THIS_THUNK_P (function
));
90 gcc_assert (!DECL_RESULT_THUNK_P (function
) || this_adjusting
);
92 /* Scale the VIRTUAL_OFFSET to be in terms of bytes. */
93 if (this_adjusting
&& virtual_offset
)
95 = size_binop (MULT_EXPR
,
98 TYPE_SIZE_UNIT (vtable_entry_type
)));
100 d
= tree_to_shwi (fixed_offset
);
102 /* See if we already have the thunk in question. For this_adjusting
103 thunks VIRTUAL_OFFSET will be an INTEGER_CST, for covariant thunks it
105 for (thunk
= DECL_THUNKS (function
); thunk
; thunk
= DECL_CHAIN (thunk
))
106 if (DECL_THIS_THUNK_P (thunk
) == this_adjusting
107 && THUNK_FIXED_OFFSET (thunk
) == d
108 && !virtual_offset
== !THUNK_VIRTUAL_OFFSET (thunk
)
111 ? tree_int_cst_equal (THUNK_VIRTUAL_OFFSET (thunk
),
113 : THUNK_VIRTUAL_OFFSET (thunk
) == virtual_offset
)))
116 /* All thunks must be created before FUNCTION is actually emitted;
117 the ABI requires that all thunks be emitted together with the
118 function to which they transfer control. */
119 gcc_assert (!TREE_ASM_WRITTEN (function
));
120 /* Likewise, we can only be adding thunks to a function declared in
121 the class currently being laid out. */
122 gcc_assert (TYPE_SIZE (DECL_CONTEXT (function
))
123 && TYPE_BEING_DEFINED (DECL_CONTEXT (function
)));
125 thunk
= build_decl (DECL_SOURCE_LOCATION (function
),
126 FUNCTION_DECL
, NULL_TREE
, TREE_TYPE (function
));
127 DECL_LANG_SPECIFIC (thunk
) = DECL_LANG_SPECIFIC (function
);
128 cxx_dup_lang_specific_decl (thunk
);
129 DECL_VIRTUAL_P (thunk
) = true;
130 SET_DECL_THUNKS (thunk
, NULL_TREE
);
132 DECL_CONTEXT (thunk
) = DECL_CONTEXT (function
);
133 TREE_READONLY (thunk
) = TREE_READONLY (function
);
134 TREE_THIS_VOLATILE (thunk
) = TREE_THIS_VOLATILE (function
);
135 TREE_PUBLIC (thunk
) = TREE_PUBLIC (function
);
136 SET_DECL_THUNK_P (thunk
, this_adjusting
);
137 THUNK_TARGET (thunk
) = function
;
138 THUNK_FIXED_OFFSET (thunk
) = d
;
139 THUNK_VIRTUAL_OFFSET (thunk
) = virtual_offset
;
140 THUNK_ALIAS (thunk
) = NULL_TREE
;
142 DECL_INTERFACE_KNOWN (thunk
) = 1;
143 DECL_NOT_REALLY_EXTERN (thunk
) = 1;
144 DECL_COMDAT (thunk
) = DECL_COMDAT (function
);
145 DECL_SAVED_FUNCTION_DATA (thunk
) = NULL
;
146 /* The thunk itself is not a constructor or destructor, even if
147 the thing it is thunking to is. */
148 DECL_DESTRUCTOR_P (thunk
) = 0;
149 DECL_CONSTRUCTOR_P (thunk
) = 0;
150 DECL_EXTERNAL (thunk
) = 1;
151 DECL_ARTIFICIAL (thunk
) = 1;
152 /* The THUNK is not a pending inline, even if the FUNCTION is. */
153 DECL_PENDING_INLINE_P (thunk
) = 0;
154 DECL_DECLARED_INLINE_P (thunk
) = 0;
155 /* Nor is it a template instantiation. */
156 DECL_USE_TEMPLATE (thunk
) = 0;
157 DECL_TEMPLATE_INFO (thunk
) = NULL
;
159 /* Add it to the list of thunks associated with FUNCTION. */
160 DECL_CHAIN (thunk
) = DECL_THUNKS (function
);
161 SET_DECL_THUNKS (function
, thunk
);
166 /* Finish THUNK, a thunk decl. */
169 finish_thunk (tree thunk
)
172 tree fixed_offset
= ssize_int (THUNK_FIXED_OFFSET (thunk
));
173 tree virtual_offset
= THUNK_VIRTUAL_OFFSET (thunk
);
175 gcc_assert (!DECL_NAME (thunk
) && DECL_THUNK_P (thunk
));
176 if (virtual_offset
&& DECL_RESULT_THUNK_P (thunk
))
177 virtual_offset
= BINFO_VPTR_FIELD (virtual_offset
);
178 function
= THUNK_TARGET (thunk
);
179 name
= mangle_thunk (function
, DECL_THIS_THUNK_P (thunk
),
180 fixed_offset
, virtual_offset
);
182 /* We can end up with declarations of (logically) different
183 covariant thunks, that do identical adjustments. The two thunks
184 will be adjusting between within different hierarchies, which
185 happen to have the same layout. We must nullify one of them to
186 refer to the other. */
187 if (DECL_RESULT_THUNK_P (thunk
))
191 for (cov_probe
= DECL_THUNKS (function
);
192 cov_probe
; cov_probe
= DECL_CHAIN (cov_probe
))
193 if (DECL_NAME (cov_probe
) == name
)
195 gcc_assert (!DECL_THUNKS (thunk
));
196 THUNK_ALIAS (thunk
) = (THUNK_ALIAS (cov_probe
)
197 ? THUNK_ALIAS (cov_probe
) : cov_probe
);
202 DECL_NAME (thunk
) = name
;
203 SET_DECL_ASSEMBLER_NAME (thunk
, name
);
206 static GTY (()) int thunk_labelno
;
208 /* Create a static alias to target. */
211 make_alias_for (tree target
, tree newid
)
213 tree alias
= build_decl (DECL_SOURCE_LOCATION (target
),
214 TREE_CODE (target
), newid
, TREE_TYPE (target
));
215 DECL_LANG_SPECIFIC (alias
) = DECL_LANG_SPECIFIC (target
);
216 cxx_dup_lang_specific_decl (alias
);
217 DECL_CONTEXT (alias
) = NULL
;
218 TREE_READONLY (alias
) = TREE_READONLY (target
);
219 TREE_THIS_VOLATILE (alias
) = TREE_THIS_VOLATILE (target
);
220 TREE_PUBLIC (alias
) = 0;
221 DECL_INTERFACE_KNOWN (alias
) = 1;
222 if (DECL_LANG_SPECIFIC (alias
))
224 DECL_NOT_REALLY_EXTERN (alias
) = 1;
225 DECL_USE_TEMPLATE (alias
) = 0;
226 DECL_TEMPLATE_INFO (alias
) = NULL
;
228 DECL_EXTERNAL (alias
) = 0;
229 DECL_ARTIFICIAL (alias
) = 1;
230 DECL_TEMPLATE_INSTANTIATED (alias
) = 0;
231 if (TREE_CODE (alias
) == FUNCTION_DECL
)
233 DECL_SAVED_FUNCTION_DATA (alias
) = NULL
;
234 DECL_DESTRUCTOR_P (alias
) = 0;
235 DECL_CONSTRUCTOR_P (alias
) = 0;
236 DECL_PENDING_INLINE_P (alias
) = 0;
237 DECL_DECLARED_INLINE_P (alias
) = 0;
238 DECL_INITIAL (alias
) = error_mark_node
;
239 DECL_ARGUMENTS (alias
) = copy_list (DECL_ARGUMENTS (target
));
242 TREE_STATIC (alias
) = 1;
243 TREE_ADDRESSABLE (alias
) = 1;
244 TREE_USED (alias
) = 1;
245 SET_DECL_ASSEMBLER_NAME (alias
, DECL_NAME (alias
));
250 make_alias_for_thunk (tree function
)
255 targetm
.asm_out
.generate_internal_label (buf
, "LTHUNK", thunk_labelno
);
258 alias
= make_alias_for (function
, get_identifier (buf
));
260 if (!flag_syntax_only
)
262 struct cgraph_node
*funcn
, *aliasn
;
263 funcn
= cgraph_get_node (function
);
264 gcc_checking_assert (funcn
);
265 aliasn
= cgraph_same_body_alias (funcn
, alias
, function
);
266 DECL_ASSEMBLER_NAME (function
);
267 gcc_assert (aliasn
!= NULL
);
273 /* Emit the definition of a C++ multiple inheritance or covariant
274 return vtable thunk. If EMIT_P is nonzero, the thunk is emitted
278 use_thunk (tree thunk_fndecl
, bool emit_p
)
280 tree a
, t
, function
, alias
;
282 HOST_WIDE_INT fixed_offset
, virtual_value
;
283 bool this_adjusting
= DECL_THIS_THUNK_P (thunk_fndecl
);
284 struct cgraph_node
*funcn
, *thunk_node
;
286 /* We should have called finish_thunk to give it a name. */
287 gcc_assert (DECL_NAME (thunk_fndecl
));
289 /* We should never be using an alias, always refer to the
291 gcc_assert (!THUNK_ALIAS (thunk_fndecl
));
293 if (TREE_ASM_WRITTEN (thunk_fndecl
))
296 function
= THUNK_TARGET (thunk_fndecl
);
297 if (DECL_RESULT (thunk_fndecl
))
298 /* We already turned this thunk into an ordinary function.
299 There's no need to process this thunk again. */
302 if (DECL_THUNK_P (function
))
303 /* The target is itself a thunk, process it now. */
304 use_thunk (function
, emit_p
);
306 /* Thunks are always addressable; they only appear in vtables. */
307 TREE_ADDRESSABLE (thunk_fndecl
) = 1;
309 /* Figure out what function is being thunked to. It's referenced in
310 this translation unit. */
311 TREE_ADDRESSABLE (function
) = 1;
312 mark_used (function
);
316 if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function
))
317 alias
= make_alias_for_thunk (function
);
321 fixed_offset
= THUNK_FIXED_OFFSET (thunk_fndecl
);
322 virtual_offset
= THUNK_VIRTUAL_OFFSET (thunk_fndecl
);
327 virtual_offset
= BINFO_VPTR_FIELD (virtual_offset
);
328 virtual_value
= tree_to_shwi (virtual_offset
);
329 gcc_assert (virtual_value
);
334 /* And, if we need to emit the thunk, it's used. */
335 mark_used (thunk_fndecl
);
336 /* This thunk is actually defined. */
337 DECL_EXTERNAL (thunk_fndecl
) = 0;
338 /* The linkage of the function may have changed. FIXME in linkage
340 gcc_assert (DECL_INTERFACE_KNOWN (function
));
341 TREE_PUBLIC (thunk_fndecl
) = TREE_PUBLIC (function
);
342 DECL_VISIBILITY (thunk_fndecl
) = DECL_VISIBILITY (function
);
343 DECL_VISIBILITY_SPECIFIED (thunk_fndecl
)
344 = DECL_VISIBILITY_SPECIFIED (function
);
345 DECL_COMDAT (thunk_fndecl
) = DECL_COMDAT (function
);
346 DECL_WEAK (thunk_fndecl
) = DECL_WEAK (function
);
348 if (flag_syntax_only
)
350 TREE_ASM_WRITTEN (thunk_fndecl
) = 1;
354 push_to_top_level ();
356 if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function
)
357 && targetm_common
.have_named_sections
)
359 resolve_unique_section (function
, 0, flag_function_sections
);
361 if (DECL_SECTION_NAME (function
) != NULL
&& DECL_ONE_ONLY (function
))
363 resolve_unique_section (thunk_fndecl
, 0, flag_function_sections
);
365 /* Output the thunk into the same section as function. */
366 DECL_SECTION_NAME (thunk_fndecl
) = DECL_SECTION_NAME (function
);
370 /* Set up cloned argument trees for the thunk. */
372 for (a
= DECL_ARGUMENTS (function
); a
; a
= DECL_CHAIN (a
))
374 tree x
= copy_node (a
);
376 DECL_CONTEXT (x
) = thunk_fndecl
;
377 SET_DECL_RTL (x
, NULL
);
378 DECL_HAS_VALUE_EXPR_P (x
) = 0;
379 TREE_ADDRESSABLE (x
) = 0;
383 DECL_ARGUMENTS (thunk_fndecl
) = a
;
384 TREE_ASM_WRITTEN (thunk_fndecl
) = 1;
385 funcn
= cgraph_get_node (function
);
386 gcc_checking_assert (funcn
);
387 thunk_node
= cgraph_add_thunk (funcn
, thunk_fndecl
, function
,
388 this_adjusting
, fixed_offset
, virtual_value
,
389 virtual_offset
, alias
);
390 if (DECL_ONE_ONLY (function
))
391 symtab_add_to_same_comdat_group (thunk_node
,
395 || !targetm
.asm_out
.can_output_mi_thunk (thunk_fndecl
, fixed_offset
,
396 virtual_value
, alias
))
398 /* If this is a covariant thunk, or we don't have the necessary
399 code for efficient thunks, generate a thunk function that
400 just makes a call to the real function. Unfortunately, this
401 doesn't work for varargs. */
403 if (varargs_function_p (function
))
404 error ("generic thunk code fails for method %q#D which uses %<...%>",
408 pop_from_top_level ();
411 /* Code for synthesizing methods which have default semantics defined. */
413 /* True iff CTYPE has a trivial SFK. */
416 type_has_trivial_fn (tree ctype
, special_function_kind sfk
)
420 case sfk_constructor
:
421 return !TYPE_HAS_COMPLEX_DFLT (ctype
);
422 case sfk_copy_constructor
:
423 return !TYPE_HAS_COMPLEX_COPY_CTOR (ctype
);
424 case sfk_move_constructor
:
425 return !TYPE_HAS_COMPLEX_MOVE_CTOR (ctype
);
426 case sfk_copy_assignment
:
427 return !TYPE_HAS_COMPLEX_COPY_ASSIGN (ctype
);
428 case sfk_move_assignment
:
429 return !TYPE_HAS_COMPLEX_MOVE_ASSIGN (ctype
);
431 return !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype
);
432 case sfk_inheriting_constructor
:
439 /* Note that CTYPE has a non-trivial SFK even though we previously thought
443 type_set_nontrivial_flag (tree ctype
, special_function_kind sfk
)
447 case sfk_constructor
:
448 TYPE_HAS_COMPLEX_DFLT (ctype
) = true;
450 case sfk_copy_constructor
:
451 TYPE_HAS_COMPLEX_COPY_CTOR (ctype
) = true;
453 case sfk_move_constructor
:
454 TYPE_HAS_COMPLEX_MOVE_CTOR (ctype
) = true;
456 case sfk_copy_assignment
:
457 TYPE_HAS_COMPLEX_COPY_ASSIGN (ctype
) = true;
459 case sfk_move_assignment
:
460 TYPE_HAS_COMPLEX_MOVE_ASSIGN (ctype
) = true;
463 TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype
) = true;
465 case sfk_inheriting_constructor
:
471 /* True iff FN is a trivial defaulted member function ([cd]tor, op=). */
474 trivial_fn_p (tree fn
)
476 if (!DECL_DEFAULTED_FN (fn
))
479 /* If fn is a clone, get the primary variant. */
480 if (tree prim
= DECL_CLONED_FUNCTION (fn
))
482 return type_has_trivial_fn (DECL_CONTEXT (fn
), special_function_p (fn
));
485 /* Subroutine of do_build_copy_constructor: Add a mem-initializer for BINFO
486 given the parameter or parameters PARM, possibly inherited constructor
487 base INH, or move flag MOVE_P. */
490 add_one_base_init (tree binfo
, tree parm
, bool move_p
, tree inh
,
491 tree member_init_list
)
496 /* An inheriting constructor only has a mem-initializer for
497 the base it inherits from. */
498 if (BINFO_TYPE (binfo
) != inh
)
499 return member_init_list
;
503 for (; parm
; parm
= DECL_CHAIN (parm
))
505 tree exp
= convert_from_reference (parm
);
506 if (TREE_CODE (TREE_TYPE (parm
)) != REFERENCE_TYPE
507 || TYPE_REF_IS_RVALUE (TREE_TYPE (parm
)))
509 *p
= build_tree_list (NULL_TREE
, exp
);
510 p
= &TREE_CHAIN (*p
);
515 init
= build_base_path (PLUS_EXPR
, parm
, binfo
, 1,
516 tf_warning_or_error
);
519 init
= build_tree_list (NULL_TREE
, init
);
521 return tree_cons (binfo
, init
, member_init_list
);
524 /* Generate code for default X(X&) or X(X&&) constructor or an inheriting
528 do_build_copy_constructor (tree fndecl
)
530 tree parm
= FUNCTION_FIRST_USER_PARM (fndecl
);
531 bool move_p
= DECL_MOVE_CONSTRUCTOR_P (fndecl
);
532 bool trivial
= trivial_fn_p (fndecl
);
533 tree inh
= DECL_INHERITED_CTOR_BASE (fndecl
);
536 parm
= convert_from_reference (parm
);
539 && is_empty_class (current_class_type
))
540 /* Don't copy the padding byte; it might not have been allocated
541 if *this is a base subobject. */;
544 tree t
= build2 (INIT_EXPR
, void_type_node
, current_class_ref
, parm
);
545 finish_expr_stmt (t
);
549 tree fields
= TYPE_FIELDS (current_class_type
);
550 tree member_init_list
= NULL_TREE
;
551 int cvquals
= cp_type_quals (TREE_TYPE (parm
));
553 tree binfo
, base_binfo
;
555 vec
<tree
, va_gc
> *vbases
;
557 /* Initialize all the base-classes with the parameter converted
558 to their type so that we get their copy constructor and not
559 another constructor that takes current_class_type. We must
560 deal with the binfo's directly as a direct base might be
561 inaccessible due to ambiguity. */
562 for (vbases
= CLASSTYPE_VBASECLASSES (current_class_type
), i
= 0;
563 vec_safe_iterate (vbases
, i
, &binfo
); i
++)
565 member_init_list
= add_one_base_init (binfo
, parm
, move_p
, inh
,
569 for (binfo
= TYPE_BINFO (current_class_type
), i
= 0;
570 BINFO_BASE_ITERATE (binfo
, i
, base_binfo
); i
++)
572 if (BINFO_VIRTUAL_P (base_binfo
))
574 member_init_list
= add_one_base_init (base_binfo
, parm
, move_p
,
575 inh
, member_init_list
);
578 for (; fields
; fields
= DECL_CHAIN (fields
))
583 if (TREE_CODE (field
) != FIELD_DECL
)
588 expr_type
= TREE_TYPE (field
);
589 if (DECL_NAME (field
))
591 if (VFIELD_NAME_P (DECL_NAME (field
)))
594 else if (ANON_AGGR_TYPE_P (expr_type
) && TYPE_FIELDS (expr_type
))
595 /* Just use the field; anonymous types can't have
596 nontrivial copy ctors or assignment ops or this
597 function would be deleted. */;
601 /* Compute the type of "init->field". If the copy-constructor
602 parameter is, for example, "const S&", and the type of
603 the field is "T", then the type will usually be "const
604 T". (There are no cv-qualified variants of reference
606 if (TREE_CODE (expr_type
) != REFERENCE_TYPE
)
610 if (DECL_MUTABLE_P (field
))
611 quals
&= ~TYPE_QUAL_CONST
;
612 quals
|= cp_type_quals (expr_type
);
613 expr_type
= cp_build_qualified_type (expr_type
, quals
);
616 init
= build3 (COMPONENT_REF
, expr_type
, parm
, field
, NULL_TREE
);
617 if (move_p
&& TREE_CODE (expr_type
) != REFERENCE_TYPE
618 /* 'move' breaks bit-fields, and has no effect for scalars. */
619 && !scalarish_type_p (expr_type
))
621 init
= build_tree_list (NULL_TREE
, init
);
623 member_init_list
= tree_cons (field
, init
, member_init_list
);
625 finish_mem_initializers (member_init_list
);
630 do_build_copy_assign (tree fndecl
)
632 tree parm
= DECL_CHAIN (DECL_ARGUMENTS (fndecl
));
634 bool move_p
= move_fn_p (fndecl
);
635 bool trivial
= trivial_fn_p (fndecl
);
636 int flags
= LOOKUP_NORMAL
| LOOKUP_NONVIRTUAL
| LOOKUP_DEFAULTED
;
638 compound_stmt
= begin_compound_stmt (0);
639 parm
= convert_from_reference (parm
);
642 && is_empty_class (current_class_type
))
643 /* Don't copy the padding byte; it might not have been allocated
644 if *this is a base subobject. */;
647 tree t
= build2 (MODIFY_EXPR
, void_type_node
, current_class_ref
, parm
);
648 finish_expr_stmt (t
);
653 int cvquals
= cp_type_quals (TREE_TYPE (parm
));
655 tree binfo
, base_binfo
;
657 /* Assign to each of the direct base classes. */
658 for (binfo
= TYPE_BINFO (current_class_type
), i
= 0;
659 BINFO_BASE_ITERATE (binfo
, i
, base_binfo
); i
++)
662 vec
<tree
, va_gc
> *parmvec
;
664 /* We must convert PARM directly to the base class
665 explicitly since the base class may be ambiguous. */
666 converted_parm
= build_base_path (PLUS_EXPR
, parm
, base_binfo
, 1,
667 tf_warning_or_error
);
669 converted_parm
= move (converted_parm
);
670 /* Call the base class assignment operator. */
671 parmvec
= make_tree_vector_single (converted_parm
);
673 (build_special_member_call (current_class_ref
,
674 ansi_assopname (NOP_EXPR
),
678 tf_warning_or_error
));
679 release_tree_vector (parmvec
);
682 /* Assign to each of the non-static data members. */
683 for (fields
= TYPE_FIELDS (current_class_type
);
685 fields
= DECL_CHAIN (fields
))
687 tree comp
= current_class_ref
;
693 if (TREE_CODE (field
) != FIELD_DECL
|| DECL_ARTIFICIAL (field
))
696 expr_type
= TREE_TYPE (field
);
698 if (CP_TYPE_CONST_P (expr_type
))
700 error ("non-static const member %q#D, can%'t use default "
701 "assignment operator", field
);
704 else if (TREE_CODE (expr_type
) == REFERENCE_TYPE
)
706 error ("non-static reference member %q#D, can%'t use "
707 "default assignment operator", field
);
711 if (DECL_NAME (field
))
713 if (VFIELD_NAME_P (DECL_NAME (field
)))
716 else if (ANON_AGGR_TYPE_P (expr_type
)
717 && TYPE_FIELDS (expr_type
) != NULL_TREE
)
718 /* Just use the field; anonymous types can't have
719 nontrivial copy ctors or assignment ops or this
720 function would be deleted. */;
724 comp
= build3 (COMPONENT_REF
, expr_type
, comp
, field
, NULL_TREE
);
726 /* Compute the type of init->field */
728 if (DECL_MUTABLE_P (field
))
729 quals
&= ~TYPE_QUAL_CONST
;
730 expr_type
= cp_build_qualified_type (expr_type
, quals
);
732 init
= build3 (COMPONENT_REF
, expr_type
, init
, field
, NULL_TREE
);
733 if (move_p
&& TREE_CODE (expr_type
) != REFERENCE_TYPE
734 /* 'move' breaks bit-fields, and has no effect for scalars. */
735 && !scalarish_type_p (expr_type
))
738 if (DECL_NAME (field
))
739 init
= cp_build_modify_expr (comp
, NOP_EXPR
, init
,
740 tf_warning_or_error
);
742 init
= build2 (MODIFY_EXPR
, TREE_TYPE (comp
), comp
, init
);
743 finish_expr_stmt (init
);
746 finish_return_stmt (current_class_ref
);
747 finish_compound_stmt (compound_stmt
);
750 /* Synthesize FNDECL, a non-static member function. */
753 synthesize_method (tree fndecl
)
755 bool nested
= (current_function_decl
!= NULL_TREE
);
756 tree context
= decl_function_context (fndecl
);
757 bool need_body
= true;
759 location_t save_input_location
= input_location
;
760 int error_count
= errorcount
;
761 int warning_count
= warningcount
+ werrorcount
;
763 /* Reset the source location, we might have been previously
764 deferred, and thus have saved where we were first needed. */
765 DECL_SOURCE_LOCATION (fndecl
)
766 = DECL_SOURCE_LOCATION (TYPE_NAME (DECL_CONTEXT (fndecl
)));
768 /* If we've been asked to synthesize a clone, just synthesize the
769 cloned function instead. Doing so will automatically fill in the
770 body for the clone. */
771 if (DECL_CLONED_FUNCTION_P (fndecl
))
772 fndecl
= DECL_CLONED_FUNCTION (fndecl
);
774 /* We may be in the middle of deferred access check. Disable
776 push_deferring_access_checks (dk_no_deferred
);
779 push_to_top_level ();
781 push_function_context ();
783 input_location
= DECL_SOURCE_LOCATION (fndecl
);
785 start_preparsed_function (fndecl
, NULL_TREE
, SF_DEFAULT
| SF_PRE_PARSED
);
786 stmt
= begin_function_body ();
788 if (DECL_OVERLOADED_OPERATOR_P (fndecl
) == NOP_EXPR
)
790 do_build_copy_assign (fndecl
);
793 else if (DECL_CONSTRUCTOR_P (fndecl
))
795 tree arg_chain
= FUNCTION_FIRST_USER_PARMTYPE (fndecl
);
796 if (arg_chain
!= void_list_node
)
797 do_build_copy_constructor (fndecl
);
799 finish_mem_initializers (NULL_TREE
);
802 /* If we haven't yet generated the body of the function, just
803 generate an empty compound statement. */
807 compound_stmt
= begin_compound_stmt (BCS_FN_BODY
);
808 finish_compound_stmt (compound_stmt
);
811 finish_function_body (stmt
);
812 expand_or_defer_fn (finish_function (0));
814 input_location
= save_input_location
;
817 pop_from_top_level ();
819 pop_function_context ();
821 pop_deferring_access_checks ();
823 if (error_count
!= errorcount
|| warning_count
!= warningcount
+ werrorcount
)
824 inform (input_location
, "synthesized method %qD first required here ",
828 /* Build a reference to type TYPE with cv-quals QUALS, which is an
829 rvalue if RVALUE is true. */
832 build_stub_type (tree type
, int quals
, bool rvalue
)
834 tree argtype
= cp_build_qualified_type (type
, quals
);
835 return cp_build_reference_type (argtype
, rvalue
);
838 /* Build a dummy glvalue from dereferencing a dummy reference of type
842 build_stub_object (tree reftype
)
844 tree stub
= build1 (NOP_EXPR
, reftype
, integer_one_node
);
845 return convert_from_reference (stub
);
848 /* Determine which function will be called when looking up NAME in TYPE,
849 called with a single ARGTYPE argument, or no argument if ARGTYPE is
850 null. FLAGS and COMPLAIN are as for build_new_method_call.
852 Returns a FUNCTION_DECL if all is well.
853 Returns NULL_TREE if overload resolution failed.
854 Returns error_mark_node if the chosen function cannot be called. */
857 locate_fn_flags (tree type
, tree name
, tree argtype
, int flags
,
858 tsubst_flags_t complain
)
860 tree ob
, fn
, fns
, binfo
, rval
;
861 vec
<tree
, va_gc
> *args
;
864 binfo
= TYPE_BINFO (type
);
868 type
= BINFO_TYPE (binfo
);
871 ob
= build_stub_object (cp_build_reference_type (type
, false));
872 args
= make_tree_vector ();
875 if (TREE_CODE (argtype
) == TREE_LIST
)
877 for (tree elt
= argtype
; elt
!= void_list_node
;
878 elt
= TREE_CHAIN (elt
))
880 tree type
= TREE_VALUE (elt
);
881 if (TREE_CODE (type
) != REFERENCE_TYPE
)
882 type
= cp_build_reference_type (type
, /*rval*/true);
883 tree arg
= build_stub_object (type
);
884 vec_safe_push (args
, arg
);
889 tree arg
= build_stub_object (argtype
);
890 args
->quick_push (arg
);
894 fns
= lookup_fnfields (binfo
, name
, 0);
895 rval
= build_new_method_call (ob
, fns
, &args
, binfo
, flags
, &fn
, complain
);
897 release_tree_vector (args
);
898 if (fn
&& rval
== error_mark_node
)
904 /* Locate the dtor of TYPE. */
907 get_dtor (tree type
, tsubst_flags_t complain
)
909 tree fn
= locate_fn_flags (type
, complete_dtor_identifier
, NULL_TREE
,
910 LOOKUP_NORMAL
, complain
);
911 if (fn
== error_mark_node
)
916 /* Locate the default ctor of TYPE. */
919 locate_ctor (tree type
)
923 push_deferring_access_checks (dk_no_check
);
924 fn
= locate_fn_flags (type
, complete_ctor_identifier
, NULL_TREE
,
925 LOOKUP_SPECULATIVE
, tf_none
);
926 pop_deferring_access_checks ();
927 if (fn
== error_mark_node
)
932 /* Likewise, but give any appropriate errors. */
935 get_default_ctor (tree type
)
937 tree fn
= locate_fn_flags (type
, complete_ctor_identifier
, NULL_TREE
,
938 LOOKUP_NORMAL
, tf_warning_or_error
);
939 if (fn
== error_mark_node
)
944 /* Locate the copy ctor of TYPE. */
947 get_copy_ctor (tree type
, tsubst_flags_t complain
)
949 int quals
= (TYPE_HAS_CONST_COPY_CTOR (type
)
950 ? TYPE_QUAL_CONST
: TYPE_UNQUALIFIED
);
951 tree argtype
= build_stub_type (type
, quals
, false);
952 tree fn
= locate_fn_flags (type
, complete_ctor_identifier
, argtype
,
953 LOOKUP_NORMAL
, complain
);
954 if (fn
== error_mark_node
)
959 /* Locate the copy assignment operator of TYPE. */
962 get_copy_assign (tree type
)
964 int quals
= (TYPE_HAS_CONST_COPY_ASSIGN (type
)
965 ? TYPE_QUAL_CONST
: TYPE_UNQUALIFIED
);
966 tree argtype
= build_stub_type (type
, quals
, false);
967 tree fn
= locate_fn_flags (type
, ansi_assopname (NOP_EXPR
), argtype
,
968 LOOKUP_NORMAL
, tf_warning_or_error
);
969 if (fn
== error_mark_node
)
974 /* Locate the inherited constructor of constructor CTOR. */
977 get_inherited_ctor (tree ctor
)
979 gcc_assert (DECL_INHERITED_CTOR_BASE (ctor
));
981 push_deferring_access_checks (dk_no_check
);
982 tree fn
= locate_fn_flags (DECL_INHERITED_CTOR_BASE (ctor
),
983 complete_ctor_identifier
,
984 FUNCTION_FIRST_USER_PARMTYPE (ctor
),
985 LOOKUP_NORMAL
|LOOKUP_SPECULATIVE
,
987 pop_deferring_access_checks ();
988 if (fn
== error_mark_node
)
993 /* Subroutine of synthesized_method_walk. Update SPEC_P, TRIVIAL_P and
994 DELETED_P or give an error message MSG with argument ARG. */
997 process_subob_fn (tree fn
, tree
*spec_p
, bool *trivial_p
,
998 bool *deleted_p
, bool *constexpr_p
,
1001 if (!fn
|| fn
== error_mark_node
)
1006 maybe_instantiate_noexcept (fn
);
1007 tree raises
= TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn
));
1008 *spec_p
= merge_exception_specifiers (*spec_p
, raises
);
1011 if (!trivial_fn_p (fn
))
1015 if (TREE_CODE (arg
) == FIELD_DECL
1016 && TREE_CODE (DECL_CONTEXT (arg
)) == UNION_TYPE
)
1021 error ("union member %q+D with non-trivial %qD", arg
, fn
);
1025 if (constexpr_p
&& !DECL_DECLARED_CONSTEXPR_P (fn
))
1027 *constexpr_p
= false;
1030 inform (0, "defaulted constructor calls non-constexpr "
1032 explain_invalid_constexpr_fn (fn
);
1043 /* Subroutine of synthesized_method_walk to allow recursion into anonymous
1047 walk_field_subobs (tree fields
, tree fnname
, special_function_kind sfk
,
1048 int quals
, bool copy_arg_p
, bool move_p
,
1049 bool assign_p
, tree
*spec_p
, bool *trivial_p
,
1050 bool *deleted_p
, bool *constexpr_p
,
1051 bool diag
, int flags
, tsubst_flags_t complain
)
1054 for (field
= fields
; field
; field
= DECL_CHAIN (field
))
1056 tree mem_type
, argtype
, rval
;
1058 if (TREE_CODE (field
) != FIELD_DECL
1059 || DECL_ARTIFICIAL (field
))
1062 mem_type
= strip_array_types (TREE_TYPE (field
));
1066 if (CP_TYPE_CONST_P (mem_type
) && !CLASS_TYPE_P (mem_type
))
1069 error ("non-static const member %q#D, can%'t use default "
1070 "assignment operator", field
);
1072 else if (TREE_CODE (mem_type
) == REFERENCE_TYPE
)
1075 error ("non-static reference member %q#D, can%'t use "
1076 "default assignment operator", field
);
1081 if (bad
&& deleted_p
)
1084 else if (sfk
== sfk_constructor
)
1088 if (DECL_INITIAL (field
))
1090 if (diag
&& DECL_INITIAL (field
) == error_mark_node
)
1091 inform (0, "initializer for %q+#D is invalid", field
);
1094 /* Core 1351: If the field has an NSDMI that could throw, the
1095 default constructor is noexcept(false). */
1098 tree nsdmi
= get_nsdmi (field
, /*ctor*/false);
1099 if (!expr_noexcept_p (nsdmi
, complain
))
1100 *spec_p
= noexcept_false_spec
;
1102 /* Don't do the normal processing. */
1107 if (CP_TYPE_CONST_P (mem_type
)
1108 && default_init_uninitialized_part (mem_type
))
1112 error ("uninitialized const member in %q#T",
1113 current_class_type
);
1114 inform (DECL_SOURCE_LOCATION (field
),
1115 "%q#D should be initialized", field
);
1119 else if (TREE_CODE (mem_type
) == REFERENCE_TYPE
)
1123 error ("uninitialized reference member in %q#T",
1124 current_class_type
);
1125 inform (DECL_SOURCE_LOCATION (field
),
1126 "%q#D should be initialized", field
);
1131 if (bad
&& deleted_p
)
1134 /* For an implicitly-defined default constructor to be constexpr,
1135 every member must have a user-provided default constructor or
1136 an explicit initializer. */
1137 if (constexpr_p
&& !CLASS_TYPE_P (mem_type
)
1138 && TREE_CODE (DECL_CONTEXT (field
)) != UNION_TYPE
)
1140 *constexpr_p
= false;
1142 inform (0, "defaulted default constructor does not "
1143 "initialize %q+#D", field
);
1146 else if (sfk
== sfk_copy_constructor
)
1149 if (TREE_CODE (mem_type
) == REFERENCE_TYPE
1150 && TYPE_REF_IS_RVALUE (mem_type
))
1153 error ("copying non-static data member %q#D of rvalue "
1154 "reference type", field
);
1160 if (!CLASS_TYPE_P (mem_type
))
1163 if (ANON_AGGR_TYPE_P (mem_type
))
1165 walk_field_subobs (TYPE_FIELDS (mem_type
), fnname
, sfk
, quals
,
1166 copy_arg_p
, move_p
, assign_p
, spec_p
, trivial_p
,
1167 deleted_p
, constexpr_p
,
1168 diag
, flags
, complain
);
1174 int mem_quals
= cp_type_quals (mem_type
) | quals
;
1175 if (DECL_MUTABLE_P (field
))
1176 mem_quals
&= ~TYPE_QUAL_CONST
;
1177 argtype
= build_stub_type (mem_type
, mem_quals
, move_p
);
1180 argtype
= NULL_TREE
;
1182 rval
= locate_fn_flags (mem_type
, fnname
, argtype
, flags
, complain
);
1184 process_subob_fn (rval
, spec_p
, trivial_p
, deleted_p
,
1185 constexpr_p
, diag
, field
);
1189 /* The caller wants to generate an implicit declaration of SFK for CTYPE
1190 which is const if relevant and CONST_P is set. If spec_p, trivial_p and
1191 deleted_p are non-null, set their referent appropriately. If diag is
1192 true, we're either being called from maybe_explain_implicit_delete to
1193 give errors, or if constexpr_p is non-null, from
1194 explain_invalid_constexpr_fn. */
1197 synthesized_method_walk (tree ctype
, special_function_kind sfk
, bool const_p
,
1198 tree
*spec_p
, bool *trivial_p
, bool *deleted_p
,
1199 bool *constexpr_p
, bool diag
,
1200 tree inherited_base
, tree inherited_parms
)
1202 tree binfo
, base_binfo
, scope
, fnname
, rval
, argtype
;
1203 bool move_p
, copy_arg_p
, assign_p
, expected_trivial
, check_vdtor
;
1204 vec
<tree
, va_gc
> *vbases
;
1205 int i
, quals
, flags
;
1206 tsubst_flags_t complain
;
1210 *spec_p
= (cxx_dialect
>= cxx11
? noexcept_true_spec
: empty_except_spec
);
1214 /* "The closure type associated with a lambda-expression has a deleted
1215 default constructor and a deleted copy assignment operator."
1216 This is diagnosed in maybe_explain_implicit_delete. */
1217 if (LAMBDA_TYPE_P (ctype
)
1218 && (sfk
== sfk_constructor
1219 || sfk
== sfk_copy_assignment
))
1230 check_vdtor
= false;
1233 case sfk_move_assignment
:
1234 case sfk_copy_assignment
:
1236 fnname
= ansi_assopname (NOP_EXPR
);
1239 case sfk_destructor
:
1241 /* The synthesized method will call base dtors, but check complete
1242 here to avoid having to deal with VTT. */
1243 fnname
= complete_dtor_identifier
;
1246 case sfk_constructor
:
1247 case sfk_move_constructor
:
1248 case sfk_copy_constructor
:
1249 case sfk_inheriting_constructor
:
1251 fnname
= complete_ctor_identifier
;
1258 gcc_assert ((sfk
== sfk_inheriting_constructor
)
1259 == (inherited_base
!= NULL_TREE
));
1261 /* If that user-written default constructor would satisfy the
1262 requirements of a constexpr constructor (7.1.5), the
1263 implicitly-defined default constructor is constexpr. */
1265 *constexpr_p
= ctor_p
;
1270 case sfk_constructor
:
1271 case sfk_destructor
:
1272 case sfk_inheriting_constructor
:
1276 case sfk_move_constructor
:
1277 case sfk_move_assignment
:
1279 case sfk_copy_constructor
:
1280 case sfk_copy_assignment
:
1288 expected_trivial
= type_has_trivial_fn (ctype
, sfk
);
1290 *trivial_p
= expected_trivial
;
1292 /* The TYPE_HAS_COMPLEX_* flags tell us about constraints from base
1293 class versions and other properties of the type. But a subobject
1294 class can be trivially copyable and yet have overload resolution
1295 choose a template constructor for initialization, depending on
1296 rvalueness and cv-quals. And furthermore, a member in a base might
1297 be trivial but deleted or otherwise not callable. So we can't exit
1298 early in C++0x. The same considerations apply in C++98/03, but
1299 there the definition of triviality does not consider overload
1300 resolution, so a constructor can be trivial even if it would otherwise
1301 call a non-trivial constructor. */
1302 if (expected_trivial
1303 && (!copy_arg_p
|| cxx_dialect
< cxx11
))
1305 if (constexpr_p
&& sfk
== sfk_constructor
)
1307 bool cx
= trivial_default_constructor_is_constexpr (ctype
);
1309 if (diag
&& !cx
&& TREE_CODE (ctype
) == UNION_TYPE
)
1310 /* A trivial constructor doesn't have any NSDMI. */
1311 inform (input_location
, "defaulted default constructor does "
1312 "not initialize any non-static data member");
1314 if (!diag
&& cxx_dialect
< cxx11
)
1318 ++cp_unevaluated_operand
;
1319 ++c_inhibit_evaluation_warnings
;
1320 push_deferring_access_checks (dk_no_deferred
);
1322 scope
= push_scope (ctype
);
1324 flags
= LOOKUP_NORMAL
|LOOKUP_SPECULATIVE
;
1325 if (!inherited_base
)
1326 flags
|= LOOKUP_DEFAULTED
;
1328 complain
= diag
? tf_warning_or_error
: tf_none
;
1331 quals
= TYPE_QUAL_CONST
;
1333 quals
= TYPE_UNQUALIFIED
;
1334 argtype
= NULL_TREE
;
1336 for (binfo
= TYPE_BINFO (ctype
), i
= 0;
1337 BINFO_BASE_ITERATE (binfo
, i
, base_binfo
); ++i
)
1339 tree basetype
= BINFO_TYPE (base_binfo
);
1341 if (!assign_p
&& BINFO_VIRTUAL_P (base_binfo
))
1342 /* We'll handle virtual bases below. */
1346 argtype
= build_stub_type (basetype
, quals
, move_p
);
1347 else if (basetype
== inherited_base
)
1348 argtype
= inherited_parms
;
1349 rval
= locate_fn_flags (base_binfo
, fnname
, argtype
, flags
, complain
);
1351 argtype
= NULL_TREE
;
1353 process_subob_fn (rval
, spec_p
, trivial_p
, deleted_p
,
1354 constexpr_p
, diag
, basetype
);
1357 /* In a constructor we also need to check the subobject
1358 destructors for cleanup of partially constructed objects. */
1359 rval
= locate_fn_flags (base_binfo
, complete_dtor_identifier
,
1360 NULL_TREE
, flags
, complain
);
1361 /* Note that we don't pass down trivial_p; the subobject
1362 destructors don't affect triviality of the constructor. Nor
1363 do they affect constexpr-ness (a constant expression doesn't
1364 throw) or exception-specification (a throw from one of the
1365 dtors would be a double-fault). */
1366 process_subob_fn (rval
, NULL
, NULL
,
1367 deleted_p
, NULL
, false,
1371 if (check_vdtor
&& type_has_virtual_destructor (basetype
))
1373 rval
= locate_fn_flags (ctype
, ansi_opname (DELETE_EXPR
),
1374 ptr_type_node
, flags
, complain
);
1375 /* Unlike for base ctor/op=/dtor, for operator delete it's fine
1376 to have a null rval (no class-specific op delete). */
1377 if (rval
&& rval
== error_mark_node
&& deleted_p
)
1379 check_vdtor
= false;
1382 if (diag
&& assign_p
&& move_p
1383 && BINFO_VIRTUAL_P (base_binfo
)
1384 && rval
&& TREE_CODE (rval
) == FUNCTION_DECL
1385 && move_fn_p (rval
) && !trivial_fn_p (rval
)
1386 && vbase_has_user_provided_move_assign (basetype
))
1387 warning (OPT_Wvirtual_move_assign
,
1388 "defaulted move assignment for %qT calls a non-trivial "
1389 "move assignment operator for virtual base %qT",
1393 vbases
= CLASSTYPE_VBASECLASSES (ctype
);
1394 if (vec_safe_is_empty (vbases
))
1395 /* No virtual bases to worry about. */;
1399 *constexpr_p
= false;
1400 FOR_EACH_VEC_ELT (*vbases
, i
, base_binfo
)
1402 tree basetype
= BINFO_TYPE (base_binfo
);
1404 argtype
= build_stub_type (basetype
, quals
, move_p
);
1405 rval
= locate_fn_flags (base_binfo
, fnname
, argtype
, flags
, complain
);
1407 process_subob_fn (rval
, spec_p
, trivial_p
, deleted_p
,
1408 constexpr_p
, diag
, basetype
);
1409 if (ctor_p
&& TYPE_HAS_NONTRIVIAL_DESTRUCTOR (basetype
))
1411 rval
= locate_fn_flags (base_binfo
, complete_dtor_identifier
,
1412 NULL_TREE
, flags
, complain
);
1413 process_subob_fn (rval
, NULL
, NULL
,
1414 deleted_p
, NULL
, false,
1420 /* Now handle the non-static data members. */
1421 walk_field_subobs (TYPE_FIELDS (ctype
), fnname
, sfk
, quals
,
1422 copy_arg_p
, move_p
, assign_p
, spec_p
, trivial_p
,
1423 deleted_p
, constexpr_p
,
1424 diag
, flags
, complain
);
1426 walk_field_subobs (TYPE_FIELDS (ctype
), complete_dtor_identifier
,
1427 sfk_destructor
, TYPE_UNQUALIFIED
, false,
1428 false, false, NULL
, NULL
,
1430 false, flags
, complain
);
1434 pop_deferring_access_checks ();
1435 --cp_unevaluated_operand
;
1436 --c_inhibit_evaluation_warnings
;
1439 /* DECL is a defaulted function whose exception specification is now
1440 needed. Return what it should be. */
1443 get_defaulted_eh_spec (tree decl
)
1445 if (DECL_CLONED_FUNCTION_P (decl
))
1446 decl
= DECL_CLONED_FUNCTION (decl
);
1447 special_function_kind sfk
= special_function_p (decl
);
1448 tree ctype
= DECL_CONTEXT (decl
);
1449 tree parms
= FUNCTION_FIRST_USER_PARMTYPE (decl
);
1450 tree parm_type
= TREE_VALUE (parms
);
1451 bool const_p
= CP_TYPE_CONST_P (non_reference (parm_type
));
1452 tree spec
= empty_except_spec
;
1453 synthesized_method_walk (ctype
, sfk
, const_p
, &spec
, NULL
, NULL
,
1454 NULL
, false, DECL_INHERITED_CTOR_BASE (decl
),
1459 /* DECL is a deleted function. If it's implicitly deleted, explain why and
1460 return true; else return false. */
1463 maybe_explain_implicit_delete (tree decl
)
1465 /* If decl is a clone, get the primary variant. */
1466 decl
= DECL_ORIGIN (decl
);
1467 gcc_assert (DECL_DELETED_FN (decl
));
1468 if (DECL_DEFAULTED_FN (decl
))
1470 /* Not marked GTY; it doesn't need to be GC'd or written to PCH. */
1471 static struct pointer_set_t
*explained
;
1473 special_function_kind sfk
;
1479 explained
= pointer_set_create ();
1480 if (pointer_set_insert (explained
, decl
))
1483 sfk
= special_function_p (decl
);
1484 ctype
= DECL_CONTEXT (decl
);
1485 loc
= input_location
;
1486 input_location
= DECL_SOURCE_LOCATION (decl
);
1489 if (LAMBDA_TYPE_P (ctype
))
1492 if (sfk
== sfk_constructor
)
1493 inform (DECL_SOURCE_LOCATION (decl
),
1494 "a lambda closure type has a deleted default constructor");
1495 else if (sfk
== sfk_copy_assignment
)
1496 inform (DECL_SOURCE_LOCATION (decl
),
1497 "a lambda closure type has a deleted copy assignment operator");
1501 else if (DECL_ARTIFICIAL (decl
)
1502 && (sfk
== sfk_copy_assignment
1503 || sfk
== sfk_copy_constructor
)
1504 && (type_has_user_declared_move_constructor (ctype
)
1505 || type_has_user_declared_move_assign (ctype
)))
1507 inform (0, "%q+#D is implicitly declared as deleted because %qT "
1508 "declares a move constructor or move assignment operator",
1514 tree parms
= FUNCTION_FIRST_USER_PARMTYPE (decl
);
1515 tree parm_type
= TREE_VALUE (parms
);
1516 bool const_p
= CP_TYPE_CONST_P (non_reference (parm_type
));
1517 tree raises
= NULL_TREE
;
1518 bool deleted_p
= false;
1519 tree scope
= push_scope (ctype
);
1521 synthesized_method_walk (ctype
, sfk
, const_p
,
1522 &raises
, NULL
, &deleted_p
, NULL
, false,
1523 DECL_INHERITED_CTOR_BASE (decl
), parms
);
1526 inform (0, "%q+#D is implicitly deleted because the default "
1527 "definition would be ill-formed:", decl
);
1528 synthesized_method_walk (ctype
, sfk
, const_p
,
1529 NULL
, NULL
, NULL
, NULL
, true,
1530 DECL_INHERITED_CTOR_BASE (decl
), parms
);
1532 else if (!comp_except_specs
1533 (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl
)),
1535 inform (DECL_SOURCE_LOCATION (decl
), "%q#F is implicitly "
1536 "deleted because its exception-specification does not "
1537 "match the implicit exception-specification %qX",
1539 #ifdef ENABLE_CHECKING
1547 input_location
= loc
;
1553 /* DECL is a defaulted function which was declared constexpr. Explain why
1554 it can't be constexpr. */
1557 explain_implicit_non_constexpr (tree decl
)
1559 tree parm_type
= TREE_VALUE (FUNCTION_FIRST_USER_PARMTYPE (decl
));
1560 bool const_p
= CP_TYPE_CONST_P (non_reference (parm_type
));
1562 synthesized_method_walk (DECL_CLASS_CONTEXT (decl
),
1563 special_function_p (decl
), const_p
,
1564 NULL
, NULL
, NULL
, &dummy
, true,
1565 NULL_TREE
, NULL_TREE
);
1568 /* DECL is an instantiation of an inheriting constructor template. Deduce
1569 the correct exception-specification and deletedness for this particular
1573 deduce_inheriting_ctor (tree decl
)
1575 gcc_assert (DECL_INHERITED_CTOR_BASE (decl
));
1577 bool trivial
, constexpr_
, deleted
;
1578 synthesized_method_walk (DECL_CONTEXT (decl
), sfk_inheriting_constructor
,
1579 false, &spec
, &trivial
, &deleted
, &constexpr_
,
1581 DECL_INHERITED_CTOR_BASE (decl
),
1582 FUNCTION_FIRST_USER_PARMTYPE (decl
));
1583 DECL_DELETED_FN (decl
) = deleted
;
1584 TREE_TYPE (decl
) = build_exception_variant (TREE_TYPE (decl
), spec
);
1587 /* Implicitly declare the special function indicated by KIND, as a
1588 member of TYPE. For copy constructors and assignment operators,
1589 CONST_P indicates whether these functions should take a const
1590 reference argument or a non-const reference. Returns the
1591 FUNCTION_DECL for the implicitly declared function. */
1594 implicitly_declare_fn (special_function_kind kind
, tree type
,
1595 bool const_p
, tree inherited_ctor
,
1596 tree inherited_parms
)
1599 tree parameter_types
= void_list_node
;
1602 tree raises
= empty_except_spec
;
1603 tree rhs_parm_type
= NULL_TREE
;
1606 HOST_WIDE_INT saved_processing_template_decl
;
1610 /* Because we create declarations for implicitly declared functions
1611 lazily, we may be creating the declaration for a member of TYPE
1612 while in some completely different context. However, TYPE will
1613 never be a dependent class (because we never want to do lookups
1614 for implicitly defined functions in a dependent class).
1615 Furthermore, we must set PROCESSING_TEMPLATE_DECL to zero here
1616 because we only create clones for constructors and destructors
1617 when not in a template. */
1618 gcc_assert (!dependent_type_p (type
));
1619 saved_processing_template_decl
= processing_template_decl
;
1620 processing_template_decl
= 0;
1622 type
= TYPE_MAIN_VARIANT (type
);
1624 if (targetm
.cxx
.cdtor_returns_this () && !TYPE_FOR_JAVA (type
))
1626 if (kind
== sfk_destructor
)
1627 /* See comment in check_special_function_return_type. */
1628 return_type
= build_pointer_type (void_type_node
);
1630 return_type
= build_pointer_type (type
);
1633 return_type
= void_type_node
;
1637 case sfk_destructor
:
1639 name
= constructor_name (type
);
1642 case sfk_constructor
:
1643 /* Default constructor. */
1644 name
= constructor_name (type
);
1647 case sfk_copy_constructor
:
1648 case sfk_copy_assignment
:
1649 case sfk_move_constructor
:
1650 case sfk_move_assignment
:
1651 case sfk_inheriting_constructor
:
1654 if (kind
== sfk_copy_assignment
1655 || kind
== sfk_move_assignment
)
1657 return_type
= build_reference_type (type
);
1658 name
= ansi_assopname (NOP_EXPR
);
1661 name
= constructor_name (type
);
1663 if (kind
== sfk_inheriting_constructor
)
1664 parameter_types
= inherited_parms
;
1668 rhs_parm_type
= cp_build_qualified_type (type
, TYPE_QUAL_CONST
);
1670 rhs_parm_type
= type
;
1671 move_p
= (kind
== sfk_move_assignment
1672 || kind
== sfk_move_constructor
);
1673 rhs_parm_type
= cp_build_reference_type (rhs_parm_type
, move_p
);
1675 parameter_types
= tree_cons (NULL_TREE
, rhs_parm_type
, parameter_types
);
1683 tree inherited_base
= (inherited_ctor
1684 ? DECL_CONTEXT (inherited_ctor
)
1686 bool trivial_p
= false;
1688 if (inherited_ctor
&& TREE_CODE (inherited_ctor
) == TEMPLATE_DECL
)
1690 /* For an inheriting constructor template, just copy these flags from
1691 the inherited constructor template for now. */
1692 raises
= TYPE_RAISES_EXCEPTIONS (TREE_TYPE (inherited_ctor
));
1693 deleted_p
= DECL_DELETED_FN (inherited_ctor
);
1694 constexpr_p
= DECL_DECLARED_CONSTEXPR_P (inherited_ctor
);
1696 else if (cxx_dialect
>= cxx11
)
1698 raises
= unevaluated_noexcept_spec ();
1699 synthesized_method_walk (type
, kind
, const_p
, NULL
, &trivial_p
,
1700 &deleted_p
, &constexpr_p
, false,
1701 inherited_base
, inherited_parms
);
1704 synthesized_method_walk (type
, kind
, const_p
, &raises
, &trivial_p
,
1705 &deleted_p
, &constexpr_p
, false,
1706 inherited_base
, inherited_parms
);
1707 /* Don't bother marking a deleted constructor as constexpr. */
1709 constexpr_p
= false;
1710 /* A trivial copy/move constructor is also a constexpr constructor,
1711 unless the class has virtual bases (7.1.5p4). */
1712 else if (trivial_p
&& cxx_dialect
>= cxx11
1713 && (kind
== sfk_copy_constructor
1714 || kind
== sfk_move_constructor
)
1715 && !CLASSTYPE_VBASECLASSES (type
))
1716 gcc_assert (constexpr_p
);
1718 if (!trivial_p
&& type_has_trivial_fn (type
, kind
))
1719 type_set_nontrivial_flag (type
, kind
);
1721 /* Create the function. */
1722 fn_type
= build_method_type_directly (type
, return_type
, parameter_types
);
1724 fn_type
= build_exception_variant (fn_type
, raises
);
1725 fn
= build_lang_decl (FUNCTION_DECL
, name
, fn_type
);
1726 if (kind
!= sfk_inheriting_constructor
)
1727 DECL_SOURCE_LOCATION (fn
) = DECL_SOURCE_LOCATION (TYPE_NAME (type
));
1728 if (kind
== sfk_constructor
|| kind
== sfk_copy_constructor
1729 || kind
== sfk_move_constructor
|| kind
== sfk_inheriting_constructor
)
1730 DECL_CONSTRUCTOR_P (fn
) = 1;
1731 else if (kind
== sfk_destructor
)
1732 DECL_DESTRUCTOR_P (fn
) = 1;
1735 DECL_ASSIGNMENT_OPERATOR_P (fn
) = 1;
1736 SET_OVERLOADED_OPERATOR_CODE (fn
, NOP_EXPR
);
1739 /* If pointers to member functions use the least significant bit to
1740 indicate whether a function is virtual, ensure a pointer
1741 to this function will have that bit clear. */
1742 if (TARGET_PTRMEMFUNC_VBIT_LOCATION
== ptrmemfunc_vbit_in_pfn
1743 && DECL_ALIGN (fn
) < 2 * BITS_PER_UNIT
)
1744 DECL_ALIGN (fn
) = 2 * BITS_PER_UNIT
;
1746 /* Create the explicit arguments. */
1749 /* Note that this parameter is *not* marked DECL_ARTIFICIAL; we
1750 want its type to be included in the mangled function
1752 tree decl
= cp_build_parm_decl (NULL_TREE
, rhs_parm_type
);
1753 TREE_READONLY (decl
) = 1;
1754 retrofit_lang_decl (decl
);
1755 DECL_PARM_INDEX (decl
) = DECL_PARM_LEVEL (decl
) = 1;
1756 DECL_ARGUMENTS (fn
) = decl
;
1758 else if (kind
== sfk_inheriting_constructor
)
1760 tree
*p
= &DECL_ARGUMENTS (fn
);
1762 for (tree parm
= inherited_parms
; parm
!= void_list_node
;
1763 parm
= TREE_CHAIN (parm
))
1765 *p
= cp_build_parm_decl (NULL_TREE
, TREE_VALUE (parm
));
1766 retrofit_lang_decl (*p
);
1767 DECL_PARM_LEVEL (*p
) = 1;
1768 DECL_PARM_INDEX (*p
) = index
++;
1769 DECL_CONTEXT (*p
) = fn
;
1770 p
= &DECL_CHAIN (*p
);
1772 SET_DECL_INHERITED_CTOR_BASE (fn
, inherited_base
);
1773 DECL_NONCONVERTING_P (fn
) = DECL_NONCONVERTING_P (inherited_ctor
);
1774 /* A constructor so declared has the same access as the corresponding
1775 constructor in X. */
1776 TREE_PRIVATE (fn
) = TREE_PRIVATE (inherited_ctor
);
1777 TREE_PROTECTED (fn
) = TREE_PROTECTED (inherited_ctor
);
1778 /* Copy constexpr from the inherited constructor even if the
1779 inheriting constructor doesn't satisfy the requirements. */
1780 constexpr_p
= DECL_DECLARED_CONSTEXPR_P (inherited_ctor
);
1782 /* Add the "this" parameter. */
1783 this_parm
= build_this_parm (fn_type
, TYPE_UNQUALIFIED
);
1784 DECL_CHAIN (this_parm
) = DECL_ARGUMENTS (fn
);
1785 DECL_ARGUMENTS (fn
) = this_parm
;
1787 grokclassfn (type
, fn
, kind
== sfk_destructor
? DTOR_FLAG
: NO_SPECIAL
);
1788 set_linkage_according_to_type (type
, fn
);
1789 rest_of_decl_compilation (fn
, toplevel_bindings_p (), at_eof
);
1790 DECL_IN_AGGR_P (fn
) = 1;
1791 DECL_ARTIFICIAL (fn
) = 1;
1792 DECL_DEFAULTED_FN (fn
) = 1;
1793 if (cxx_dialect
>= cxx11
)
1795 DECL_DELETED_FN (fn
) = deleted_p
;
1796 DECL_DECLARED_CONSTEXPR_P (fn
) = constexpr_p
;
1798 DECL_EXTERNAL (fn
) = true;
1799 DECL_NOT_REALLY_EXTERN (fn
) = 1;
1800 DECL_DECLARED_INLINE_P (fn
) = 1;
1801 gcc_assert (!TREE_USED (fn
));
1803 /* Restore PROCESSING_TEMPLATE_DECL. */
1804 processing_template_decl
= saved_processing_template_decl
;
1806 if (inherited_ctor
&& TREE_CODE (inherited_ctor
) == TEMPLATE_DECL
)
1807 fn
= add_inherited_template_parms (fn
, inherited_ctor
);
1809 /* Warn about calling a non-trivial move assignment in a virtual base. */
1810 if (kind
== sfk_move_assignment
&& !deleted_p
&& !trivial_p
1811 && CLASSTYPE_VBASECLASSES (type
))
1813 location_t loc
= input_location
;
1814 input_location
= DECL_SOURCE_LOCATION (fn
);
1815 synthesized_method_walk (type
, kind
, const_p
,
1816 NULL
, NULL
, NULL
, NULL
, true,
1817 NULL_TREE
, NULL_TREE
);
1818 input_location
= loc
;
1824 /* Gives any errors about defaulted functions which need to be deferred
1825 until the containing class is complete. */
1828 defaulted_late_check (tree fn
)
1830 /* Complain about invalid signature for defaulted fn. */
1831 tree ctx
= DECL_CONTEXT (fn
);
1832 special_function_kind kind
= special_function_p (fn
);
1833 bool fn_const_p
= (copy_fn_p (fn
) == 2);
1834 tree implicit_fn
= implicitly_declare_fn (kind
, ctx
, fn_const_p
,
1836 tree eh_spec
= TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn
));
1838 if (!same_type_p (TREE_TYPE (TREE_TYPE (fn
)),
1839 TREE_TYPE (TREE_TYPE (implicit_fn
)))
1840 || !compparms (TYPE_ARG_TYPES (TREE_TYPE (fn
)),
1841 TYPE_ARG_TYPES (TREE_TYPE (implicit_fn
))))
1843 error ("defaulted declaration %q+D", fn
);
1844 error_at (DECL_SOURCE_LOCATION (fn
),
1845 "does not match expected signature %qD", implicit_fn
);
1848 /* 8.4.2/2: An explicitly-defaulted function (...) may have an explicit
1849 exception-specification only if it is compatible (15.4) with the
1850 exception-specification on the implicit declaration. If a function
1851 is explicitly defaulted on its first declaration, (...) it is
1852 implicitly considered to have the same exception-specification as if
1853 it had been implicitly declared. */
1854 tree fn_spec
= TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn
));
1857 if (DECL_DEFAULTED_IN_CLASS_P (fn
))
1858 TREE_TYPE (fn
) = build_exception_variant (TREE_TYPE (fn
), eh_spec
);
1860 else if (UNEVALUATED_NOEXCEPT_SPEC_P (fn_spec
))
1861 /* Equivalent to the implicit spec. */;
1862 else if (DECL_DEFAULTED_IN_CLASS_P (fn
)
1863 && !CLASSTYPE_TEMPLATE_INSTANTIATION (ctx
))
1864 /* We can't compare an explicit exception-specification on a
1865 constructor defaulted in the class body to the implicit
1866 exception-specification until after we've parsed any NSDMI; see
1867 after_nsdmi_defaulted_late_checks. */;
1870 tree eh_spec
= get_defaulted_eh_spec (fn
);
1871 if (!comp_except_specs (fn_spec
, eh_spec
, ce_normal
))
1873 if (DECL_DEFAULTED_IN_CLASS_P (fn
))
1874 DECL_DELETED_FN (fn
) = true;
1876 error ("function %q+D defaulted on its redeclaration "
1877 "with an exception-specification that differs from "
1878 "the implicit exception-specification %qX", fn
, eh_spec
);
1882 if (DECL_DEFAULTED_IN_CLASS_P (fn
)
1883 && DECL_DECLARED_CONSTEXPR_P (implicit_fn
))
1885 /* Hmm...should we do this for out-of-class too? Should it be OK to
1886 add constexpr later like inline, rather than requiring
1887 declarations to match? */
1888 DECL_DECLARED_CONSTEXPR_P (fn
) = true;
1889 if (kind
== sfk_constructor
)
1890 TYPE_HAS_CONSTEXPR_CTOR (ctx
) = true;
1893 if (!DECL_DECLARED_CONSTEXPR_P (implicit_fn
)
1894 && DECL_DECLARED_CONSTEXPR_P (fn
))
1896 if (!CLASSTYPE_TEMPLATE_INSTANTIATION (ctx
))
1898 error ("explicitly defaulted function %q+D cannot be declared "
1899 "as constexpr because the implicit declaration is not "
1901 explain_implicit_non_constexpr (fn
);
1903 DECL_DECLARED_CONSTEXPR_P (fn
) = false;
1906 if (DECL_DELETED_FN (implicit_fn
))
1907 DECL_DELETED_FN (fn
) = 1;
1910 /* OK, we've parsed the NSDMI for class T, now we can check any explicit
1911 exception-specifications on functions defaulted in the class body. */
1914 after_nsdmi_defaulted_late_checks (tree t
)
1916 if (uses_template_parms (t
))
1918 if (t
== error_mark_node
)
1920 for (tree fn
= TYPE_METHODS (t
); fn
; fn
= DECL_CHAIN (fn
))
1921 if (!DECL_ARTIFICIAL (fn
) && DECL_DEFAULTED_IN_CLASS_P (fn
))
1923 tree fn_spec
= TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn
));
1924 if (UNEVALUATED_NOEXCEPT_SPEC_P (fn_spec
))
1927 tree eh_spec
= get_defaulted_eh_spec (fn
);
1928 if (!comp_except_specs (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn
)),
1929 eh_spec
, ce_normal
))
1930 DECL_DELETED_FN (fn
) = true;
1934 /* Returns true iff FN can be explicitly defaulted, and gives any
1935 errors if defaulting FN is ill-formed. */
1938 defaultable_fn_check (tree fn
)
1940 special_function_kind kind
= sfk_none
;
1942 if (template_parm_scope_p ())
1944 error ("a template cannot be defaulted");
1948 if (DECL_CONSTRUCTOR_P (fn
))
1950 if (FUNCTION_FIRST_USER_PARMTYPE (fn
) == void_list_node
)
1951 kind
= sfk_constructor
;
1952 else if (copy_fn_p (fn
) > 0
1953 && (TREE_CHAIN (FUNCTION_FIRST_USER_PARMTYPE (fn
))
1955 kind
= sfk_copy_constructor
;
1956 else if (move_fn_p (fn
))
1957 kind
= sfk_move_constructor
;
1959 else if (DECL_DESTRUCTOR_P (fn
))
1960 kind
= sfk_destructor
;
1961 else if (DECL_ASSIGNMENT_OPERATOR_P (fn
)
1962 && DECL_OVERLOADED_OPERATOR_P (fn
) == NOP_EXPR
)
1965 kind
= sfk_copy_assignment
;
1966 else if (move_fn_p (fn
))
1967 kind
= sfk_move_assignment
;
1970 if (kind
== sfk_none
)
1972 error ("%qD cannot be defaulted", fn
);
1977 for (tree t
= FUNCTION_FIRST_USER_PARMTYPE (fn
);
1978 t
&& t
!= void_list_node
; t
= TREE_CHAIN (t
))
1979 if (TREE_PURPOSE (t
))
1981 error ("defaulted function %q+D with default argument", fn
);
1985 /* Avoid do_warn_unused_parameter warnings. */
1986 for (tree p
= FUNCTION_FIRST_USER_PARM (fn
); p
; p
= DECL_CHAIN (p
))
1988 TREE_NO_WARNING (p
) = 1;
1990 if (TYPE_BEING_DEFINED (DECL_CONTEXT (fn
)))
1991 /* Defer checking. */;
1992 else if (!processing_template_decl
)
1993 defaulted_late_check (fn
);
1999 /* Add an implicit declaration to TYPE for the kind of function
2000 indicated by SFK. Return the FUNCTION_DECL for the new implicit
2004 lazily_declare_fn (special_function_kind sfk
, tree type
)
2007 /* Whether or not the argument has a const reference type. */
2008 bool const_p
= false;
2012 case sfk_constructor
:
2013 CLASSTYPE_LAZY_DEFAULT_CTOR (type
) = 0;
2015 case sfk_copy_constructor
:
2016 const_p
= TYPE_HAS_CONST_COPY_CTOR (type
);
2017 CLASSTYPE_LAZY_COPY_CTOR (type
) = 0;
2019 case sfk_move_constructor
:
2020 CLASSTYPE_LAZY_MOVE_CTOR (type
) = 0;
2022 case sfk_copy_assignment
:
2023 const_p
= TYPE_HAS_CONST_COPY_ASSIGN (type
);
2024 CLASSTYPE_LAZY_COPY_ASSIGN (type
) = 0;
2026 case sfk_move_assignment
:
2027 CLASSTYPE_LAZY_MOVE_ASSIGN (type
) = 0;
2029 case sfk_destructor
:
2030 CLASSTYPE_LAZY_DESTRUCTOR (type
) = 0;
2036 /* Declare the function. */
2037 fn
= implicitly_declare_fn (sfk
, type
, const_p
, NULL
, NULL
);
2039 /* [class.copy]/8 If the class definition declares a move constructor or
2040 move assignment operator, the implicitly declared copy constructor is
2041 defined as deleted.... */
2042 if ((sfk
== sfk_copy_assignment
2043 || sfk
== sfk_copy_constructor
)
2044 && (type_has_user_declared_move_constructor (type
)
2045 || type_has_user_declared_move_assign (type
)))
2046 DECL_DELETED_FN (fn
) = true;
2048 /* A destructor may be virtual. */
2049 if (sfk
== sfk_destructor
2050 || sfk
== sfk_move_assignment
2051 || sfk
== sfk_copy_assignment
)
2052 check_for_override (fn
, type
);
2053 /* Add it to CLASSTYPE_METHOD_VEC. */
2054 add_method (type
, fn
, NULL_TREE
);
2055 /* Add it to TYPE_METHODS. */
2056 if (sfk
== sfk_destructor
2057 && DECL_VIRTUAL_P (fn
)
2058 && abi_version_at_least (2))
2059 /* The ABI requires that a virtual destructor go at the end of the
2061 TYPE_METHODS (type
) = chainon (TYPE_METHODS (type
), fn
);
2064 /* G++ 3.2 put the implicit destructor at the *beginning* of the
2065 TYPE_METHODS list, which cause the destructor to be emitted
2066 in an incorrect location in the vtable. */
2067 if (warn_abi
&& sfk
== sfk_destructor
&& DECL_VIRTUAL_P (fn
))
2068 warning (OPT_Wabi
, "vtable layout for class %qT may not be ABI-compliant"
2069 "and may change in a future version of GCC due to "
2070 "implicit virtual destructor",
2072 DECL_CHAIN (fn
) = TYPE_METHODS (type
);
2073 TYPE_METHODS (type
) = fn
;
2075 maybe_add_class_template_decl_list (type
, fn
, /*friend_p=*/0);
2076 if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn
)
2077 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn
))
2078 /* Create appropriate clones. */
2079 clone_function_decl (fn
, /*update_method_vec=*/true);
2084 /* Given a FUNCTION_DECL FN and a chain LIST, skip as many elements of LIST
2085 as there are artificial parms in FN. */
2088 skip_artificial_parms_for (const_tree fn
, tree list
)
2090 if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn
))
2091 list
= TREE_CHAIN (list
);
2095 if (DECL_HAS_IN_CHARGE_PARM_P (fn
))
2096 list
= TREE_CHAIN (list
);
2097 if (DECL_HAS_VTT_PARM_P (fn
))
2098 list
= TREE_CHAIN (list
);
2102 /* Given a FUNCTION_DECL FN and a chain LIST, return the number of
2103 artificial parms in FN. */
2106 num_artificial_parms_for (const_tree fn
)
2110 if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn
))
2115 if (DECL_HAS_IN_CHARGE_PARM_P (fn
))
2117 if (DECL_HAS_VTT_PARM_P (fn
))
2123 #include "gt-cp-method.h"