2017-06-16 Nathan Sidwell <nathan@acm.org>
+ * cp-tree.h (build_this_parm, cp_build_parm_decl,
+ build_artificial_parm): Add FN parm.
+ * decl.c (start_cleanup_fn): Adjust.
+ (build_this_parm): Add FN parm, pass it through.
+ (grokfndecl): Adjust parm building.
+ * decl2.c (cp_build_parm_decl): Add FN parm, set context.
+ (build_artificial_parm): Add FN parm, pass through.
+ (maybe_retrofit_in_chrg): Adjust parm building.
+ (start_static_storage_duration_function): Likwise.
+ * lambda.c (maybe_aadd_lambda_conv_op): Likewise.
+ * method.c (implicitly_declare_fn): Likewise.
+ * parser.c (inject_this_parameter): Likewise.
+
Symbol tables are insert only.
* cp-tree.h (default_hash_traits <lang_identifier *>): Don't
derive from pointer_hash. Make undeletable.
extern tree build_ptrmemfunc_type (tree);
extern tree build_ptrmem_type (tree, tree);
/* the grokdeclarator prototype is in decl.h */
-extern tree build_this_parm (tree, cp_cv_quals);
+extern tree build_this_parm (tree, tree, cp_cv_quals);
extern tree grokparms (tree, tree *);
extern int copy_fn_p (const_tree);
extern bool move_fn_p (const_tree);
extern bool mark_used (tree);
extern bool mark_used (tree, tsubst_flags_t);
extern void finish_static_data_member_decl (tree, tree, bool, tree, int);
-extern tree cp_build_parm_decl (tree, tree);
+extern tree cp_build_parm_decl (tree, tree, tree);
extern tree get_guard (tree);
extern tree get_guard_cond (tree, bool);
extern tree set_guard (tree);
extern bool decl_needed_p (tree);
extern void note_vague_linkage_fn (tree);
extern void note_variable_template_instantiation (tree);
-extern tree build_artificial_parm (tree, tree);
+extern tree build_artificial_parm (tree, tree, tree);
extern bool possibly_inlined_p (tree);
extern int parm_index (tree);
extern tree vtv_start_verification_constructor_init_function (void);
/* Build the parameter. */
if (use_cxa_atexit)
{
- tree parmdecl;
-
- parmdecl = cp_build_parm_decl (NULL_TREE, ptr_type_node);
- DECL_CONTEXT (parmdecl) = fndecl;
+ tree parmdecl = cp_build_parm_decl (fndecl, NULL_TREE, ptr_type_node);
TREE_USED (parmdecl) = 1;
DECL_READ_P (parmdecl) = 1;
DECL_ARGUMENTS (fndecl) = parmdecl;
decl, DECL_CONTEXT (decl));
}
-/* Build a PARM_DECL for the "this" parameter. TYPE is the
+/* Build a PARM_DECL for the "this" parameter of FN. TYPE is the
METHOD_TYPE for a non-static member function; QUALS are the
cv-qualifiers that apply to the function. */
tree
-build_this_parm (tree type, cp_cv_quals quals)
+build_this_parm (tree fn, tree type, cp_cv_quals quals)
{
tree this_type;
tree qual_type;
assigned to. */
this_quals = (quals & TYPE_QUAL_RESTRICT) | TYPE_QUAL_CONST;
qual_type = cp_build_qualified_type (this_type, this_quals);
- parm = build_artificial_parm (this_identifier, qual_type);
+ parm = build_artificial_parm (fn, this_identifier, qual_type);
cp_apply_type_quals_to_decl (this_quals, parm);
return parm;
}
if (TREE_CODE (type) == METHOD_TYPE)
{
- tree parm;
- parm = build_this_parm (type, quals);
+ tree parm = build_this_parm (decl, type, quals);
DECL_CHAIN (parm) = parms;
parms = parm;
args && args != void_list_node;
args = TREE_CHAIN (args))
{
- tree decl = cp_build_parm_decl (NULL_TREE, TREE_VALUE (args));
+ tree decl = cp_build_parm_decl (NULL_TREE, NULL_TREE,
+ TREE_VALUE (args));
DECL_CHAIN (decl) = decls;
decls = decl;
if (decl_context == PARM)
{
- decl = cp_build_parm_decl (unqualified_id, type);
+ decl = cp_build_parm_decl (NULL_TREE, unqualified_id, type);
DECL_ARRAY_PARAMETER_P (decl) = array_parameter_p;
bad_specifiers (decl, BSP_PARM, virtualp,
return newtype;
}
-/* Build a PARM_DECL with NAME and TYPE, and set DECL_ARG_TYPE
+/* Build a PARM_DECL of FN with NAME and TYPE, and set DECL_ARG_TYPE
appropriately. */
tree
-cp_build_parm_decl (tree name, tree type)
+cp_build_parm_decl (tree fn, tree name, tree type)
{
tree parm = build_decl (input_location,
PARM_DECL, name, type);
+ DECL_CONTEXT (parm) = fn;
+
/* DECL_ARG_TYPE is only used by the back end and the back end never
sees templates. */
if (!processing_template_decl)
return parm;
}
-/* Returns a PARM_DECL for a parameter of the indicated TYPE, with the
+/* Returns a PARM_DECL of FN for a parameter of the indicated TYPE, with the
indicated NAME. */
tree
-build_artificial_parm (tree name, tree type)
+build_artificial_parm (tree fn, tree name, tree type)
{
- tree parm = cp_build_parm_decl (name, type);
+ tree parm = cp_build_parm_decl (fn, name, type);
DECL_ARTIFICIAL (parm) = 1;
/* All our artificial parms are implicitly `const'; they cannot be
assigned to. */
pass us a pointer to our VTT. */
if (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fn)))
{
- parm = build_artificial_parm (vtt_parm_identifier, vtt_parm_type);
+ parm = build_artificial_parm (fn, vtt_parm_identifier, vtt_parm_type);
/* First add it to DECL_ARGUMENTS between 'this' and the real args... */
DECL_CHAIN (parm) = parms;
}
/* Then add the in-charge parm (before the VTT parm). */
- parm = build_artificial_parm (in_charge_identifier, integer_type_node);
+ parm = build_artificial_parm (fn, in_charge_identifier, integer_type_node);
DECL_CHAIN (parm) = parms;
parms = parm;
arg_types = hash_tree_chain (integer_type_node, arg_types);
/* Create the argument list. */
initialize_p_decl = cp_build_parm_decl
- (get_identifier (INITIALIZE_P_IDENTIFIER), integer_type_node);
- DECL_CONTEXT (initialize_p_decl) = ssdf_decl;
+ (ssdf_decl, get_identifier (INITIALIZE_P_IDENTIFIER), integer_type_node);
TREE_USED (initialize_p_decl) = 1;
priority_decl = cp_build_parm_decl
- (get_identifier (PRIORITY_IDENTIFIER), integer_type_node);
- DECL_CONTEXT (priority_decl) = ssdf_decl;
+ (ssdf_decl, get_identifier (PRIORITY_IDENTIFIER), integer_type_node);
TREE_USED (priority_decl) = 1;
DECL_CHAIN (initialize_p_decl) = priority_decl;
DECL_ARTIFICIAL (fn) = 1;
DECL_NOT_REALLY_EXTERN (fn) = 1;
DECL_DECLARED_INLINE_P (fn) = 1;
- DECL_ARGUMENTS (fn) = build_this_parm (fntype, TYPE_QUAL_CONST);
+ DECL_ARGUMENTS (fn) = build_this_parm (fn, fntype, TYPE_QUAL_CONST);
+
if (nested_def)
DECL_INTERFACE_KNOWN (fn) = 1;
/* Note that this parameter is *not* marked DECL_ARTIFICIAL; we
want its type to be included in the mangled function
name. */
- tree decl = cp_build_parm_decl (NULL_TREE, rhs_parm_type);
+ tree decl = cp_build_parm_decl (fn, NULL_TREE, rhs_parm_type);
TREE_READONLY (decl) = 1;
retrofit_lang_decl (decl);
DECL_PARM_INDEX (decl) = DECL_PARM_LEVEL (decl) = 1;
for (tree parm = inherited_parms; parm && parm != void_list_node;
parm = TREE_CHAIN (parm))
{
- *p = cp_build_parm_decl (NULL_TREE, TREE_VALUE (parm));
+ *p = cp_build_parm_decl (fn, NULL_TREE, TREE_VALUE (parm));
retrofit_lang_decl (*p);
DECL_PARM_LEVEL (*p) = 1;
DECL_PARM_INDEX (*p) = index++;
- DECL_CONTEXT (*p) = fn;
p = &DECL_CHAIN (*p);
}
SET_DECL_INHERITED_CTOR (fn, inherited_ctor);
constexpr_p = DECL_DECLARED_CONSTEXPR_P (inherited_ctor);
}
/* Add the "this" parameter. */
- this_parm = build_this_parm (fn_type, TYPE_UNQUALIFIED);
+ this_parm = build_this_parm (fn, fn_type, TYPE_UNQUALIFIED);
DECL_CHAIN (this_parm) = DECL_ARGUMENTS (fn);
DECL_ARGUMENTS (fn) = this_parm;
return;
}
- this_parm = build_this_parm (ctype, quals);
+ this_parm = build_this_parm (NULL_TREE, ctype, quals);
/* Clear this first to avoid shortcut in cp_build_indirect_ref. */
current_class_ptr = NULL_TREE;
current_class_ref
+2017-06-16 Nathan Sidwell <nathan@acm.org>
+
+ * libcp1plugin.cc (plugin_build_decl): Adjust parm building.
+
2017-05-26 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_make_namespace_inline): Push onto linees.
overloading. */
SET_DECL_LANGUAGE (decl, lang_cplusplus);
if (TREE_CODE (sym_type) == METHOD_TYPE)
- DECL_ARGUMENTS (decl) = build_this_parm (current_class_type,
+ DECL_ARGUMENTS (decl) = build_this_parm (decl, current_class_type,
cp_type_quals (sym_type));
for (tree arg = TREE_CODE (sym_type) == METHOD_TYPE
? TREE_CHAIN (TYPE_ARG_TYPES (sym_type))
arg && arg != void_list_node;
arg = TREE_CHAIN (arg))
{
- tree parm = cp_build_parm_decl (NULL_TREE, TREE_VALUE (arg));
+ tree parm = cp_build_parm_decl (decl, NULL_TREE, TREE_VALUE (arg));
DECL_CHAIN (parm) = DECL_ARGUMENTS (decl);
DECL_ARGUMENTS (decl) = parm;
}