search.c (52284) | search.c (60967) |
---|---|
1/* Breadth-first and depth-first routines for 2 searching multiple-inheritance lattice for GNU C++. 3 Copyright (C) 1987, 89, 92-97, 1998, 1999 Free Software Foundation, Inc. 4 Contributed by Michael Tiemann (tiemann@cygnus.com) 5 6This file is part of GNU CC. 7 8GNU CC is free software; you can redistribute it and/or modify --- 137 unchanged lines hidden (view full) --- 146static tree access_in_type PROTO ((tree, tree)); 147static tree dfs_canonical_queue PROTO ((tree, void *)); 148static tree dfs_assert_unmarked_p PROTO ((tree, void *)); 149static void assert_canonical_unmarked PROTO ((tree)); 150static int protected_accessible_p PROTO ((tree, tree, tree, tree)); 151static int friend_accessible_p PROTO ((tree, tree, tree, tree)); 152static void setup_class_bindings PROTO ((tree, int)); 153static int template_self_reference_p PROTO ((tree, tree)); | 1/* Breadth-first and depth-first routines for 2 searching multiple-inheritance lattice for GNU C++. 3 Copyright (C) 1987, 89, 92-97, 1998, 1999 Free Software Foundation, Inc. 4 Contributed by Michael Tiemann (tiemann@cygnus.com) 5 6This file is part of GNU CC. 7 8GNU CC is free software; you can redistribute it and/or modify --- 137 unchanged lines hidden (view full) --- 146static tree access_in_type PROTO ((tree, tree)); 147static tree dfs_canonical_queue PROTO ((tree, void *)); 148static tree dfs_assert_unmarked_p PROTO ((tree, void *)); 149static void assert_canonical_unmarked PROTO ((tree)); 150static int protected_accessible_p PROTO ((tree, tree, tree, tree)); 151static int friend_accessible_p PROTO ((tree, tree, tree, tree)); 152static void setup_class_bindings PROTO ((tree, int)); 153static int template_self_reference_p PROTO ((tree, tree)); |
154static void expand_direct_vtbls_init_thunks PROTO((tree, tree, int)); 155static void expand_indirect_vtbls_init_thunks PROTO((tree, tree, tree)); |
|
154 | 156 |
157 |
|
155/* Allocate a level of searching. */ 156 157static struct search_level * 158push_search_level (stack, obstack) 159 struct stack_level *stack; 160 struct obstack *obstack; 161{ 162 struct search_level tem; --- 2458 unchanged lines hidden (view full) --- 2621 if (init_self && CLASSTYPE_VFIELDS (BINFO_TYPE (real_binfo))) 2622 { 2623 tree new_addr = convert_pointer_to_real (binfo, addr); 2624 expand_upcast_fixups (real_binfo, new_addr, orig_addr, vbase, addr, 2625 type, vbase_offsets); 2626 } 2627} 2628 | 158/* Allocate a level of searching. */ 159 160static struct search_level * 161push_search_level (stack, obstack) 162 struct stack_level *stack; 163 struct obstack *obstack; 164{ 165 struct search_level tem; --- 2458 unchanged lines hidden (view full) --- 2624 if (init_self && CLASSTYPE_VFIELDS (BINFO_TYPE (real_binfo))) 2625 { 2626 tree new_addr = convert_pointer_to_real (binfo, addr); 2627 expand_upcast_fixups (real_binfo, new_addr, orig_addr, vbase, addr, 2628 type, vbase_offsets); 2629 } 2630} 2631 |
2632/* Emit initialization of vfields of BASE, where the complete object 2633 is pointed to by decl_ptr. DO_SELF indicates we have to do our own 2634 vfield, otherwise only proceed to our own direct non-virtual bases. */ 2635 2636static void 2637expand_direct_vtbls_init_thunks (base, decl_ptr, do_self) 2638 tree base, decl_ptr; 2639 int do_self; 2640{ 2641 tree addr, expr; 2642 tree type = BINFO_TYPE (base); 2643 tree binfos = BINFO_BASETYPES (base); 2644 int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0; 2645 tree vlist = lookup_name (vlist_identifier, 0); 2646 int in_dtor = DECL_DESTRUCTOR_FOR_PVBASE_P (current_function_decl); 2647 2648 my_friendly_assert (vlist != NULL_TREE, 990320); 2649 2650 if (in_dtor) 2651 /* In the destructor, we find the vfield pointers for the bases in 2652 reverse order, before we find our own vfield pointer. */ 2653 for (i = n_baselinks - 1; i >= 0; i--) 2654 { 2655 tree base_binfo = TREE_VEC_ELT (binfos, i); 2656 int is_not_base_vtable 2657 = i != CLASSTYPE_VFIELD_PARENT (type); 2658 if (! TREE_VIA_VIRTUAL (base_binfo)) 2659 expand_direct_vtbls_init_thunks (base_binfo, decl_ptr, 2660 is_not_base_vtable); 2661 } 2662 2663 if (do_self && CLASSTYPE_VFIELDS (type)) 2664 { 2665 addr = build_vbase_path (PLUS_EXPR, build_pointer_type (type), 2666 decl_ptr, base, 1); 2667 addr = build_indirect_ref (addr, "vptr"); 2668 addr = build_vfield_ref (addr, type); 2669 2670 /* In a destructor, we decrease the vlist before we retrieve the 2671 value. In a constructor, we increase the vlist after we 2672 retrieve the value. */ 2673 if (in_dtor) 2674 { 2675 expr = build_binary_op (MINUS_EXPR, vlist, integer_one_node); 2676 expr = build_modify_expr (vlist, NOP_EXPR, expr); 2677 expand_expr_stmt (expr); 2678 } 2679 2680 /* Store the next vptr into the vbase's vptr. */ 2681 expr = build_indirect_ref (vlist, "__vlist"); 2682 expr = convert_force (TREE_TYPE (addr), expr, 0); 2683 expr = build_modify_expr (addr, NOP_EXPR, expr); 2684 expand_expr_stmt (expr); 2685 2686 /* Advance the vlist. */ 2687 if (!in_dtor) 2688 { 2689 expr = build_binary_op (PLUS_EXPR, vlist, integer_one_node); 2690 expr = build_modify_expr (vlist, NOP_EXPR, expr); 2691 expand_expr_stmt (expr); 2692 } 2693 } 2694 2695 if (!in_dtor) 2696 for (i = 0; i < n_baselinks; i++) 2697 { 2698 tree base_binfo = TREE_VEC_ELT (binfos, i); 2699 int is_not_base_vtable = i != CLASSTYPE_VFIELD_PARENT (type); 2700 if (! TREE_VIA_VIRTUAL (base_binfo)) 2701 expand_direct_vtbls_init_thunks (base_binfo, decl_ptr, 2702 is_not_base_vtable); 2703 } 2704} 2705 2706/* Like expand_indirect_vtbls_init below, but based on the vtable list 2707 passed to the constructor. */ 2708 2709static void 2710expand_indirect_vtbls_init_thunks (binfo, true_exp, decl_ptr) 2711 tree binfo; 2712 tree true_exp, decl_ptr; 2713{ 2714 tree type = BINFO_TYPE (binfo); 2715 tree vbases = CLASSTYPE_VBASECLASSES (type); 2716 struct vbase_info vi; 2717 2718 vi.decl_ptr = (true_exp ? build_unary_op (ADDR_EXPR, true_exp, 0) 2719 : decl_ptr); 2720 vi.vbase_types = vbases; 2721 2722 dfs_walk (binfo, dfs_find_vbases, unmarked_new_vtablep, &vi); 2723 2724 /* Initialized with vtables of type TYPE. */ 2725 for (; vbases; vbases = TREE_CHAIN (vbases)) 2726 { 2727 tree addr; 2728 2729 if (!CLASSTYPE_VFIELD (BINFO_TYPE (vbases))) 2730 /* This vbase doesn't have a vptr of its own. */ 2731 /* FIXME: check */ 2732 continue; 2733 2734 addr = convert_pointer_to_vbase (TREE_TYPE (vbases), decl_ptr); 2735 expand_direct_vtbls_init_thunks (TYPE_BINFO (BINFO_TYPE (vbases)), 2736 addr, 1); 2737 2738 } 2739 2740 dfs_walk (binfo, dfs_clear_vbase_slots, marked_new_vtablep, 0); 2741} 2742 |
|
2629/* Build a COMPOUND_EXPR which when expanded will generate the code 2630 needed to initialize all the virtual function table slots of all 2631 the virtual baseclasses. MAIN_BINFO is the binfo which determines 2632 the virtual baseclasses to use; TYPE is the type of the object to 2633 which the initialization applies. TRUE_EXP is the true object we 2634 are initializing, and DECL_PTR is the pointer to the sub-object we 2635 are initializing. 2636 --- 15 unchanged lines hidden (view full) --- 2652 some of them might fit within what the compiler now thinks 2653 are available stack slots... These values are actually initialized at 2654 the beginnning of the function, so when the automatics use their space, 2655 they will overwrite the values that are placed here. Marking all 2656 temporary space as unavailable prevents this from happening. */ 2657 2658 mark_all_temps_used(); 2659 | 2743/* Build a COMPOUND_EXPR which when expanded will generate the code 2744 needed to initialize all the virtual function table slots of all 2745 the virtual baseclasses. MAIN_BINFO is the binfo which determines 2746 the virtual baseclasses to use; TYPE is the type of the object to 2747 which the initialization applies. TRUE_EXP is the true object we 2748 are initializing, and DECL_PTR is the pointer to the sub-object we 2749 are initializing. 2750 --- 15 unchanged lines hidden (view full) --- 2766 some of them might fit within what the compiler now thinks 2767 are available stack slots... These values are actually initialized at 2768 the beginnning of the function, so when the automatics use their space, 2769 they will overwrite the values that are placed here. Marking all 2770 temporary space as unavailable prevents this from happening. */ 2771 2772 mark_all_temps_used(); 2773 |
2774 if (TYPE_USES_PVBASES (type)) 2775 { 2776 expand_indirect_vtbls_init_thunks (binfo, true_exp, decl_ptr); 2777 return; 2778 } 2779 |
|
2660 if (TYPE_USES_VIRTUAL_BASECLASSES (type)) 2661 { 2662 rtx fixup_insns = NULL_RTX; 2663 tree vbases = CLASSTYPE_VBASECLASSES (type); 2664 struct vbase_info vi; 2665 vi.decl_ptr = (true_exp ? build_unary_op (ADDR_EXPR, true_exp, 0) 2666 : decl_ptr); 2667 vi.vbase_types = vbases; --- 563 unchanged lines hidden --- | 2780 if (TYPE_USES_VIRTUAL_BASECLASSES (type)) 2781 { 2782 rtx fixup_insns = NULL_RTX; 2783 tree vbases = CLASSTYPE_VBASECLASSES (type); 2784 struct vbase_info vi; 2785 vi.decl_ptr = (true_exp ? build_unary_op (ADDR_EXPR, true_exp, 0) 2786 : decl_ptr); 2787 vi.vbase_types = vbases; --- 563 unchanged lines hidden --- |