Commit Graph

281 Commits

Author SHA1 Message Date
Kriang Lerdsuwanakij 7088fca941 Core issue 287, PR c++/7639
Core issue 287, PR c++/7639
	* cp-tree.h (lang_type_class): Add decl_list field.
	(CLASSTYPE_DECL_LIST): New macro.
	(maybe_add_class_template_decl_list): Add declaration.
	* class.c (duplicate_tag_error): Initialize CLASSTYPE_DECL_LIST.
	(unreverse_member_declarations): Reverse CLASSTYPE_DECL_LIST.
	(maybe_add_class_template_decl_list): New function.
	(add_implicitly_declared_members): Use it.
	* decl.c (maybe_process_template_type_declaration): Likewise.
	(pushtag): Likewise.
	* friend.c (add_friend): Likewise.
	(make_friend_class): Likewise.
	* semantics.c (finish_member_declaration): Likewise.
	(begin_class_definition): Initialize CLASSTYPE_DECL_LIST.
	* pt.c (instantiate_class_template): Use CLASSTYPE_DECL_LIST
	to process members and friends in the order of declaration.

	Core issue 287, PR c++/7639
	* g++.dg/template/instantiate1.C: Adjust error location.
	* g++.dg/template/instantiate3.C: New test.
	* g++.old-deja/g++.pt/crash10.C: Adjust error location.
	* g++.old-deja/g++.pt/derived3.C: Adjust error location.
	* g++.old-deja/g++.pt/spec28.C: Reorder declaration.

From-SVN: r58654
2002-10-30 15:54:10 +00:00
Mark Mitchell bb5e8a7ffc class.c (build_vtbl_initializer): Don't use build_vtable_entry.
* class.c (build_vtbl_initializer): Don't use build_vtable_entry.
	(build_vtable_entry): Remove.
	* cp-tree.h (BINFO_VIRTUALS): Expand documentation.
	(lang_decl): Add thunks.
	(DECL_THUNKS): New macro.
	* decl.c (duplicate_decls): Copy it.
	* method.c (make_thunk): Simplify, and add thunks to DECL_THUNKS.
	* semantics.c (emit_associated_thunks): Simplify.

	* g++.dg/abi/vthunk2.C: New test.

From-SVN: r58536
2002-10-25 19:39:47 +00:00
Jason Merrill 5275f2bf28 re PR c++/8080 ([Regression in main trunk] g++ 3.3 ICE in make_decl_rtl)
PR c++/8080
        * semantics.c (finish_for_cond, finish_while_stmt_cond): Don't mess
        with condition decls in a template.

From-SVN: r58282
2002-10-18 05:00:47 -04:00
Mark Mitchell 2282d28d48 re PR c++/7188 (Segfault with template class and recursive (incorrect) initalizer list.)
PR c++/7188.
	* cp-tree.def (CTOR_INITIALIZER): Use one slot, not two.
	* cp-tree.h (emit_base_init): Rename to ....
	(emit_mem_initializers): ... this.
	(expand_member_init): Change prototype.
	* init.c (perform_member_init): Compute explicit, rather than
	requiring it as a parameter.
	(sort_member_init): Rename to ...
	(sort_mem_initializers): ... this.  Process bases and data members
	together.
	(sort_base_init): Remove.
	(emit_base_init): Rename to ...
	(emit_mem_initializers): ... this.
	(expand_aggr_vbase_init_1): Remove.
	(construct_virtual_bases): Rename to ...
	(construct_virtual_base): ... this.
	(expand_member_init): Rework handling of base initializers.
	* method.c (do_build_copy_constructor): Use
	finish_mem_initializers.
	* parse.y (member_init): Adjust calls to expand_member_init.
	* pt.c (tsubst_expr): Simplify CTOR_INITIALIZER case.
	(tsubst_initializer_list): Use expand_member_init.
	* semantics.c (finish_mem_intiailizers): Simplify.

	PR c++/7188.
	* g++.dg/template/meminit1.C: New test.
	* g++.dg/warn/Wreorder-1.C: Likewise.
	* g++.old-deja/g++.mike/warn3.C: Tweak.
	* lib/prune.exp: Ingore "in copy constructor".

From-SVN: r57748
2002-10-02 20:01:38 +00:00
Kazu Hirata 838dfd8a4e ChangeLog: Follow spelling conventions.
* ChangeLog: Follow spelling conventions.
	* ChangeLog.2: Likewise.
	* call.c: Likewise.
	* class.c: Likewise.
	* cp-tree.h: Likewise.
	* cvt.c: Likewise.
	* decl.c: Likewise.
	* decl2.c: Likewise.
	* except.c: Likewise.
	* friend.c: Likewise.
	* g++spec.c: Likewise.
	* init.c: Likewise.
	* lex.c: Likewise.
	* mangle.c: Likewise.
	* method.c: Likewise.
	* operators.def: Likewise.
	* optimize.c: Likewise.
	* pt.c: Likewise.
	* rtti.c: Likewise.
	* search.c: Likewise.
	* semantics.c: Likewise.
	* spew.c: Likewise.
	* tree.c: Likewise.
	* typeck.c: Likewise.

From-SVN: r57387
2002-09-21 12:51:56 +00:00
Nathan Sidwell 28c56d2569 re PR c++/7015 (certain __asm__ constructs rejected)
cp:
2002-09-16  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/7015
	* semantic.c (finish_asm_stmt): Fix operand/output_operands
	thinko.
	* typeck.c (c_expand_asm_operands): Protect from error_mark_node.
testsuite
	* g++.dg/ext/asm3.C: New test.

From-SVN: r57192
2002-09-16 14:34:02 +00:00
Kazu Hirata c600262528 error.c: Fix comment formatting.
* error.c: Fix comment formatting.
	* except.c: Likewise.
	* expr.c: Likewise.
	* friend.c: Likewise.
	* g++spec.c: Likewise.
	* init.c: Likewise.
	* lex.c: Likewise.
	* mangle.c: Likewise.
	* method.c: Likewise.
	* optimize.c: Likewise.
	* pt.c: Likewise.
	* rtti.c: Likewise.
	* search.c: Likewise.
	* semantics.c: Likewise.
	* spew.c: Likewise.
	* tree.c: Likewise.
	* typeck.c: Likewise.
	* typeck2.c: Likewise.

From-SVN: r57138
2002-09-14 12:07:44 +00:00
Jason Merrill d65b1d77fd c-common.h (RETURN_STMT_EXPR): Rename from RETURN_EXPR.
* c-common.h (RETURN_STMT_EXPR): Rename from RETURN_EXPR.
        * c-common.def: Adjust.
        * c-dump.c (c_dump_tree): Adjust.
        * c-semantics.c (genrtl_return_stmt): Adjust.
        * c-pretty-print.c (pp_c_statement): Adjust.
        * tree-inline.c (copy_body_r): Adjust.

2002-08-22  Jason Merrill  <jason@redhat.com>

        * pt.c (tsubst_expr): RETURN_EXPR is now RETURN_STMT_EXPR.
        * semantics.c (nullify_returns_r): Likewise.

From-SVN: r56523
2002-08-22 19:22:53 -04:00
Jason Merrill 5d764395db semantics.c (finish_then_clause): Remove redundant assignment.
* semantics.c (finish_then_clause): Remove redundant assignment.
        (finish_if_stmt, begin_switch_stmt, finish_switch_stmt): Move the
        extra binding level outside the if/switch statement.
        (finish_while_cond, finish_for_cond): Rewrite complex condition
        into the loop body.

From-SVN: r56402
2002-08-16 21:17:24 -04:00
Mike Stump 0e3397527a call.c (add_builtin_candidate): legal -> valid, illegal -> invalid.
* call.c (add_builtin_candidate): legal -> valid, illegal -> invalid.
        (type_decays_to): Likewise.
        * class.c (find_final_overrider): Likewise.
        (maybe_note_name_used_in_class): Likewise.
        * decl.c (current_tmpl_spec_kind): Likewise.
        (add_binding): Likewise.
        (push_class_binding): Likewise.
        (duplicate_decls): Likewise.
        (layout_var_decl): Likewise.
        (grokfndecl): Likewise.
        (grokdeclarator): Likewise.
        (check_default_argument): Likewise.
        * decl2.c (handle_class_head): Likewise.
        * error.c (dump_template_decl): Likewise.
        * init.c (build_offset_ref): Likewise.
        * pt.c (check_specialization_scope): Likewise.
        (determine_specialization): Likewise.
        (check_explicit_specialization): Likewise.
        (maybe_check_template_type): Likewise.
        (process_partial_specialization): Likewise.
        (check_default_tmpl_args): Likewise.
        (push_template_decl_real): Likewise.
        (convert_template_argument): Likewise.
        (try_class_unification): Likewise.
        (get_bindings_real): Likewise.
        (do_decl_instantiation): Likewise.
        * semantics.c (begin_function_definition): Likewise.
        (finish_member_declaration): Likewise.
        (check_multiple_declarators): Likewise.
        * typeck.c (comp_array_types): Likewise.
        (comptypes): Likewise.
        (expr_sizeof): Likewise.
        (build_binary_op): Likewise.
        (dubious_conversion_warnings): Likewise.
        (check_return_expr): Likewise.

From-SVN: r56144
2002-08-09 01:16:39 +00:00
Mark Mitchell 50ad964280 Rework build_component_ref.
* call.c (build_vfield_ref): Do not go through build_component_ref.
	(build_field_call): Use build_class_member_access_expr.
	(build_user_type_conversion_1): Use BASELINK_FUNCTIONS.
	(build_object_call): Likewise.
	* class.c (convert_to_base): New function.
	(type_requires_array_cookie): Use BASELINK_FUNCTIONS.
	(instantiate_type): Handle BASELINKs.
	* cp-tree.def (BASELINK): New tree code.
	* cp-tree.h (BASELINK_P): Reimplement.
	(SET_BASELINK_P): Remove.
	(BASELINK_BINFO): Reimplement.
	(BASELINK_FUNCTIONS): Likewise.
	(BASELINK_ACCESS_BINFO): Likewise.
	(BASELINK_OPTYPE): Likewise.
	(convert_to_base): New function.
	(name_p): Likewise.
	(build_object_ref): Remove.
	(build_component_ref_1): Likewise.
	(build_component_ref): Likewise.
	(build_x_component_ref): Likewise.
	(build_class_member_access_expr): New function.
	(finish_class_member_access_expr): Likewise.
	(build_ptrmemfunc_access_expr): Likewise.
	* decl.c (grokdeclarator): Handle BASELINKs.
	* decl2. (build_expr_from_tree): Handle COMPONENT_REFs by using
	finish_class_member_access_expr.
	(arg_assoc): Handle BASELINKs.
	(do_class_using_decl): Likewise.
	* error.c (dump_decl): Likewise.
	(dump_expr): Use build_ptrmemfunc_access_expr.
	* except.c (dtor_nothrow): Use CLASSTYPE_DESTRUCTORS to find
	destructors.
	(build_throw): Use BASELINK_FUNCTIONS.
	* init.c (perform_member_init): Use
	build_class_member_access_expr.
	(build_offset_ref): Handle BASELINKs.  Use
	build_class_member_access_expr.
	* method.c (hack_identifier): Likewise.
	* parse.y (do_id): Use BASELINK, not TREE_LIST.
	(primary): Remove uses of build_object_ref.
	* pt.c (lookup_template_function): Handle BASELINKs.
	(resolve_overloaded_unification): Likewise.
	* search.c (build_baselink): Build a BASELINK, not a TREE_LIST.
	(lookup_field): Use BASELINK, not TREE_LIST.
	(lookup_fnfiels): Likewise.
	(setup_class_bindings): Likewise.
	* semantics.c (finish_object_call_expr): Do not use
	build_method_call when we already know what function is being
	called.
	* spew.c (identifier_type): Use BASELINK, not TREE_LIST.
	* tree.c (really_overloaded_fn): Use OVL_CHAIN for OVERLOADs, not
	TREE_CHAIN.
	(name_p): New function.
	* typeck.c (build_object_ref): Remove.
	(build_component_ref_1): Likewise.
	(build_x_component_ref): Likewise.
	(build_class_member_access_expr): New function.
	(finish_class_member_access_expr): Likewise.
	(build_ptrmemfunc_access_expr): Likewise.
	(get_member_function_from_ptrfunc): Use
	build_ptrmemfunc_access_expr.
	(build_binary_op): Likewise.
	(build_unary_op): Likewise.
	(build_ptrmemfunc): Likewise.
	(pfn_from_ptrmemfunc): Likewise.
	* typeck2.c (build_m_component_ref): Adjust comment.

	* g++.dg/abi/offsetof.C: Tweak error messages.
	* g++.old-deja/g++.mike/p10769a.C: Likewise.

From-SVN: r56117
2002-08-08 05:48:39 +00:00
Jason Merrill 367aa58580 semantics.c (expand_body): Do tree optimization in the function context, too.
* semantics.c (expand_body): Do tree optimization in the function
        context, too.

From-SVN: r55982
2002-08-02 07:52:38 -04:00
Mark Mitchell 4ba126e468 call.c (build_field_call): Do not look up the field by name.
* call.c (build_field_call): Do not look up the field by name.
	(build_method_call): Simplify.
	(struct z_candidate): Add access_path and conversion_path.  Remove
	basetype_path.
	(convert_class_to_reference): Adjust use of
	add_function_candidate.
	(add_candidate): Add conversion_path argument.
	(add_function_candidate): Use it.
	(add_conv_dndidate): Likewise.
	(build_builtin_candidate): Likewise.
	(add_template_candidate_real): Add conversion_path argument.
	(add_template_conv_candidate): Likewise.
	(add_template_candidate): Likewise.
	(build_user_type_conversion_1): Use it.
	(build_new_function_call): Remove name lookup code.  Adjust use of
	add_template_candidate and add_function_candidate.
	(build_new_op): Likewise.
	(convert_like_real): Use build_special_member_call.
	(build_over_call): Use cand->conversion_path.
	(build_special_member_call): New method.
	(build_new_method_call): Remove name lookup code.
	* cp-tree.def (OFFSET_REF): Update documentation.
	(TEMPLATE_ID_EXPR): Likewise.
	* cp-tree.h (BASELINK_ACCESS_BINFO): New macro.
	(BASELINK_OPTYPE): Likewise.
	(build_new_method_call): Adjust prototype.
	(build_special_member_call): New method.
	(build_baselink): New method.
	(build_offset_ref_call_from_tree): Likewise.
	(build_call_from_tree): Likewise.
	(finish_qualified_call_expr): Remove.
	(finish_call_expr): Adjust prototype.
	(build_x_function_call): Remove.
	* cvt.c (ocp_convert): Use build_special_member_call.
	* decl2.c (reparse_absdcl_as_expr): Use finish_call_expr.
	(build_expr_from_tree): Adjust handling for TEMPLATE_ID_EXPR and
	CALL_EXPR.
	(build_offset_ref_call_from_tree): New function.
	(build_call_from_tree): Likewise.
	* init.c (expand_cleanup): Use build_special_member_call.
	(expand_default_init): Likewise.
	(build_member_call): Use finish_call_expr.
	(build_new_1): Use build_special_member_call.
	(push_base_cleanups): Likewise.
	* method.c (do_build_assign_ref): Likewise.
	* parse.y (template_id): Do not pass a COMPONENT_REF to
	lookup_template_function.
	(primary): Use parse_finish_call_epxr, not finish_call_expr.
	(parse_finish_call_expr): New function.
	* pt.c (lookup_template_function): Add assertions.
	* search.c (lookup_base): Allow T to be a binfo.
	(build_baselink): New function.
	(lookup_member): Use it.
	* semantics.c (finish_call_expr): Do not do name lookup.
	(finish_object_call_expr): Remove #if 0'd code.
	(finish_qualified_call_expr): Remove.
	* typeck.c (build_x_function_call): Remove.
	(build_static_case): Use build_special_member_call.
	* typeck2.c (build_functional_cast): Likewise.

	* g++.dg/inherit/operator1.C: New test.
	* g++.dg/lookup/disamb1.C: Fix typo in comment.
	* g++.dg/other/error1.C: Change expected error message.
	* g++.dg/template/conv4.C: Likewise.

From-SVN: r55920
2002-08-01 04:46:23 +00:00
Gabriel Dos Reis fa72b06489 Fix PR/7363:
2002-07-21  Gabriel Dos Reis  <gdr@nerim.net>

        Fix PR/7363:
        * c-common.c (c_sizeof_or_alignof_type): New function.
        (c_alignof): Remove definition.
        * c-common.h (c_sizeof, c_alignof): Define as macros.
        (c_sizeof_or_alignof_type): Declare.
        (my_friendly_assert): Moved from cp/cp-tree.h
        * c-typeck.c (c_sizeof): Remove definition.

cp/

2002-07-21  Gabriel Dos Reis  <gdr@nerim.net>

        Fix PR/7363:
        * typeck.c (cxx_sizeof_or_alignof_type): New function.
        (c_sizeof): Remove definition.
        (expr_sizeof): Use cxx_sizeof.
        * decl2.c (build_expr_from_tree): Use cxx_sizeof_or_alignof_type.
        * decl.c (finish_destructor_body): Use cxx_sizeof.
        * semantics.c (finish_alignof): Likewise.
        (finish_alignof): Use cxx_alignof.
        * cp-tree.h (cxx_sizeof, cxx_alignof): New macros.
        (cxx_sizeof_or_alignof_type): Declare.
        (my_friendly_assert): Move to ../c-common.h.

From-SVN: r55678
2002-07-23 13:54:06 +00:00
Mark Mitchell 15c7fb9cfd cp-tree.h (unqualified_name_lookup_error): Declare it.
* cp-tree.h (unqualified_name_lookup_error): Declare it.
	(begin_function_definition): Adjust prototype.
	* lex.c (unqualified_name_lookup_error): New function, split out
	from ...
	(do_identifier): ... here.
	* parse.y (parse_begin_function_definition): New function.
	(fn.def1): Use it.
	* semantics.c (begin_function_definition): Accept decl-specifiers
	and attributes as separate parameters.

From-SVN: r55372
2002-07-10 18:16:24 +00:00
Mark Mitchell 8ba658eea5 cp-tree.h (constructor_name_p): Declare it.
* cp-tree.h (constructor_name_p): Declare it.
	(check_template_template_default_arg): Likewise.
	* class.c (handle_using_decl): Use constructor_name_p.
	* decl.c (grokdeclarator): Likewise.
	* decl2.c (constructor_name_p): Define it.
	* init.c (build_member_call): Use constructor_name_p.
	* parse.y (template_parm): Use check_template_template_default_arg.
	* pt.c (check_explicit_specialization): Use constructor_name_p.
	* semantics.c (check_template_template_default_arg): New function.

From-SVN: r55350
2002-07-09 23:31:28 +00:00
Mark Mitchell da15dae6f5 call.c (build_op_delete_call): Use BASELINK_FUNCTIONS.
* call.c (build_op_delete_call): Use BASELINK_FUNCTIONS.
	* class.c (handle_using_decl): Likewise.
	(instantiate_type): Likewise.
	* cp-tree.h (BASELINK_FUNCTIONS): New macro.
	(xref_basetypes): Change prototype.
	(begin_mem_initializers): New function.
	(get_overloaded_fn): Likewise.
	* decl.c (xref_basetypes): Simplify.
	* error.c (dump_expr): Use BASELINK_FUNCTIONS.
	* init.c (build_offset_ref): Likewise.
	* parse.y (base_init): Use begin_mem_initializers().
	(structsp): Adjust call to xref_basetypes.
	* pt.c (determine_specialization): Use BASELINK_FUNCTIONS.
	(instantiate_class_template): Adjust call to xref_basetypes.
	* semantics.c (begin_mem_initializers): New function.
	* tree.c (is_overloaded_fn): Use BASELINK_FUNCTIONS.
	(really_overlaoded_fn): Likewise.
	(get_overloaded_fn): New function.'
	(get_first_fn): USe BASELINK_FUNCTIONS.

From-SVN: r54989
2002-06-25 15:35:27 +00:00
Mark Mitchell 5f261ba970 cp-tree.h (SCALAR_TYPE_P): New macro.
* cp-tree.h (SCALAR_TYPE_P): New macro.
	(check_for_out_of_scope_variable): New function.
	(at_class_scope_p): Likewise.
	(finish_fname): Likewise.
	* class.c (finish_struct): Use at_function_scope_p.
	* decl.c (check_for_out_of_scope_variable): New function, split
	out from do_identifier.
	(finish_enum): Use at_function_scope_p.
	* lex.c (do_identifier): Use check_for_out_of_scope_variable.
	* parse.y (VAR_FUNC_NAME): Give it <ttype>.  Use finish_fname.
	(primary): Use at_function_scope_p.
	* search.c (at_class_scope_p): New function.
	* semantics.c (finish_fname): Likewise.
	(check_multiple_declarators): Use at_function_scope_p.

From-SVN: r54962
2002-06-24 19:18:43 +00:00
Jason Merrill 18ba380b3a semantics.c (begin_for_stmt): Push the 'for' scope before adding the FOR_STMT.
* semantics.c (begin_for_stmt): Push the 'for' scope before
        adding the FOR_STMT.

From-SVN: r54749
2002-06-18 12:21:25 -04:00
Geoffrey Keating e2500fedef Merge from pch-branch up to tag pch-commit-20020603.
From-SVN: r54232
2002-06-04 07:11:05 +00:00
Richard Henderson b84a387434 c-common.c (fix_string_type): Split out of ...
* c-common.c (fix_string_type): Split out of ...
        (combine_strings): ... here.  Take a varray, not a tree list.
        (c_expand_builtin_printf): Use fix_string_type.
        * c-common.h: Update decls.
        * c-parse.in (string): Remove.  Update all uses to use STRING
        instead, and not call combine_strings.
        (yylexstring): New.
        (_yylex): Use it.
        * c-typeck.c (simple_asm_stmt): Don't call combine_strings.
        (build_asm_stmt): Likewise.
        * objc/objc-act.c (my_build_string): Use fix_string_type.
        (build_objc_string_object): Build varray for combine_strings.

        * parse.y (string): Remove.  Update all uses to use STRING
        instead, and not call combine_strings.
        * rtti.c (tinfo_name): Use fix_string_type.
        * semantics.c (finish_asm_stmt): Don't call combine_strings.
        * spew.c (yylexstring): New.
        (read_token): Use it.

	* g++.dg/parse/concat1.C: New.
	* gcc.dg/concat2.c: New.

From-SVN: r52790
2002-04-26 00:40:12 -07:00
Mark Mitchell b2123dc0d8 c-common.h (STMT_EXPR_NO_SCOPE): New macro.
* c-common.h (STMT_EXPR_NO_SCOPE): New macro.
	* c-common.c (c_expand_expr): Respect STMT_EXPR_NO_SCOPE.
	* tree.h (expand_start_stmt_expr): Update prototype.
	* stmt.c (expand_start_stmt_expr): Add has_scope parameter.
	* tree-inline.c (expand_call_inline): Set STMT_EXPR_NO_SCOPE
	on the STMT_EXPR created for the inline function.

	* trans.c (tree_transform): Add has_scope argument to
	expand_start_stmt_expr.

	* com.c (ffecom_expr_power_integer): Add has_scope argument to
	call to expand_start_stmt_expr.

	* init.c (begin_init_stmts): Remove commented out code.
	(finish_init_stmts): Set STMT_EXPR_NO_SCOPE.
	* semantics.c (begin_gobal_stmt_expr): Adjust call to
	expand_start_stmt_expr.

From-SVN: r52395
2002-04-17 01:47:36 +00:00
Mark Mitchell 0481bc2173 re PR c++/5373 (Statement expressions broken in C++)
PR c++ 5373.
	* g++.dg/parse/stmtexpr1.C: New test.

	PR c++/5373.
	* semantics.c (finish_expr_stmt): Remember the type of the
	expression before any conversions are performed.

From-SVN: r52264
2002-04-13 07:10:12 +00:00
Jason Merrill edf5cd1d1d re PR rtl-optimization/6189 (Regression from 3.0.x: g++ -O3 generates wrong code)
PR optimization/6189
        * semantics.c (genrtl_start_function): Don't free
        DECL_SAVED_FUNCTION_DATA for inline functions.

From-SVN: r52082
2002-04-09 13:01:59 -04:00
Neil Booth 78ef5b895f c-common.c (truthvalue_conversion): Rename, update.
* c-common.c (truthvalue_conversion): Rename, update.
	* c-common.h (c_common_truthvalue_conversion): New.
	* c-convert.c (convert): Update.
	* c-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
	* c-parse.in (expr_no_commas, if_prefix, select_or_iter_stmt): Update.
	* c-typeck.c (build_binary_op, build_unary_op,
	build_conditional_expr): Update.
	* fold-const.c (constant_boolean_node, fold): Use langhook.
	* langhooks-def.h (LANGHOOK_INITIALIZER): Update.
	* langhooks.h (struct lang_hooks): New hook.
	* stmt.c (expand_decl_cleanup): Use langhook.
	* tree.h (truthvalue_conversion): Remove.
ada:
	* gigi.h (truthvalue_conversion): Rename.
	* misc.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
	* trans.c (tree_transform): Update.
	* utils2.c (truthvalue_conversion): Rename, update.
	(build_binary_op, build_unary_op): Update.
cp:
	* cp-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
	* cvt.c: Update comment.
	* init.c (expand_cleanup_for_base): Update.
	* semantics.c (finish_parenthesized_expr): Update.
	* typeck.c (cp_truthvalue_conversion): Update.
f:
	* com.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
	(truthvalue_conversion): Rename.  Update.  Make static.
	(ffecom_truth_value): Update.
java:
	* expr.c (truthvalue_conversion): Rename.  Update.
	(expand_compare): Update.
	* java-tree.h (java_truthvalue_conversion): New.
	* lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.
objc:
	* objc-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Redefine.

From-SVN: r51880
2002-04-04 22:19:58 +00:00
Jason Merrill 659e5a7aa9 re PR c++/5636 (gcc-3.0.3, memory leakage: function that take a string as parameter will not call local variable destructors if exception is thrown.)
PR c++/5636
        * tree.h (CLEANUP_EH_ONLY): New macro.
        * stmt.c (expand_decl_cleanup_eh): New fn.
        (expand_cleanups): Check CLEANUP_EH_ONLY.
        * c-semantics.c (genrtl_decl_cleanup): Just take the CLEANUP_STMT.
        Use expand_decl_cleanup_eh.
        (expand_stmt): Adjust.
        * c-common.h: Adjust prototype.
        * cp/semantics.c (nullify_returns_r): Just set CLEANUP_EH_ONLY on
        cleanup for nrv.

        * except.c (struct eh_status): Remove protect_list.
        (begin_protect_partials, end_protect_partials): Remove.
        (add_partial_entry): Remove.
        * except.h: Remove prototypes.

        * expr.c (expand_expr) [WITH_CLEANUP_EXPR, TARGET_EXPR]: Use
        expand_decl_cleanup_eh.

cp/:
        * semantics.c (finish_eh_cleanup): New fn.
        * cp-tree.h: Add prototype.
        * init.c (perform_member_init, expand_cleanup_for_base): Use
        finish_eh_cleanup.
        * cp-tree.def (SUBOBJECT, CTOR_STMT): Remove.
        * cp-tree.h: Remove references.
        * decl.c (begin_constructor_body, end_constructor_body): Likewise.
        * dump.c (cp_dump_tree): Likewise.
        * pt.c (tsubst_expr): Likewise.
        * semantics.c (genrtl_ctor_stmt, genrtl_subobject): Remove.
        (cp_expand_stmt): Remove handling of CTOR_STMT and SUBOBJECT.
        * tree.c (cp_statement_code_p): Likewise.

        * init.c (build_new_1): Set CLEANUP_EH_ONLY on deleting cleanup.

From-SVN: r51827
2002-04-03 19:11:00 -05:00
Neil Booth dffd7eb68a c-decl.c (grokdeclarator): Update.
* c-decl.c (grokdeclarator): Update.
	* c-lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
	* c-tree.h (c_mark_addressable): New.
	* c-typeck.c (default_function_array_conversion, build_unary_op,
	build_array_ref, convert_for_assignment): Update.
	(mark_addressable): Rename.
	* calls.c (try_to_integrate, expand_call): Use langhook.
	* expr.c (expand_expr): Use langhook.
	* langhooks-def.h (LANG_HOOKS_INITIALIZER): Update.
	* langhooks.h (struct lang_hooks): New hook.
	* stmt.c (expand_asm_operands): Use langhook.
	* tree.h (mark_addressable): Remove.
ada:
	* decl.c (gnat_to_gnu_entity): Update.
	* gigi.h (mark_addressable): Rename.
	* misc.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
	* trans.c (tree_transform): Update.
	* utils.c (create_var_decl): Update.
	* util2.c (build_binary_op, build_unary_op,
	fill_vms_descriptor): Update.
	(mark_addressable): Rename, update.
cp:
	* call.c (build_addr_func): Update.
	* class.c (resolve_address_of_overloaded_function): Update.
	* cp-lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
	* cp-tree.h (cxx_mark_addressable): New.
	* decl.c (register_dtor_fn, cxx_maybe_build_cleanup): Update.
	* decl2.c (build_cleanup): Update.
	* except.c (build_throw): Update.
	* init.c (resolve_offset_ref): Update.
	* pt.c (convert_nontype_argument): Update.
	* semantics.c (finish_asm_stmt, simplify_affr_init_exprs_r): Update.
	* typeck.c (decay_conversion, build_array_ref, build_unary_op,
	unary_complex_lvalue): Update.
	(mark_addressable): Rename.
f:
	* com.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
	(mark_addressable): Rename.
	(ffecom_arrayref_, ffecom_1): Update.
java:
	* java-tree.h (java_mark_addressable): New.
	* lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.
	* typeck.c (mark_addressable): Rename, update.
objc:
	* objc-lang.c (LANG_HOOKS_MARK_ADDRESSABLE): Redefine.

From-SVN: r51705
2002-04-01 20:26:18 +00:00
Gabriel Dos Reis acb044eef1 re PR c++/3656 (ICE when incorrectly deriving a class from a templated base in another namespace)
cp/
        PR C++/3656
        * semantics.c (finish_base_specifier): Handle erronous base
        classes.

testsuite/
        * g++.dg/inherit/template-as-base.C: New test.

From-SVN: r51214
2002-03-23 01:24:18 +00:00
Mark Mitchell 6e4ae815bd c-common.c (statement_code_p): Handle CLEANUP_STMT.
* c-common.c (statement_code_p): Handle CLEANUP_STMT.
	* c-common.def (CLEANUP_STMT): New tree node.
	* c-common.h (CLEANUP_DECL): New macro.
	(CLEANUP_EXPR): Likewise.
	* c-semantics.c (expand_stmt): Handle CLEANUP_STMT.
	* tree-dump.c (dequeue_and_dump): Handle CLEANUP_STMT.
	* tree-inline.c (initialize_inlined_parameters): Clean up
	new local variables.

	* cp-tree.h (CLEANUP_DECL): Remove.
	(CLEANUP_EXPR): Likewise.
	* decl.c (destroy_local_var): Simplify.
	(maybe_build_cleanup): Tidy.
	* dump.c (cp_dump_tree): Remove handling of CLEANUP_STMT.
	* semantics.c (cp_expand_stmt): Likewise.
	* cp/tree.c (cp_statement_code_p): Likewise.

	* g++.dg/opt/dtor1.C: New test.

From-SVN: r50830
2002-03-15 20:08:39 +00:00
Nathan Sidwell ab04e34bff Revert 2001-03-26 Nathan Sidwell <nathan@codesourcery.com>, DR209 is now not a defect.
cp:
	Revert 2001-03-26  Nathan Sidwell  <nathan@codesourcery.com>,
	DR209 is now not a defect.
	* cp-tree.h (skip_type_access_control): Remove.
	* decl.c (grokdeclarator): Do type access control for friend
	declarations.
	* semantics.c (decl_type_access_control): Don't reset
	current_type_lookups.
	(save_type_access_control): Always save the lookups.
	(skip_type_access_control): Remove.
	(finish_class_definition): Don't change type_lookups.
testsuite:
	* testsuite/g++.old-deja/g++.other/friend9.C: Revert DR 209 changes.
	* testsuite/g++.old-deja/g++.robertl/eb56.C: Likewise.

From-SVN: r50595
2002-03-11 20:51:00 +00:00
Jakub Jelinek 25c8b645ed re PR other/5746 (0220 cvs crashes using undeclared type)
PR other/5746
	* semantics.c (finish_switch_cond): Don't call get_unwidened
	if error_mark_node.

From-SVN: r49969
2002-02-22 18:42:19 +01:00
Jakub Jelinek 6f9fdf4db2 PR c/4475, c++/3780:
* c-common.def (SWITCH_STMT): Add SWITCH_TYPE operand.
	* c-common.h (SWITCH_TYPE): Define.
	* c-typeck.c (c_start_case): Set SWITCH_TYPE.
	* stmt.c (all_cases_count): Set lastval to thisval at end of loop.
	Rename spareness variable to sparseness.
	(expand_end_case_type): Renamed from expand_end_case, use orig_type
	if non-NULL instead of TREE_TYPE (orig_index).
	* tree.h (expand_end_case_type): Renamed from expand_end_case.
	(expand_end_case): Define using expand_end_case_type.
	* c-semantics.c (genrtl_switch_stmt): Pass SWITCH_TYPE
	to expand_end_case_type.
	* doc/c-tree.texi (SWITCH_STMT): Document SWITCH_TYPE.

	* semantics.c (begin_switch_stmt): Clear SWITCH_TYPE.
	(finish_switch_cond): Set SWITCH_TYPE.

	* gcc.dg/Wswitch.c: Fix typos.  Don't return unconditionally
	before all tests.  Move warning one line above to match where it
	C frontend emits.
	* gcc.dg/Wswitch-2.c: New test.
	* g++.dg/warn/Wswitch-1.C: New test.
	* g++.dg/warn/Wswitch-2.C: New test.

From-SVN: r49497
2002-02-04 23:05:15 +01:00
Richard Henderson 14691f8d24 alpha.c (current_function_is_thunk): Don't check current_function_is_thunk.
* config/alpha/alpha.c (current_function_is_thunk): Don't check
        current_function_is_thunk.
        (alpha_sa_mask): Distinguish between current_function_is_thunk
        called from ASM_OUTPUT_MI_THUNK and not.
        (alpha_does_function_need_gp): Thunks always need gp.
        (alpha_start_function, alpha_output_function_end_prologue): Likewise.
        (alpha_output_mi_thunk_osf): New.
        * config/alpha/alpha-protos.h: Update.
        * config/alpha/alpha.h (ASM_OUTPUT_MI_THUNK): New.

cp/
        * method.c (use_thunk): Always initialize the block tree.  Reindent.
        * semantics.c (expand_body): Emit thunks after function, not before.

From-SVN: r49484
2002-02-04 09:44:26 -08:00
Jason Merrill 9780c24faf xref.c: Remove.
* xref.c: Remove.
        * Make-lang.in (CXX_OBJS): Remove cp/xref.o
        (cp/xref.o): Remove dependencies.
        * class.c (finish_struct_1, check_methods): Don't call xref fns.
        (finish_struct_1): Likewise.
        * friend.c (make_friend_class): Likewise.
        * lex.c (cxx_init, cxx_finish, extract_interface_info): Likewise.
        * spew.c (read_process_identifier): Likewise.

From-SVN: r49472
2002-02-04 03:55:43 -05:00
Jason Merrill a588fe25b7 re PR c++/3395 (Attribute causes type lookup to fail. Regression.)
PR c++/3395
        * decl.c (xref_tag): Remember early attributes in TYPE_ATTRIBUTES,
        not TREE_TYPE.
        * semantics.c (finish_class_definition): Adjust.

From-SVN: r49380
2002-01-31 17:52:11 -05:00
Zack Weinberg 7437519c9e Make-lang.in (parse.c): Adjust expected number of shift-reduce conflicts.
* Make-lang.in (parse.c): Adjust expected number of
	shift-reduce conflicts.
	(decl.o): Depend on diagnostic.h.
	* decl.c: Include diagnostic.h.
	(grokdeclarator): Check for null pointer.
	(finish_function): Don't abort when
	current_binding_level->parm_flag != 1, if errors have
	occurred; throw away the statement tree and extra binding
	levels, and continue.
	* lex.c (note_list_got_semicolon): Check for null pointer.
	* method.c (hack_identifier): Just return error_mark_node if
	value is error_mark_node.
	* parse.y (primary: TYPEID(type_id)): No need to use
	TYPE_MAIN_VARIANT here.
	(handler_seq): Accept an empty list of catch clauses and
	generate a fake handler block to avoid later crashes.
	(ansi_raise_identifier): Accept the error token too.
	* semantics.c (begin_class_definition,
	finish_class_definition): Check for error_mark_node.

From-SVN: r49163
2002-01-24 03:27:30 +00:00
Craig Rodrigues a98facb0de call.c, [...]: Change my_fancy_abort() to abort().
2002-01-23  Craig Rodrigues  <rodrigc@gcc.gnu.org>

        * call.c, class.c, decl.c, decl2.c, error.c, expr.c, friend.c,
        init.c, lex.c, mangle.c, method.c, pt.c, repo.c, rtti.c, search.c,
        semantics.c, spew.c, tree.c, typeck.c, typeck2.c, xref.c:
        Change my_fancy_abort() to abort().

From-SVN: r49139
2002-01-23 14:26:07 +00:00
Jason Merrill cdd2559cec decl.c (begin_constructor_body, [...]): New fns.
* decl.c (begin_constructor_body, begin_destructor_body): New fns.
        (begin_function_body): Call them and keep_next_level.
        * init.c (emit_base_init): Call keep_next_level.
        * semantics.c (setup_vtbl_ptr): Lose.
        * cp-tree.h (struct cp_language_function): Remove vtbls_set_up_p.
        (vtbls_set_up_p): Lose.
        * pt.c (tsubst_expr, CTOR_INITIALIZER): Call emit_base_init.
        * method.c (do_build_copy_constructor): Likewise.
        (synthesize_method): Call finish_mem_initializers.
        * parse.y (nodecls): Likewise.

From-SVN: r48948
2002-01-17 08:07:27 -05:00
Graham Stott c3af729ad7 semantics.c (FINISH_COND): Uppercase macro paramaters and add parenthesis.
* semantics.c (FINISH_COND): Uppercase macro paramaters and
        add parenthesis.

From-SVN: r48674
2002-01-09 06:07:18 +00:00
Richard Henderson c28abdf00d c-decl.c (c_expand_body): Don't call outlining_inline_function.
* c-decl.c (c_expand_body): Don't call outlining_inline_function.
        * integrate.c (output_inline_function): Likewise.
        * toplev.c (rest_of_compilation): Do it here instead.  Move call
        to remove_unnecessary_notes after emitting abstract instance.
        Force an emitted nested function to have its parent emited as well.
        * dwarf2out.c (loc_descriptor_from_tree): Read mode after checking
        for null.
        (rtl_for_decl_location): Do not look at reload data structures
        before reload has run.

        * semantics.c (expand_body): Revert last change.

From-SVN: r48572
2002-01-05 19:51:13 -08:00
Jason Merrill a420065799 c-decl.c (c_expand_body): Call outlining_inline_function when emitting an inline function out of line.
* c-decl.c (c_expand_body): Call outlining_inline_function when
        emitting an inline function out of line.

        * semantics.c (expand_body): Call outlining_inline_function when
        emitting an inline function out of line.

From-SVN: r48479
2002-01-02 10:28:43 -08:00
Nathan Sidwell 41f5d4b195 call.c (build_user_type_conversion_1): Use my_friendly_assert rather than if ...
cp:
	* call.c (build_user_type_conversion_1): Use my_friendly_assert
	rather than if ... abort.
	* cvt.c (convert_to_reference): Likewise.
	* semantics.c (setup_vtbl_ptr): Likewise.
	* pt.c (lookup_template_class): Comment typo.

From-SVN: r48371
2001-12-29 17:24:59 +00:00
Jason Merrill f21add0737 C++ ABI change: destroy value arguments in caller.
* calls.c (initialize_argument_information): Pass the address of
        the TARGET_EXPR temporary rather than storing it into another.
        * semantics.c (genrtl_start_function, genrtl_finish_function): Don't
        create an extra binding level for the parameters.
        * decl.c (store_parm_decls): Don't do parameter cleanups.

From-SVN: r48154
2001-12-18 08:30:30 -05:00
Zack Weinberg 33bd39a26a cp-tree.h: Delete #defines for cp_error, cp_warning, cp_pedwarn, and cp_compiler_error.
* cp-tree.h: Delete #defines for cp_error, cp_warning,
	cp_pedwarn, and cp_compiler_error.
	* call.c, class.c, cp-tree.h, cvt.c, decl.c, decl2.c, error.c,
	except.c, friend.c, init.c, lex.c, method.c, parse.y, pt.c,
	rtti.c, search.c, semantics.c, spew.c, tree.c, typeck.c,
	typeck2.c: Change calls to the above macros to use their
	language-independent equivalents: error, warning, pedwarn, and
	internal_error respectively.

From-SVN: r48140
2001-12-18 03:35:42 +00:00
Joseph Myers aba649ba4d ChangeLog.1, [...]: Fix spelling errors.
* ChangeLog.1, ChangeLog.2, ChangeLog, NEWS, call.c, class.c,
	cp-tree.h, decl.c, decl2.c, except.c, operators.def, optimize.c,
	pt.c, rtti.c, semantics.c, typeck.c: Fix spelling errors.

From-SVN: r48072
2001-12-16 16:07:01 +00:00
Jason Merrill ade3dc07d5 c-common.h (COMPOUND_STMT_BODY_BLOCK): New macro.
* c-common.h (COMPOUND_STMT_BODY_BLOCK): New macro.

        * Make-lang.in (parse.h): Separate rule, just depend on parse.c.

        Use cleanups to run base and member destructors.
        * init.c (push_base_cleanups): New function, split out from...
        (build_delete): ...here.  Lose !TYPE_HAS_DESTRUCTOR code.
        * decl.c (finish_destructor_body): Move vbase destruction code to
        push_base_cleanups.
        (begin_function_body, finish_function_body): New fns.
        (finish_function): Move [cd]tor handling and call_poplevel to
        finish_function_body.
        (pushdecl): Skip the new level.
        * semantics.c (genrtl_try_block): Don't call end_protect_partials.
        (setup_vtbl_ptr): Call push_base_cleanups.
        * method.c (synthesize_method): Call {begin,end}_function_body.
        * pt.c (tsubst_expr): Handle COMPOUND_STMT_BODY_BLOCK.
        * cp-tree.h: Declare new fns.
        * parse.y (function_body, .begin_function_body): New nonterminals.
        (fndef, pending_inline, function_try_block): Use function_body.
        (ctor_initializer_opt, function_try_block): No longer has a value.
        (base_init): Remove .set_base_init token.
        (.set_base_init, compstmt_or_error): Remove.
        * Make-lang.in (parse.c): Expect two fewer s/r conflicts.

From-SVN: r47987
2001-12-13 22:01:59 -05:00
Jason Merrill a0de9d2025 decl.c (store_parm_decls): Remove parms_have_cleanups cruft.
* decl.c (store_parm_decls): Remove parms_have_cleanups cruft.
        * semantics.c (genrtl_start_function): Don't pass
        parms_have_cleanups or push an extra binding level.
        (genrtl_finish_function): Lose cleanup_label cruft.

        * cp-tree.h (struct cp_language_function): Remove x_ctor_label.
        (ctor_label): Remove.
        * semantics.c (finish_return_stmt): Lose ctor_label support.
        * decl.c (finish_constructor_body, mark_lang_function): Likewise.
        * typeck.c (check_return_expr): Check DECL_DESTRUCTOR_P, not
        dtor_label.

        * call.c (build_new_method_call): Let resolves_to_fixed_type_p
        check for [cd]tors.
        * class.c (fixed_type_or_null, case INDIRECT_REF): Fix.

        * decl.c (finish_function): Check VMS_TARGET, not VMS.

        * decl.c (start_cleanup_fn): Remove redundant pushlevel.
        (end_cleanup_fn): And poplevel.

        * semantics.c (setup_vtbl_ptr): Always build a CTOR_INITIALIZER
        if we're in a template.

From-SVN: r47962
2001-12-12 20:37:52 -05:00
Neil Booth a23c9413df c-lex.c, [...]: Revert concatenation changes.
* c-lex.c, c-parse.in, c-typeck.c: Revert concatenation changes.
cp:
	* parse.y, semantics.c: Similarly.

From-SVN: r47848
2001-12-10 20:08:59 +00:00
John David Anglin 46af705afa semantics.c (simplify_aggr_init_exprs_r): Add DIRECT_BIND flag in call to build_aggr_init.
* semantics.c (simplify_aggr_init_exprs_r): Add DIRECT_BIND flag in
	call to build_aggr_init.
	* cp-tree.h (DIRECT_BIND): Document new use of DIRECT_BIND.

From-SVN: r47793
2001-12-08 15:44:23 +00:00
Neil Booth cb97d97dee c-lex.c (c_lex): Peek a token ahead for a string to concatenate...
* c-lex.c (c_lex): Peek a token ahead for a string to concatenate,
	using combine_strings to do the concatenation.
	* c-parse.in: Replace uses of the string non-terminal with STRING.
	Don't attempt string concatenation.
	(OBJC_STRING): New terminal.
	(string): Remove non-terminal.
	(_yylex): Call combine_strings on function names.  Generate
	OBJC_STRING terminals; don't pass '@' on to yacc.
	* c-typeck.c (simple_asm_stmt): Don't concatenate strings here.
	(build_asm_stmt): Similarly.
cp:
	* parse.y: Replace uses of the string non-terminal with STRING.
	Don't perform string concatentaion here.
	(string): Remove non-terminal.
	* semantics.c (finish_asm_stmt): Don't concatenate strings here.

From-SVN: r47792
2001-12-08 12:01:59 +00:00