1 /* Handle the hair of processing (but not expanding) inline functions.
2 Also manage function and variable name overloading.
3 Copyright (C) 1987-2015 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"
31 #include "double-int.h"
38 #include "stringpool.h"
45 #include "common/common-target.h"
46 #include "diagnostic.h"
49 #include "plugin-api.h"
50 #include "hard-reg-set.h"
56 /* Various flags to control the mangling process. */
62 /* The thing we are presently mangling is part of a template type,
63 rather than a fully instantiated type. Therefore, we may see
64 complex expressions where we would normally expect to see a
65 simple integer constant. */
66 mf_maybe_uninstantiated = 1,
67 /* When mangling a numeric value, use the form `_XX_' (instead of
68 just `XX') if the value has more than one digit. */
69 mf_use_underscores_around_value = 2
72 typedef enum mangling_flags mangling_flags;
74 static void do_build_copy_assign (tree);
75 static void do_build_copy_constructor (tree);
76 static tree make_alias_for_thunk (tree);
78 /* Called once to initialize method.c. */
86 /* Return a this or result adjusting thunk to FUNCTION. THIS_ADJUSTING
87 indicates whether it is a this or result adjusting thunk.
88 FIXED_OFFSET and VIRTUAL_OFFSET indicate how to do the adjustment
89 (see thunk_adjust). VIRTUAL_OFFSET can be NULL, but FIXED_OFFSET
90 never is. VIRTUAL_OFFSET is the /index/ into the vtable for this
91 adjusting thunks, we scale it to a byte offset. For covariant
92 thunks VIRTUAL_OFFSET is the virtual binfo. You must post process
93 the returned thunk with finish_thunk. */
96 make_thunk (tree function, bool this_adjusting,
97 tree fixed_offset, tree virtual_offset)
102 gcc_assert (TREE_CODE (function) == FUNCTION_DECL);
103 /* We can have this thunks to covariant thunks, but not vice versa. */
104 gcc_assert (!DECL_THIS_THUNK_P (function));
105 gcc_assert (!DECL_RESULT_THUNK_P (function) || this_adjusting);
107 /* Scale the VIRTUAL_OFFSET to be in terms of bytes. */
108 if (this_adjusting && virtual_offset)
110 = size_binop (MULT_EXPR,
113 TYPE_SIZE_UNIT (vtable_entry_type)));
115 d = tree_to_shwi (fixed_offset);
117 /* See if we already have the thunk in question. For this_adjusting
118 thunks VIRTUAL_OFFSET will be an INTEGER_CST, for covariant thunks it
120 for (thunk = DECL_THUNKS (function); thunk; thunk = DECL_CHAIN (thunk))
121 if (DECL_THIS_THUNK_P (thunk) == this_adjusting
122 && THUNK_FIXED_OFFSET (thunk) == d
123 && !virtual_offset == !THUNK_VIRTUAL_OFFSET (thunk)
126 ? tree_int_cst_equal (THUNK_VIRTUAL_OFFSET (thunk),
128 : THUNK_VIRTUAL_OFFSET (thunk) == virtual_offset)))
131 /* All thunks must be created before FUNCTION is actually emitted;
132 the ABI requires that all thunks be emitted together with the
133 function to which they transfer control. */
134 gcc_assert (!TREE_ASM_WRITTEN (function));
135 /* Likewise, we can only be adding thunks to a function declared in
136 the class currently being laid out. */
137 gcc_assert (TYPE_SIZE (DECL_CONTEXT (function))
138 && TYPE_BEING_DEFINED (DECL_CONTEXT (function)));
140 thunk = build_decl (DECL_SOURCE_LOCATION (function),
141 FUNCTION_DECL, NULL_TREE, TREE_TYPE (function));
142 DECL_LANG_SPECIFIC (thunk) = DECL_LANG_SPECIFIC (function);
143 cxx_dup_lang_specific_decl (thunk);
144 DECL_VIRTUAL_P (thunk) = true;
145 SET_DECL_THUNKS (thunk, NULL_TREE);
147 DECL_CONTEXT (thunk) = DECL_CONTEXT (function);
148 TREE_READONLY (thunk) = TREE_READONLY (function);
149 TREE_THIS_VOLATILE (thunk) = TREE_THIS_VOLATILE (function);
150 TREE_PUBLIC (thunk) = TREE_PUBLIC (function);
151 SET_DECL_THUNK_P (thunk, this_adjusting);
152 THUNK_TARGET (thunk) = function;
153 THUNK_FIXED_OFFSET (thunk) = d;
154 THUNK_VIRTUAL_OFFSET (thunk) = virtual_offset;
155 THUNK_ALIAS (thunk) = NULL_TREE;
157 DECL_INTERFACE_KNOWN (thunk) = 1;
158 DECL_NOT_REALLY_EXTERN (thunk) = 1;
159 DECL_COMDAT (thunk) = DECL_COMDAT (function);
160 DECL_SAVED_FUNCTION_DATA (thunk) = NULL;
161 /* The thunk itself is not a constructor or destructor, even if
162 the thing it is thunking to is. */
163 DECL_DESTRUCTOR_P (thunk) = 0;
164 DECL_CONSTRUCTOR_P (thunk) = 0;
165 DECL_EXTERNAL (thunk) = 1;
166 DECL_ARTIFICIAL (thunk) = 1;
167 /* The THUNK is not a pending inline, even if the FUNCTION is. */
168 DECL_PENDING_INLINE_P (thunk) = 0;
169 DECL_DECLARED_INLINE_P (thunk) = 0;
170 /* Nor is it a template instantiation. */
171 DECL_USE_TEMPLATE (thunk) = 0;
172 DECL_TEMPLATE_INFO (thunk) = NULL;
174 /* Add it to the list of thunks associated with FUNCTION. */
175 DECL_CHAIN (thunk) = DECL_THUNKS (function);
176 SET_DECL_THUNKS (function, thunk);
181 /* Finish THUNK, a thunk decl. */
184 finish_thunk (tree thunk)
187 tree fixed_offset = ssize_int (THUNK_FIXED_OFFSET (thunk));
188 tree virtual_offset = THUNK_VIRTUAL_OFFSET (thunk);
190 gcc_assert (!DECL_NAME (thunk) && DECL_THUNK_P (thunk));
191 if (virtual_offset && DECL_RESULT_THUNK_P (thunk))
192 virtual_offset = BINFO_VPTR_FIELD (virtual_offset);
193 function = THUNK_TARGET (thunk);
194 name = mangle_thunk (function, DECL_THIS_THUNK_P (thunk),
195 fixed_offset, virtual_offset);
197 /* We can end up with declarations of (logically) different
198 covariant thunks, that do identical adjustments. The two thunks
199 will be adjusting between within different hierarchies, which
200 happen to have the same layout. We must nullify one of them to
201 refer to the other. */
202 if (DECL_RESULT_THUNK_P (thunk))
206 for (cov_probe = DECL_THUNKS (function);
207 cov_probe; cov_probe = DECL_CHAIN (cov_probe))
208 if (DECL_NAME (cov_probe) == name)
210 gcc_assert (!DECL_THUNKS (thunk));
211 THUNK_ALIAS (thunk) = (THUNK_ALIAS (cov_probe)
212 ? THUNK_ALIAS (cov_probe) : cov_probe);
217 DECL_NAME (thunk) = name;
218 SET_DECL_ASSEMBLER_NAME (thunk, name);
221 static GTY (()) int thunk_labelno;
223 /* Create a static alias to target. */
226 make_alias_for (tree target, tree newid)
228 tree alias = build_decl (DECL_SOURCE_LOCATION (target),
229 TREE_CODE (target), newid, TREE_TYPE (target));
230 DECL_LANG_SPECIFIC (alias) = DECL_LANG_SPECIFIC (target);
231 cxx_dup_lang_specific_decl (alias);
232 DECL_CONTEXT (alias) = NULL;
233 TREE_READONLY (alias) = TREE_READONLY (target);
234 TREE_THIS_VOLATILE (alias) = TREE_THIS_VOLATILE (target);
235 TREE_PUBLIC (alias) = 0;
236 DECL_INTERFACE_KNOWN (alias) = 1;
237 if (DECL_LANG_SPECIFIC (alias))
239 DECL_NOT_REALLY_EXTERN (alias) = 1;
240 DECL_USE_TEMPLATE (alias) = 0;
241 DECL_TEMPLATE_INFO (alias) = NULL;
243 DECL_EXTERNAL (alias) = 0;
244 DECL_ARTIFICIAL (alias) = 1;
245 DECL_TEMPLATE_INSTANTIATED (alias) = 0;
246 if (TREE_CODE (alias) == FUNCTION_DECL)
248 DECL_SAVED_FUNCTION_DATA (alias) = NULL;
249 DECL_DESTRUCTOR_P (alias) = 0;
250 DECL_CONSTRUCTOR_P (alias) = 0;
251 DECL_PENDING_INLINE_P (alias) = 0;
252 DECL_DECLARED_INLINE_P (alias) = 0;
253 DECL_INITIAL (alias) = error_mark_node;
254 DECL_ARGUMENTS (alias) = copy_list (DECL_ARGUMENTS (target));
257 TREE_STATIC (alias) = 1;
258 TREE_ADDRESSABLE (alias) = 1;
259 TREE_USED (alias) = 1;
260 SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias));
265 make_alias_for_thunk (tree function)
270 targetm.asm_out.generate_internal_label (buf, "LTHUNK", thunk_labelno);
273 alias = make_alias_for (function, get_identifier (buf));
275 if (!flag_syntax_only)
277 struct cgraph_node *funcn, *aliasn;
278 funcn = cgraph_node::get (function);
279 gcc_checking_assert (funcn);
280 aliasn = cgraph_node::create_same_body_alias (alias, function);
281 DECL_ASSEMBLER_NAME (function);
282 gcc_assert (aliasn != NULL);
288 /* Emit the definition of a C++ multiple inheritance or covariant
289 return vtable thunk. If EMIT_P is nonzero, the thunk is emitted
293 use_thunk (tree thunk_fndecl, bool emit_p)
295 tree a, t, function, alias;
297 HOST_WIDE_INT fixed_offset, virtual_value;
298 bool this_adjusting = DECL_THIS_THUNK_P (thunk_fndecl);
299 struct cgraph_node *funcn, *thunk_node;
301 /* We should have called finish_thunk to give it a name. */
302 gcc_assert (DECL_NAME (thunk_fndecl));
304 /* We should never be using an alias, always refer to the
306 gcc_assert (!THUNK_ALIAS (thunk_fndecl));
308 if (TREE_ASM_WRITTEN (thunk_fndecl))
311 function = THUNK_TARGET (thunk_fndecl);
312 if (DECL_RESULT (thunk_fndecl))
313 /* We already turned this thunk into an ordinary function.
314 There's no need to process this thunk again. */
317 if (DECL_THUNK_P (function))
318 /* The target is itself a thunk, process it now. */
319 use_thunk (function, emit_p);
321 /* Thunks are always addressable; they only appear in vtables. */
322 TREE_ADDRESSABLE (thunk_fndecl) = 1;
324 /* Figure out what function is being thunked to. It's referenced in
325 this translation unit. */
326 TREE_ADDRESSABLE (function) = 1;
327 mark_used (function);
331 if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function))
332 alias = make_alias_for_thunk (function);
336 fixed_offset = THUNK_FIXED_OFFSET (thunk_fndecl);
337 virtual_offset = THUNK_VIRTUAL_OFFSET (thunk_fndecl);
342 virtual_offset = BINFO_VPTR_FIELD (virtual_offset);
343 virtual_value = tree_to_shwi (virtual_offset);
344 gcc_assert (virtual_value);
349 /* And, if we need to emit the thunk, it's used. */
350 mark_used (thunk_fndecl);
351 /* This thunk is actually defined. */
352 DECL_EXTERNAL (thunk_fndecl) = 0;
353 /* The linkage of the function may have changed. FIXME in linkage
355 gcc_assert (DECL_INTERFACE_KNOWN (function));
356 TREE_PUBLIC (thunk_fndecl) = TREE_PUBLIC (function);
357 DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function);
358 DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
359 = DECL_VISIBILITY_SPECIFIED (function);
360 DECL_COMDAT (thunk_fndecl) = DECL_COMDAT (function);
361 DECL_WEAK (thunk_fndecl) = DECL_WEAK (function);
363 if (flag_syntax_only)
365 TREE_ASM_WRITTEN (thunk_fndecl) = 1;
369 push_to_top_level ();
371 if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function)
372 && targetm_common.have_named_sections)
375 struct symtab_node *symbol;
377 if ((symbol = symtab_node::get (function))
380 if (symbol->analyzed)
381 fn = symtab_node::get (function)->ultimate_alias_target ()->decl;
383 fn = symtab_node::get (function)->alias_target;
385 resolve_unique_section (fn, 0, flag_function_sections);
387 if (DECL_SECTION_NAME (fn) != NULL && DECL_ONE_ONLY (fn))
389 resolve_unique_section (thunk_fndecl, 0, flag_function_sections);
391 /* Output the thunk into the same section as function. */
392 set_decl_section_name (thunk_fndecl, DECL_SECTION_NAME (fn));
393 symtab_node::get (thunk_fndecl)->implicit_section
394 = symtab_node::get (fn)->implicit_section;
398 /* Set up cloned argument trees for the thunk. */
400 for (a = DECL_ARGUMENTS (function); a; a = DECL_CHAIN (a))
402 tree x = copy_node (a);
404 DECL_CONTEXT (x) = thunk_fndecl;
405 SET_DECL_RTL (x, NULL);
406 DECL_HAS_VALUE_EXPR_P (x) = 0;
407 TREE_ADDRESSABLE (x) = 0;
411 DECL_ARGUMENTS (thunk_fndecl) = a;
412 TREE_ASM_WRITTEN (thunk_fndecl) = 1;
413 funcn = cgraph_node::get (function);
414 gcc_checking_assert (funcn);
415 thunk_node = funcn->create_thunk (thunk_fndecl, function,
416 this_adjusting, fixed_offset, virtual_value,
417 virtual_offset, alias);
418 if (DECL_ONE_ONLY (function))
419 thunk_node->add_to_same_comdat_group (funcn);
421 pop_from_top_level ();
424 /* Code for synthesizing methods which have default semantics defined. */
426 /* True iff CTYPE has a trivial SFK. */
429 type_has_trivial_fn (tree ctype, special_function_kind sfk)
433 case sfk_constructor:
434 return !TYPE_HAS_COMPLEX_DFLT (ctype);
435 case sfk_copy_constructor:
436 return !TYPE_HAS_COMPLEX_COPY_CTOR (ctype);
437 case sfk_move_constructor:
438 return !TYPE_HAS_COMPLEX_MOVE_CTOR (ctype);
439 case sfk_copy_assignment:
440 return !TYPE_HAS_COMPLEX_COPY_ASSIGN (ctype);
441 case sfk_move_assignment:
442 return !TYPE_HAS_COMPLEX_MOVE_ASSIGN (ctype);
444 return !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype);
445 case sfk_inheriting_constructor:
452 /* Note that CTYPE has a non-trivial SFK even though we previously thought
456 type_set_nontrivial_flag (tree ctype, special_function_kind sfk)
460 case sfk_constructor:
461 TYPE_HAS_COMPLEX_DFLT (ctype) = true;
463 case sfk_copy_constructor:
464 TYPE_HAS_COMPLEX_COPY_CTOR (ctype) = true;
466 case sfk_move_constructor:
467 TYPE_HAS_COMPLEX_MOVE_CTOR (ctype) = true;
469 case sfk_copy_assignment:
470 TYPE_HAS_COMPLEX_COPY_ASSIGN (ctype) = true;
472 case sfk_move_assignment:
473 TYPE_HAS_COMPLEX_MOVE_ASSIGN (ctype) = true;
476 TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype) = true;
478 case sfk_inheriting_constructor:
484 /* True iff FN is a trivial defaulted member function ([cd]tor, op=). */
487 trivial_fn_p (tree fn)
489 if (!DECL_DEFAULTED_FN (fn))
492 /* If fn is a clone, get the primary variant. */
493 if (tree prim = DECL_CLONED_FUNCTION (fn))
495 return type_has_trivial_fn (DECL_CONTEXT (fn), special_function_p (fn));
498 /* Subroutine of do_build_copy_constructor: Add a mem-initializer for BINFO
499 given the parameter or parameters PARM, possibly inherited constructor
500 base INH, or move flag MOVE_P. */
503 add_one_base_init (tree binfo, tree parm, bool move_p, tree inh,
504 tree member_init_list)
509 /* An inheriting constructor only has a mem-initializer for
510 the base it inherits from. */
511 if (BINFO_TYPE (binfo) != inh)
512 return member_init_list;
516 for (; parm; parm = DECL_CHAIN (parm))
518 tree exp = convert_from_reference (parm);
519 if (TREE_CODE (TREE_TYPE (parm)) != REFERENCE_TYPE
520 || TYPE_REF_IS_RVALUE (TREE_TYPE (parm)))
522 *p = build_tree_list (NULL_TREE, exp);
523 p = &TREE_CHAIN (*p);
528 init = build_base_path (PLUS_EXPR, parm, binfo, 1,
529 tf_warning_or_error);
532 init = build_tree_list (NULL_TREE, init);
534 return tree_cons (binfo, init, member_init_list);
537 /* Generate code for default X(X&) or X(X&&) constructor or an inheriting
541 do_build_copy_constructor (tree fndecl)
543 tree parm = FUNCTION_FIRST_USER_PARM (fndecl);
544 bool move_p = DECL_MOVE_CONSTRUCTOR_P (fndecl);
545 bool trivial = trivial_fn_p (fndecl);
546 tree inh = DECL_INHERITED_CTOR_BASE (fndecl);
549 parm = convert_from_reference (parm);
552 && is_empty_class (current_class_type))
553 /* Don't copy the padding byte; it might not have been allocated
554 if *this is a base subobject. */;
557 tree t = build2 (INIT_EXPR, void_type_node, current_class_ref, parm);
558 finish_expr_stmt (t);
562 tree fields = TYPE_FIELDS (current_class_type);
563 tree member_init_list = NULL_TREE;
564 int cvquals = cp_type_quals (TREE_TYPE (parm));
566 tree binfo, base_binfo;
568 vec<tree, va_gc> *vbases;
570 /* Initialize all the base-classes with the parameter converted
571 to their type so that we get their copy constructor and not
572 another constructor that takes current_class_type. We must
573 deal with the binfo's directly as a direct base might be
574 inaccessible due to ambiguity. */
575 for (vbases = CLASSTYPE_VBASECLASSES (current_class_type), i = 0;
576 vec_safe_iterate (vbases, i, &binfo); i++)
578 member_init_list = add_one_base_init (binfo, parm, move_p, inh,
582 for (binfo = TYPE_BINFO (current_class_type), i = 0;
583 BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
585 if (BINFO_VIRTUAL_P (base_binfo))
587 member_init_list = add_one_base_init (base_binfo, parm, move_p,
588 inh, member_init_list);
591 for (; fields; fields = DECL_CHAIN (fields))
596 if (TREE_CODE (field) != FIELD_DECL)
601 expr_type = TREE_TYPE (field);
602 if (DECL_NAME (field))
604 if (VFIELD_NAME_P (DECL_NAME (field)))
607 else if (ANON_AGGR_TYPE_P (expr_type) && TYPE_FIELDS (expr_type))
608 /* Just use the field; anonymous types can't have
609 nontrivial copy ctors or assignment ops or this
610 function would be deleted. */;
614 /* Compute the type of "init->field". If the copy-constructor
615 parameter is, for example, "const S&", and the type of
616 the field is "T", then the type will usually be "const
617 T". (There are no cv-qualified variants of reference
619 if (TREE_CODE (expr_type) != REFERENCE_TYPE)
623 if (DECL_MUTABLE_P (field))
624 quals &= ~TYPE_QUAL_CONST;
625 quals |= cp_type_quals (expr_type);
626 expr_type = cp_build_qualified_type (expr_type, quals);
629 init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE);
630 if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
631 /* 'move' breaks bit-fields, and has no effect for scalars. */
632 && !scalarish_type_p (expr_type))
634 init = build_tree_list (NULL_TREE, init);
636 member_init_list = tree_cons (field, init, member_init_list);
638 finish_mem_initializers (member_init_list);
643 do_build_copy_assign (tree fndecl)
645 tree parm = DECL_CHAIN (DECL_ARGUMENTS (fndecl));
647 bool move_p = move_fn_p (fndecl);
648 bool trivial = trivial_fn_p (fndecl);
649 int flags = LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED;
651 compound_stmt = begin_compound_stmt (0);
652 parm = convert_from_reference (parm);
655 && is_empty_class (current_class_type))
656 /* Don't copy the padding byte; it might not have been allocated
657 if *this is a base subobject. */;
660 tree t = build2 (MODIFY_EXPR, void_type_node, current_class_ref, parm);
661 finish_expr_stmt (t);
666 int cvquals = cp_type_quals (TREE_TYPE (parm));
668 tree binfo, base_binfo;
670 /* Assign to each of the direct base classes. */
671 for (binfo = TYPE_BINFO (current_class_type), i = 0;
672 BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
675 vec<tree, va_gc> *parmvec;
677 /* We must convert PARM directly to the base class
678 explicitly since the base class may be ambiguous. */
679 converted_parm = build_base_path (PLUS_EXPR, parm, base_binfo, 1,
680 tf_warning_or_error);
682 converted_parm = move (converted_parm);
683 /* Call the base class assignment operator. */
684 parmvec = make_tree_vector_single (converted_parm);
686 (build_special_member_call (current_class_ref,
687 ansi_assopname (NOP_EXPR),
691 tf_warning_or_error));
692 release_tree_vector (parmvec);
695 /* Assign to each of the non-static data members. */
696 for (fields = TYPE_FIELDS (current_class_type);
698 fields = DECL_CHAIN (fields))
700 tree comp = current_class_ref;
706 if (TREE_CODE (field) != FIELD_DECL || DECL_ARTIFICIAL (field))
709 expr_type = TREE_TYPE (field);
711 if (CP_TYPE_CONST_P (expr_type))
713 error ("non-static const member %q#D, can%'t use default "
714 "assignment operator", field);
717 else if (TREE_CODE (expr_type) == REFERENCE_TYPE)
719 error ("non-static reference member %q#D, can%'t use "
720 "default assignment operator", field);
724 if (DECL_NAME (field))
726 if (VFIELD_NAME_P (DECL_NAME (field)))
729 else if (ANON_AGGR_TYPE_P (expr_type)
730 && TYPE_FIELDS (expr_type) != NULL_TREE)
731 /* Just use the field; anonymous types can't have
732 nontrivial copy ctors or assignment ops or this
733 function would be deleted. */;
737 comp = build3 (COMPONENT_REF, expr_type, comp, field, NULL_TREE);
739 /* Compute the type of init->field */
741 if (DECL_MUTABLE_P (field))
742 quals &= ~TYPE_QUAL_CONST;
743 expr_type = cp_build_qualified_type (expr_type, quals);
745 init = build3 (COMPONENT_REF, expr_type, init, field, NULL_TREE);
746 if (move_p && TREE_CODE (expr_type) != REFERENCE_TYPE
747 /* 'move' breaks bit-fields, and has no effect for scalars. */
748 && !scalarish_type_p (expr_type))
751 if (DECL_NAME (field))
752 init = cp_build_modify_expr (comp, NOP_EXPR, init,
753 tf_warning_or_error);
755 init = build2 (MODIFY_EXPR, TREE_TYPE (comp), comp, init);
756 finish_expr_stmt (init);
759 finish_return_stmt (current_class_ref);
760 finish_compound_stmt (compound_stmt);
763 /* Synthesize FNDECL, a non-static member function. */
766 synthesize_method (tree fndecl)
768 bool nested = (current_function_decl != NULL_TREE);
769 tree context = decl_function_context (fndecl);
770 bool need_body = true;
772 location_t save_input_location = input_location;
773 int error_count = errorcount;
774 int warning_count = warningcount + werrorcount;
776 /* Reset the source location, we might have been previously
777 deferred, and thus have saved where we were first needed. */
778 DECL_SOURCE_LOCATION (fndecl)
779 = DECL_SOURCE_LOCATION (TYPE_NAME (DECL_CONTEXT (fndecl)));
781 /* If we've been asked to synthesize a clone, just synthesize the
782 cloned function instead. Doing so will automatically fill in the
783 body for the clone. */
784 if (DECL_CLONED_FUNCTION_P (fndecl))
785 fndecl = DECL_CLONED_FUNCTION (fndecl);
787 /* We may be in the middle of deferred access check. Disable
789 push_deferring_access_checks (dk_no_deferred);
792 push_to_top_level ();
794 push_function_context ();
796 input_location = DECL_SOURCE_LOCATION (fndecl);
798 start_preparsed_function (fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
799 stmt = begin_function_body ();
801 if (DECL_OVERLOADED_OPERATOR_P (fndecl) == NOP_EXPR)
803 do_build_copy_assign (fndecl);
806 else if (DECL_CONSTRUCTOR_P (fndecl))
808 tree arg_chain = FUNCTION_FIRST_USER_PARMTYPE (fndecl);
809 if (arg_chain != void_list_node)
810 do_build_copy_constructor (fndecl);
812 finish_mem_initializers (NULL_TREE);
815 /* If we haven't yet generated the body of the function, just
816 generate an empty compound statement. */
820 compound_stmt = begin_compound_stmt (BCS_FN_BODY);
821 finish_compound_stmt (compound_stmt);
824 finish_function_body (stmt);
825 expand_or_defer_fn (finish_function (0));
827 input_location = save_input_location;
830 pop_from_top_level ();
832 pop_function_context ();
834 pop_deferring_access_checks ();
836 if (error_count != errorcount || warning_count != warningcount + werrorcount)
837 inform (input_location, "synthesized method %qD first required here ",
841 /* Build a reference to type TYPE with cv-quals QUALS, which is an
842 rvalue if RVALUE is true. */
845 build_stub_type (tree type, int quals, bool rvalue)
847 tree argtype = cp_build_qualified_type (type, quals);
848 return cp_build_reference_type (argtype, rvalue);
851 /* Build a dummy glvalue from dereferencing a dummy reference of type
855 build_stub_object (tree reftype)
857 if (TREE_CODE (reftype) != REFERENCE_TYPE)
858 reftype = cp_build_reference_type (reftype, /*rval*/true);
859 tree stub = build1 (CONVERT_EXPR, reftype, integer_one_node);
860 return convert_from_reference (stub);
863 /* Determine which function will be called when looking up NAME in TYPE,
864 called with a single ARGTYPE argument, or no argument if ARGTYPE is
865 null. FLAGS and COMPLAIN are as for build_new_method_call.
867 Returns a FUNCTION_DECL if all is well.
868 Returns NULL_TREE if overload resolution failed.
869 Returns error_mark_node if the chosen function cannot be called. */
872 locate_fn_flags (tree type, tree name, tree argtype, int flags,
873 tsubst_flags_t complain)
875 tree ob, fn, fns, binfo, rval;
876 vec<tree, va_gc> *args;
879 binfo = TYPE_BINFO (type);
883 type = BINFO_TYPE (binfo);
886 ob = build_stub_object (cp_build_reference_type (type, false));
887 args = make_tree_vector ();
890 if (TREE_CODE (argtype) == TREE_LIST)
892 for (tree elt = argtype; elt != void_list_node;
893 elt = TREE_CHAIN (elt))
895 tree type = TREE_VALUE (elt);
896 tree arg = build_stub_object (type);
897 vec_safe_push (args, arg);
902 tree arg = build_stub_object (argtype);
903 args->quick_push (arg);
907 fns = lookup_fnfields (binfo, name, 0);
908 rval = build_new_method_call (ob, fns, &args, binfo, flags, &fn, complain);
910 release_tree_vector (args);
911 if (fn && rval == error_mark_node)
917 /* Locate the dtor of TYPE. */
920 get_dtor (tree type, tsubst_flags_t complain)
922 tree fn = locate_fn_flags (type, complete_dtor_identifier, NULL_TREE,
923 LOOKUP_NORMAL, complain);
924 if (fn == error_mark_node)
929 /* Locate the default ctor of TYPE. */
932 locate_ctor (tree type)
936 push_deferring_access_checks (dk_no_check);
937 fn = locate_fn_flags (type, complete_ctor_identifier, NULL_TREE,
938 LOOKUP_SPECULATIVE, tf_none);
939 pop_deferring_access_checks ();
940 if (fn == error_mark_node)
945 /* Likewise, but give any appropriate errors. */
948 get_default_ctor (tree type)
950 tree fn = locate_fn_flags (type, complete_ctor_identifier, NULL_TREE,
951 LOOKUP_NORMAL, tf_warning_or_error);
952 if (fn == error_mark_node)
957 /* Locate the copy ctor of TYPE. */
960 get_copy_ctor (tree type, tsubst_flags_t complain)
962 int quals = (TYPE_HAS_CONST_COPY_CTOR (type)
963 ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED);
964 tree argtype = build_stub_type (type, quals, false);
965 tree fn = locate_fn_flags (type, complete_ctor_identifier, argtype,
966 LOOKUP_NORMAL, complain);
967 if (fn == error_mark_node)
972 /* Locate the copy assignment operator of TYPE. */
975 get_copy_assign (tree type)
977 int quals = (TYPE_HAS_CONST_COPY_ASSIGN (type)
978 ? TYPE_QUAL_CONST : TYPE_UNQUALIFIED);
979 tree argtype = build_stub_type (type, quals, false);
980 tree fn = locate_fn_flags (type, ansi_assopname (NOP_EXPR), argtype,
981 LOOKUP_NORMAL, tf_warning_or_error);
982 if (fn == error_mark_node)
987 /* Locate the inherited constructor of constructor CTOR. */
990 get_inherited_ctor (tree ctor)
992 gcc_assert (DECL_INHERITED_CTOR_BASE (ctor));
994 push_deferring_access_checks (dk_no_check);
995 tree fn = locate_fn_flags (DECL_INHERITED_CTOR_BASE (ctor),
996 complete_ctor_identifier,
997 FUNCTION_FIRST_USER_PARMTYPE (ctor),
998 LOOKUP_NORMAL|LOOKUP_SPECULATIVE,
1000 pop_deferring_access_checks ();
1001 if (fn == error_mark_node)
1006 /* walk_tree helper function for is_trivially_xible. If *TP is a call,
1007 return it if it calls something other than a trivial special member
1011 check_nontriv (tree *tp, int *, void *)
1014 if (TREE_CODE (*tp) == CALL_EXPR)
1015 fn = CALL_EXPR_FN (*tp);
1016 else if (TREE_CODE (*tp) == AGGR_INIT_EXPR)
1017 fn = AGGR_INIT_EXPR_FN (*tp);
1021 if (TREE_CODE (fn) == ADDR_EXPR)
1022 fn = TREE_OPERAND (fn, 0);
1024 if (TREE_CODE (fn) != FUNCTION_DECL
1025 || !trivial_fn_p (fn))
1030 /* Return declval<T>() = declval<U>() treated as an unevaluated operand. */
1033 assignable_expr (tree to, tree from)
1035 ++cp_unevaluated_operand;
1036 to = build_stub_object (to);
1037 from = build_stub_object (from);
1038 tree r = cp_build_modify_expr (to, NOP_EXPR, from, tf_none);
1039 --cp_unevaluated_operand;
1043 /* The predicate condition for a template specialization
1044 is_constructible<T, Args...> shall be satisfied if and only if the
1045 following variable definition would be well-formed for some invented
1046 variable t: T t(create<Args>()...);
1048 Return something equivalent in well-formedness and triviality. */
1051 constructible_expr (tree to, tree from)
1054 if (CLASS_TYPE_P (to))
1057 vec<tree, va_gc> *args = NULL;
1058 if (TREE_CODE (to) != REFERENCE_TYPE)
1059 to = cp_build_reference_type (to, /*rval*/false);
1060 tree ob = build_stub_object (to);
1061 for (; from; from = TREE_CHAIN (from))
1062 vec_safe_push (args, build_stub_object (TREE_VALUE (from)));
1063 expr = build_special_member_call (ob, complete_ctor_identifier, &args,
1064 ctype, LOOKUP_NORMAL, tf_none);
1065 if (expr == error_mark_node)
1066 return error_mark_node;
1067 /* The current state of the standard vis-a-vis LWG 2116 is that
1068 is_*constructible involves destruction as well. */
1069 if (type_build_dtor_call (ctype))
1071 tree dtor = build_special_member_call (ob, complete_dtor_identifier,
1072 NULL, ctype, LOOKUP_NORMAL,
1074 if (dtor == error_mark_node)
1075 return error_mark_node;
1076 if (!TYPE_HAS_TRIVIAL_DESTRUCTOR (ctype))
1077 expr = build2 (COMPOUND_EXPR, void_type_node, expr, dtor);
1082 if (from == NULL_TREE)
1083 return build_value_init (to, tf_none);
1084 else if (TREE_CHAIN (from))
1085 return error_mark_node; // too many initializers
1086 from = build_stub_object (TREE_VALUE (from));
1087 expr = perform_direct_initialization_if_possible (to, from,
1094 /* Returns true iff TO is trivially assignable (if CODE is MODIFY_EXPR) or
1095 constructible (otherwise) from FROM, which is a single type for
1096 assignment or a list of types for construction. */
1099 is_trivially_xible (enum tree_code code, tree to, tree from)
1102 if (code == MODIFY_EXPR)
1103 expr = assignable_expr (to, from);
1104 else if (from && TREE_CHAIN (from))
1105 return false; // only 0- and 1-argument ctors can be trivial
1107 expr = constructible_expr (to, from);
1109 if (expr == error_mark_node)
1111 tree nt = cp_walk_tree_without_duplicates (&expr, check_nontriv, NULL);
1115 /* Subroutine of synthesized_method_walk. Update SPEC_P, TRIVIAL_P and
1116 DELETED_P or give an error message MSG with argument ARG. */
1119 process_subob_fn (tree fn, tree *spec_p, bool *trivial_p,
1120 bool *deleted_p, bool *constexpr_p,
1121 bool diag, tree arg, bool dtor_from_ctor = false)
1123 if (!fn || fn == error_mark_node)
1128 maybe_instantiate_noexcept (fn);
1129 tree raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
1130 *spec_p = merge_exception_specifiers (*spec_p, raises);
1133 if (!trivial_fn_p (fn) && !dtor_from_ctor)
1137 if (TREE_CODE (arg) == FIELD_DECL
1138 && TREE_CODE (DECL_CONTEXT (arg)) == UNION_TYPE)
1143 error ("union member %q+D with non-trivial %qD", arg, fn);
1147 if (constexpr_p && !DECL_DECLARED_CONSTEXPR_P (fn))
1149 *constexpr_p = false;
1152 inform (0, "defaulted constructor calls non-constexpr "
1154 explain_invalid_constexpr_fn (fn);
1165 /* Subroutine of synthesized_method_walk to allow recursion into anonymous
1166 aggregates. If DTOR_FROM_CTOR is true, we're walking subobject destructors
1167 called from a synthesized constructor, in which case we don't consider
1168 the triviality of the subobject destructor. */
1171 walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
1172 int quals, bool copy_arg_p, bool move_p,
1173 bool assign_p, tree *spec_p, bool *trivial_p,
1174 bool *deleted_p, bool *constexpr_p,
1175 bool diag, int flags, tsubst_flags_t complain,
1176 bool dtor_from_ctor)
1179 for (field = fields; field; field = DECL_CHAIN (field))
1181 tree mem_type, argtype, rval;
1183 if (TREE_CODE (field) != FIELD_DECL
1184 || DECL_ARTIFICIAL (field))
1187 mem_type = strip_array_types (TREE_TYPE (field));
1191 if (CP_TYPE_CONST_P (mem_type) && !CLASS_TYPE_P (mem_type))
1194 error ("non-static const member %q#D, can%'t use default "
1195 "assignment operator", field);
1197 else if (TREE_CODE (mem_type) == REFERENCE_TYPE)
1200 error ("non-static reference member %q#D, can%'t use "
1201 "default assignment operator", field);
1206 if (bad && deleted_p)
1209 else if (sfk == sfk_constructor)
1213 if (DECL_INITIAL (field))
1215 if (diag && DECL_INITIAL (field) == error_mark_node)
1216 inform (0, "initializer for %q+#D is invalid", field);
1219 /* Core 1351: If the field has an NSDMI that could throw, the
1220 default constructor is noexcept(false). */
1223 tree nsdmi = get_nsdmi (field, /*ctor*/false);
1224 if (!expr_noexcept_p (nsdmi, complain))
1225 *spec_p = noexcept_false_spec;
1227 /* Don't do the normal processing. */
1232 if (CP_TYPE_CONST_P (mem_type)
1233 && default_init_uninitialized_part (mem_type))
1237 error ("uninitialized const member in %q#T",
1238 current_class_type);
1239 inform (DECL_SOURCE_LOCATION (field),
1240 "%q#D should be initialized", field);
1244 else if (TREE_CODE (mem_type) == REFERENCE_TYPE)
1248 error ("uninitialized reference member in %q#T",
1249 current_class_type);
1250 inform (DECL_SOURCE_LOCATION (field),
1251 "%q#D should be initialized", field);
1256 if (bad && deleted_p)
1259 /* For an implicitly-defined default constructor to be constexpr,
1260 every member must have a user-provided default constructor or
1261 an explicit initializer. */
1262 if (constexpr_p && !CLASS_TYPE_P (mem_type)
1263 && TREE_CODE (DECL_CONTEXT (field)) != UNION_TYPE)
1265 *constexpr_p = false;
1267 inform (0, "defaulted default constructor does not "
1268 "initialize %q+#D", field);
1271 else if (sfk == sfk_copy_constructor)
1274 if (TREE_CODE (mem_type) == REFERENCE_TYPE
1275 && TYPE_REF_IS_RVALUE (mem_type))
1278 error ("copying non-static data member %q#D of rvalue "
1279 "reference type", field);
1285 if (!CLASS_TYPE_P (mem_type))
1288 if (ANON_AGGR_TYPE_P (mem_type))
1290 walk_field_subobs (TYPE_FIELDS (mem_type), fnname, sfk, quals,
1291 copy_arg_p, move_p, assign_p, spec_p, trivial_p,
1292 deleted_p, constexpr_p,
1293 diag, flags, complain, dtor_from_ctor);
1299 int mem_quals = cp_type_quals (mem_type) | quals;
1300 if (DECL_MUTABLE_P (field))
1301 mem_quals &= ~TYPE_QUAL_CONST;
1302 argtype = build_stub_type (mem_type, mem_quals, move_p);
1305 argtype = NULL_TREE;
1307 rval = locate_fn_flags (mem_type, fnname, argtype, flags, complain);
1309 process_subob_fn (rval, spec_p, trivial_p, deleted_p,
1310 constexpr_p, diag, field, dtor_from_ctor);
1314 /* The caller wants to generate an implicit declaration of SFK for CTYPE
1315 which is const if relevant and CONST_P is set. If spec_p, trivial_p and
1316 deleted_p are non-null, set their referent appropriately. If diag is
1317 true, we're either being called from maybe_explain_implicit_delete to
1318 give errors, or if constexpr_p is non-null, from
1319 explain_invalid_constexpr_fn. */
1322 synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p,
1323 tree *spec_p, bool *trivial_p, bool *deleted_p,
1324 bool *constexpr_p, bool diag,
1325 tree inherited_base, tree inherited_parms)
1327 tree binfo, base_binfo, scope, fnname, rval, argtype;
1328 bool move_p, copy_arg_p, assign_p, expected_trivial, check_vdtor;
1329 vec<tree, va_gc> *vbases;
1330 int i, quals, flags;
1331 tsubst_flags_t complain;
1335 *spec_p = (cxx_dialect >= cxx11 ? noexcept_true_spec : empty_except_spec);
1339 /* "The closure type associated with a lambda-expression has a deleted
1340 default constructor and a deleted copy assignment operator."
1341 This is diagnosed in maybe_explain_implicit_delete. */
1342 if (LAMBDA_TYPE_P (ctype)
1343 && (sfk == sfk_constructor
1344 || sfk == sfk_copy_assignment))
1355 check_vdtor = false;
1358 case sfk_move_assignment:
1359 case sfk_copy_assignment:
1361 fnname = ansi_assopname (NOP_EXPR);
1364 case sfk_destructor:
1366 /* The synthesized method will call base dtors, but check complete
1367 here to avoid having to deal with VTT. */
1368 fnname = complete_dtor_identifier;
1371 case sfk_constructor:
1372 case sfk_move_constructor:
1373 case sfk_copy_constructor:
1374 case sfk_inheriting_constructor:
1376 fnname = complete_ctor_identifier;
1383 gcc_assert ((sfk == sfk_inheriting_constructor)
1384 == (inherited_base != NULL_TREE));
1386 /* If that user-written default constructor would satisfy the
1387 requirements of a constexpr constructor (7.1.5), the
1388 implicitly-defined default constructor is constexpr.
1390 The implicitly-defined copy/move assignment operator is constexpr if
1391 - X is a literal type, and
1392 - the assignment operator selected to copy/move each direct base class
1393 subobject is a constexpr function, and
1394 - for each non-static data member of X that is of class type (or array
1395 thereof), the assignment operator selected to copy/move that member is a
1396 constexpr function. */
1398 *constexpr_p = ctor_p
1399 || (assign_p && cxx_dialect >= cxx14);
1404 case sfk_constructor:
1405 case sfk_destructor:
1406 case sfk_inheriting_constructor:
1410 case sfk_move_constructor:
1411 case sfk_move_assignment:
1413 case sfk_copy_constructor:
1414 case sfk_copy_assignment:
1422 expected_trivial = type_has_trivial_fn (ctype, sfk);
1424 *trivial_p = expected_trivial;
1426 /* The TYPE_HAS_COMPLEX_* flags tell us about constraints from base
1427 class versions and other properties of the type. But a subobject
1428 class can be trivially copyable and yet have overload resolution
1429 choose a template constructor for initialization, depending on
1430 rvalueness and cv-quals. And furthermore, a member in a base might
1431 be trivial but deleted or otherwise not callable. So we can't exit
1432 early in C++0x. The same considerations apply in C++98/03, but
1433 there the definition of triviality does not consider overload
1434 resolution, so a constructor can be trivial even if it would otherwise
1435 call a non-trivial constructor. */
1436 if (expected_trivial
1437 && (!copy_arg_p || cxx_dialect < cxx11))
1439 if (constexpr_p && sfk == sfk_constructor)
1441 bool cx = trivial_default_constructor_is_constexpr (ctype);
1443 if (diag && !cx && TREE_CODE (ctype) == UNION_TYPE)
1444 /* A trivial constructor doesn't have any NSDMI. */
1445 inform (input_location, "defaulted default constructor does "
1446 "not initialize any non-static data member");
1448 if (!diag && cxx_dialect < cxx11)
1452 ++cp_unevaluated_operand;
1453 ++c_inhibit_evaluation_warnings;
1454 push_deferring_access_checks (dk_no_deferred);
1456 scope = push_scope (ctype);
1458 flags = LOOKUP_NORMAL|LOOKUP_SPECULATIVE;
1459 if (!inherited_base)
1460 flags |= LOOKUP_DEFAULTED;
1462 complain = diag ? tf_warning_or_error : tf_none;
1465 quals = TYPE_QUAL_CONST;
1467 quals = TYPE_UNQUALIFIED;
1468 argtype = NULL_TREE;
1470 for (binfo = TYPE_BINFO (ctype), i = 0;
1471 BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
1473 tree basetype = BINFO_TYPE (base_binfo);
1475 if (!assign_p && BINFO_VIRTUAL_P (base_binfo))
1476 /* We'll handle virtual bases below. */
1480 argtype = build_stub_type (basetype, quals, move_p);
1481 else if (basetype == inherited_base)
1482 argtype = inherited_parms;
1483 rval = locate_fn_flags (base_binfo, fnname, argtype, flags, complain);
1485 argtype = NULL_TREE;
1487 process_subob_fn (rval, spec_p, trivial_p, deleted_p,
1488 constexpr_p, diag, basetype);
1491 /* In a constructor we also need to check the subobject
1492 destructors for cleanup of partially constructed objects. */
1493 rval = locate_fn_flags (base_binfo, complete_dtor_identifier,
1494 NULL_TREE, flags, complain);
1495 /* Note that we don't pass down trivial_p; the subobject
1496 destructors don't affect triviality of the constructor. Nor
1497 do they affect constexpr-ness (a constant expression doesn't
1498 throw) or exception-specification (a throw from one of the
1499 dtors would be a double-fault). */
1500 process_subob_fn (rval, NULL, NULL,
1501 deleted_p, NULL, false,
1502 basetype, /*dtor_from_ctor*/true);
1505 if (check_vdtor && type_has_virtual_destructor (basetype))
1507 rval = locate_fn_flags (ctype, ansi_opname (DELETE_EXPR),
1508 ptr_type_node, flags, complain);
1509 /* Unlike for base ctor/op=/dtor, for operator delete it's fine
1510 to have a null rval (no class-specific op delete). */
1511 if (rval && rval == error_mark_node && deleted_p)
1513 check_vdtor = false;
1516 if (diag && assign_p && move_p
1517 && BINFO_VIRTUAL_P (base_binfo)
1518 && rval && TREE_CODE (rval) == FUNCTION_DECL
1519 && move_fn_p (rval) && !trivial_fn_p (rval)
1520 && vbase_has_user_provided_move_assign (basetype))
1521 warning (OPT_Wvirtual_move_assign,
1522 "defaulted move assignment for %qT calls a non-trivial "
1523 "move assignment operator for virtual base %qT",
1527 vbases = CLASSTYPE_VBASECLASSES (ctype);
1528 if (vec_safe_is_empty (vbases))
1529 /* No virtual bases to worry about. */;
1533 *constexpr_p = false;
1534 FOR_EACH_VEC_ELT (*vbases, i, base_binfo)
1536 tree basetype = BINFO_TYPE (base_binfo);
1538 argtype = build_stub_type (basetype, quals, move_p);
1539 rval = locate_fn_flags (base_binfo, fnname, argtype, flags, complain);
1541 process_subob_fn (rval, spec_p, trivial_p, deleted_p,
1542 constexpr_p, diag, basetype);
1543 if (ctor_p && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (basetype))
1545 rval = locate_fn_flags (base_binfo, complete_dtor_identifier,
1546 NULL_TREE, flags, complain);
1547 process_subob_fn (rval, NULL, NULL,
1548 deleted_p, NULL, false,
1549 basetype, /*dtor_from_ctor*/true);
1554 /* Now handle the non-static data members. */
1555 walk_field_subobs (TYPE_FIELDS (ctype), fnname, sfk, quals,
1556 copy_arg_p, move_p, assign_p, spec_p, trivial_p,
1557 deleted_p, constexpr_p,
1558 diag, flags, complain, /*dtor_from_ctor*/false);
1560 walk_field_subobs (TYPE_FIELDS (ctype), complete_dtor_identifier,
1561 sfk_destructor, TYPE_UNQUALIFIED, false,
1562 false, false, NULL, NULL,
1564 false, flags, complain, /*dtor_from_ctor*/true);
1568 pop_deferring_access_checks ();
1569 --cp_unevaluated_operand;
1570 --c_inhibit_evaluation_warnings;
1573 /* DECL is a defaulted function whose exception specification is now
1574 needed. Return what it should be. */
1577 get_defaulted_eh_spec (tree decl)
1579 if (DECL_CLONED_FUNCTION_P (decl))
1580 decl = DECL_CLONED_FUNCTION (decl);
1581 special_function_kind sfk = special_function_p (decl);
1582 tree ctype = DECL_CONTEXT (decl);
1583 tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl);
1584 tree parm_type = TREE_VALUE (parms);
1585 bool const_p = CP_TYPE_CONST_P (non_reference (parm_type));
1586 tree spec = empty_except_spec;
1587 synthesized_method_walk (ctype, sfk, const_p, &spec, NULL, NULL,
1588 NULL, false, DECL_INHERITED_CTOR_BASE (decl),
1593 /* DECL is a deleted function. If it's implicitly deleted, explain why and
1594 return true; else return false. */
1597 maybe_explain_implicit_delete (tree decl)
1599 /* If decl is a clone, get the primary variant. */
1600 decl = DECL_ORIGIN (decl);
1601 gcc_assert (DECL_DELETED_FN (decl));
1602 if (DECL_DEFAULTED_FN (decl))
1604 /* Not marked GTY; it doesn't need to be GC'd or written to PCH. */
1605 static hash_set<tree> *explained;
1607 special_function_kind sfk;
1613 explained = new hash_set<tree>;
1614 if (explained->add (decl))
1617 sfk = special_function_p (decl);
1618 ctype = DECL_CONTEXT (decl);
1619 loc = input_location;
1620 input_location = DECL_SOURCE_LOCATION (decl);
1623 if (LAMBDA_TYPE_P (ctype))
1626 if (sfk == sfk_constructor)
1627 inform (DECL_SOURCE_LOCATION (decl),
1628 "a lambda closure type has a deleted default constructor");
1629 else if (sfk == sfk_copy_assignment)
1630 inform (DECL_SOURCE_LOCATION (decl),
1631 "a lambda closure type has a deleted copy assignment operator");
1635 else if (DECL_ARTIFICIAL (decl)
1636 && (sfk == sfk_copy_assignment
1637 || sfk == sfk_copy_constructor)
1638 && (type_has_user_declared_move_constructor (ctype)
1639 || type_has_user_declared_move_assign (ctype)))
1641 inform (0, "%q+#D is implicitly declared as deleted because %qT "
1642 "declares a move constructor or move assignment operator",
1648 tree parms = FUNCTION_FIRST_USER_PARMTYPE (decl);
1649 tree parm_type = TREE_VALUE (parms);
1650 bool const_p = CP_TYPE_CONST_P (non_reference (parm_type));
1651 tree raises = NULL_TREE;
1652 bool deleted_p = false;
1653 tree scope = push_scope (ctype);
1655 synthesized_method_walk (ctype, sfk, const_p,
1656 &raises, NULL, &deleted_p, NULL, false,
1657 DECL_INHERITED_CTOR_BASE (decl), parms);
1660 inform (0, "%q+#D is implicitly deleted because the default "
1661 "definition would be ill-formed:", decl);
1662 synthesized_method_walk (ctype, sfk, const_p,
1663 NULL, NULL, NULL, NULL, true,
1664 DECL_INHERITED_CTOR_BASE (decl), parms);
1666 else if (!comp_except_specs
1667 (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (decl)),
1669 inform (DECL_SOURCE_LOCATION (decl), "%q#F is implicitly "
1670 "deleted because its exception-specification does not "
1671 "match the implicit exception-specification %qX",
1673 #ifdef ENABLE_CHECKING
1681 input_location = loc;
1687 /* DECL is a defaulted function which was declared constexpr. Explain why
1688 it can't be constexpr. */
1691 explain_implicit_non_constexpr (tree decl)
1693 tree parm_type = TREE_VALUE (FUNCTION_FIRST_USER_PARMTYPE (decl));
1694 bool const_p = CP_TYPE_CONST_P (non_reference (parm_type));
1696 synthesized_method_walk (DECL_CLASS_CONTEXT (decl),
1697 special_function_p (decl), const_p,
1698 NULL, NULL, NULL, &dummy, true,
1699 DECL_INHERITED_CTOR_BASE (decl),
1700 FUNCTION_FIRST_USER_PARMTYPE (decl));
1703 /* DECL is an instantiation of an inheriting constructor template. Deduce
1704 the correct exception-specification and deletedness for this particular
1708 deduce_inheriting_ctor (tree decl)
1710 gcc_assert (DECL_INHERITED_CTOR_BASE (decl));
1712 bool trivial, constexpr_, deleted;
1713 synthesized_method_walk (DECL_CONTEXT (decl), sfk_inheriting_constructor,
1714 false, &spec, &trivial, &deleted, &constexpr_,
1716 DECL_INHERITED_CTOR_BASE (decl),
1717 FUNCTION_FIRST_USER_PARMTYPE (decl));
1718 DECL_DELETED_FN (decl) = deleted;
1719 TREE_TYPE (decl) = build_exception_variant (TREE_TYPE (decl), spec);
1722 /* Implicitly declare the special function indicated by KIND, as a
1723 member of TYPE. For copy constructors and assignment operators,
1724 CONST_P indicates whether these functions should take a const
1725 reference argument or a non-const reference. Returns the
1726 FUNCTION_DECL for the implicitly declared function. */
1729 implicitly_declare_fn (special_function_kind kind, tree type,
1730 bool const_p, tree inherited_ctor,
1731 tree inherited_parms)
1734 tree parameter_types = void_list_node;
1737 tree raises = empty_except_spec;
1738 tree rhs_parm_type = NULL_TREE;
1741 HOST_WIDE_INT saved_processing_template_decl;
1745 /* Because we create declarations for implicitly declared functions
1746 lazily, we may be creating the declaration for a member of TYPE
1747 while in some completely different context. However, TYPE will
1748 never be a dependent class (because we never want to do lookups
1749 for implicitly defined functions in a dependent class).
1750 Furthermore, we must set PROCESSING_TEMPLATE_DECL to zero here
1751 because we only create clones for constructors and destructors
1752 when not in a template. */
1753 gcc_assert (!dependent_type_p (type));
1754 saved_processing_template_decl = processing_template_decl;
1755 processing_template_decl = 0;
1757 type = TYPE_MAIN_VARIANT (type);
1759 if (targetm.cxx.cdtor_returns_this () && !TYPE_FOR_JAVA (type))
1761 if (kind == sfk_destructor)
1762 /* See comment in check_special_function_return_type. */
1763 return_type = build_pointer_type (void_type_node);
1765 return_type = build_pointer_type (type);
1768 return_type = void_type_node;
1772 case sfk_destructor:
1774 name = constructor_name (type);
1777 case sfk_constructor:
1778 /* Default constructor. */
1779 name = constructor_name (type);
1782 case sfk_copy_constructor:
1783 case sfk_copy_assignment:
1784 case sfk_move_constructor:
1785 case sfk_move_assignment:
1786 case sfk_inheriting_constructor:
1789 if (kind == sfk_copy_assignment
1790 || kind == sfk_move_assignment)
1792 return_type = build_reference_type (type);
1793 name = ansi_assopname (NOP_EXPR);
1796 name = constructor_name (type);
1798 if (kind == sfk_inheriting_constructor)
1799 parameter_types = inherited_parms;
1803 rhs_parm_type = cp_build_qualified_type (type, TYPE_QUAL_CONST);
1805 rhs_parm_type = type;
1806 move_p = (kind == sfk_move_assignment
1807 || kind == sfk_move_constructor);
1808 rhs_parm_type = cp_build_reference_type (rhs_parm_type, move_p);
1810 parameter_types = tree_cons (NULL_TREE, rhs_parm_type, parameter_types);
1818 tree inherited_base = (inherited_ctor
1819 ? DECL_CONTEXT (inherited_ctor)
1821 bool trivial_p = false;
1823 if (inherited_ctor && TREE_CODE (inherited_ctor) == TEMPLATE_DECL)
1825 /* For an inheriting constructor template, just copy these flags from
1826 the inherited constructor template for now. */
1827 raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (inherited_ctor));
1828 deleted_p = DECL_DELETED_FN (inherited_ctor);
1829 constexpr_p = DECL_DECLARED_CONSTEXPR_P (inherited_ctor);
1831 else if (cxx_dialect >= cxx11)
1833 raises = unevaluated_noexcept_spec ();
1834 synthesized_method_walk (type, kind, const_p, NULL, &trivial_p,
1835 &deleted_p, &constexpr_p, false,
1836 inherited_base, inherited_parms);
1839 synthesized_method_walk (type, kind, const_p, &raises, &trivial_p,
1840 &deleted_p, &constexpr_p, false,
1841 inherited_base, inherited_parms);
1842 /* Don't bother marking a deleted constructor as constexpr. */
1844 constexpr_p = false;
1845 /* A trivial copy/move constructor is also a constexpr constructor,
1846 unless the class has virtual bases (7.1.5p4). */
1847 else if (trivial_p && cxx_dialect >= cxx11
1848 && (kind == sfk_copy_constructor
1849 || kind == sfk_move_constructor)
1850 && !CLASSTYPE_VBASECLASSES (type))
1851 gcc_assert (constexpr_p);
1853 if (!trivial_p && type_has_trivial_fn (type, kind))
1854 type_set_nontrivial_flag (type, kind);
1856 /* Create the function. */
1857 fn_type = build_method_type_directly (type, return_type, parameter_types);
1859 fn_type = build_exception_variant (fn_type, raises);
1860 fn = build_lang_decl (FUNCTION_DECL, name, fn_type);
1861 if (kind != sfk_inheriting_constructor)
1862 DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (TYPE_NAME (type));
1863 if (kind == sfk_constructor || kind == sfk_copy_constructor
1864 || kind == sfk_move_constructor || kind == sfk_inheriting_constructor)
1865 DECL_CONSTRUCTOR_P (fn) = 1;
1866 else if (kind == sfk_destructor)
1867 DECL_DESTRUCTOR_P (fn) = 1;
1870 DECL_ASSIGNMENT_OPERATOR_P (fn) = 1;
1871 SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR);
1874 /* If pointers to member functions use the least significant bit to
1875 indicate whether a function is virtual, ensure a pointer
1876 to this function will have that bit clear. */
1877 if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
1878 && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT)
1879 DECL_ALIGN (fn) = 2 * BITS_PER_UNIT;
1881 /* Create the explicit arguments. */
1884 /* Note that this parameter is *not* marked DECL_ARTIFICIAL; we
1885 want its type to be included in the mangled function
1887 tree decl = cp_build_parm_decl (NULL_TREE, rhs_parm_type);
1888 TREE_READONLY (decl) = 1;
1889 retrofit_lang_decl (decl);
1890 DECL_PARM_INDEX (decl) = DECL_PARM_LEVEL (decl) = 1;
1891 DECL_ARGUMENTS (fn) = decl;
1893 else if (kind == sfk_inheriting_constructor)
1895 tree *p = &DECL_ARGUMENTS (fn);
1897 for (tree parm = inherited_parms; parm != void_list_node;
1898 parm = TREE_CHAIN (parm))
1900 *p = cp_build_parm_decl (NULL_TREE, TREE_VALUE (parm));
1901 retrofit_lang_decl (*p);
1902 DECL_PARM_LEVEL (*p) = 1;
1903 DECL_PARM_INDEX (*p) = index++;
1904 DECL_CONTEXT (*p) = fn;
1905 p = &DECL_CHAIN (*p);
1907 SET_DECL_INHERITED_CTOR_BASE (fn, inherited_base);
1908 DECL_NONCONVERTING_P (fn) = DECL_NONCONVERTING_P (inherited_ctor);
1909 /* A constructor so declared has the same access as the corresponding
1910 constructor in X. */
1911 TREE_PRIVATE (fn) = TREE_PRIVATE (inherited_ctor);
1912 TREE_PROTECTED (fn) = TREE_PROTECTED (inherited_ctor);
1913 /* Copy constexpr from the inherited constructor even if the
1914 inheriting constructor doesn't satisfy the requirements. */
1915 constexpr_p = DECL_DECLARED_CONSTEXPR_P (inherited_ctor);
1917 /* Add the "this" parameter. */
1918 this_parm = build_this_parm (fn_type, TYPE_UNQUALIFIED);
1919 DECL_CHAIN (this_parm) = DECL_ARGUMENTS (fn);
1920 DECL_ARGUMENTS (fn) = this_parm;
1922 grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL);
1923 DECL_IN_AGGR_P (fn) = 1;
1924 DECL_ARTIFICIAL (fn) = 1;
1925 DECL_DEFAULTED_FN (fn) = 1;
1926 if (cxx_dialect >= cxx11)
1928 /* "The closure type associated with a lambda-expression has a deleted
1929 default constructor and a deleted copy assignment operator." */
1930 if ((kind == sfk_constructor
1931 || kind == sfk_copy_assignment)
1932 && LAMBDA_TYPE_P (type))
1934 DECL_DELETED_FN (fn) = deleted_p;
1935 DECL_DECLARED_CONSTEXPR_P (fn) = constexpr_p;
1937 DECL_EXTERNAL (fn) = true;
1938 DECL_NOT_REALLY_EXTERN (fn) = 1;
1939 DECL_DECLARED_INLINE_P (fn) = 1;
1940 DECL_COMDAT (fn) = 1;
1941 set_linkage_according_to_type (type, fn);
1942 rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);
1943 gcc_assert (!TREE_USED (fn));
1945 /* Restore PROCESSING_TEMPLATE_DECL. */
1946 processing_template_decl = saved_processing_template_decl;
1948 if (inherited_ctor && TREE_CODE (inherited_ctor) == TEMPLATE_DECL)
1949 fn = add_inherited_template_parms (fn, inherited_ctor);
1951 /* Warn about calling a non-trivial move assignment in a virtual base. */
1952 if (kind == sfk_move_assignment && !deleted_p && !trivial_p
1953 && CLASSTYPE_VBASECLASSES (type))
1955 location_t loc = input_location;
1956 input_location = DECL_SOURCE_LOCATION (fn);
1957 synthesized_method_walk (type, kind, const_p,
1958 NULL, NULL, NULL, NULL, true,
1959 NULL_TREE, NULL_TREE);
1960 input_location = loc;
1966 /* Gives any errors about defaulted functions which need to be deferred
1967 until the containing class is complete. */
1970 defaulted_late_check (tree fn)
1972 /* Complain about invalid signature for defaulted fn. */
1973 tree ctx = DECL_CONTEXT (fn);
1974 special_function_kind kind = special_function_p (fn);
1975 bool fn_const_p = (copy_fn_p (fn) == 2);
1976 tree implicit_fn = implicitly_declare_fn (kind, ctx, fn_const_p,
1978 tree eh_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (implicit_fn));
1980 if (!same_type_p (TREE_TYPE (TREE_TYPE (fn)),
1981 TREE_TYPE (TREE_TYPE (implicit_fn)))
1982 || !compparms (TYPE_ARG_TYPES (TREE_TYPE (fn)),
1983 TYPE_ARG_TYPES (TREE_TYPE (implicit_fn))))
1985 error ("defaulted declaration %q+D", fn);
1986 error_at (DECL_SOURCE_LOCATION (fn),
1987 "does not match expected signature %qD", implicit_fn);
1990 /* 8.4.2/2: An explicitly-defaulted function (...) may have an explicit
1991 exception-specification only if it is compatible (15.4) with the
1992 exception-specification on the implicit declaration. If a function
1993 is explicitly defaulted on its first declaration, (...) it is
1994 implicitly considered to have the same exception-specification as if
1995 it had been implicitly declared. */
1996 maybe_instantiate_noexcept (fn);
1997 tree fn_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
2000 if (DECL_DEFAULTED_IN_CLASS_P (fn))
2001 TREE_TYPE (fn) = build_exception_variant (TREE_TYPE (fn), eh_spec);
2003 else if (UNEVALUATED_NOEXCEPT_SPEC_P (fn_spec))
2004 /* Equivalent to the implicit spec. */;
2005 else if (DECL_DEFAULTED_IN_CLASS_P (fn)
2006 && !CLASSTYPE_TEMPLATE_INSTANTIATION (ctx))
2007 /* We can't compare an explicit exception-specification on a
2008 constructor defaulted in the class body to the implicit
2009 exception-specification until after we've parsed any NSDMI; see
2010 after_nsdmi_defaulted_late_checks. */;
2013 tree eh_spec = get_defaulted_eh_spec (fn);
2014 if (!comp_except_specs (fn_spec, eh_spec, ce_normal))
2016 if (DECL_DEFAULTED_IN_CLASS_P (fn))
2017 DECL_DELETED_FN (fn) = true;
2019 error ("function %q+D defaulted on its redeclaration "
2020 "with an exception-specification that differs from "
2021 "the implicit exception-specification %qX", fn, eh_spec);
2025 if (DECL_DEFAULTED_IN_CLASS_P (fn)
2026 && DECL_DECLARED_CONSTEXPR_P (implicit_fn))
2028 /* Hmm...should we do this for out-of-class too? Should it be OK to
2029 add constexpr later like inline, rather than requiring
2030 declarations to match? */
2031 DECL_DECLARED_CONSTEXPR_P (fn) = true;
2032 if (kind == sfk_constructor)
2033 TYPE_HAS_CONSTEXPR_CTOR (ctx) = true;
2036 if (!DECL_DECLARED_CONSTEXPR_P (implicit_fn)
2037 && DECL_DECLARED_CONSTEXPR_P (fn))
2039 if (!CLASSTYPE_TEMPLATE_INSTANTIATION (ctx))
2041 error ("explicitly defaulted function %q+D cannot be declared "
2042 "as constexpr because the implicit declaration is not "
2044 explain_implicit_non_constexpr (fn);
2046 DECL_DECLARED_CONSTEXPR_P (fn) = false;
2049 if (DECL_DELETED_FN (implicit_fn))
2050 DECL_DELETED_FN (fn) = 1;
2053 /* OK, we've parsed the NSDMI for class T, now we can check any explicit
2054 exception-specifications on functions defaulted in the class body. */
2057 after_nsdmi_defaulted_late_checks (tree t)
2059 if (uses_template_parms (t))
2061 if (t == error_mark_node)
2063 for (tree fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn))
2064 if (!DECL_ARTIFICIAL (fn) && DECL_DEFAULTED_IN_CLASS_P (fn))
2066 tree fn_spec = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn));
2067 if (UNEVALUATED_NOEXCEPT_SPEC_P (fn_spec))
2070 tree eh_spec = get_defaulted_eh_spec (fn);
2071 if (!comp_except_specs (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)),
2072 eh_spec, ce_normal))
2073 DECL_DELETED_FN (fn) = true;
2077 /* Returns true iff FN can be explicitly defaulted, and gives any
2078 errors if defaulting FN is ill-formed. */
2081 defaultable_fn_check (tree fn)
2083 special_function_kind kind = sfk_none;
2085 if (template_parm_scope_p ())
2087 error ("a template cannot be defaulted");
2091 if (DECL_CONSTRUCTOR_P (fn))
2093 if (FUNCTION_FIRST_USER_PARMTYPE (fn) == void_list_node)
2094 kind = sfk_constructor;
2095 else if (copy_fn_p (fn) > 0
2096 && (TREE_CHAIN (FUNCTION_FIRST_USER_PARMTYPE (fn))
2098 kind = sfk_copy_constructor;
2099 else if (move_fn_p (fn))
2100 kind = sfk_move_constructor;
2102 else if (DECL_DESTRUCTOR_P (fn))
2103 kind = sfk_destructor;
2104 else if (DECL_ASSIGNMENT_OPERATOR_P (fn)
2105 && DECL_OVERLOADED_OPERATOR_P (fn) == NOP_EXPR)
2108 kind = sfk_copy_assignment;
2109 else if (move_fn_p (fn))
2110 kind = sfk_move_assignment;
2113 if (kind == sfk_none)
2115 error ("%qD cannot be defaulted", fn);
2120 for (tree t = FUNCTION_FIRST_USER_PARMTYPE (fn);
2121 t && t != void_list_node; t = TREE_CHAIN (t))
2122 if (TREE_PURPOSE (t))
2124 error ("defaulted function %q+D with default argument", fn);
2128 /* Avoid do_warn_unused_parameter warnings. */
2129 for (tree p = FUNCTION_FIRST_USER_PARM (fn); p; p = DECL_CHAIN (p))
2131 TREE_NO_WARNING (p) = 1;
2133 if (TYPE_BEING_DEFINED (DECL_CONTEXT (fn)))
2134 /* Defer checking. */;
2135 else if (!processing_template_decl)
2136 defaulted_late_check (fn);
2142 /* Add an implicit declaration to TYPE for the kind of function
2143 indicated by SFK. Return the FUNCTION_DECL for the new implicit
2147 lazily_declare_fn (special_function_kind sfk, tree type)
2150 /* Whether or not the argument has a const reference type. */
2151 bool const_p = false;
2155 case sfk_constructor:
2156 CLASSTYPE_LAZY_DEFAULT_CTOR (type) = 0;
2158 case sfk_copy_constructor:
2159 const_p = TYPE_HAS_CONST_COPY_CTOR (type);
2160 CLASSTYPE_LAZY_COPY_CTOR (type) = 0;
2162 case sfk_move_constructor:
2163 CLASSTYPE_LAZY_MOVE_CTOR (type) = 0;
2165 case sfk_copy_assignment:
2166 const_p = TYPE_HAS_CONST_COPY_ASSIGN (type);
2167 CLASSTYPE_LAZY_COPY_ASSIGN (type) = 0;
2169 case sfk_move_assignment:
2170 CLASSTYPE_LAZY_MOVE_ASSIGN (type) = 0;
2172 case sfk_destructor:
2173 CLASSTYPE_LAZY_DESTRUCTOR (type) = 0;
2179 /* Declare the function. */
2180 fn = implicitly_declare_fn (sfk, type, const_p, NULL, NULL);
2182 /* [class.copy]/8 If the class definition declares a move constructor or
2183 move assignment operator, the implicitly declared copy constructor is
2184 defined as deleted.... */
2185 if ((sfk == sfk_copy_assignment
2186 || sfk == sfk_copy_constructor)
2187 && (type_has_user_declared_move_constructor (type)
2188 || type_has_user_declared_move_assign (type)))
2189 DECL_DELETED_FN (fn) = true;
2191 /* A destructor may be virtual. */
2192 if (sfk == sfk_destructor
2193 || sfk == sfk_move_assignment
2194 || sfk == sfk_copy_assignment)
2195 check_for_override (fn, type);
2196 /* Add it to CLASSTYPE_METHOD_VEC. */
2197 add_method (type, fn, NULL_TREE);
2198 /* Add it to TYPE_METHODS. */
2199 if (sfk == sfk_destructor
2200 && DECL_VIRTUAL_P (fn))
2201 /* The ABI requires that a virtual destructor go at the end of the
2203 TYPE_METHODS (type) = chainon (TYPE_METHODS (type), fn);
2206 DECL_CHAIN (fn) = TYPE_METHODS (type);
2207 TYPE_METHODS (type) = fn;
2209 maybe_add_class_template_decl_list (type, fn, /*friend_p=*/0);
2210 if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn)
2211 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn))
2212 /* Create appropriate clones. */
2213 clone_function_decl (fn, /*update_method_vec=*/true);
2218 /* Given a FUNCTION_DECL FN and a chain LIST, skip as many elements of LIST
2219 as there are artificial parms in FN. */
2222 skip_artificial_parms_for (const_tree fn, tree list)
2224 if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
2225 list = TREE_CHAIN (list);
2229 if (DECL_HAS_IN_CHARGE_PARM_P (fn))
2230 list = TREE_CHAIN (list);
2231 if (DECL_HAS_VTT_PARM_P (fn))
2232 list = TREE_CHAIN (list);
2236 /* Given a FUNCTION_DECL FN and a chain LIST, return the number of
2237 artificial parms in FN. */
2240 num_artificial_parms_for (const_tree fn)
2244 if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
2249 if (DECL_HAS_IN_CHARGE_PARM_P (fn))
2251 if (DECL_HAS_VTT_PARM_P (fn))
2257 #include "gt-cp-method.h"