gcc/gcc/cp/rtti.c

1176 lines
33 KiB
C
Raw Normal View History

1996-02-01 20:33:01 +01:00
/* RunTime Type Identification
Copyright (C) 1995, 96-97, 1998, 1999 Free Software Foundation, Inc.
Mostly written by Jason Merrill (jason@cygnus.com).
1996-02-01 20:33:01 +01:00
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
1996-02-01 20:33:01 +01:00
#include "tree.h"
#include "cp-tree.h"
#include "flags.h"
#include "output.h"
1996-09-12 21:19:15 +02:00
#include "assert.h"
#include "toplev.h"
1996-02-01 20:33:01 +01:00
#ifndef INT_TYPE_SIZE
#define INT_TYPE_SIZE BITS_PER_WORD
#endif
1997-08-20 00:37:19 +02:00
extern struct obstack permanent_obstack;
1996-02-01 20:33:01 +01:00
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
static tree call_void_fn PROTO((const char *));
static tree build_headof_sub PROTO((tree));
static tree build_headof PROTO((tree));
static tree get_tinfo_var PROTO((tree));
static tree ifnonnull PROTO((tree, tree));
static tree build_dynamic_cast_1 PROTO((tree, tree));
static void expand_si_desc PROTO((tree, tree));
static void expand_class_desc PROTO((tree, tree));
static void expand_attr_desc PROTO((tree, tree));
static void expand_ptr_desc PROTO((tree, tree));
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
static void expand_generic_desc PROTO((tree, tree, const char *));
static tree throw_bad_cast PROTO((void));
static tree throw_bad_typeid PROTO((void));
tree type_info_type_node;
tree tinfo_fn_id;
tree tinfo_fn_type;
1996-02-01 20:33:01 +01:00
void
init_rtti_processing ()
{
if (flag_honor_std)
push_namespace (get_identifier ("std"));
type_info_type_node = xref_tag
(class_type_node, get_identifier ("type_info"), 1);
if (flag_honor_std)
pop_namespace ();
tinfo_fn_id = get_identifier ("__tf");
tinfo_fn_type = build_function_type
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
(build_reference_type (build_qualified_type (type_info_type_node,
TYPE_QUAL_CONST)),
void_list_node);
}
/* Given a pointer to an object with at least one virtual table
pointer somewhere, return a pointer to a possible sub-object that
has a virtual table pointer in it that is the vtable parent for
that sub-object. */
1996-07-11 03:13:25 +02:00
static tree
build_headof_sub (exp)
tree exp;
{
tree type = TREE_TYPE (TREE_TYPE (exp));
tree basetype = CLASSTYPE_RTTI (type);
tree binfo = get_binfo (basetype, type, 0);
exp = convert_pointer_to_real (binfo, exp);
return exp;
}
/* Given the expression EXP of type `class *', return the head of the
object pointed to by EXP with type cv void*, if the class has any
virtual functions (TYPE_VIRTUAL_P), else just return the
expression. */
1996-07-11 03:13:25 +02:00
static tree
1996-02-01 20:33:01 +01:00
build_headof (exp)
tree exp;
{
tree type = TREE_TYPE (exp);
tree aref;
tree offset;
1996-02-01 20:33:01 +01:00
if (TREE_CODE (type) != POINTER_TYPE)
{
error ("`headof' applied to non-pointer type");
1996-02-01 20:33:01 +01:00
return error_mark_node;
}
type = TREE_TYPE (type);
if (!TYPE_VIRTUAL_P (type))
1996-02-01 20:33:01 +01:00
return exp;
if (CLASSTYPE_COM_INTERFACE (type))
{
cp_error ("RTTI not supported for COM interface type `%T'", type);
return error_mark_node;
}
1996-02-01 20:33:01 +01:00
/* If we don't have rtti stuff, get to a sub-object that does. */
if (!CLASSTYPE_VFIELDS (TREE_TYPE (TREE_TYPE (exp))))
exp = build_headof_sub (exp);
/* We use this a couple of times below, protect it. */
exp = save_expr (exp);
aref = build_vtbl_ref (build_indirect_ref (exp, NULL_PTR), integer_zero_node);
1996-02-01 20:33:01 +01:00
if (flag_vtable_thunks)
offset = aref;
1996-02-01 20:33:01 +01:00
else
offset = build_component_ref (aref, delta_identifier, NULL_TREE, 0);
1996-02-01 20:33:01 +01:00
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
type = build_qualified_type (ptr_type_node,
CP_TYPE_QUALS (TREE_TYPE (exp)));
1996-02-01 20:33:01 +01:00
return build (PLUS_EXPR, type, exp,
cp_convert (ptrdiff_type_node, offset));
1996-02-01 20:33:01 +01:00
}
/* Build a call to a generic entry point taking and returning void. */
static tree
call_void_fn (name)
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *name;
{
tree d = get_identifier (name);
tree type;
if (IDENTIFIER_GLOBAL_VALUE (d))
d = IDENTIFIER_GLOBAL_VALUE (d);
else
{
push_obstacks (&permanent_obstack, &permanent_obstack);
type = build_function_type (void_type_node, void_list_node);
d = build_lang_decl (FUNCTION_DECL, d, type);
DECL_EXTERNAL (d) = 1;
TREE_PUBLIC (d) = 1;
DECL_ARTIFICIAL (d) = 1;
pushdecl_top_level (d);
make_function_rtl (d);
pop_obstacks ();
}
mark_used (d);
return build_call (d, void_type_node, NULL_TREE);
}
/* Get a bad_cast node for the program to throw...
See libstdc++/exception.cc for __throw_bad_cast */
static tree
throw_bad_cast ()
{
return call_void_fn ("__throw_bad_cast");
}
static tree
throw_bad_typeid ()
{
return call_void_fn ("__throw_bad_typeid");
}
1996-02-01 20:33:01 +01:00
/* Return the type_info function associated with the expression EXP. If
EXP is a reference to a polymorphic class, return the dynamic type;
otherwise return the static type of the expression. */
1996-07-11 03:13:25 +02:00
1996-02-01 20:33:01 +01:00
tree
get_tinfo_fn_dynamic (exp)
1996-02-01 20:33:01 +01:00
tree exp;
{
tree type;
if (exp == error_mark_node)
return error_mark_node;
if (type_unknown_p (exp))
{
error ("typeid of overloaded function");
return error_mark_node;
}
1996-02-01 20:33:01 +01:00
type = TREE_TYPE (exp);
1996-07-11 03:13:25 +02:00
/* peel back references, so they match. */
1996-02-01 20:33:01 +01:00
if (TREE_CODE (type) == REFERENCE_TYPE)
type = TREE_TYPE (type);
1996-07-11 03:13:25 +02:00
/* Peel off cv qualifiers. */
1996-02-01 20:33:01 +01:00
type = TYPE_MAIN_VARIANT (type);
if (TYPE_SIZE (complete_type (type)) == NULL_TREE)
{
cp_error ("taking typeid of incomplete type `%T'", type);
return error_mark_node;
}
1996-02-01 20:33:01 +01:00
/* If exp is a reference to polymorphic type, get the real type_info. */
if (TYPE_VIRTUAL_P (type) && ! resolves_to_fixed_type_p (exp, 0))
1996-02-01 20:33:01 +01:00
{
/* build reference to type_info from vtable. */
tree t;
if (! flag_rtti)
error ("taking dynamic typeid of object with -fno-rtti");
if (CLASSTYPE_COM_INTERFACE (type))
{
cp_error ("RTTI not supported for COM interface type `%T'", type);
return error_mark_node;
}
/* If we don't have rtti stuff, get to a sub-object that does. */
if (! CLASSTYPE_VFIELDS (type))
{
exp = build_unary_op (ADDR_EXPR, exp, 0);
exp = build_headof_sub (exp);
exp = build_indirect_ref (exp, NULL_PTR);
}
1996-02-01 20:33:01 +01:00
if (flag_vtable_thunks)
t = build_vfn_ref ((tree *) 0, exp, integer_one_node);
1996-02-01 20:33:01 +01:00
else
t = build_vfn_ref ((tree *) 0, exp, integer_zero_node);
TREE_TYPE (t) = build_pointer_type (tinfo_fn_type);
return t;
1996-02-01 20:33:01 +01:00
}
/* otherwise return the type_info for the static type of the expr. */
return get_tinfo_fn (TYPE_MAIN_VARIANT (type));
}
tree
build_typeid (exp)
tree exp;
{
exp = get_tinfo_fn_dynamic (exp);
exp = build_call (exp, TREE_TYPE (tinfo_fn_type), NULL_TREE);
return convert_from_reference (exp);
}
tree
build_x_typeid (exp)
tree exp;
{
tree cond = NULL_TREE;
tree type = TREE_TYPE (tinfo_fn_type);
int nonnull;
if (TYPE_SIZE (type_info_type_node) == NULL_TREE)
{
error ("must #include <typeinfo> before using typeid");
return error_mark_node;
}
if (processing_template_decl)
return build_min_nt (TYPEID_EXPR, exp);
if (TREE_CODE (exp) == INDIRECT_REF
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == POINTER_TYPE
&& TYPE_VIRTUAL_P (TREE_TYPE (exp))
&& ! resolves_to_fixed_type_p (exp, &nonnull)
&& ! nonnull)
{
exp = stabilize_reference (exp);
cond = cp_convert (boolean_type_node, TREE_OPERAND (exp, 0));
}
exp = get_tinfo_fn_dynamic (exp);
if (exp == error_mark_node)
return error_mark_node;
exp = build_call (exp, type, NULL_TREE);
if (cond)
{
tree bad = throw_bad_typeid ();
bad = build_compound_expr
(expr_tree_cons (NULL_TREE, bad, build_expr_list
(NULL_TREE, cp_convert (type, integer_zero_node))));
exp = build (COND_EXPR, type, cond, exp, bad);
}
return convert_from_reference (exp);
1996-02-01 20:33:01 +01:00
}
static tree
get_tinfo_var (type)
tree type;
{
tree tname = build_overload_with_type (get_identifier ("__ti"), type);
tree tdecl, arrtype;
int size;
if (IDENTIFIER_GLOBAL_VALUE (tname))
return IDENTIFIER_GLOBAL_VALUE (tname);
/* Figure out how much space we need to allocate for the type_info object.
If our struct layout or the type_info classes are changed, this will
need to be modified. */
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
if (TYPE_QUALS (type) != TYPE_UNQUALIFIED)
size = 3 * POINTER_SIZE + INT_TYPE_SIZE;
else if (TREE_CODE (type) == POINTER_TYPE
&& ! (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE
|| TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE))
size = 3 * POINTER_SIZE;
else if (IS_AGGR_TYPE (type))
{
if (CLASSTYPE_N_BASECLASSES (type) == 0)
size = 2 * POINTER_SIZE;
else if (! TYPE_USES_COMPLEX_INHERITANCE (type)
&& (TREE_VIA_PUBLIC
(TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0))))
size = 3 * POINTER_SIZE;
else
size = 3 * POINTER_SIZE + TYPE_PRECISION (sizetype);
}
else
size = 2 * POINTER_SIZE;
push_obstacks (&permanent_obstack, &permanent_obstack);
/* The type for a character array of the appropriate size. */
arrtype = build_cplus_array_type
(unsigned_char_type_node,
build_index_type (size_int (size / BITS_PER_UNIT - 1)));
tdecl = build_decl (VAR_DECL, tname, arrtype);
TREE_PUBLIC (tdecl) = 1;
DECL_EXTERNAL (tdecl) = 1;
DECL_ARTIFICIAL (tdecl) = 1;
pushdecl_top_level (tdecl);
cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
pop_obstacks ();
return tdecl;
}
tree
get_tinfo_fn (type)
tree type;
{
tree name;
tree d;
if (TREE_CODE (type) == OFFSET_TYPE)
type = TREE_TYPE (type);
if (TREE_CODE (type) == METHOD_TYPE)
type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (type)));
name = build_overload_with_type (tinfo_fn_id, type);
if (IDENTIFIER_GLOBAL_VALUE (name))
return IDENTIFIER_GLOBAL_VALUE (name);
push_obstacks (&permanent_obstack, &permanent_obstack);
d = build_lang_decl (FUNCTION_DECL, name, tinfo_fn_type);
DECL_EXTERNAL (d) = 1;
TREE_PUBLIC (d) = 1;
DECL_ARTIFICIAL (d) = 1;
DECL_NOT_REALLY_EXTERN (d) = 1;
cp-tree.h (lang_decl_flags): Remove returns_first_arg and preserves_first_arg. * cp-tree.h (lang_decl_flags): Remove returns_first_arg and preserves_first_arg. Enlarge dummy accordingly. (DECL_TINFO_FN_P): New macro. (SET_DECL_TINO_FN_P): Likeiwse. (DECL_RETURNS_FIRST_ARG): Remove. (DECL_PRESERVES_THIS): Likewise. (DECL_INIT_PRIORITY): New macro. (finish_struct_1): Change prototype. (cat_namespace_levels): Remove prototype. (vtable_decl_p): New prototype. (vtype_decl_p): Likewise. (sigtable_decl_p): Likewise. (walk_globals_pred): New typedef. (walk_globals_fn): Likewise. (walk_globals): New prototype. (walk_namespaces_fn): New typedef. (walk_namespaces): New prototype. (wrapup_globals_for_namespace): Likewise. (walk_vtables): Remove prototype. (walk_sigtables): Likewise. (instantiate_pending_templates): New prototype. * class.c (finish_struct_1): Don't return a value. * decl.h (pending_statics): Remove declaration. * decl.c (walk_namespaces_r): New function. (walk_globals_r): Likewise. (vtable_decl_p): Likewise. (vtype_decl_p): Likewise. (sigtable_decl_p): Likewise. (walk_namespaces): Likewise. (walk_globals_data): New type. (walk_globals): New function. (wrapup_globals_for_namespace): Likewise. (expand_static_init): Remove assertion. Remove redundancy in conditional. Don't put static data members in static_aggregates Tidy. (finish_function): Remove redundancy in conditional. Don't set DECL_RETURNS_FIRST_ARG. (cat_namespace_levels): Remove. * decl2.c: Include splay-tree.h and varray.h. (priority_info_s): New structure. (finish_vtable_vardecl): Change prototype. Adjust for new calling conventions. (prune_vtable_vardecl): Likewise. (finish_sigtable_vardecl): Likewise. (setup_initp): Remove. (do_dtors): Remove. (do_ctors): Remove. (start_static_storage_duration_function): New function. (generate_inits_for_priority): Likewise. (finish_static_storage_duration_function): Likewise. (get_priority_info): Likewise. (do_static_initialization): Likewise. (do_static_destruction): Likewise. (do_static_initialization_and_destruction): Likewise. (generate_ctor_or_dtor_function): Likewise. (generate_ctor_and_dtor_functions_for_priority): Likewise. (pending_statics): Make it a varray. (pending_statics_used): New variable. (saved_inlines): Make it a varray. (saved_inlines_used): New variable. (finish_static_data_member): Change method of updating pending_statics. (mark_inline_for_output): Remove #if 0'd code. Change method of updating saved_inlines. (walk_vtables): Remove. (walk_sigtables): Likewise. (import_export_decl): Use DECL_TINFO_FN_P. (pending_templates): Remove declaration. (maybe_templates): Likewise. (static_aggregates_initp): Likewise. (setup_initp): Likewise. (finish_objects): Simplify. (INITIALIZE_P_IDENTIFIER): New macro. (PRIORITY_IDENTIFIER): New macro. (SSDF_IDENTIFIER): New macro. (initialize_p_decl): New variable. (priority_decl): Likewise. (ssdf_decl): Likewise. (priority_info_map): Likewise. (finish_file): Recode output of static intializers and other file-scope finalization tasks. * error.c (OB_END_TEMPLATE_ID): New macro. (dump_type_real): Use it. (dump_decl): Likewise. (dump_function_name): Likewise. * lex.c (set_typedecl_interface_info): Adjust for new walk_globals interface. (check_newline): Use walk_globals, not walk_vtables. * pt.c (pending_tempalte_expansions): Remove. (set_vardecl_interface_info): Likewise. (pending_templates): Make static. (maybe_templates): Likewise. (instantiate_class_template): Adjust call to finish_struct_1. (instantiate_pending_templates): New function. * rtti.c (get_tinfo_fn): Use SET_DECL_TINFO_FN_P. * tree.c (static_aggregates_initp): Remove. (cp_valid_lang_attribute): Don't use it; use DECL_INIT_PRIORITY instead. * Makefile.in (decl2.o): Depend on varray.h and splay-tree.h. From-SVN: r26594
1999-04-23 01:13:12 +02:00
SET_DECL_TINFO_FN_P (d);
TREE_TYPE (name) = copy_to_permanent (type);
pushdecl_top_level (d);
make_function_rtl (d);
mark_used (d);
mark_inline_for_output (d);
pop_obstacks ();
return d;
}
tree
get_typeid_1 (type)
tree type;
{
tree t;
t = build_call
(get_tinfo_fn (type), TREE_TYPE (tinfo_fn_type), NULL_TREE);
return convert_from_reference (t);
}
1996-02-01 20:33:01 +01:00
/* Return the type_info object for TYPE, creating it if necessary. */
1996-07-11 03:13:25 +02:00
1996-02-01 20:33:01 +01:00
tree
get_typeid (type)
tree type;
{
if (type == error_mark_node)
return error_mark_node;
if (TYPE_SIZE (type_info_type_node) == NULL_TREE)
{
error ("must #include <typeinfo> before using typeid");
return error_mark_node;
}
if (! flag_rtti)
error ("requesting typeid with -fno-rtti");
if (processing_template_decl)
return build_min_nt (TYPEID_EXPR, type);
/* If the type of the type-id is a reference type, the result of the
typeid expression refers to a type_info object representing the
referenced type. */
1996-02-01 20:33:01 +01:00
if (TREE_CODE (type) == REFERENCE_TYPE)
type = TREE_TYPE (type);
/* The top-level cv-qualifiers of the lvalue expression or the type-id
1996-07-11 03:13:25 +02:00
that is the operand of typeid are always ignored. */
type = TYPE_MAIN_VARIANT (type);
1996-02-01 20:33:01 +01:00
if (TYPE_SIZE (complete_type (type)) == NULL_TREE)
{
cp_error ("taking typeid of incomplete type `%T'", type);
return error_mark_node;
}
return get_typeid_1 (type);
1996-02-01 20:33:01 +01:00
}
/* Check whether TEST is null before returning RESULT. If TEST is used in
RESULT, it must have previously had a save_expr applied to it. */
static tree
1996-07-11 03:13:25 +02:00
ifnonnull (test, result)
tree test, result;
{
return build (COND_EXPR, TREE_TYPE (result),
build (EQ_EXPR, boolean_type_node, test, integer_zero_node),
cp_convert (TREE_TYPE (result), integer_zero_node),
result);
}
1996-02-01 20:33:01 +01:00
/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working
paper. */
static tree
build_dynamic_cast_1 (type, expr)
1996-02-01 20:33:01 +01:00
tree type, expr;
{
enum tree_code tc = TREE_CODE (type);
tree exprtype;
1996-09-12 21:19:15 +02:00
enum tree_code ec;
tree dcast_fn;
tree old_expr = expr;
1996-02-01 20:33:01 +01:00
if (TREE_CODE (expr) == OFFSET_REF)
expr = resolve_offset_ref (expr);
exprtype = TREE_TYPE (expr);
1996-09-12 21:19:15 +02:00
assert (exprtype != NULL_TREE);
ec = TREE_CODE (exprtype);
1996-02-01 20:33:01 +01:00
switch (tc)
{
case POINTER_TYPE:
if (ec == REFERENCE_TYPE)
{
expr = convert_from_reference (expr);
exprtype = TREE_TYPE (expr);
ec = TREE_CODE (exprtype);
}
if (ec != POINTER_TYPE)
goto fail;
if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE)
goto fail;
if (TYPE_SIZE (complete_type (TREE_TYPE (exprtype))) == NULL_TREE)
1996-02-01 20:33:01 +01:00
goto fail;
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
if (!at_least_as_qualified_p (TREE_TYPE (type),
TREE_TYPE (exprtype)))
1996-02-01 20:33:01 +01:00
goto fail;
if (TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node)
break;
/* else fall through */
case REFERENCE_TYPE:
if (TREE_CODE (TREE_TYPE (type)) != RECORD_TYPE)
goto fail;
if (TYPE_SIZE (complete_type (TREE_TYPE (type))) == NULL_TREE)
goto fail;
break;
1996-02-01 20:33:01 +01:00
/* else fall through */
default:
goto fail;
}
/* Apply trivial conversion T -> T& for dereferenced ptrs. */
if (ec == RECORD_TYPE)
{
exprtype = build_reference_type (exprtype);
expr = convert_to_reference (exprtype, expr, CONV_IMPLICIT,
LOOKUP_NORMAL, NULL_TREE);
ec = REFERENCE_TYPE;
}
if (tc == REFERENCE_TYPE)
{
if (ec != REFERENCE_TYPE)
goto fail;
if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE)
goto fail;
if (TYPE_SIZE (complete_type (TREE_TYPE (exprtype))) == NULL_TREE)
1996-02-01 20:33:01 +01:00
goto fail;
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
if (!at_least_as_qualified_p (TREE_TYPE (type),
TREE_TYPE (exprtype)))
1996-02-01 20:33:01 +01:00
goto fail;
}
/* If *type is an unambiguous accessible base class of *exprtype,
convert statically. */
{
int distance;
tree path;
distance = get_base_distance (TREE_TYPE (type), TREE_TYPE (exprtype), 1,
&path);
if (distance == -2)
{
cp_error ("dynamic_cast from `%T' to ambiguous base class `%T'",
TREE_TYPE (exprtype), TREE_TYPE (type));
return error_mark_node;
}
if (distance == -3)
{
cp_error ("dynamic_cast from `%T' to private base class `%T'",
TREE_TYPE (exprtype), TREE_TYPE (type));
return error_mark_node;
}
1996-02-01 20:33:01 +01:00
if (distance >= 0)
return build_vbase_path (PLUS_EXPR, type, expr, path, 0);
}
/* Otherwise *exprtype must be a polymorphic class (have a vtbl). */
if (TYPE_VIRTUAL_P (TREE_TYPE (exprtype)))
{
tree expr1;
1996-02-01 20:33:01 +01:00
/* if TYPE is `void *', return pointer to complete object. */
if (tc == POINTER_TYPE
&& TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node)
{
/* if b is an object, dynamic_cast<void *>(&b) == (void *)&b. */
if (TREE_CODE (expr) == ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE)
return build1 (NOP_EXPR, type, expr);
/* Since expr is used twice below, save it. */
expr = save_expr (expr);
expr1 = build_headof (expr);
if (TREE_TYPE (expr1) != type)
expr1 = build1 (NOP_EXPR, type, expr1);
return ifnonnull (expr, expr1);
1996-02-01 20:33:01 +01:00
}
else
{
tree retval;
tree result, td1, td2, td3, elems, expr2;
1996-02-01 20:33:01 +01:00
/* If we got here, we can't convert statically. Therefore,
dynamic_cast<D&>(b) (b an object) cannot succeed. */
if (ec == REFERENCE_TYPE)
{
if (TREE_CODE (old_expr) == VAR_DECL
&& TREE_CODE (TREE_TYPE (old_expr)) == RECORD_TYPE)
1996-02-01 20:33:01 +01:00
{
cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
old_expr, type);
return throw_bad_cast ();
1996-02-01 20:33:01 +01:00
}
}
/* Ditto for dynamic_cast<D*>(&b). */
else if (TREE_CODE (expr) == ADDR_EXPR)
{
tree op = TREE_OPERAND (expr, 0);
if (TREE_CODE (op) == VAR_DECL
&& TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE)
{
cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
op, type);
1996-02-01 20:33:01 +01:00
retval = build_int_2 (0, 0);
TREE_TYPE (retval) = type;
return retval;
}
}
/* Since expr is used twice below, save it. */
expr = save_expr (expr);
1996-02-01 20:33:01 +01:00
expr1 = expr;
if (tc == REFERENCE_TYPE)
expr1 = build_unary_op (ADDR_EXPR, expr1, 0);
/* Build run-time conversion. */
expr2 = build_headof (expr1);
1996-02-01 20:33:01 +01:00
if (ec == POINTER_TYPE)
td1 = get_tinfo_fn_dynamic (build_indirect_ref (expr, NULL_PTR));
1996-02-01 20:33:01 +01:00
else
td1 = get_tinfo_fn_dynamic (expr);
td1 = decay_conversion (td1);
1996-02-01 20:33:01 +01:00
td2 = decay_conversion
(get_tinfo_fn (TYPE_MAIN_VARIANT (TREE_TYPE (type))));
td3 = decay_conversion
(get_tinfo_fn (TYPE_MAIN_VARIANT (TREE_TYPE (exprtype))));
elems = tree_cons
(NULL_TREE, td1, tree_cons
(NULL_TREE, td2, tree_cons
(NULL_TREE, build_int_2 (1, 0), tree_cons
(NULL_TREE, expr2, tree_cons
(NULL_TREE, td3, tree_cons
(NULL_TREE, expr1, NULL_TREE))))));
dcast_fn = get_identifier ("__dynamic_cast");
if (IDENTIFIER_GLOBAL_VALUE (dcast_fn))
dcast_fn = IDENTIFIER_GLOBAL_VALUE (dcast_fn);
else
{
tree tmp;
push_obstacks (&permanent_obstack, &permanent_obstack);
tmp = tree_cons
(NULL_TREE, TREE_TYPE (td1), tree_cons
(NULL_TREE, TREE_TYPE (td1), tree_cons
(NULL_TREE, integer_type_node, tree_cons
(NULL_TREE, ptr_type_node, tree_cons
(NULL_TREE, TREE_TYPE (td1), tree_cons
(NULL_TREE, ptr_type_node, void_list_node))))));
tmp = build_function_type (ptr_type_node, tmp);
dcast_fn = build_lang_decl (FUNCTION_DECL, dcast_fn, tmp);
DECL_EXTERNAL (dcast_fn) = 1;
TREE_PUBLIC (dcast_fn) = 1;
DECL_ARTIFICIAL (dcast_fn) = 1;
pushdecl_top_level (dcast_fn);
make_function_rtl (dcast_fn);
pop_obstacks ();
}
mark_used (dcast_fn);
result = build_call
(dcast_fn, TREE_TYPE (TREE_TYPE (dcast_fn)), elems);
1996-02-01 20:33:01 +01:00
if (tc == REFERENCE_TYPE)
{
expr1 = throw_bad_cast ();
expr1 = build_compound_expr
(expr_tree_cons (NULL_TREE, expr1,
build_expr_list (NULL_TREE, cp_convert (type, integer_zero_node))));
1996-02-01 20:33:01 +01:00
TREE_TYPE (expr1) = type;
result = save_expr (result);
return build (COND_EXPR, type, result, result, expr1);
}
1996-07-11 03:13:25 +02:00
/* Now back to the type we want from a void*. */
result = cp_convert (type, result);
return ifnonnull (expr, result);
1996-02-01 20:33:01 +01:00
}
}
fail:
cp_error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T'",
1996-02-01 20:33:01 +01:00
expr, exprtype, type);
return error_mark_node;
}
tree
build_dynamic_cast (type, expr)
tree type, expr;
{
if (type == error_mark_node || expr == error_mark_node)
return error_mark_node;
if (processing_template_decl)
return build_min (DYNAMIC_CAST_EXPR, copy_to_permanent (type), expr);
return convert_from_reference (build_dynamic_cast_1 (type, expr));
}
1996-02-01 20:33:01 +01:00
/* Build and initialize various sorts of descriptors. Every descriptor
node has a name associated with it (the name created by mangling).
For this reason, we use the identifier as our access to the __*_desc
nodes, instead of sticking them directly in the types. Otherwise we
would burden all built-in types (and pointer types) with slots that
we don't necessarily want to use.
For each descriptor we build, we build a variable that contains
the descriptor's information. When we need this info at runtime,
all we need is access to these variables.
Note: these constructors always return the address of the descriptor
info, since that is simplest for their mutual interaction. */
extern tree const_string_type_node;
1996-02-01 20:33:01 +01:00
/* Build an initializer for a __si_type_info node. */
1996-02-01 20:33:01 +01:00
static void
expand_si_desc (tdecl, type)
1996-02-01 20:33:01 +01:00
tree tdecl;
tree type;
{
tree t, elems, fn;
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
type = BINFO_TYPE (TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0));
expand_expr_stmt (get_typeid_1 (type));
t = decay_conversion (get_tinfo_var (type));
elems = tree_cons
(NULL_TREE, decay_conversion (tdecl), tree_cons
(NULL_TREE, decay_conversion (name_string), tree_cons
(NULL_TREE, t, NULL_TREE)));
fn = get_identifier ("__rtti_si");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
1996-02-01 20:33:01 +01:00
else
{
tree tmp;
push_obstacks (&permanent_obstack, &permanent_obstack);
tmp = tree_cons
(NULL_TREE, ptr_type_node, tree_cons
(NULL_TREE, const_string_type_node, tree_cons
(NULL_TREE, build_pointer_type (type_info_type_node),
void_list_node)));
tmp = build_function_type (void_type_node, tmp);
fn = build_lang_decl (FUNCTION_DECL, fn, tmp);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
pop_obstacks ();
1996-02-01 20:33:01 +01:00
}
mark_used (fn);
fn = build_call (fn, TREE_TYPE (TREE_TYPE (fn)), elems);
expand_expr_stmt (fn);
1996-02-01 20:33:01 +01:00
}
1996-07-11 03:13:25 +02:00
/* Build an initializer for a __class_type_info node. */
static void
expand_class_desc (tdecl, type)
1996-02-01 20:33:01 +01:00
tree tdecl;
tree type;
{
tree name_string;
tree fn, tmp;
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *name;
1996-02-01 20:33:01 +01:00
int i = CLASSTYPE_N_BASECLASSES (type);
int base_cnt = 0;
tree binfos = TYPE_BINFO_BASETYPES (type);
#if 0
/* See code below that used these. */
1996-02-01 20:33:01 +01:00
tree vb = CLASSTYPE_VBASECLASSES (type);
int n_base = i;
#endif
1996-02-01 20:33:01 +01:00
tree base, elems, access, offset, isvir;
tree elt, elts = NULL_TREE;
static tree base_info_type_node;
1996-02-01 20:33:01 +01:00
if (base_info_type_node == NULL_TREE)
1996-02-01 20:33:01 +01:00
{
tree fields [4];
/* A reasonably close approximation of __class_type_info::base_info */
push_obstacks (&permanent_obstack, &permanent_obstack);
base_info_type_node = make_lang_type (RECORD_TYPE);
/* Actually const __user_type_info * */
fields [0] = build_lang_field_decl
(FIELD_DECL, NULL_TREE,
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
build_pointer_type (build_qualified_type
(type_info_type_node,
TYPE_QUAL_CONST)));
fields [1] = build_lang_field_decl
(FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
DECL_BIT_FIELD (fields[1]) = 1;
DECL_FIELD_SIZE (fields[1]) = 29;
fields [2] = build_lang_field_decl
(FIELD_DECL, NULL_TREE, boolean_type_node);
DECL_BIT_FIELD (fields[2]) = 1;
DECL_FIELD_SIZE (fields[2]) = 1;
/* Actually enum access */
fields [3] = build_lang_field_decl
(FIELD_DECL, NULL_TREE, integer_type_node);
DECL_BIT_FIELD (fields[3]) = 1;
DECL_FIELD_SIZE (fields[3]) = 2;
finish_builtin_type (base_info_type_node, "__base_info", fields,
3, ptr_type_node);
pop_obstacks ();
1996-02-01 20:33:01 +01:00
}
while (--i >= 0)
{
tree binfo = TREE_VEC_ELT (binfos, i);
expand_expr_stmt (get_typeid_1 (BINFO_TYPE (binfo)));
base = decay_conversion (get_tinfo_var (BINFO_TYPE (binfo)));
1996-02-01 20:33:01 +01:00
if (TREE_VIA_VIRTUAL (binfo))
{
tree t = BINFO_TYPE (binfo);
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *name;
1996-02-01 20:33:01 +01:00
tree field;
FORMAT_VBASE_NAME (name, t);
1996-02-01 20:33:01 +01:00
field = lookup_field (type, get_identifier (name), 0, 0);
offset = size_binop (FLOOR_DIV_EXPR,
DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT));
offset = convert (sizetype, offset);
1996-02-01 20:33:01 +01:00
}
else
offset = BINFO_OFFSET (binfo);
if (TREE_VIA_PUBLIC (binfo))
access = access_public_node;
1996-02-01 20:33:01 +01:00
else if (TREE_VIA_PROTECTED (binfo))
access = access_protected_node;
1996-02-01 20:33:01 +01:00
else
access = access_private_node;
1996-02-01 20:33:01 +01:00
if (TREE_VIA_VIRTUAL (binfo))
isvir = boolean_true_node;
1996-02-01 20:33:01 +01:00
else
isvir = boolean_false_node;
elt = build
(CONSTRUCTOR, base_info_type_node, NULL_TREE, tree_cons
(NULL_TREE, base, tree_cons
(NULL_TREE, offset, tree_cons
(NULL_TREE, isvir, tree_cons
(NULL_TREE, access, NULL_TREE)))));
TREE_HAS_CONSTRUCTOR (elt) = TREE_CONSTANT (elt) = TREE_STATIC (elt) = 1;
elts = expr_tree_cons (NULL_TREE, elt, elts);
1996-02-01 20:33:01 +01:00
base_cnt++;
}
#if 0
i = n_base;
while (vb)
{
tree b;
access = access_public_node;
1996-02-01 20:33:01 +01:00
while (--i >= 0)
{
b = TREE_VEC_ELT (binfos, i);
if (BINFO_TYPE (vb) == BINFO_TYPE (b) && TREE_VIA_VIRTUAL (b))
{
if (TREE_VIA_PUBLIC (b))
access = access_public_node;
1996-02-01 20:33:01 +01:00
else if (TREE_VIA_PROTECTED (b))
access = access_protected_node;
1996-02-01 20:33:01 +01:00
else
access = access_private_node;
1996-02-01 20:33:01 +01:00
break;
}
}
base = build_t_desc (BINFO_TYPE (vb), 1);
offset = BINFO_OFFSET (vb);
isvir = build_int_2 (1, 0);
base_list = expr_tree_cons (NULL_TREE, base, base_list);
isvir_list = expr_tree_cons (NULL_TREE, isvir, isvir_list);
acc_list = expr_tree_cons (NULL_TREE, access, acc_list);
off_list = expr_tree_cons (NULL_TREE, offset, off_list);
1996-02-01 20:33:01 +01:00
base_cnt++;
vb = TREE_CHAIN (vb);
}
#endif
name = build_overload_name (type, 1, 1);
name_string = combine_strings (build_string (strlen (name)+1, name));
1996-02-01 20:33:01 +01:00
{
tree arrtype = build_array_type (base_info_type_node, NULL_TREE);
elts = build (CONSTRUCTOR, arrtype, NULL_TREE, elts);
TREE_HAS_CONSTRUCTOR (elts) = TREE_CONSTANT (elts)
= TREE_STATIC (elts) = 1;
complete_array_type (arrtype, elts, 1);
}
1996-02-01 20:33:01 +01:00
elems = tree_cons
(NULL_TREE, decay_conversion (tdecl), tree_cons
(NULL_TREE, decay_conversion (name_string), tree_cons
(NULL_TREE, decay_conversion (elts), tree_cons
(NULL_TREE, cp_convert (sizetype, build_int_2 (base_cnt, 0)),
NULL_TREE))));
1996-02-01 20:33:01 +01:00
fn = get_identifier ("__rtti_class");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
1996-02-01 20:33:01 +01:00
else
{
push_obstacks (&permanent_obstack, &permanent_obstack);
tmp = tree_cons
(NULL_TREE, ptr_type_node, tree_cons
(NULL_TREE, const_string_type_node, tree_cons
(NULL_TREE, build_pointer_type (base_info_type_node), tree_cons
(NULL_TREE, sizetype, void_list_node))));
tmp = build_function_type (void_type_node, tmp);
fn = build_lang_decl (FUNCTION_DECL, fn, tmp);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
pop_obstacks ();
1996-02-01 20:33:01 +01:00
}
mark_used (fn);
fn = build_call (fn, TREE_TYPE (TREE_TYPE (fn)), elems);
expand_expr_stmt (fn);
1996-02-01 20:33:01 +01:00
}
/* Build an initializer for a __pointer_type_info node. */
1996-07-11 03:13:25 +02:00
static void
expand_ptr_desc (tdecl, type)
1996-02-01 20:33:01 +01:00
tree tdecl;
tree type;
{
tree t, elems, fn;
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
type = TREE_TYPE (type);
expand_expr_stmt (get_typeid_1 (type));
t = decay_conversion (get_tinfo_var (type));
elems = tree_cons
(NULL_TREE, decay_conversion (tdecl), tree_cons
(NULL_TREE, decay_conversion (name_string), tree_cons
(NULL_TREE, t, NULL_TREE)));
fn = get_identifier ("__rtti_ptr");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
else
{
tree tmp;
push_obstacks (&permanent_obstack, &permanent_obstack);
tmp = tree_cons
(NULL_TREE, ptr_type_node, tree_cons
(NULL_TREE, const_string_type_node, tree_cons
(NULL_TREE, build_pointer_type (type_info_type_node),
void_list_node)));
tmp = build_function_type (void_type_node, tmp);
fn = build_lang_decl (FUNCTION_DECL, fn, tmp);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
pop_obstacks ();
}
mark_used (fn);
fn = build_call (fn, TREE_TYPE (TREE_TYPE (fn)), elems);
expand_expr_stmt (fn);
1996-02-01 20:33:01 +01:00
}
/* Build an initializer for a __attr_type_info node. */
1996-02-01 20:33:01 +01:00
static void
expand_attr_desc (tdecl, type)
tree tdecl;
1996-02-01 20:33:01 +01:00
tree type;
{
tree elems, t, fn;
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
tree attrval = build_int_2 (TYPE_QUALS (type), 0);
expand_expr_stmt (get_typeid_1 (TYPE_MAIN_VARIANT (type)));
t = decay_conversion (get_tinfo_var (TYPE_MAIN_VARIANT (type)));
elems = tree_cons
(NULL_TREE, decay_conversion (tdecl), tree_cons
(NULL_TREE, decay_conversion (name_string), tree_cons
(NULL_TREE, attrval, expr_tree_cons (NULL_TREE, t, NULL_TREE))));
fn = get_identifier ("__rtti_attr");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
else
{
tree tmp;
push_obstacks (&permanent_obstack, &permanent_obstack);
tmp = tree_cons
(NULL_TREE, ptr_type_node, tree_cons
(NULL_TREE, const_string_type_node, tree_cons
(NULL_TREE, integer_type_node, tree_cons
(NULL_TREE, build_pointer_type (type_info_type_node),
void_list_node))));
tmp = build_function_type (void_type_node, tmp);
fn = build_lang_decl (FUNCTION_DECL, fn, tmp);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
pop_obstacks ();
}
1996-02-01 20:33:01 +01:00
mark_used (fn);
fn = build_call (fn, TREE_TYPE (TREE_TYPE (fn)), elems);
expand_expr_stmt (fn);
1996-02-01 20:33:01 +01:00
}
/* Build an initializer for a type_info node that just has a name. */
1996-02-01 20:33:01 +01:00
static void
expand_generic_desc (tdecl, type, fnname)
tree tdecl;
1996-02-01 20:33:01 +01:00
tree type;
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *fnname;
1996-02-01 20:33:01 +01:00
{
Warning fixes: * call.c (op_error): Const-ify a char*. (add_candidate, source_type, add_warning): Add static prototype. (print_z_candidates): Const-ify a char*. * class.c (resolve_address_of_overloaded_function, fixed_type_or_null, build_vtable_entry_ref): Add static prototype. (get_vtable_name, finish_struct_1): Const-ify a char*. * cvt.c (convert_to_reference): Likewise. * decl.c (redeclaration_error_message, record_builtin_type, record_unknown_type, member_function_or_else, bad_specifiers): Likewise. (find_binding, select_decl, unqualified_namespace_lookup, lookup_flags, qualify_lookup, record_builtin_java_type, tag_name): Add static prototype. (warn_extern_redeclared_static, duplicate_decls, pushdecl, implicitly_declare, record_builtin_java_type, define_function, grok_op_properties, tag_name): Const-ify a char*. * cp-tree.h (FORMAT_VBASE_NAME): Allow parameter `BUF' to be const. (define_function, finish_builtin_type): Const-ify a char*. (cp_error, cp_error_at, cp_warning, cp_warning_at, cp_pedwarn, cp_pedwarn_at, cp_compiler_error, cp_sprintf): Add prototype args. (file_name_nondirectory): Const-ify a char*. (init_filename_times): Don't prototype. (compiler_error): Prototype. (yyerror, init_repo): Const-ify a char*. (build_srcloc): Don't prototype. (build_x_indirect_ref, build_indirect_ref, build_component_addr): Const-ify a char*. (warn_for_assignment): Don't prototype. (convert_for_initialization, readonly_error, check_for_new_type, GNU_xref_begin, GNU_xref_file, GNU_xref_ref, GNU_xref_call): Const-ify a char*. * decl2.c (acceptable_java_type, output_vtable_inherit, setup_initp, start_objects, finish_objects, do_dtors, do_ctors, merge_functions, decl_namespace, validate_nonmember_using_decl, do_nonmember_using_decl): Add static prototype. (lang_f_options): Const-ify a char*. (finish_builtin_type): Likewise. (add_function, arg_assoc_namespace, arg_assoc_class): Add static prototype. * errfn.c: Include cp-tree.h. (cp_thing): Add static prototype. (compiler_error): Don't protoptype. (cp_compiler_error): Cast `compiler_error' to `errorfn' before passing it to `cp_thing'. * error.c (interesting_scope_p): Add static prototype. * except.c (build_eh_type_type, build_eh_type_type_ref): Const-ify a char*. * init.c (compiler_error): Don't prototype. (member_init_ok_or_else): Const-ify a char*. (build_java_class_ref): Add static prototype. * lex.c (compiler_error): Don't prototype. (get_time_identifier, interface_strcmp, extend_token_buffer, handle_cp_pragma): Const-ify a char*. (is_global, init_filename_times): Add static prototype. (file_name_nondirectory, cplus_tree_code_name): Const-ify a char*. (compiler_error): Change from fixed args to variable args. (yyerror): Const-ify a char*. * parse.y (cond_stmt_keyword): Const-ify a char*. (parse_decl): Add static prototype. * pt.c (template_args_equal, print_template_context): Likewise. (print_candidates, check_default_tmpl_args): Const-ify a char*. (instantiate_class_template): Likewise. * repo.c (get_base_filename, open_repo_file, init_repo): Likewise. * rtti.c (call_void_fn, expand_generic_desc, expand_si_desc, expand_class_desc, expand_ptr_desc, expand_attr_desc): Likewise. * search.c (lookup_field_info, lookup_member): Likewise. (lookup_member): Cast the first argument of `bzero' to a PTR. * sig.c (compiler_error): Don't prototype. (build_signature_pointer_or_reference_nam): Const-ify a char*. (get_sigtable_name, build_member_function_pointer): Likewise. * tree.c (compiler_error): Don't prototype. (no_linkage_helper, build_srcloc): Add static prototype. (build_vbase_pointer_fields): Const-ify a char*. (__eprintf): Don't unnecessarily handle `const' when !__STDC__. * typeck.c (compiler_error): Don't prototype. (convert_for_assignment): Const-ify a char*. (comp_cv_target_types): Add static prototype. (build_x_indirect_ref, build_indirect_ref, convert_arguments, build_component_addr, build_unary_op, convert_for_initialization): Const-ify a char*. * typeck2.c (ack): Add static prototype and change from fixed args to variable args. (readonly_error, check_for_new_type): Const-ify a char*. * xref.c (_XREF_FILE, find_file, filename, fctname, declname, fixname, open_xref_file, classname, GNU_xref_begin): Likewise. (GNU_xref_file): Likewise. Also use `xmalloc' instead of `malloc'. (GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call, gen_assign, GNU_xref_member): Const-ify a char*. From-SVN: r25994
1999-03-26 08:45:00 +01:00
const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name)+1, name));
tree elems = tree_cons
(NULL_TREE, decay_conversion (tdecl), tree_cons
(NULL_TREE, decay_conversion (name_string), NULL_TREE));
tree fn = get_identifier (fnname);
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
else
1996-02-01 20:33:01 +01:00
{
tree tmp;
push_obstacks (&permanent_obstack, &permanent_obstack);
tmp = tree_cons
(NULL_TREE, ptr_type_node, tree_cons
(NULL_TREE, const_string_type_node, void_list_node));
tmp = build_function_type (void_type_node, tmp);
fn = build_lang_decl (FUNCTION_DECL, fn, tmp);
DECL_EXTERNAL (fn) = 1;
TREE_PUBLIC (fn) = 1;
DECL_ARTIFICIAL (fn) = 1;
pushdecl_top_level (fn);
make_function_rtl (fn);
pop_obstacks ();
1996-02-01 20:33:01 +01:00
}
mark_used (fn);
fn = build_call (fn, TREE_TYPE (TREE_TYPE (fn)), elems);
expand_expr_stmt (fn);
}
1996-02-01 20:33:01 +01:00
/* Generate the code for a type_info initialization function.
Note that we take advantage of the passage
1996-02-01 20:33:01 +01:00
5.2.7 Type identification [expr.typeid]
Whether or not the destructor is called for the type_info object at the
end of the program is unspecified.
1996-02-01 20:33:01 +01:00
and don't bother to arrange for these objects to be destroyed. It
doesn't matter, anyway, since the destructors don't do anything.
This must only be called from toplevel (i.e. from finish_file)! */
1996-02-01 20:33:01 +01:00
void
synthesize_tinfo_fn (fndecl)
tree fndecl;
{
tree type = TREE_TYPE (DECL_NAME (fndecl));
tree tmp, addr, tdecl;
if (at_eof)
{
import_export_decl (fndecl);
if (DECL_REALLY_EXTERN (fndecl))
return;
}
1996-02-01 20:33:01 +01:00
tdecl = get_tinfo_var (type);
DECL_EXTERNAL (tdecl) = 0;
TREE_STATIC (tdecl) = 1;
DECL_COMMON (tdecl) = 1;
TREE_USED (tdecl) = 1;
DECL_ALIGN (tdecl) = TYPE_ALIGN (ptr_type_node);
cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
1996-09-12 21:19:15 +02:00
start_function (NULL_TREE, fndecl, NULL_TREE, 1);
store_parm_decls ();
clear_last_expr ();
push_momentary ();
/* If the first word of the array (the vtable) is non-zero, we've already
initialized the object, so don't do it again. */
addr = decay_conversion (tdecl);
tmp = cp_convert (build_pointer_type (ptr_type_node), addr);
tmp = build_indirect_ref (tmp, 0);
tmp = build_binary_op (EQ_EXPR, tmp, integer_zero_node);
expand_start_cond (tmp, 0);
1996-02-01 20:33:01 +01:00
if (TREE_CODE (type) == FUNCTION_TYPE)
expand_generic_desc (tdecl, type, "__rtti_func");
1996-02-01 20:33:01 +01:00
else if (TREE_CODE (type) == ARRAY_TYPE)
expand_generic_desc (tdecl, type, "__rtti_array");
cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. * cplus-dem.c (work_stuff): Replace const_type and volatile_type with type_quals. (TYPE_UNQUALIFIED): New macro. (TYPE_QUAL_CONST): Likewise. (TYPE_QUAL_VOLATILE): Likewise. (TYPE_QUAL_RESTRICT): Likewise. (code_for_qualifier): New function. (qualifier_string): Likewise. (demangle_qualifier): Likewise. (internal_cplus_demangle): Use them. (demangle_signature): Likewise. (demangle_template_value_parm): Likewise. (do_type): Likewise. (demangle_fund_type)): Likewise. * Makefile.in (hash.h): Run gperf when necessary. * cp-tree.h (CP_TYPE_READONLY): Remove. (CP_TYPE_VOLATILE): Likewise. (CP_TYPE_QUALS): New macro. (CP_TYPE_CONST_P): Likewise. (CP_TYPE_VOLATILE_P): Likewise. (CP_TYPE_RESTRICT_P): Likewise. (CP_TYPE_CONST_NON_VOLATILE_P): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. (c_apply_type_quals_to_decl): Declare. (SIGNATURE_POINTER_NAME_FORMAT): Modify to allow `restrict'. (SIGNATURE_REFERENCE_NAME_FORMAT): Likewise. (cp_type_qual_from_rid): New function. (compparms): Remove unused parameter. All callers changed. (cp_type_quals): New function. (at_least_as_qualified_p): Likewise. (more_qualified_p): Likewise. * call.c (standard_conversion): Replace calls to cp_build_type_variant with cp_build_qualified_type. Use CP_TYPE_QUALS to get qualifiers and at_least_as_qualified_p to compare them. Use CP_TYPE_* macros to check qualifiers. (reference_binding): Likewise. (implicit_conversion): Likewise. (add_builtin_candidates): Likewise. (build_over_call): Likewise. * class.c (overrides): Compare all qualifiers, not just `const', on method declarations. * cvt.c (convert_to_reference): More CP_TYPE_QUALS conversion, etc. (convert_pointer_to_real): Likewise. (type_promotes_to): Likewise. * decl.c (check_for_uninitialized_const_var): New function. (init_decl_processing): More CP_TYPE_QUALS conversion, etc. (cp_finish_decl): Use check_for_uninitialized_const_var. (grokdeclarator): More CP_TYPE_QUALS conversion, etc. Update to handle `restrict'. (grok_ctor_properties): Likewise. (grok_op_properties): Likewise. (start_function): Likewise. (rever_static_member_fn): Likewise. * decl2.c (grok_method_quals): Likewise. (grokfield): Likewise. * error.c (dump_readonly_or_volatile): Rename to ... (dump_qualifiers): New function. Handle `restrict'. (dump_type_real): Use it. (dump_aggr_type): Likewise. (dump_type_prefix): Likewise. (dump_type_suffix): Likewise. (dump_function_decl): Likewise. (cv_as_string): Likewise. * gxx.gperf: Add __restrict and __restrict__. * gxxint.texi: Document `u' as used for `__restrict', and a few other previously undocumented codes. * hash.h: Regenerated. * init.c (expand_aggr_init): More CP_TYPE_QUALS conversion, etc. (build_member_call): Likewise. (build_new_1): Likewise. * lex.c (init_parse): Add entry for RID_RESTRICT. (cons_up_default_function): More CP_TYPE_QUALS conversion, etc. (cp_type_qual_from_rid): Define. * lex.h (enum rid): Add RID_RESTRICT. * method.c (process_modifiers): Deal with `restrict'. * parse.y (primary): More CP_TYPE_QUALS conversion, etc. * parse.c: Regenerated. * pt.c (convert_nontype_argument): More CP_TYPE_QUALS conversion, etc. (tsubst_aggr_type): Likewise. (tsubst): Likewise. (check_cv_quals_for_unify): Likewise. (unify): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (get_tinfo_var): Likewise. (buidl_dynamic_cast_1): Likewise. Fix `volatile' handling. (expand_class_desc): Likewise. (expand_attr_desc): Likewise. (synthesize_tinfo_fn): Likewise. * search.c (covariant_return_p): Likewise. Fix `volatile' handling. (get_matching_virtual): Likewise. (expand_upcast_fixups): Likewise. * sig.c (build_signature_pointer_or_reference_name): Take type_quals, not constp and volatilep. (build_signature_pointer_or_reference_type): Likewise. (match_method_types): More CP_TYPE_QUALS conversion, etc. (build_signature_pointer_constructor): Likewise. (build_signature_method_call): Likewise. * tree.c (build_cplus_array_type): Likewise. (cp_build_type_variant): Rename to ... (cp_build_qualified_type): New function. Deal with `__restrict'. (canonical_type_variant): More CP_TYPE_QUALS conversion, etc. (build_exception_variant): Likewise. (mapcar): Likewise. * typeck.c (qualif_type): Likewise. (common_type): Likewise. (comptypes): Likewise. (comp_cv_target_types): Likewise. (at_least_as_qualified_p): Define. (more_qualified_p): Likewise. (comp_cv_qualification): More CP_TYPE_QUALS conversion, etc. (compparms): Likewise. (inline_conversion): Likewise. (string_conv_p): Likewise. (build_component_ref): Likewise. (build_indirect_ref): Likewise. (build_array_ref): Likewise. (build_unary_op): Likewise. (build_conditional_expr): Likewise. (build_static_cast): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_For_assignment): Likewise. (comp_ptr_ttypes_real): Likewise. (cp_type_quals): New function. From-SVN: r23258
1998-10-23 16:53:28 +02:00
else if (TYPE_QUALS (type) != TYPE_UNQUALIFIED)
expand_attr_desc (tdecl, type);
1996-02-01 20:33:01 +01:00
else if (TREE_CODE (type) == POINTER_TYPE)
{
if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE)
expand_generic_desc (tdecl, type, "__rtti_ptmd");
else if (TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)
expand_generic_desc (tdecl, type, "__rtti_ptmf");
1996-02-01 20:33:01 +01:00
else
expand_ptr_desc (tdecl, type);
1996-02-01 20:33:01 +01:00
}
else if (TYPE_PTRMEMFUNC_P (type))
expand_generic_desc (tdecl, type, "__rtti_ptmf");
1996-02-01 20:33:01 +01:00
else if (IS_AGGR_TYPE (type))
{
if (CLASSTYPE_N_BASECLASSES (type) == 0)
expand_generic_desc (tdecl, type, "__rtti_user");
else if (! TYPE_USES_COMPLEX_INHERITANCE (type)
&& (TREE_VIA_PUBLIC
(TREE_VEC_ELT (TYPE_BINFO_BASETYPES (type), 0))))
expand_si_desc (tdecl, type);
1996-02-01 20:33:01 +01:00
else
expand_class_desc (tdecl, type);
1996-02-01 20:33:01 +01:00
}
else if (TREE_CODE (type) == ENUMERAL_TYPE)
expand_generic_desc (tdecl, type, "__rtti_user");
else
my_friendly_abort (252);
1996-02-01 20:33:01 +01:00
expand_end_cond ();
/* OK, now return the type_info object. */
tmp = cp_convert (build_pointer_type (type_info_type_node), addr);
tmp = build_indirect_ref (tmp, 0);
c_expand_return (tmp);
finish_function (lineno, 0, 0);
1996-02-01 20:33:01 +01:00
}