diff -Nrc3pad gcc-3.1.1/gcc/cp/ChangeLog gcc-3.2/gcc/cp/ChangeLog *** gcc-3.1.1/gcc/cp/ChangeLog Thu Jul 25 23:35:12 2002 --- gcc-3.2/gcc/cp/ChangeLog Wed Aug 14 09:00:06 2002 *************** *** 1,3 **** --- 1,93 ---- + 2002-08-14 Release Manager + + * GCC 3.2 Released. + + 2002-08-03 Nathan Sidwell + + PR 7470. + C++ ABI change - vfunc ordering. + * class.c (add_virtual_function): Remove. + (dfs_modify_all_vtables): Take list of all declared + virtuals. Assign all that are not in primary base. + (check_for_override): Adjust comments. + (create_vtable_ptr): Take single list of virtuals. Build chain + of declared virtuals here. + (layout_class_type): Take single list of virtuals. Adjust. + (finish_struct_1): Keep virtuals on single list. Adjust. + + 2002-07-30 Franz Sirl + + * lang-specs.h: Remove __GXX_ABI_VERSION, moved to gcc.c. + + 2002-07-17 Scott Snyder + + PR c++/7320 + * rtti.c (get_tinfo_decl): Set DECL_COMDAT. + + 2002-07-05 Nathan Sidwell + + Repair damage on weak-impared targets caused by my previous patch. + * cp-tree.h (import_export_tinfo): Add parameter. + * decl2.c (import_export_tinfo): Add parameter, post adjust + DECL_COMDAT. + * rtti.c (emit_tinfo_decl): DECL_COMDAT is (nearly) always setup by + import_export_tinfo. + + 2002-06-30 Nathan Sidwell + + * cp-tree.h (CPTI_TINFO_DECL_TYPE): Replace with ... + (CPTI_TYPE_INFO_PTR_TYPE): ... this. + (tinfo_decl_type): Replace with ... + (type_info_ptr_type): ... this. + (import_export_tinfo): Declare. + (tinfo_decl_p): Rename to ... + (unemitted_tinfo_decl_p): ... this. + * decl2.c (import_export_decl): Break out tinfo handling into ... + (import_export_tinfo): ... here. New function. + (finish_file): Adjust. + * rtti.c (TINFO_REAL_NAME): New macro. + (init_rtti_processing): Create the tinfo types. + (get_tinfo_decl_dynamic): Use type_info_ptr_type, get_tinfo_ptr. + (get_tinfo_decl): Adjust. + (get_tinfo_ptr): New function. + (get_type_id): Use it. + (tinfo_base_init): Create vtable decl here, if it doesn't exist. + (ptr_initializer): Use get_tinfo_ptr. + (ptm_initializer): Likewise. + (synthesize_tinfo_var): Break into ... + (get_pseudo_ti_init): ... this. Just create the initializer. + (get_pseudo_ti_desc): .. and this. + (create_real_tinfo_var): Remove. + (create_pseudo_type_info): Don't create the vtable decl here. + (get_vmi_pseudo_type_info): Remove. + (create_tinfo_types): Adjust. + (tinfo_decl_p): Rename to ... + (unemitted_tinfo_decl_p): ... here. Adjust. + (emit_tinfo_decl): Adjust. Create the initializer. + + 2002-06-14 Jason Merrill + + C++ ABI changes. + * class.c (build_base_field): Set DECL_PACKED. + (layout_class_type): Don't use tail padding of PODs. + * mangle.c (write_unqualified_name): Fix template conversion op + mangling. + + 2002-05-18 Jason Merrill + + PR c++/6611 + * decl2.c (import_export_decl): If we clear + DECL_NOT_REALLY_EXTERN, make sure DECL_EXTERNAL is set. + + 2002-05-14 Jason Merrill + + * rtti.c (get_tinfo_decl): Don't call comdat_linkage. + Do set DECL_COMDAT. + (synthesize_tinfo_var): Take the public decl. + (create_real_tinfo_var): Likewise. Check DECL_COMDAT. + (emit_tinfo_decl): Adjust. Call import_export_decl. + * decl2.c (import_export_decl): Simplify tinfo decl handling. + 2002-07-25 Release Manager * GCC 3.1.1 Released. diff -Nrc3pad gcc-3.1.1/gcc/cp/class.c gcc-3.2/gcc/cp/class.c *** gcc-3.1.1/gcc/cp/class.c Fri Jul 12 07:55:28 2002 --- gcc-3.2/gcc/cp/class.c Sun Aug 4 13:09:31 2002 *************** static int build_primary_vtable PARAMS ( *** 114,120 **** static int build_secondary_vtable PARAMS ((tree, tree)); static void finish_vtbls PARAMS ((tree)); static void modify_vtable_entry PARAMS ((tree, tree, tree, tree, tree *)); - static void add_virtual_function PARAMS ((tree *, tree *, int *, tree, tree)); static tree delete_duplicate_fields_1 PARAMS ((tree, tree)); static void delete_duplicate_fields PARAMS ((tree)); static void finish_struct_bits PARAMS ((tree)); --- 114,119 ---- *************** static void check_methods PARAMS ((tree) *** 150,157 **** static void remove_zero_width_bit_fields PARAMS ((tree)); static void check_bases PARAMS ((tree, int *, int *, int *)); static void check_bases_and_members PARAMS ((tree, int *)); ! static tree create_vtable_ptr PARAMS ((tree, int *, int *, tree *, tree *)); ! static void layout_class_type PARAMS ((tree, int *, int *, tree *, tree *)); static void fixup_pending_inline PARAMS ((tree)); static void fixup_inline_methods PARAMS ((tree)); static void set_primary_base PARAMS ((tree, tree, int *)); --- 149,156 ---- static void remove_zero_width_bit_fields PARAMS ((tree)); static void check_bases PARAMS ((tree, int *, int *, int *)); static void check_bases_and_members PARAMS ((tree, int *)); ! static tree create_vtable_ptr PARAMS ((tree, int *, int *, tree *)); ! static void layout_class_type PARAMS ((tree, int *, int *, tree *)); static void fixup_pending_inline PARAMS ((tree)); static void fixup_inline_methods PARAMS ((tree)); static void set_primary_base PARAMS ((tree, tree, int *)); *************** set_vindex (decl, vfuns_p) *** 792,852 **** ? TARGET_VTABLE_USES_DESCRIPTORS : 1); DECL_VINDEX (decl) = build_shared_int_cst (vindex); } - - /* Add a virtual function to all the appropriate vtables for the class - T. DECL_VINDEX(X) should be error_mark_node, if we want to - allocate a new slot in our table. If it is error_mark_node, we - know that no other function from another vtable is overridden by X. - VFUNS_P keeps track of how many virtuals there are in our - main vtable for the type, and we build upon the NEW_VIRTUALS list - and return it. */ - - static void - add_virtual_function (new_virtuals_p, overridden_virtuals_p, - vfuns_p, fndecl, t) - tree *new_virtuals_p; - tree *overridden_virtuals_p; - int *vfuns_p; - tree fndecl; - tree t; /* Structure type. */ - { - tree new_virtual; - - /* If this function doesn't override anything from a base class, we - can just assign it a new DECL_VINDEX now. Otherwise, if it does - override something, we keep it around and assign its DECL_VINDEX - later, in modify_all_vtables. */ - if (TREE_CODE (DECL_VINDEX (fndecl)) == INTEGER_CST) - /* We've already dealt with this function. */ - return; - - new_virtual = make_node (TREE_LIST); - BV_FN (new_virtual) = fndecl; - BV_DELTA (new_virtual) = integer_zero_node; - - if (DECL_VINDEX (fndecl) == error_mark_node) - { - /* FNDECL is a new virtual function; it doesn't override any - virtual function in a base class. */ - - /* We remember that this was the base sub-object for rtti. */ - CLASSTYPE_RTTI (t) = t; - - /* Now assign virtual dispatch information. */ - set_vindex (fndecl, vfuns_p); - DECL_VIRTUAL_CONTEXT (fndecl) = t; - - /* Save the state we've computed on the NEW_VIRTUALS list. */ - TREE_CHAIN (new_virtual) = *new_virtuals_p; - *new_virtuals_p = new_virtual; - } - else - { - /* FNDECL overrides a function from a base class. */ - TREE_CHAIN (new_virtual) = *overridden_virtuals_p; - *overridden_virtuals_p = new_virtual; - } - } /* Add method METHOD to class TYPE. If ERROR_P is true, we are adding the method after the class has already been defined because a --- 791,796 ---- *************** dfs_modify_vtables (binfo, data) *** 2632,2649 **** /* Update all of the primary and secondary vtables for T. Create new vtables as required, and initialize their RTTI information. Each ! of the functions in OVERRIDDEN_VIRTUALS overrides a virtual ! function from a base class; find and modify the appropriate entries ! to point to the overriding functions. Returns a list, in ! declaration order, of the functions that are overridden in this ! class, but do not appear in the primary base class vtable, and ! which should therefore be appended to the end of the vtable for T. */ static tree ! modify_all_vtables (t, vfuns_p, overridden_virtuals) tree t; int *vfuns_p; ! tree overridden_virtuals; { tree binfo = TYPE_BINFO (t); tree *fnsp; --- 2576,2593 ---- /* Update all of the primary and secondary vtables for T. Create new vtables as required, and initialize their RTTI information. Each ! of the functions in VIRTUALS is declared in T and may override a ! virtual function from a base class; find and modify the appropriate ! entries to point to the overriding functions. Returns a list, in ! declaration order, of the virtual functions that are declared in T, ! but do not appear in the primary base class vtable, and which ! should therefore be appended to the end of the vtable for T. */ static tree ! modify_all_vtables (t, vfuns_p, virtuals) tree t; int *vfuns_p; ! tree virtuals; { tree binfo = TYPE_BINFO (t); tree *fnsp; *************** modify_all_vtables (t, vfuns_p, overridd *** 2655,2668 **** t); dfs_walk (binfo, dfs_unmark, dfs_marked_real_bases_queue_p, t); ! /* Include overriding functions for secondary vtables in our primary ! vtable. */ ! for (fnsp = &overridden_virtuals; *fnsp; ) { tree fn = TREE_VALUE (*fnsp); ! if (!BINFO_VIRTUALS (binfo) ! || !value_member (fn, BINFO_VIRTUALS (binfo))) { /* Set the vtable index. */ set_vindex (fn, vfuns_p); --- 2599,2614 ---- t); dfs_walk (binfo, dfs_unmark, dfs_marked_real_bases_queue_p, t); ! /* Add virtual functions not already in our primary vtable. These ! will be both those introduced by this class, and those overridden ! from secondary bases. It does not include virtuals merely ! inherited from secondary bases. */ ! for (fnsp = &virtuals; *fnsp; ) { tree fn = TREE_VALUE (*fnsp); ! if (!value_member (fn, BINFO_VIRTUALS (binfo)) ! || DECL_VINDEX (fn) == error_mark_node) { /* Set the vtable index. */ set_vindex (fn, vfuns_p); *************** modify_all_vtables (t, vfuns_p, overridd *** 2675,2682 **** BV_DELTA (*fnsp) = integer_zero_node; BV_VCALL_INDEX (*fnsp) = NULL_TREE; ! /* This is an overridden function not already in our ! vtable. Keep it. */ fnsp = &TREE_CHAIN (*fnsp); } else --- 2621,2627 ---- BV_DELTA (*fnsp) = integer_zero_node; BV_VCALL_INDEX (*fnsp) = NULL_TREE; ! /* This is a function not already in our vtable. Keep it. */ fnsp = &TREE_CHAIN (*fnsp); } else *************** modify_all_vtables (t, vfuns_p, overridd *** 2684,2690 **** *fnsp = TREE_CHAIN (*fnsp); } ! return overridden_virtuals; } /* Here, we already know that they match in every respect. --- 2629,2635 ---- *fnsp = TREE_CHAIN (*fnsp); } ! return virtuals; } /* Here, we already know that they match in every respect. *************** check_for_override (decl, ctype) *** 2754,2769 **** || IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))) && look_for_overrides (ctype, decl) && !DECL_STATIC_FUNCTION_P (decl)) ! { ! /* Set DECL_VINDEX to a value that is neither an ! INTEGER_CST nor the error_mark_node so that ! add_virtual_function will realize this is an ! overriding function. */ ! DECL_VINDEX (decl) = decl; ! } if (DECL_VIRTUAL_P (decl)) { ! if (DECL_VINDEX (decl) == NULL_TREE) DECL_VINDEX (decl) = error_mark_node; IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1; } --- 2699,2712 ---- || IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))) && look_for_overrides (ctype, decl) && !DECL_STATIC_FUNCTION_P (decl)) ! /* Set DECL_VINDEX to a value that is neither an INTEGER_CST nor ! the error_mark_node so that we know it is an overriding ! function. */ ! DECL_VINDEX (decl) = decl; ! if (DECL_VIRTUAL_P (decl)) { ! if (!DECL_VINDEX (decl)) DECL_VINDEX (decl) = error_mark_node; IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1; } *************** build_base_field (rli, binfo, empty_p, o *** 3830,3835 **** --- 3773,3780 ---- DECL_SIZE_UNIT (decl) = CLASSTYPE_SIZE_UNIT (basetype); DECL_ALIGN (decl) = CLASSTYPE_ALIGN (basetype); DECL_USER_ALIGN (decl) = CLASSTYPE_USER_ALIGN (basetype); + /* Tell the backend not to round up to TYPE_ALIGN. */ + DECL_PACKED (decl) = 1; if (!integer_zerop (DECL_SIZE (decl))) { *************** check_bases_and_members (t, empty_p) *** 4383,4413 **** accordingly. If a new vfield was created (because T doesn't have a primary base class), then the newly created field is returned. It is not added to the TYPE_FIELDS list; it is the caller's ! responsibility to do that. */ static tree ! create_vtable_ptr (t, empty_p, vfuns_p, ! new_virtuals_p, overridden_virtuals_p) tree t; int *empty_p; int *vfuns_p; ! tree *new_virtuals_p; ! tree *overridden_virtuals_p; { tree fn; ! /* Loop over the virtual functions, adding them to our various ! vtables. */ for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn)) ! if (DECL_VINDEX (fn) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)) ! add_virtual_function (new_virtuals_p, overridden_virtuals_p, ! vfuns_p, fn, t); /* If we couldn't find an appropriate base class, create a new field here. Even if there weren't any new virtual functions, we might need a new virtual function table if we're supposed to include vptrs in all classes that need them. */ ! if (!TYPE_VFIELD (t) && (*vfuns_p || TYPE_CONTAINS_VPTR_P (t))) { /* We build this decl with vtbl_ptr_type_node, which is a `vtable_entry_type*'. It might seem more precise to use --- 4328,4364 ---- accordingly. If a new vfield was created (because T doesn't have a primary base class), then the newly created field is returned. It is not added to the TYPE_FIELDS list; it is the caller's ! responsibility to do that. Accumulate declared virtual functions ! on VIRTUALS_P. */ static tree ! create_vtable_ptr (t, empty_p, vfuns_p, virtuals_p) tree t; int *empty_p; int *vfuns_p; ! tree *virtuals_p; { tree fn; ! /* Collect the virtual functions declared in T. */ for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn)) ! if (DECL_VINDEX (fn) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn) ! && TREE_CODE (DECL_VINDEX (fn)) != INTEGER_CST) ! { ! tree new_virtual = make_node (TREE_LIST); ! ! BV_FN (new_virtual) = fn; ! BV_DELTA (new_virtual) = integer_zero_node; + TREE_CHAIN (new_virtual) = *virtuals_p; + *virtuals_p = new_virtual; + } + /* If we couldn't find an appropriate base class, create a new field here. Even if there weren't any new virtual functions, we might need a new virtual function table if we're supposed to include vptrs in all classes that need them. */ ! if (!TYPE_VFIELD (t) && (*virtuals_p || TYPE_CONTAINS_VPTR_P (t))) { /* We build this decl with vtbl_ptr_type_node, which is a `vtable_entry_type*'. It might seem more precise to use *************** splay_tree_compare_integer_csts (k1, k2) *** 4799,4814 **** /* Calculate the TYPE_SIZE, TYPE_ALIGN, etc for T. Calculate BINFO_OFFSETs for all of the base-classes. Position the vtable ! pointer. */ static void ! layout_class_type (t, empty_p, vfuns_p, ! new_virtuals_p, overridden_virtuals_p) tree t; int *empty_p; int *vfuns_p; ! tree *new_virtuals_p; ! tree *overridden_virtuals_p; { tree non_static_data_members; tree field; --- 4750,4763 ---- /* Calculate the TYPE_SIZE, TYPE_ALIGN, etc for T. Calculate BINFO_OFFSETs for all of the base-classes. Position the vtable ! pointer. Accumulate declared virtual functions on VIRTUALS_P. */ static void ! layout_class_type (t, empty_p, vfuns_p, virtuals_p) tree t; int *empty_p; int *vfuns_p; ! tree *virtuals_p; { tree non_static_data_members; tree field; *************** layout_class_type (t, empty_p, vfuns_p, *** 4830,4837 **** determine_primary_base (t, vfuns_p); /* Create a pointer to our virtual function table. */ ! vptr = create_vtable_ptr (t, empty_p, vfuns_p, ! new_virtuals_p, overridden_virtuals_p); /* The vptr is always the first thing in the class. */ if (vptr) --- 4779,4785 ---- determine_primary_base (t, vfuns_p); /* Create a pointer to our virtual function table. */ ! vptr = create_vtable_ptr (t, empty_p, vfuns_p, virtuals_p); /* The vptr is always the first thing in the class. */ if (vptr) *************** layout_class_type (t, empty_p, vfuns_p, *** 4971,4976 **** --- 4919,4930 ---- CLASSTYPE_SIZE (t) = bitsize_zero_node; CLASSTYPE_SIZE_UNIT (t) = size_zero_node; } + /* If this is a POD, we can't reuse its tail padding. */ + else if (!CLASSTYPE_NON_POD_P (t)) + { + CLASSTYPE_SIZE (t) = TYPE_SIZE (t); + CLASSTYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (t); + } else { CLASSTYPE_SIZE (t) = TYPE_BINFO_SIZE (t); *************** finish_struct_1 (t) *** 5032,5046 **** { tree x; int vfuns; ! /* The NEW_VIRTUALS is a TREE_LIST. The TREE_VALUE of each node is ! a FUNCTION_DECL. Each of these functions is a virtual function ! declared in T that does not override any virtual function from a ! base class. */ ! tree new_virtuals = NULL_TREE; ! /* The OVERRIDDEN_VIRTUALS list is like the NEW_VIRTUALS list, ! except that each declaration here overrides the declaration from ! a base class. */ ! tree overridden_virtuals = NULL_TREE; int n_fields = 0; tree vfield; int empty = 1; --- 4986,4993 ---- { tree x; int vfuns; ! /* A TREE_LIST. The TREE_VALUE of each node is a FUNCTION_DECL. */ ! tree virtuals = NULL_TREE; int n_fields = 0; tree vfield; int empty = 1; *************** finish_struct_1 (t) *** 5070,5077 **** check_bases_and_members (t, &empty); /* Layout the class itself. */ ! layout_class_type (t, &empty, &vfuns, ! &new_virtuals, &overridden_virtuals); /* Make sure that we get our own copy of the vfield FIELD_DECL. */ vfield = TYPE_VFIELD (t); --- 5017,5023 ---- check_bases_and_members (t, &empty); /* Layout the class itself. */ ! layout_class_type (t, &empty, &vfuns, &virtuals); /* Make sure that we get our own copy of the vfield FIELD_DECL. */ vfield = TYPE_VFIELD (t); *************** finish_struct_1 (t) *** 5095,5102 **** else my_friendly_assert (!vfield || DECL_FIELD_CONTEXT (vfield) == t, 20010726); ! overridden_virtuals ! = modify_all_vtables (t, &vfuns, nreverse (overridden_virtuals)); /* If we created a new vtbl pointer for this class, add it to the list. */ --- 5041,5047 ---- else my_friendly_assert (!vfield || DECL_FIELD_CONTEXT (vfield) == t, 20010726); ! virtuals = modify_all_vtables (t, &vfuns, nreverse (virtuals)); /* If we created a new vtbl pointer for this class, add it to the list. */ *************** finish_struct_1 (t) *** 5105,5113 **** = chainon (CLASSTYPE_VFIELDS (t), build_tree_list (NULL_TREE, t)); /* If necessary, create the primary vtable for this class. */ ! if (new_virtuals || overridden_virtuals || TYPE_CONTAINS_VPTR_P (t)) { - new_virtuals = nreverse (new_virtuals); /* We must enter these virtuals into the table. */ if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t)) build_primary_vtable (NULL_TREE, t); --- 5050,5057 ---- = chainon (CLASSTYPE_VFIELDS (t), build_tree_list (NULL_TREE, t)); /* If necessary, create the primary vtable for this class. */ ! if (virtuals || TYPE_CONTAINS_VPTR_P (t)) { /* We must enter these virtuals into the table. */ if (!CLASSTYPE_HAS_PRIMARY_BASE_P (t)) build_primary_vtable (NULL_TREE, t); *************** finish_struct_1 (t) *** 5120,5126 **** constructors might clobber the virtual function table. But they don't if the derived class shares the exact vtable of the base class. */ - CLASSTYPE_NEEDS_VIRTUAL_REINIT (t) = 1; } /* If we didn't need a new vtable, see if we should copy one from --- 5064,5069 ---- *************** finish_struct_1 (t) *** 5146,5159 **** 20000116); CLASSTYPE_VSIZE (t) = vfuns; ! /* Entries for virtual functions defined in the primary base are ! followed by entries for new functions unique to this class. */ ! TYPE_BINFO_VIRTUALS (t) ! = chainon (TYPE_BINFO_VIRTUALS (t), new_virtuals); ! /* Finally, add entries for functions that override virtuals ! from non-primary bases. */ ! TYPE_BINFO_VIRTUALS (t) ! = chainon (TYPE_BINFO_VIRTUALS (t), overridden_virtuals); } finish_struct_bits (t); --- 5089,5096 ---- 20000116); CLASSTYPE_VSIZE (t) = vfuns; ! /* Add entries for virtual functions introduced by this class. */ ! TYPE_BINFO_VIRTUALS (t) = chainon (TYPE_BINFO_VIRTUALS (t), virtuals); } finish_struct_bits (t); diff -Nrc3pad gcc-3.1.1/gcc/cp/cp-tree.h gcc-3.2/gcc/cp/cp-tree.h *** gcc-3.1.1/gcc/cp/cp-tree.h Thu May 23 17:57:42 2002 --- gcc-3.2/gcc/cp/cp-tree.h Fri Jul 26 23:23:00 2002 *************** enum cp_tree_index *** 539,545 **** CPTI_STD, CPTI_ABI, CPTI_TYPE_INFO_TYPE, ! CPTI_TINFO_DECL_TYPE, CPTI_ABORT_FNDECL, CPTI_GLOBAL_DELETE_FNDECL, CPTI_AGGR_TAG, --- 539,545 ---- CPTI_STD, CPTI_ABI, CPTI_TYPE_INFO_TYPE, ! CPTI_TYPE_INFO_PTR_TYPE, CPTI_ABORT_FNDECL, CPTI_GLOBAL_DELETE_FNDECL, CPTI_AGGR_TAG, *************** extern tree cp_global_trees[CPTI_MAX]; *** 626,632 **** #define std_node cp_global_trees[CPTI_STD] #define abi_node cp_global_trees[CPTI_ABI] #define type_info_type_node cp_global_trees[CPTI_TYPE_INFO_TYPE] ! #define tinfo_decl_type cp_global_trees[CPTI_TINFO_DECL_TYPE] #define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL] #define global_delete_fndecl cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL] #define current_aggr cp_global_trees[CPTI_AGGR_TAG] --- 626,632 ---- #define std_node cp_global_trees[CPTI_STD] #define abi_node cp_global_trees[CPTI_ABI] #define type_info_type_node cp_global_trees[CPTI_TYPE_INFO_TYPE] ! #define type_info_ptr_type cp_global_trees[CPTI_TYPE_INFO_PTR_TYPE] #define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL] #define global_delete_fndecl cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL] #define current_aggr cp_global_trees[CPTI_AGGR_TAG] *************** extern tree coerce_delete_type PARAMS *** 3819,3824 **** --- 3819,3825 ---- extern void comdat_linkage PARAMS ((tree)); extern void import_export_vtable PARAMS ((tree, tree, int)); extern void import_export_decl PARAMS ((tree)); + extern void import_export_tinfo PARAMS ((tree, tree, int)); extern tree build_cleanup PARAMS ((tree)); extern void finish_file PARAMS ((void)); extern tree reparse_absdcl_as_expr PARAMS ((tree, tree)); *************** extern tree get_tinfo_decl *** 4051,4057 **** extern tree get_typeid PARAMS((tree)); extern tree build_dynamic_cast PARAMS((tree, tree)); extern void emit_support_tinfos PARAMS((void)); ! extern int tinfo_decl_p PARAMS((tree, void *)); extern int emit_tinfo_decl PARAMS((tree *, void *)); /* in search.c */ --- 4052,4058 ---- extern tree get_typeid PARAMS((tree)); extern tree build_dynamic_cast PARAMS((tree, tree)); extern void emit_support_tinfos PARAMS((void)); ! extern int unemitted_tinfo_decl_p PARAMS((tree, void *)); extern int emit_tinfo_decl PARAMS((tree *, void *)); /* in search.c */ diff -Nrc3pad gcc-3.1.1/gcc/cp/decl2.c gcc-3.2/gcc/cp/decl2.c *** gcc-3.1.1/gcc/cp/decl2.c Thu Jul 4 10:57:18 2002 --- gcc-3.2/gcc/cp/decl2.c Fri Jul 26 23:22:59 2002 *************** import_export_decl (decl) *** 2529,2573 **** else comdat_linkage (decl); } ! else if (tinfo_decl_p (decl, 0)) ! { ! tree ctype = TREE_TYPE (DECL_NAME (decl)); ! if (IS_AGGR_TYPE (ctype)) ! import_export_class (ctype); ! if (IS_AGGR_TYPE (ctype) && CLASSTYPE_INTERFACE_KNOWN (ctype) ! && TYPE_POLYMORPHIC_P (ctype) ! /* If -fno-rtti, we're not necessarily emitting this stuff with ! the class, so go ahead and emit it now. This can happen ! when a class is used in exception handling. */ ! && flag_rtti ! /* If the type is a cv-qualified variant of a type, then we ! must emit the tinfo function in this translation unit ! since it will not be emitted when the vtable for the type ! is output (which is when the unqualified version is ! generated). */ ! && same_type_p (ctype, TYPE_MAIN_VARIANT (ctype))) ! { ! DECL_NOT_REALLY_EXTERN (decl) ! = ! (CLASSTYPE_INTERFACE_ONLY (ctype) ! || (DECL_DECLARED_INLINE_P (decl) ! && ! flag_implement_inlines ! && !DECL_VINDEX (decl))); ! /* Always make artificials weak. */ ! if (flag_weak) ! comdat_linkage (decl); ! } ! else if (TYPE_BUILT_IN (ctype) ! && same_type_p (ctype, TYPE_MAIN_VARIANT (ctype))) ! DECL_NOT_REALLY_EXTERN (decl) = 0; ! else ! comdat_linkage (decl); ! } else ! comdat_linkage (decl); DECL_INTERFACE_KNOWN (decl) = 1; } --- 2529,2578 ---- else comdat_linkage (decl); } ! else ! comdat_linkage (decl); ! DECL_INTERFACE_KNOWN (decl) = 1; ! } ! /* Here, we only decide whether or not the tinfo node should be ! emitted with the vtable. IS_IN_LIBRARY is non-zero iff the ! typeinfo for TYPE should be in the runtime library. */ ! void ! import_export_tinfo (decl, type, is_in_library) ! tree decl; ! tree type; ! int is_in_library; ! { ! if (DECL_INTERFACE_KNOWN (decl)) ! return; ! ! if (IS_AGGR_TYPE (type)) ! import_export_class (type); ! ! if (IS_AGGR_TYPE (type) && CLASSTYPE_INTERFACE_KNOWN (type) ! && TYPE_POLYMORPHIC_P (type) ! /* If -fno-rtti, we're not necessarily emitting this stuff with ! the class, so go ahead and emit it now. This can happen when ! a class is used in exception handling. */ ! && flag_rtti) ! { ! DECL_NOT_REALLY_EXTERN (decl) = !CLASSTYPE_INTERFACE_ONLY (type); ! DECL_COMDAT (decl) = 0; ! } else ! { ! DECL_NOT_REALLY_EXTERN (decl) = 1; ! DECL_COMDAT (decl) = 1; ! } + /* Now override some cases. */ + if (flag_weak) + DECL_COMDAT (decl) = 1; + else if (is_in_library) + DECL_COMDAT (decl) = 0; + DECL_INTERFACE_KNOWN (decl) = 1; } *************** finish_file () *** 3364,3370 **** /* Write out needed type info variables. Writing out one variable might cause others to be needed. */ ! if (walk_globals (tinfo_decl_p, emit_tinfo_decl, /*data=*/0)) reconsider = 1; /* The list of objects with static storage duration is built up --- 3369,3375 ---- /* Write out needed type info variables. Writing out one variable might cause others to be needed. */ ! if (walk_globals (unemitted_tinfo_decl_p, emit_tinfo_decl, /*data=*/0)) reconsider = 1; /* The list of objects with static storage duration is built up diff -Nrc3pad gcc-3.1.1/gcc/cp/lang-specs.h gcc-3.2/gcc/cp/lang-specs.h *** gcc-3.1.1/gcc/cp/lang-specs.h Mon Mar 18 20:10:19 2002 --- gcc-3.2/gcc/cp/lang-specs.h Tue Jul 30 20:42:14 2002 *************** Boston, MA 02111-1307, USA. */ *** 38,51 **** "%{E|M|MM:cpp0 -lang-c++ %{!no-gcc:-D__GNUG__=%v1}\ %{!Wno-deprecated:-D__DEPRECATED}\ %{!fno-exceptions:-D__EXCEPTIONS}\ - -D__GXX_ABI_VERSION=100\ %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\ %{!E:%{!M:%{!MM:\ %{save-temps|no-integrated-cpp:cpp0 -lang-c++ \ %{!no-gcc:-D__GNUG__=%v1}\ %{!Wno-deprecated:-D__DEPRECATED}\ %{!fno-exceptions:-D__EXCEPTIONS}\ - -D__GXX_ABI_VERSION=100\ %{ansi:-D__STRICT_ANSI__ -trigraphs -$}\ %(cpp_options) %{save-temps:%b.ii} %{!save-temps:%g.ii} \n}\ cc1plus %{save-temps|no-integrated-cpp:-fpreprocessed %{save-temps:%b.ii} %{!save-temps:%g.ii}}\ --- 38,49 ---- *************** Boston, MA 02111-1307, USA. */ *** 53,59 **** %{!no-gcc:-D__GNUG__=%v1} \ %{!Wno-deprecated:-D__DEPRECATED}\ %{!fno-exceptions:-D__EXCEPTIONS}\ - -D__GXX_ABI_VERSION=100\ %{ansi:-D__STRICT_ANSI__}}}\ %{ansi:-trigraphs -$}\ %(cc1_options) %2 %{+e1*}\ --- 51,56 ---- diff -Nrc3pad gcc-3.1.1/gcc/cp/mangle.c gcc-3.2/gcc/cp/mangle.c *** gcc-3.1.1/gcc/cp/mangle.c Tue Jul 2 03:14:24 2002 --- gcc-3.2/gcc/cp/mangle.c Fri Jul 26 23:22:58 2002 *************** write_unqualified_name (decl) *** 982,989 **** { /* Conversion operator. Handle it right here. ::= cv */ write_string ("cv"); ! write_type (TREE_TYPE (DECL_NAME (decl))); } else if (DECL_OVERLOADED_OPERATOR_P (decl)) { --- 982,998 ---- { /* Conversion operator. Handle it right here. ::= cv */ + tree type; + if (decl_is_template_id (decl, NULL)) + { + tree fn_type = get_mostly_instantiated_function_type (decl, NULL, + NULL); + type = TREE_TYPE (fn_type); + } + else + type = TREE_TYPE (DECL_NAME (decl)); write_string ("cv"); ! write_type (type); } else if (DECL_OVERLOADED_OPERATOR_P (decl)) { diff -Nrc3pad gcc-3.1.1/gcc/cp/rtti.c gcc-3.2/gcc/cp/rtti.c *** gcc-3.1.1/gcc/cp/rtti.c Wed Jan 23 14:26:02 2002 --- gcc-3.2/gcc/cp/rtti.c Fri Jul 26 23:22:59 2002 *************** *** 1,5 **** /* RunTime Type Identification ! Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. Mostly written by Jason Merrill (jason@cygnus.com). --- 1,5 ---- /* RunTime Type Identification ! Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Mostly written by Jason Merrill (jason@cygnus.com). *************** Boston, MA 02111-1307, USA. */ *** 30,45 **** #include "assert.h" #include "toplev.h" /* Accessors for the type_info objects. We need to remember several things about each of the type_info types. The global tree nodes such as bltn_desc_type_node are TREE_LISTs, and these macros are used to access the required information. */ /* The RECORD_TYPE of a type_info derived class. */ #define TINFO_PSEUDO_TYPE(NODE) TREE_TYPE (NODE) ! /* The VAR_DECL of the vtable for the type_info derived class. */ #define TINFO_VTABLE_DECL(NODE) TREE_VALUE (NODE) ! ! extern struct obstack permanent_obstack; static tree build_headof PARAMS((tree)); static tree ifnonnull PARAMS((tree, tree)); --- 30,75 ---- #include "assert.h" #include "toplev.h" + /* C++ returns type information to the user in struct type_info + objects. We also use type information to implement dynamic_cast and + exception handlers. Type information for a particular type is + indicated with an ABI defined structure derived from type_info. + This would all be very straight forward, but for the fact that the + runtime library provides the definitions of the type_info structure + and the ABI defined derived classes. We cannot build declarations + of them directly in the compiler, but we need to layout objects of + their type. Somewhere we have to lie. + + We define layout compatible POD-structs with compiler-defined names + and generate the appropriate initializations for them (complete + with explicit mention of their vtable). When we have to provide a + type_info to the user we reinterpret_cast the internal compiler + type to type_info. A well formed program can only explicitly refer + to the type_infos of complete types (& cv void). However, we chain + pointer type_infos to the pointed-to-type, and that can be + incomplete. We only need the addresses of such incomplete + type_info objects for static initialization. + + The type information VAR_DECL of a type is held on the + IDENTIFIER_GLOBAL_VALUE of the type's mangled name. That VAR_DECL + will be the internal type. It will usually have the correct + internal type reflecting the kind of type it represents (pointer, + array, function, class, inherited class, etc). When the type it + represents is incomplete, it will have the internal type + corresponding to type_info. That will only happen at the end of + translation, when we are emitting the type info objects. */ + /* Accessors for the type_info objects. We need to remember several things about each of the type_info types. The global tree nodes such as bltn_desc_type_node are TREE_LISTs, and these macros are used to access the required information. */ /* The RECORD_TYPE of a type_info derived class. */ #define TINFO_PSEUDO_TYPE(NODE) TREE_TYPE (NODE) ! /* The VAR_DECL of the vtable for the type_info derived class. ! This is only filled in at the end of the translation. */ #define TINFO_VTABLE_DECL(NODE) TREE_VALUE (NODE) ! /* The IDENTIFIER_NODE naming the real class. */ ! #define TINFO_REAL_NAME(NODE) TREE_PURPOSE (NODE) static tree build_headof PARAMS((tree)); static tree ifnonnull PARAMS((tree, tree)); *************** static tree build_dynamic_cast_1 PARAMS( *** 48,54 **** static tree throw_bad_cast PARAMS((void)); static tree throw_bad_typeid PARAMS((void)); static tree get_tinfo_decl_dynamic PARAMS((tree)); ! static bool typeid_ok_p PARAMS ((void)); static int qualifier_flags PARAMS((tree)); static int target_incomplete_p PARAMS((tree)); static tree tinfo_base_init PARAMS((tree, tree)); --- 78,85 ---- static tree throw_bad_cast PARAMS((void)); static tree throw_bad_typeid PARAMS((void)); static tree get_tinfo_decl_dynamic PARAMS((tree)); ! static tree get_tinfo_ptr PARAMS((tree)); ! static bool typeid_ok_p PARAMS((void)); static int qualifier_flags PARAMS((tree)); static int target_incomplete_p PARAMS((tree)); static tree tinfo_base_init PARAMS((tree, tree)); *************** static tree dfs_class_hint_mark PARAMS ( *** 59,73 **** static tree dfs_class_hint_unmark PARAMS ((tree, void *)); static int class_hint_flags PARAMS((tree)); static tree class_initializer PARAMS((tree, tree, tree)); - static tree synthesize_tinfo_var PARAMS((tree, tree)); - static tree create_real_tinfo_var PARAMS((tree, tree, tree, tree, int)); static tree create_pseudo_type_info PARAMS((const char *, int, ...)); ! static tree get_vmi_pseudo_type_info PARAMS((int)); static void create_tinfo_types PARAMS((void)); static int typeinfo_in_lib_p PARAMS((tree)); static int doing_runtime = 0; void init_rtti_processing () { --- 90,110 ---- static tree dfs_class_hint_unmark PARAMS ((tree, void *)); static int class_hint_flags PARAMS((tree)); static tree class_initializer PARAMS((tree, tree, tree)); static tree create_pseudo_type_info PARAMS((const char *, int, ...)); ! static tree get_pseudo_ti_init PARAMS ((tree, tree, int *)); ! static tree get_pseudo_ti_desc PARAMS((tree)); static void create_tinfo_types PARAMS((void)); static int typeinfo_in_lib_p PARAMS((tree)); static int doing_runtime = 0; + + /* Declare language defined type_info type and a pointer to const + type_info. This is incomplete here, and will be completed when + the user #includes . There are language defined + restrictions on what can be done until that is included. Create + the internal versions of the ABI types. */ + void init_rtti_processing () { *************** init_rtti_processing () *** 75,82 **** type_info_type_node = xref_tag (class_type_node, get_identifier ("type_info"), 1); pop_namespace (); ! tinfo_decl_type = ! build_qualified_type (type_info_type_node, TYPE_QUAL_CONST); } /* Given the expression EXP of type `class *', return the head of the --- 112,122 ---- type_info_type_node = xref_tag (class_type_node, get_identifier ("type_info"), 1); pop_namespace (); ! type_info_ptr_type = ! build_pointer_type ! (build_qualified_type (type_info_type_node, TYPE_QUAL_CONST)); ! ! create_tinfo_types (); } /* Given the expression EXP of type `class *', return the head of the *************** get_tinfo_decl_dynamic (exp) *** 183,195 **** /* The RTTI information is at index -1. */ index = integer_minus_one_node; t = build_vtbl_ref (exp, index); ! TREE_TYPE (t) = build_pointer_type (tinfo_decl_type); return t; } ! /* otherwise return the type_info for the static type of the expr. */ ! exp = get_tinfo_decl (TYPE_MAIN_VARIANT (type)); ! return build_unary_op (ADDR_EXPR, exp, 0); } static bool --- 223,234 ---- /* The RTTI information is at index -1. */ index = integer_minus_one_node; t = build_vtbl_ref (exp, index); ! TREE_TYPE (t) = type_info_ptr_type; return t; } ! /* Otherwise return the type_info for the static type of the expr. */ ! return get_tinfo_ptr (TYPE_MAIN_VARIANT (type)); } static bool *************** tinfo_name (type) *** 263,271 **** return name_string; } ! /* Returns a decl for the type_info variable for TYPE. You must ! arrange that the decl is mark_used, if actually use it --- decls in ! vtables are only used if the vtable is output. */ tree get_tinfo_decl (type) --- 302,310 ---- return name_string; } ! /* Return a VAR_DECL for the internal ABI defined type_info object for ! TYPE. You must arrange that the decl is mark_used, if actually use ! it --- decls in vtables are only used if the vtable is output. */ tree get_tinfo_decl (type) *************** get_tinfo_decl (type) *** 278,284 **** && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) { error ("cannot create type information for type `%T' because its size is variable", ! type); return error_mark_node; } --- 317,323 ---- && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) { error ("cannot create type information for type `%T' because its size is variable", ! type); return error_mark_node; } *************** get_tinfo_decl (type) *** 291,327 **** name = mangle_typeinfo_for_type (type); d = IDENTIFIER_GLOBAL_VALUE (name); ! if (d) ! /* OK */; ! else { ! /* The tinfo decl is the type_info object itself. We make all ! tinfo objects look as type_info, even though they will end up ! being a subclass of that when emitted. This means that we'll ! erroneously think we know the dynamic type -- be careful in the ! runtime. */ ! d = build_lang_decl (VAR_DECL, name, tinfo_decl_type); DECL_ARTIFICIAL (d) = 1; - DECL_ALIGN (d) = TYPE_ALIGN (ptr_type_node); - DECL_USER_ALIGN (d) = 0; TREE_READONLY (d) = 1; TREE_STATIC (d) = 1; DECL_EXTERNAL (d) = 1; - TREE_PUBLIC (d) = 1; - if (flag_weak || !typeinfo_in_lib_p (type)) - comdat_linkage (d); SET_DECL_ASSEMBLER_NAME (d, name); cp_finish_decl (d, NULL_TREE, NULL_TREE, 0); pushdecl_top_level (d); /* Remember the type it is for. */ TREE_TYPE (name) = type; - TREE_USED (name) = 1; } return d; } /* Return the type_info object for TYPE. */ tree --- 330,374 ---- name = mangle_typeinfo_for_type (type); d = IDENTIFIER_GLOBAL_VALUE (name); ! if (!d) { ! tree var_desc = get_pseudo_ti_desc (type); ! ! d = build_lang_decl (VAR_DECL, name, TINFO_PSEUDO_TYPE (var_desc)); DECL_ARTIFICIAL (d) = 1; TREE_READONLY (d) = 1; TREE_STATIC (d) = 1; DECL_EXTERNAL (d) = 1; SET_DECL_ASSEMBLER_NAME (d, name); + DECL_COMDAT (d) = 1; cp_finish_decl (d, NULL_TREE, NULL_TREE, 0); pushdecl_top_level (d); + /* Remember the type it is for. */ TREE_TYPE (name) = type; } + return d; } + /* Return a pointer to a type_info object describing TYPE, suitably + cast to the language defined type. */ + + static tree + get_tinfo_ptr (type) + tree type; + { + tree exp = get_tinfo_decl (type); + + /* Convert to type_info type. */ + exp = build_unary_op (ADDR_EXPR, exp, 0); + exp = ocp_convert (type_info_ptr_type, exp, CONV_REINTERPRET, 0); + + return exp; + } + /* Return the type_info object for TYPE. */ tree *************** get_typeid (type) *** 350,356 **** if (!type) return error_mark_node; ! return get_tinfo_decl (type); } /* Check whether TEST is null before returning RESULT. If TEST is used in --- 397,403 ---- if (!type) return error_mark_node; ! return build_indirect_ref (get_tinfo_ptr (type), NULL); } /* Check whether TEST is null before returning RESULT. If TEST is used in *************** tinfo_base_init (desc, target) *** 683,688 **** --- 730,736 ---- { tree init = NULL_TREE; tree name_decl; + tree vtable_ptr; { tree name_name; *************** tinfo_base_init (desc, target) *** 710,721 **** cp_finish_decl (name_decl, name_string, NULL_TREE, 0); pushdecl_top_level (name_decl); } ! ! if (TINFO_VTABLE_DECL (desc)) { ! tree vtbl_ptr = TINFO_VTABLE_DECL (desc); ! init = tree_cons (NULL_TREE, vtbl_ptr, init); } init = tree_cons (NULL_TREE, decay_conversion (name_decl), init); --- 758,797 ---- cp_finish_decl (name_decl, name_string, NULL_TREE, 0); pushdecl_top_level (name_decl); } ! ! vtable_ptr = TINFO_VTABLE_DECL (desc); ! if (!vtable_ptr) { ! tree real_type; ! ! push_nested_namespace (abi_node); ! real_type = xref_tag (class_type_node, TINFO_REAL_NAME (desc), 1); ! pop_nested_namespace (abi_node); ! ! if (!COMPLETE_TYPE_P (real_type)) ! { ! /* We never saw a definition of this type, so we need to ! tell the compiler that this is an exported class, as ! indeed all of the __*_type_info classes are. */ ! SET_CLASSTYPE_INTERFACE_KNOWN (real_type); ! CLASSTYPE_INTERFACE_ONLY (real_type) = 1; ! } ! ! vtable_ptr = get_vtable_decl (real_type, /*complete=*/1); ! vtable_ptr = build_unary_op (ADDR_EXPR, vtable_ptr, 0); ! ! /* We need to point into the middle of the vtable. */ ! vtable_ptr = build ! (PLUS_EXPR, TREE_TYPE (vtable_ptr), vtable_ptr, ! size_binop (MULT_EXPR, ! size_int (2), ! TYPE_SIZE_UNIT (vtable_entry_type))); ! TREE_CONSTANT (vtable_ptr) = 1; ! ! TINFO_VTABLE_DECL (desc) = vtable_ptr; } + + init = tree_cons (NULL_TREE, vtable_ptr, init); init = tree_cons (NULL_TREE, decay_conversion (name_decl), init); *************** ptr_initializer (desc, target, non_publi *** 764,771 **** } init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init); init = tree_cons (NULL_TREE, ! build_unary_op (ADDR_EXPR, ! get_tinfo_decl (TYPE_MAIN_VARIANT (to)), 0), init); init = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, nreverse (init)); --- 840,846 ---- } init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init); init = tree_cons (NULL_TREE, ! get_tinfo_ptr (TYPE_MAIN_VARIANT (to)), init); init = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, nreverse (init)); *************** ptm_initializer (desc, target, non_publi *** 802,813 **** } init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init); init = tree_cons (NULL_TREE, ! build_unary_op (ADDR_EXPR, ! get_tinfo_decl (TYPE_MAIN_VARIANT (to)), 0), init); init = tree_cons (NULL_TREE, ! build_unary_op (ADDR_EXPR, get_tinfo_decl (klass), 0), ! init); init = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, nreverse (init)); TREE_HAS_CONSTRUCTOR (init) = TREE_CONSTANT (init) = TREE_STATIC (init) = 1; --- 877,887 ---- } init = tree_cons (NULL_TREE, build_int_2 (flags, 0), init); init = tree_cons (NULL_TREE, ! get_tinfo_ptr (TYPE_MAIN_VARIANT (to)), init); init = tree_cons (NULL_TREE, ! get_tinfo_ptr (klass), ! init); init = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, nreverse (init)); TREE_HAS_CONSTRUCTOR (init) = TREE_CONSTANT (init) = TREE_STATIC (init) = 1; *************** typeinfo_in_lib_p (type) *** 928,1004 **** } } ! /* Generate a pseudo_type_info VAR_DECL suitable for the supplied ! TARGET_TYPE and given the REAL_NAME. This is the structure expected by ! the runtime, and therefore has additional fields. If we need not emit a ! definition (because the runtime must contain it), return NULL_TREE, ! otherwise return the VAR_DECL. */ static tree ! synthesize_tinfo_var (target_type, real_name) ! tree target_type; ! tree real_name; { ! tree var_init = NULL_TREE; ! tree var_type = NULL_TREE; ! int non_public = 0; ! ! switch (TREE_CODE (target_type)) { case POINTER_TYPE: ! if (TYPE_PTRMEM_P (target_type)) ! { ! var_type = ptm_desc_type_node; ! var_init = ptm_initializer (var_type, target_type, &non_public); ! } else ! { ! if (typeinfo_in_lib_p (target_type) && !doing_runtime) ! /* These are in the runtime. */ ! return NULL_TREE; ! var_type = ptr_desc_type_node; ! var_init = ptr_initializer (var_type, target_type, &non_public); ! } break; case ENUMERAL_TYPE: ! var_type = enum_desc_type_node; ! var_init = generic_initializer (var_type, target_type); break; case FUNCTION_TYPE: ! var_type = func_desc_type_node; ! var_init = generic_initializer (var_type, target_type); break; case ARRAY_TYPE: ! var_type = ary_desc_type_node; ! var_init = generic_initializer (var_type, target_type); break; case UNION_TYPE: case RECORD_TYPE: ! if (TYPE_PTRMEMFUNC_P (target_type)) ! { ! var_type = ptm_desc_type_node; ! var_init = ptm_initializer (var_type, target_type, &non_public); ! } ! else if (!COMPLETE_TYPE_P (target_type)) ! { ! /* Emit a non-public class_type_info. */ ! non_public = 1; ! var_type = class_desc_type_node; ! var_init = class_initializer (var_type, target_type, NULL_TREE); ! } ! else if (!CLASSTYPE_N_BASECLASSES (target_type)) { ! var_type = class_desc_type_node; ! var_init = class_initializer (var_type, target_type, NULL_TREE); } else { ! /* if this has a single public non-virtual base, it's easier */ ! tree binfo = TYPE_BINFO (target_type); int nbases = BINFO_N_BASETYPES (binfo); tree base_binfos = BINFO_BASETYPES (binfo); tree base_inits = NULL_TREE; - int is_simple = nbases == 1; int ix; /* Generate the base information initializer. */ --- 1002,1064 ---- } } ! /* Generate the initializer for the type info describing ! TYPE. VAR_DESC is a . NON_PUBLIC_P is set non-zero, if the VAR_DECL ! should not be exported from this object file. This should only be ! called at the end of translation, when we know that no further ! types will be completed. */ static tree ! get_pseudo_ti_init (type, var_desc, non_public_p) ! tree type; ! tree var_desc; ! int *non_public_p; { ! my_friendly_assert (at_eof, 20021120); ! switch (TREE_CODE (type)) { case POINTER_TYPE: ! if (TYPE_PTRMEM_P (type)) ! return ptm_initializer (var_desc, type, non_public_p); else ! return ptr_initializer (var_desc, type, non_public_p); break; case ENUMERAL_TYPE: ! return generic_initializer (var_desc, type); break; case FUNCTION_TYPE: ! return generic_initializer (var_desc, type); break; case ARRAY_TYPE: ! return generic_initializer (var_desc, type); break; case UNION_TYPE: case RECORD_TYPE: ! if (TYPE_PTRMEMFUNC_P (type)) ! return ptm_initializer (var_desc, type, non_public_p); ! else if (var_desc == class_desc_type_node) { ! if (!COMPLETE_TYPE_P (type)) ! /* Emit a non-public class_type_info. */ ! *non_public_p = 1; ! return class_initializer (var_desc, type, NULL_TREE); } + else if (var_desc == si_class_desc_type_node) + { + tree base_binfos = BINFO_BASETYPES (TYPE_BINFO (type)); + tree base_binfo = TREE_VEC_ELT (base_binfos, 0); + tree tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo)); + tree base_inits = tree_cons (NULL_TREE, tinfo, NULL_TREE); + + return class_initializer (var_desc, type, base_inits); + } else { ! int hint = class_hint_flags (type); ! tree binfo = TYPE_BINFO (type); int nbases = BINFO_N_BASETYPES (binfo); tree base_binfos = BINFO_BASETYPES (binfo); tree base_inits = NULL_TREE; int ix; /* Generate the base information initializer. */ *************** synthesize_tinfo_var (target_type, real_ *** 1012,1039 **** if (TREE_PUBLIC (base_binfo)) flags |= 2; ! tinfo = get_tinfo_decl (BINFO_TYPE (base_binfo)); ! tinfo = build_unary_op (ADDR_EXPR, tinfo, 0); if (TREE_VIA_VIRTUAL (base_binfo)) { /* We store the vtable offset at which the virtual base offset can be found. */ ! offset = BINFO_VPTR_FIELD (binfo_for_vbase (BINFO_TYPE (base_binfo), ! target_type)); offset = convert (sizetype, offset); flags |= 1; } else offset = BINFO_OFFSET (base_binfo); - /* is it a single public inheritance? */ - if (is_simple && flags == 2 && integer_zerop (offset)) - { - base_inits = tree_cons (NULL_TREE, tinfo, NULL_TREE); - break; - } - is_simple = 0; - /* combine offset and flags into one field */ offset = cp_build_binary_op (LSHIFT_EXPR, offset, build_int_2 (8, 0)); --- 1072,1090 ---- if (TREE_PUBLIC (base_binfo)) flags |= 2; ! tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo)); if (TREE_VIA_VIRTUAL (base_binfo)) { /* We store the vtable offset at which the virtual base offset can be found. */ ! offset = BINFO_VPTR_FIELD ! (binfo_for_vbase (BINFO_TYPE (base_binfo), type)); offset = convert (sizetype, offset); flags |= 1; } else offset = BINFO_OFFSET (base_binfo); /* combine offset and flags into one field */ offset = cp_build_binary_op (LSHIFT_EXPR, offset, build_int_2 (8, 0)); *************** synthesize_tinfo_var (target_type, real_ *** 1044,1129 **** base_init = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, base_init); base_inits = tree_cons (NULL_TREE, base_init, base_inits); } ! ! if (is_simple) ! var_type = si_class_desc_type_node; ! else ! { ! int hint = class_hint_flags (target_type); ! ! base_inits = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, base_inits); ! base_inits = tree_cons (NULL_TREE, base_inits, NULL_TREE); ! /* Prepend the number of bases. */ ! base_inits = tree_cons (NULL_TREE, ! build_int_2 (nbases, 0), base_inits); ! /* Prepend the hint flags. */ ! base_inits = tree_cons (NULL_TREE, ! build_int_2 (hint, 0), base_inits); ! var_type = get_vmi_pseudo_type_info (nbases); ! } ! var_init = class_initializer (var_type, target_type, base_inits); } break; default: ! if (typeinfo_in_lib_p (target_type)) ! { ! if (!doing_runtime) ! /* These are guaranteed to be in the runtime. */ ! return NULL_TREE; ! var_type = bltn_desc_type_node; ! var_init = generic_initializer (var_type, target_type); ! break; ! } ! abort (); ! } ! ! return create_real_tinfo_var (target_type, ! real_name, TINFO_PSEUDO_TYPE (var_type), ! var_init, non_public); ! } ! ! /* Create the real typeinfo variable. NON_PUBLIC indicates that we cannot ! make this variable public (comdat). */ ! ! static tree ! create_real_tinfo_var (target_type, name, type, init, non_public) ! tree target_type; ! tree name; ! tree type; ! tree init; ! int non_public; ! { ! static int count = 0; ! tree decl; ! tree hidden_name; ! char hidden[30]; ! ! /* We cannot give this the name NAME, as that already is globally ! bound to the tinfo_decl we originally created for this type in ! get_tinfo_decl. */ ! sprintf (hidden, "__ti_%d", count++); ! hidden_name = get_identifier (hidden); ! ! decl = build_lang_decl (VAR_DECL, hidden_name, ! build_qualified_type (type, TYPE_QUAL_CONST)); ! DECL_ARTIFICIAL (decl) = 1; ! TREE_READONLY (decl) = 1; ! TREE_STATIC (decl) = 1; ! DECL_EXTERNAL (decl) = 0; ! ! if (!non_public) ! { ! TREE_PUBLIC (decl) = 1; ! if (flag_weak || !typeinfo_in_lib_p (target_type)) ! comdat_linkage (decl); } - SET_DECL_ASSEMBLER_NAME (decl, name); - DECL_INITIAL (decl) = init; - cp_finish_decl (decl, init, NULL_TREE, 0); - pushdecl_top_level (decl); - TREE_USED (decl) = 1; - return decl; } /* Generate the RECORD_TYPE containing the data layout of a type_info --- 1095,1117 ---- base_init = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, base_init); base_inits = tree_cons (NULL_TREE, base_init, base_inits); } ! base_inits = build (CONSTRUCTOR, ! NULL_TREE, NULL_TREE, base_inits); ! base_inits = tree_cons (NULL_TREE, base_inits, NULL_TREE); ! /* Prepend the number of bases. */ ! base_inits = tree_cons (NULL_TREE, ! build_int_2 (nbases, 0), base_inits); ! /* Prepend the hint flags. */ ! base_inits = tree_cons (NULL_TREE, ! build_int_2 (hint, 0), base_inits); ! ! return class_initializer (var_desc, type, base_inits); } break; default: ! return generic_initializer (var_desc, type); } } /* Generate the RECORD_TYPE containing the data layout of a type_info *************** create_real_tinfo_var (target_type, name *** 1132,1138 **** type's vtable. We explicitly manage the vtable member, and name it for real type as used in the runtime. The RECORD type has a different name, to avoid collisions. Return a TREE_LIST who's TINFO_PSEUDO_TYPE ! is the generated type and TINFO_VTABLE_DECL is the vtable decl. REAL_NAME is the runtime's name of the type. Trailing arguments are additional FIELD_DECL's for the structure. The final argument must be --- 1120,1129 ---- type's vtable. We explicitly manage the vtable member, and name it for real type as used in the runtime. The RECORD type has a different name, to avoid collisions. Return a TREE_LIST who's TINFO_PSEUDO_TYPE ! is the generated type and TINFO_VTABLE_NAME is the name of the ! vtable. We have to delay generating the VAR_DECL of the vtable ! until the end of the translation, when we'll have seen the library ! definition, if there was one. REAL_NAME is the runtime's name of the type. Trailing arguments are additional FIELD_DECL's for the structure. The final argument must be *************** create_real_tinfo_var (target_type, name *** 1141,1149 **** static tree create_pseudo_type_info VPARAMS((const char *real_name, int ident, ...)) { ! tree real_type, pseudo_type; char *pseudo_name; - tree vtable_decl; int ix; tree fields[10]; tree field_decl; --- 1132,1139 ---- static tree create_pseudo_type_info VPARAMS((const char *real_name, int ident, ...)) { ! tree pseudo_type; char *pseudo_name; int ix; tree fields[10]; tree field_decl; *************** create_pseudo_type_info VPARAMS((const c *** 1160,1188 **** if (ident) sprintf (pseudo_name + strlen (pseudo_name), "%d", ident); - /* Get the vtable decl. */ - real_type = xref_tag (class_type_node, get_identifier (real_name), 1); - if (! TYPE_SIZE (real_type)) - { - /* We never saw a definition of this type, so we need to tell the - compiler that this is an exported class, as indeed all of the - __*_type_info classes are. */ - SET_CLASSTYPE_INTERFACE_KNOWN (real_type); - CLASSTYPE_INTERFACE_ONLY (real_type) = 1; - } - - vtable_decl = get_vtable_decl (real_type, /*complete=*/1); - vtable_decl = build_unary_op (ADDR_EXPR, vtable_decl, 0); - - /* We need to point into the middle of the vtable. */ - vtable_decl = build (PLUS_EXPR, - TREE_TYPE (vtable_decl), - vtable_decl, - size_binop (MULT_EXPR, - size_int (2), - TYPE_SIZE_UNIT (vtable_entry_type))); - TREE_CONSTANT (vtable_decl) = 1; - /* First field is the pseudo type_info base class. */ fields[0] = build_decl (FIELD_DECL, NULL_TREE, ti_desc_type_node); --- 1150,1155 ---- *************** create_pseudo_type_info VPARAMS((const c *** 1196,1248 **** TYPE_HAS_CONSTRUCTOR (pseudo_type) = 1; result = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); ! TINFO_VTABLE_DECL (result) = vtable_decl; ! TINFO_PSEUDO_TYPE (result) = pseudo_type; VA_CLOSE (ap); return result; } ! /* Return a descriptor for a vmi type with NUM_BASES bases. */ static tree ! get_vmi_pseudo_type_info (num_bases) ! int num_bases; { ! tree desc; ! tree array_domain, base_array; ! ! if (TREE_VEC_LENGTH (vmi_class_desc_type_node) <= num_bases) { ! int ix; ! tree extend = make_tree_vec (num_bases + 5); ! ! for (ix = TREE_VEC_LENGTH (vmi_class_desc_type_node); ix--;) ! TREE_VEC_ELT (extend, ix) = TREE_VEC_ELT (vmi_class_desc_type_node, ix); ! vmi_class_desc_type_node = extend; ! } ! desc = TREE_VEC_ELT (vmi_class_desc_type_node, num_bases); ! ! if (desc) ! return desc; ! /* Add number of bases and trailing array of base_class_type_info. */ ! array_domain = build_index_type (size_int (num_bases)); ! base_array = build_array_type (base_desc_type_node, array_domain); ! ! push_nested_namespace (abi_node); ! ! desc = create_pseudo_type_info ! ("__vmi_class_type_info", num_bases, ! build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, base_array), ! NULL); ! pop_nested_namespace (abi_node); ! TREE_VEC_ELT (vmi_class_desc_type_node, num_bases) = desc; ! return desc; } /* Make sure the required builtin types exist for generating the type_info --- 1163,1258 ---- TYPE_HAS_CONSTRUCTOR (pseudo_type) = 1; result = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); ! TINFO_REAL_NAME (result) = get_identifier (real_name); ! TINFO_PSEUDO_TYPE (result) = ! cp_build_qualified_type (pseudo_type, TYPE_QUAL_CONST); VA_CLOSE (ap); return result; } ! /* Return a pseudo type info type node used to describe TYPE. TYPE ! must be a complete type (or cv void), except at the end of the ! translation unit. */ static tree ! get_pseudo_ti_desc (type) ! tree type; { ! switch (TREE_CODE (type)) { ! case POINTER_TYPE: ! return TYPE_PTRMEM_P (type) ? ptm_desc_type_node : ptr_desc_type_node; ! case ENUMERAL_TYPE: ! return enum_desc_type_node; ! case FUNCTION_TYPE: ! return func_desc_type_node; ! case ARRAY_TYPE: ! return ary_desc_type_node; ! case UNION_TYPE: ! case RECORD_TYPE: ! if (TYPE_PTRMEMFUNC_P (type)) ! return ptm_desc_type_node; ! else if (!COMPLETE_TYPE_P (type)) ! { ! my_friendly_assert (at_eof, 20020609); ! return class_desc_type_node; ! } ! else if (!CLASSTYPE_N_BASECLASSES (type)) ! return class_desc_type_node; ! else ! { ! tree base_binfo = ! TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), 0); ! int num_bases = BINFO_N_BASETYPES (TYPE_BINFO (type)); ! ! if (num_bases == 1 ! && TREE_PUBLIC (base_binfo) ! && !TREE_VIA_VIRTUAL (base_binfo) ! && integer_zerop (BINFO_OFFSET (base_binfo))) ! /* single non-virtual public. */ ! return si_class_desc_type_node; ! else ! { ! tree var_desc; ! tree array_domain, base_array; ! ! if (TREE_VEC_LENGTH (vmi_class_desc_type_node) <= num_bases) ! { ! int ix; ! tree extend = make_tree_vec (num_bases + 5); ! ! for (ix = TREE_VEC_LENGTH (vmi_class_desc_type_node); ix--;) ! TREE_VEC_ELT (extend, ix) ! = TREE_VEC_ELT (vmi_class_desc_type_node, ix); ! vmi_class_desc_type_node = extend; ! } ! var_desc = TREE_VEC_ELT (vmi_class_desc_type_node, num_bases); ! if (var_desc) ! return var_desc; ! /* Add number of bases and trailing array of ! base_class_type_info. */ ! array_domain = build_index_type (size_int (num_bases)); ! base_array = ! build_array_type (base_desc_type_node, array_domain); ! push_nested_namespace (abi_node); ! var_desc = create_pseudo_type_info ! ("__vmi_class_type_info", num_bases, ! build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, base_array), ! NULL); ! pop_nested_namespace (abi_node); ! TREE_VEC_ELT (vmi_class_desc_type_node, num_bases) = var_desc; ! return var_desc; ! } ! } ! default: ! return bltn_desc_type_node; ! } } /* Make sure the required builtin types exist for generating the type_info *************** get_vmi_pseudo_type_info (num_bases) *** 1251,1265 **** static void create_tinfo_types () { ! tree ptr_type_info; ! ! if (bltn_desc_type_node) ! return; ! push_nested_namespace (abi_node); ! ptr_type_info = build_pointer_type ! (build_qualified_type ! (type_info_type_node, TYPE_QUAL_CONST)); /* Create the internal type_info structure. This is used as a base for the other structures. */ --- 1261,1269 ---- static void create_tinfo_types () { ! my_friendly_assert (!ti_desc_type_node, 20020609); ! push_nested_namespace (abi_node); /* Create the internal type_info structure. This is used as a base for the other structures. */ *************** create_tinfo_types () *** 1299,1305 **** This is really a descendant of __class_type_info. */ si_class_desc_type_node = create_pseudo_type_info ("__si_class_type_info", 0, ! build_decl (FIELD_DECL, NULL_TREE, ptr_type_info), NULL); /* Base class internal helper. Pointer to base type, offset to base, --- 1303,1309 ---- This is really a descendant of __class_type_info. */ si_class_desc_type_node = create_pseudo_type_info ("__si_class_type_info", 0, ! build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type), NULL); /* Base class internal helper. Pointer to base type, offset to base, *************** create_tinfo_types () *** 1307,1313 **** { tree fields[2]; ! fields[0] = build_decl (FIELD_DECL, NULL_TREE, ptr_type_info); fields[1] = build_decl (FIELD_DECL, NULL_TREE, integer_types[itk_long]); base_desc_type_node = make_aggr_type (RECORD_TYPE); finish_builtin_type (base_desc_type_node, "__base_class_type_info_pseudo", --- 1311,1317 ---- { tree fields[2]; ! fields[0] = build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type); fields[1] = build_decl (FIELD_DECL, NULL_TREE, integer_types[itk_long]); base_desc_type_node = make_aggr_type (RECORD_TYPE); finish_builtin_type (base_desc_type_node, "__base_class_type_info_pseudo", *************** create_tinfo_types () *** 1324,1330 **** ptr_desc_type_node = create_pseudo_type_info ("__pointer_type_info", 0, build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, ptr_type_info), NULL); /* Pointer to member data type_info. Add qualifications flags, --- 1328,1334 ---- ptr_desc_type_node = create_pseudo_type_info ("__pointer_type_info", 0, build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type), NULL); /* Pointer to member data type_info. Add qualifications flags, *************** create_tinfo_types () *** 1333,1340 **** ptm_desc_type_node = create_pseudo_type_info ("__pointer_to_member_type_info", 0, build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, ptr_type_info), ! build_decl (FIELD_DECL, NULL_TREE, ptr_type_info), NULL); pop_nested_namespace (abi_node); --- 1337,1344 ---- ptm_desc_type_node = create_pseudo_type_info ("__pointer_to_member_type_info", 0, build_decl (FIELD_DECL, NULL_TREE, integer_type_node), ! build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type), ! build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type), NULL); pop_nested_namespace (abi_node); *************** emit_support_tinfos () *** 1401,1475 **** definition emitted for it. */ int ! tinfo_decl_p (t, data) tree t; void *data ATTRIBUTE_UNUSED; { ! return TREE_CODE (t) == VAR_DECL ! && IDENTIFIER_GLOBAL_VALUE (DECL_NAME (t)) == (t) ! && TREE_TYPE (t) == tinfo_decl_type ! && TREE_TYPE (DECL_NAME (t)); } ! /* Emit a suitable type_info definition for the type_info decl pointed to by ! DECL_PTR. We emit a completely new variable, of the correct type for the ! actual type this is describing. The DECL_ASSEMBLER_NAME of the generated ! definition is set to that of the supplied decl, so that they can be tied ! up. Mark the supplied decl as having been dealt with. Emitting one ! definition might cause other definitions to be required. ! ! We need to do things this way, because we're trying to do something like ! ! struct B : A { ! ... ! }; ! ! extern const A tinfo_var; ! ! const B tinfo_var = {...}; ! ! which is not permitted. Also, we've not necessarily seen the definition of B. ! So we do something like the following, ! ! extern const A tinfo_var; ! ! struct pseudo_A { ! const void *vtable_ptr; ! const char *name; ! }; ! struct pseudo_B { ! pseudo_A base; ! ... ! }; ! ! const pseudo_B proxy_tinfo_var attribute((assembler_name="tinfo_var")) = ! { ! {&B::vtable, "..."}, ! ... ! }; ! ! pseudo_A and pseudo_B must be layout equivalent to the real definitions in ! the runtime. */ int emit_tinfo_decl (decl_ptr, data) tree *decl_ptr; void *data ATTRIBUTE_UNUSED; { ! tree tinfo_decl = *decl_ptr; ! tree tinfo_type, decl; ! ! my_friendly_assert (TREE_TYPE (tinfo_decl) == tinfo_decl_type, 20000121); ! tinfo_type = TREE_TYPE (DECL_NAME (tinfo_decl)); ! my_friendly_assert (tinfo_type != NULL_TREE, 20000120); ! if (!DECL_NEEDED_P (tinfo_decl)) return 0; ! /* Say we've dealt with it. */ ! TREE_TYPE (DECL_NAME (tinfo_decl)) = NULL_TREE; ! create_tinfo_types (); ! decl = synthesize_tinfo_var (tinfo_type, DECL_ASSEMBLER_NAME (tinfo_decl)); ! return decl != 0; } --- 1405,1465 ---- definition emitted for it. */ int ! unemitted_tinfo_decl_p (t, data) tree t; void *data ATTRIBUTE_UNUSED; { ! if (/* It's a var decl */ ! TREE_CODE (t) == VAR_DECL ! /* whos name points back to itself */ ! && IDENTIFIER_GLOBAL_VALUE (DECL_NAME (t)) == t ! /* whos name's type is non-null */ ! && TREE_TYPE (DECL_NAME (t)) ! /* and whos type is a struct */ ! && TREE_CODE (TREE_TYPE (t)) == RECORD_TYPE ! /* with a first field of our pseudo type info */ ! && TREE_TYPE (TYPE_FIELDS (TREE_TYPE (t))) == ti_desc_type_node) ! return 1; ! return 0; } ! /* Finish a type info decl. DECL_PTR is a pointer to an unemitted ! tinfo decl. Determine whether it needs emitting, and if so ! generate the initializer. */ int emit_tinfo_decl (decl_ptr, data) tree *decl_ptr; void *data ATTRIBUTE_UNUSED; { ! tree decl = *decl_ptr; ! tree type = TREE_TYPE (DECL_NAME (decl)); ! int non_public; ! int in_library = typeinfo_in_lib_p (type); ! tree var_desc, var_init; ! import_export_tinfo (decl, type, in_library); ! if (DECL_REALLY_EXTERN (decl) || !DECL_NEEDED_P (decl)) return 0; ! ! if (!doing_runtime && in_library) ! return 0; ! ! non_public = 0; ! var_desc = get_pseudo_ti_desc (type); ! var_init = get_pseudo_ti_init (type, var_desc, &non_public); ! DECL_EXTERNAL (decl) = 0; ! TREE_PUBLIC (decl) = !non_public; ! if (non_public) ! DECL_COMDAT (decl) = 0; ! ! DECL_INITIAL (decl) = var_init; ! cp_finish_decl (decl, var_init, NULL_TREE, 0); ! /* cp_finish_decl will have dealt with linkage. */ ! /* Say we've dealt with it. */ ! TREE_TYPE (DECL_NAME (decl)) = NULL_TREE; ! ! return 1; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/ChangeLog gcc-3.2/libstdc++-v3/ChangeLog *** gcc-3.1.1/libstdc++-v3/ChangeLog Thu Jul 25 23:40:22 2002 --- gcc-3.2/libstdc++-v3/ChangeLog Wed Aug 14 09:01:05 2002 *************** *** 1,3 **** --- 1,221 ---- + 2002-08-14 Release Manager + + * GCC 3.2 Released. + + 2002-08-06 Benjamin Kosnik + + Revert PR libstdc++/6594 + * src/strstream.cc (strstreambuf): Revert. + (strstreambuf::overflow): Same. + (strstreambuf::~strstreambuf): Same. + * testsuite/backward/strstream_members.cc (test02): Add. + + * testsuite/19_diagnostics/stdexceptions.cc (test04): Add bool test. + + 2002-08-01 Benjamin Kosnik + Jakub Jelinek + + * config/linker-map.gnu: Change CXXABI_1 to CXXABI_1.2, + GLIBCPP_3.1 to GLIBCPP_3.2. + + 2002-07-31 Benjamin Kosnik + Mark Mitchell + + PR libstdc++/7442 + * libsupc++/cxxabi.h (class __base_class_type_info::hwm_bit): + Change to __hwm_bit. + (__class_type_info): And here. + + 2002-07-31 Benjamin Kosnik + + PR libstdc++/7442 + * libsupc++/cxxabi.h + (__base_class_info): Change to __base_class_type_info. 2.9.5p6c + (__base_class_info::__base): Change to __base_type. 2.9.5p6c + (__base_class_info::offset_shift): Change to __offset_shift. 2.9.5p6c + (__vmi_class_type_info::__base_info): Don't make const, of type + __base_class_type_info, as per 2.9.5p6c + (__pbase_type_info::__qualifier_flags): Change to __flags, as per + 2.9.5p7. + (__pbase_type_info::__qualifier_masks): Change to __masks, as per + 2.9.5p7. + (__pointer_to_member_type_info::__context_class): Change member to + __context, as per 2.9.5p9. + * libsupc++/tinfo2.cc (__pointer_catch): Change __context_class to + __context. + * libsupc++/tinfo2.cc (__do_catch): Change __qualifier_flags to + __flags. + * libsupc++/tinfo.cc (__do_find_public_src): Change __base to + __base_type. + * libsupc++/tinfo.cc (__do_dyncast): Same. + * libsupc++/tinfo.cc (__do_upcast): Same. + + 2002-07-31 Simon Whomsley + + * docs/html/22_locale/howto.html: Fix. + + 2002-07-31 Alex Kompel + + PR libstdc++/7445 + * src/locale.cc (locale::classic): Move locks inside !_S_classic + block. + + 2002-07-30 Benjamin Kosnik + Gabriel Dos Reis + + * include/bits/char_traits.h: Remove generic definitions. + * include/bits/streambuf_iterator.h (istreambuf_iterator): Use + eof, not -2. + * include/bits/istream.tcc (istream::readsome): Don't check + against eof, instead use constants. + (istream::sync): Same. + (istream::sentry::sentry): Use eq_int_type. + (istream::get): Same. + * include/bits/ostream.tcc: Change __pad to + __pad<_CharT, _Traits>::_S_pad. + * include/bits/locale_facets.h: Add __pad_traits generic and + ostreambuf_iterator specialization. + * include/bits/locale_facets.tcc: Change __pad into struct __pad + with a _CharT and _Traits template parameter and _S_pad static + member function. + * src/locale-inst.cc: Update __pad instantiations. + + * include/std/std_fstream.h: Declare _M_underflow_common + specializations. + * src/fstream.cc: New. Add _M_underflow_common specializations. + * include/bits/fstream.tcc (filebuf::close): Use traits_type. + (filebuf::_M_underflow_common(bool)): Remove generic version, as + sys_ungetc and custom int_types don't get along. + * include/std/std_streambuf.h: Add _M_pos. + * src/Makefile.am (sources): Add fstream.cc. + * src/Makefile.in: Regenerate. + + * testsuite/21_strings/capacity.cc: Add char_traits specializations. + * testsuite/22_locale/codecvt_members_unicode_char.cc: Same. + * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same. + * testsuite/22_locale/ctor_copy_dtor.cc: Same. + * testsuite/27_io/filebuf_virtuals.cc (test07): Move to... + * testsuite/27_io/filebuf.cc: ...here. + * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits + specialization for both. + * testsuite/27_io/streambuf.cc: Add instantiation test, + testsuite_hooks include. + * testsuite/27_io/istream.cc: Same. + * testsuite/27_io/ostream.cc: Same. + * testsuite/27_io/fstream.cc: Same. + * testsuite/27_io/stringstream.cc: Same. + * testsuite/27_io/filebuf.cc: Same. + * testsuite/27_io/stringbuf.cc: Same. + + 2002-07-26 Phil Edwards + + * libsupc++/new (placement delete): Remove unused paramater names. + + 2002-07-25 Benjamin Kosnik + + PR libstdc++/7216 + * include/std/std_istream.h (basic_iostream): Add typedefs for + char_type, int_type, pos_type, off_type, and traits_type. + * testsuite/27_io/iostream.cc (test01): Add typedef tests. + * testsuite/27_io/istream.cc: Same. + * testsuite/27_io/ostream.cc: Same. + * testsuite/27_io/filebuf.cc: Same. + * testsuite/27_io/stringbuf.cc: Replace content, move to... + * testsuite/27_io/stringbuf_members.cc: ...here. + * testsuite/27_io/streambuf.cc: Replace content, move to... + * testsuite/27_io/streambuf_members.cc: ...here. + * testsuite/27_io/stringstream.cc: Replace content, move to... + * testsuite/27_io/stringstream_members.cc: ...here. + * testsuite/27_io/ios.cc: New file. + * testsuite/27_io/fstream.cc: New file. + * testsuite/27_io/ifstream.cc: New file. + * testsuite/27_io/ofstream.cc: New file. + * testsuite/27_io/istringstream.cc: New file. + * testsuite/27_io/ostringstream.cc: New file. + + 2002-07-25 Benjamin Kosnik + + PR libstdc++/7220 + * include/bits/istream.tcc (istream::ignore): Don't extract on + zero. + * testsuite/27_io/istream_unformatted.cc (test10): Add. + + 2002-07-24 Benjamin Kosnik + + PR libstdc++/7222 + * src/locale.cc (locale::locale(const char*)): Use setlocale NULL. + * testsuite/22_locale/ctor_copy_dtor.cc (test02): New. + + 2002-07-24 Benjamin Kosnik + + PR libstdc++/7286 + * libsupc++/new: Add placement delete. + * testsuite/18_support/new_delete_placement.cc: New. + + 2002-07-07 Paolo Carlini + + PR libstdc++/7186 + * include/bits/stl_deque.h (_Deque_iterator::operator-): + Make non-member, as already happens for the comparison + operators in accord with DR179 (Ready). + * testsuite/23_containers/deque_operators.cc: Add test02. + + 2002-07-04 Benjamin Kosnik + Jack Reeves + + * include/std/std_streambuf.h (basic_streambuf::_M_buf): Change to + size_t, from int_type. + (basic_streambuf::_M_buf_size_opt): Same. + (basic_streambuf::_S_pback_sizex): Same. + * include/bits/streambuf.tcc: Same. + * include/std/std_streambuf.h (basic_streambuf::snextc): Use + eq_int_type. + (basic_streambuf::uflow): Same. + * include/bits/sstream.tcc (basic_stringbuf::overflow): Use + to_char_type. + * include/bits/basic_ios.tcc (basic_ios::init): Use _CharT(). + * include/bits/streambuf.tcc (basic_streambuf::xsgetn): Use + eq_int_type. + (basic_streambuf::xsputn): Same. + (__copy_streambufs): Same. + + 2002-07-02 Paolo Carlini + + PR libstdc++/6642 + * include/bits/stl_iterator.h + (__normal_iterator::operator-(const __normal_iterator&)): + Make non-member, as already happens for the comparison + operators in accord with DR179 (Ready). + * testsuite/24_iterators/iterator.cc: Add test from the PR. + + 2002-07-02 Benjamin Kosnik + + PR libstdc++/6410 + * include/bits/locale_facets.h (moneypunct::moneypunct): Add const + char* name parameter. + * config/locale/gnu/monetary_members.cc: Use it. + * config/locale/generic/monetary_members.cc: Same. + * src/localename.cc (_Impl::_Impl(const char*, size_t)): Use it. + + 2002-07-01 Benjamin Kosnik + + * configure.in (libtool_VERSION): Bump to 5:0:0. + * configure: Regenerate. + + 2002-05-19 Paolo Carlini + + * testsuite/23_containers/deque_operators.cc (test01): + Fix minor typo in last commit. + + 2002-05-18 Paolo Carlini + + PR libstdc++/6503 + * include/bits/stl_deque.h (_Deque_iterator::operator==, + operator!=, operator<, operator>, operator>=, operator<=): + Make non-member functions, to allow comparing const and + non-const iterators in any order. + * testsuite/23_containers/deque_operators.cc: New testfile. + 2002-07-25 Release Manager * GCC 3.1.1 Released. diff -Nrc3pad gcc-3.1.1/libstdc++-v3/config/linker-map.gnu gcc-3.2/libstdc++-v3/config/linker-map.gnu *** gcc-3.1.1/libstdc++-v3/config/linker-map.gnu Fri Apr 19 08:28:13 2002 --- gcc-3.2/libstdc++-v3/config/linker-map.gnu Thu Aug 1 21:29:14 2002 *************** *** 21,27 **** ## USA. ! GLIBCPP_3.1 { global: --- 21,27 ---- ## USA. ! GLIBCPP_3.2 { global: *************** GLIBCPP_3.1 { *** 97,103 **** # Symbols in the support library (libsupc++) have their own tag. ! CXXABI_1 { global: __cxa_*; --- 97,103 ---- # Symbols in the support library (libsupc++) have their own tag. ! CXXABI_1.2 { global: __cxa_*; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/config/locale/generic/monetary_members.cc gcc-3.2/libstdc++-v3/config/locale/generic/monetary_members.cc *** gcc-3.1.1/libstdc++-v3/config/locale/generic/monetary_members.cc Fri Apr 19 07:59:01 2002 --- gcc-3.2/libstdc++-v3/config/locale/generic/monetary_members.cc Fri Jul 26 23:23:42 2002 *************** namespace std *** 45,51 **** template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale) { // "C" locale _M_decimal_point = '.'; --- 45,51 ---- template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, const char*) { // "C" locale _M_decimal_point = '.'; *************** namespace std *** 61,67 **** template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale) { // "C" locale _M_decimal_point = '.'; --- 61,67 ---- template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, const char*) { // "C" locale _M_decimal_point = '.'; *************** namespace std *** 86,92 **** #ifdef _GLIBCPP_USE_WCHAR_T template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale) { // "C" locale _M_decimal_point = L'.'; --- 86,93 ---- #ifdef _GLIBCPP_USE_WCHAR_T template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, ! const char*) { // "C" locale _M_decimal_point = L'.'; *************** namespace std *** 102,108 **** template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale) { // "C" locale _M_decimal_point = L'.'; --- 103,110 ---- template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, ! const char*) { // "C" locale _M_decimal_point = L'.'; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/config/locale/gnu/monetary_members.cc gcc-3.2/libstdc++-v3/config/locale/gnu/monetary_members.cc *** gcc-3.1.1/libstdc++-v3/config/locale/gnu/monetary_members.cc Fri Apr 19 07:59:03 2002 --- gcc-3.2/libstdc++-v3/config/locale/gnu/monetary_members.cc Fri Jul 26 23:23:42 2002 *************** namespace std *** 216,222 **** template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc) { if (__cloc == _S_c_locale) { --- 216,223 ---- template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc, ! const char*) { if (__cloc == _S_c_locale) { *************** namespace std *** 260,266 **** template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc) { if (__cloc == _S_c_locale) { --- 261,268 ---- template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc, ! const char*) { if (__cloc == _S_c_locale) { *************** namespace std *** 313,319 **** #ifdef _GLIBCPP_USE_WCHAR_T template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc) { if (__cloc == _S_c_locale) { --- 315,322 ---- #ifdef _GLIBCPP_USE_WCHAR_T template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc, ! const char* __name) { if (__cloc == _S_c_locale) { *************** namespace std *** 331,336 **** --- 334,343 ---- else { // Named locale. + // XXX Fix me. Switch to named locale so that mbsrtowcs will work. + char* __old = strdup(setlocale(LC_ALL, NULL)); + setlocale(LC_ALL, __name); + _M_decimal_point = static_cast(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w); _M_thousands_sep = static_cast(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w); *************** namespace std *** 391,402 **** char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); } } template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc) { if (__cloc == _S_c_locale) { --- 398,414 ---- char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + + // XXX + setlocale(LC_ALL, __old); + free(__old); } } template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc, ! const char* __name) { if (__cloc == _S_c_locale) { *************** namespace std *** 414,419 **** --- 426,435 ---- else { // Named locale. + // XXX Fix me. Switch to named locale so that mbsrtowcs will work. + char* __old = strdup(setlocale(LC_ALL, NULL)); + setlocale(LC_ALL, __name); + _M_decimal_point = static_cast(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w); _M_thousands_sep = static_cast(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w); _M_grouping = __nl_langinfo_l(GROUPING, __cloc); *************** namespace std *** 473,478 **** --- 489,498 ---- char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc)); _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); + + // XXX + setlocale(LC_ALL, __old); + free(__old); } } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/configure gcc-3.2/libstdc++-v3/configure *** gcc-3.1.1/libstdc++-v3/configure Wed Jul 3 22:47:36 2002 --- gcc-3.2/libstdc++-v3/configure Fri Jul 26 23:23:04 2002 *************** ORIGINAL_LD_FOR_MULTILIBS=$LD *** 599,605 **** PACKAGE=libstdc++ # For libtool versioning info, format is CURRENT:REVISION:AGE ! libtool_VERSION=4:1:0 --- 599,605 ---- PACKAGE=libstdc++ # For libtool versioning info, format is CURRENT:REVISION:AGE ! libtool_VERSION=5:0:0 diff -Nrc3pad gcc-3.1.1/libstdc++-v3/configure.in gcc-3.2/libstdc++-v3/configure.in *** gcc-3.1.1/libstdc++-v3/configure.in Wed Jul 3 22:47:34 2002 --- gcc-3.2/libstdc++-v3/configure.in Fri Jul 26 23:23:04 2002 *************** ORIGINAL_LD_FOR_MULTILIBS=$LD *** 13,19 **** PACKAGE=libstdc++ AC_SUBST(PACKAGE) # For libtool versioning info, format is CURRENT:REVISION:AGE ! libtool_VERSION=4:1:0 AC_SUBST(libtool_VERSION) GLIBCPP_TOPREL_CONFIGURE --- 13,19 ---- PACKAGE=libstdc++ AC_SUBST(PACKAGE) # For libtool versioning info, format is CURRENT:REVISION:AGE ! libtool_VERSION=5:0:0 AC_SUBST(libtool_VERSION) GLIBCPP_TOPREL_CONFIGURE diff -Nrc3pad gcc-3.1.1/libstdc++-v3/docs/html/22_locale/howto.html gcc-3.2/libstdc++-v3/docs/html/22_locale/howto.html *** gcc-3.1.1/libstdc++-v3/docs/html/22_locale/howto.html Thu Oct 11 18:41:44 2001 --- gcc-3.2/libstdc++-v3/docs/html/22_locale/howto.html Thu Aug 1 21:29:14 2002 *************** *** 163,169 **** struct Toupper { ! Toupper (std::locale const& l) : loc(l) {;} char operator() (char c) { return std::toupper(c,loc); } private: std::locale const& loc; --- 163,169 ---- struct Toupper { ! Toupper(std::locale const& l) : loc(l) {;} char operator() (char c) { return std::toupper(c,loc); } private: std::locale const& loc; *************** *** 171,177 **** struct Tolower { ! Tolower (std::locale const& l) : loc(l) {;} char operator() (char c) { return std::tolower(c,loc); } private: std::locale const& loc; --- 171,177 ---- struct Tolower { ! Tolower(std::locale const& l) : loc(l) {;} char operator() (char c) { return std::tolower(c,loc); } private: std::locale const& loc; *************** *** 179,204 **** int main () { ! std::string s ("Some Kind Of Initial Input Goes Here"); ! Toupper up ( std::locale("C") ); ! Tolower down ( std::locale("C") ); ! // Change everything into upper case ! std::transform (s.begin(), s.end(), s.begin(), ! up ! ); ! // Change everything into lower case ! std::transform (s.begin(), s.end(), s.begin(), ! down ! ); // Change everything back into upper case, but store the ! // result in a different string std::string capital_s; ! std::transform (s.begin(), s.end(), std::back_inserter(capital_s), ! up ! ); }

The final version of the code uses bind2nd to eliminate --- 179,199 ---- int main () { ! std::string s("Some Kind Of Initial Input Goes Here"); ! std::locale loc_c("C"); ! Toupper up(loc_c); ! Tolower down(loc_c); ! // Change everything into upper case. ! std::transform(s.begin(), s.end(), s.begin(), up); ! // Change everything into lower case. ! std::transform(s.begin(), s.end(), s.begin(), down); // Change everything back into upper case, but store the ! // result in a different string. std::string capital_s; ! std::transform(s.begin(), s.end(), std::back_inserter(capital_s), up); }

The final version of the code uses bind2nd to eliminate diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/basic_ios.tcc gcc-3.2/libstdc++-v3/include/bits/basic_ios.tcc *** gcc-3.1.1/libstdc++-v3/include/bits/basic_ios.tcc Wed Apr 3 02:33:12 2002 --- gcc-3.2/libstdc++-v3/include/bits/basic_ios.tcc Fri Jul 26 23:23:44 2002 *************** namespace std *** 156,162 **** // unformatted input and output with non-required basic_ios // instantiations is possible even without imbuing the expected // ctype facet. ! _M_fill = 0; _M_fill_init = false; _M_exception = goodbit; --- 156,162 ---- // unformatted input and output with non-required basic_ios // instantiations is possible even without imbuing the expected // ctype facet. ! _M_fill = _CharT(); _M_fill_init = false; _M_exception = goodbit; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/c++config gcc-3.2/libstdc++-v3/include/bits/c++config *** gcc-3.1.1/libstdc++-v3/include/bits/c++config Thu Jul 25 07:16:28 2002 --- gcc-3.2/libstdc++-v3/include/bits/c++config Wed Aug 14 07:16:24 2002 *************** *** 34,40 **** #include // The current version of the C++ library in compressed ISO date format. ! #define __GLIBCPP__ 20020725 // This is necessary until GCC supports separate template // compilation. --- 34,40 ---- #include // The current version of the C++ library in compressed ISO date format. ! #define __GLIBCPP__ 20020814 // This is necessary until GCC supports separate template // compilation. diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/char_traits.h gcc-3.2/libstdc++-v3/include/bits/char_traits.h *** gcc-3.1.1/libstdc++-v3/include/bits/char_traits.h Fri Jan 4 21:27:31 2002 --- gcc-3.2/libstdc++-v3/include/bits/char_traits.h Thu Aug 1 21:29:17 2002 *************** *** 1,6 **** // Character Traits for use by standard string and iostream -*- C++ -*- ! // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,7 ---- // Character Traits for use by standard string and iostream -*- C++ -*- ! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 ! // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** namespace std *** 53,134 **** struct char_traits { typedef _CharT char_type; ! // Unsigned as wint_t in unsigned. typedef unsigned long int_type; typedef streampos pos_type; typedef streamoff off_type; typedef mbstate_t state_type; static void ! assign(char_type& __c1, const char_type& __c2) ! { __c1 = __c2; } static bool ! eq(const char_type& __c1, const char_type& __c2) ! { return __c1 == __c2; } static bool ! lt(const char_type& __c1, const char_type& __c2) ! { return __c1 < __c2; } static int ! compare(const char_type* __s1, const char_type* __s2, size_t __n) ! { ! for (size_t __i = 0; __i < __n; ++__i) ! if (!eq(__s1[__i], __s2[__i])) ! return lt(__s1[__i], __s2[__i]) ? -1 : 1; ! return 0; ! } static size_t ! length(const char_type* __s) ! { ! const char_type* __p = __s; ! while (*__p) ++__p; ! return (__p - __s); ! } static const char_type* ! find(const char_type* __s, size_t __n, const char_type& __a) ! { ! for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) ! if (*__p == __a) return __p; ! return 0; ! } static char_type* ! move(char_type* __s1, const char_type* __s2, size_t __n) ! { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } static char_type* ! copy(char_type* __s1, const char_type* __s2, size_t __n) ! { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } static char_type* ! assign(char_type* __s, size_t __n, char_type __a) ! { ! for (char_type* __p = __s; __p < __s + __n; ++__p) ! assign(*__p, __a); ! return __s; ! } static char_type ! to_char_type(const int_type& __c) ! { return char_type(__c); } static int_type ! to_int_type(const char_type& __c) { return int_type(__c); } static bool ! eq_int_type(const int_type& __c1, const int_type& __c2) ! { return __c1 == __c2; } static int_type ! eof() { return static_cast(-1); } static int_type ! not_eof(const int_type& __c) ! { return eq_int_type(__c, eof()) ? int_type(0) : __c; } }; --- 54,106 ---- struct char_traits { typedef _CharT char_type; ! // Unsigned as wint_t is unsigned. typedef unsigned long int_type; typedef streampos pos_type; typedef streamoff off_type; typedef mbstate_t state_type; static void ! assign(char_type& __c1, const char_type& __c2); static bool ! eq(const char_type& __c1, const char_type& __c2); static bool ! lt(const char_type& __c1, const char_type& __c2); static int ! compare(const char_type* __s1, const char_type* __s2, size_t __n); static size_t ! length(const char_type* __s); static const char_type* ! find(const char_type* __s, size_t __n, const char_type& __a); static char_type* ! move(char_type* __s1, const char_type* __s2, size_t __n); static char_type* ! copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* ! assign(char_type* __s, size_t __n, char_type __a); static char_type ! to_char_type(const int_type& __c); static int_type ! to_int_type(const char_type& __c); static bool ! eq_int_type(const int_type& __c1, const int_type& __c2); static int_type ! eof(); static int_type ! not_eof(const int_type& __c); }; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/fpos.h gcc-3.2/libstdc++-v3/include/bits/fpos.h *** gcc-3.1.1/libstdc++-v3/include/bits/fpos.h Fri Jan 4 21:27:31 2002 --- gcc-3.2/libstdc++-v3/include/bits/fpos.h Thu Aug 1 21:29:17 2002 *************** namespace std *** 105,111 **** bool operator!=(const fpos& __pos) const { return _M_off != __pos._M_off; } ! streamoff _M_position() const { return _M_off; } --- 105,111 ---- bool operator!=(const fpos& __pos) const { return _M_off != __pos._M_off; } ! streamoff _M_position() const { return _M_off; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/fstream.tcc gcc-3.2/libstdc++-v3/include/bits/fstream.tcc *** gcc-3.1.1/libstdc++-v3/include/bits/fstream.tcc Sat May 18 14:37:46 2002 --- gcc-3.2/libstdc++-v3/include/bits/fstream.tcc Thu Aug 1 21:29:17 2002 *************** namespace std *** 112,118 **** { const int_type __eof = traits_type::eof(); bool __testput = _M_out_cur && _M_out_beg < _M_out_end; ! if (__testput && _M_really_overflow(__eof) == __eof) return __ret; // NB: Do this here so that re-opened filebufs will be cool... --- 112,119 ---- { const int_type __eof = traits_type::eof(); bool __testput = _M_out_cur && _M_out_beg < _M_out_end; ! if (__testput ! && traits_type::eq_int_type(_M_really_overflow(__eof), __eof)) return __ret; // NB: Do this here so that re-opened filebufs will be cool... *************** namespace std *** 154,249 **** } _M_last_overflowed = false; return __ret; - } - - template - typename basic_filebuf<_CharT, _Traits>::int_type - basic_filebuf<_CharT, _Traits>:: - _M_underflow_common(bool __bump) - { - int_type __ret = traits_type::eof(); - bool __testin = _M_mode & ios_base::in; - bool __testout = _M_mode & ios_base::out; - - if (__testin) - { - // Check for pback madness, and if so swich back to the - // normal buffers and jet outta here before expensive - // fileops happen... - if (_M_pback_init) - { - _M_pback_destroy(); - if (_M_in_cur < _M_in_end) - return traits_type::to_int_type(*_M_in_cur); - } - - // Sync internal and external buffers. - // NB: __testget -> __testput as _M_buf_unified here. - bool __testget = _M_in_cur && _M_in_beg < _M_in_cur; - bool __testinit = _M_is_indeterminate(); - if (__testget) - { - if (__testout) - _M_really_overflow(); - else if (_M_in_cur != _M_filepos) - _M_file.seekoff(_M_in_cur - _M_filepos, - ios_base::cur, ios_base::in); - } - - if (__testinit || __testget) - { - const locale __loc = this->getloc(); - const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc); - - streamsize __elen = 0; - streamsize __ilen = 0; - if (__cvt.always_noconv()) - { - __elen = _M_file.xsgetn(reinterpret_cast(_M_in_beg), - _M_buf_size); - __ilen = __elen; - } - else - { - char* __buf = static_cast(__builtin_alloca(_M_buf_size)); - __elen = _M_file.xsgetn(__buf, _M_buf_size); - - const char* __eend; - char_type* __iend; - __res_type __r = __cvt.in(_M_state_cur, __buf, - __buf + __elen, __eend, _M_in_beg, - _M_in_beg + _M_buf_size, __iend); - if (__r == codecvt_base::ok) - __ilen = __iend - _M_in_beg; - else - { - // Unwind. - __ilen = 0; - _M_file.seekoff(-__elen, ios_base::cur, ios_base::in); - } - } - - if (0 < __ilen) - { - _M_set_determinate(__ilen); - if (__testout) - _M_out_cur = _M_in_cur; - __ret = traits_type::to_int_type(*_M_in_cur); - if (__bump) - _M_in_cur_move(1); - else if (_M_buf_size == 1) - { - // If we are synced with stdio, we have to unget the - // character we just read so that the file pointer - // doesn't move. - _M_file.sys_ungetc(*_M_in_cur); - _M_set_indeterminate(); - } - } - } - } - _M_last_overflowed = false; - return __ret; } template --- 155,160 ---- diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/istream.tcc gcc-3.2/libstdc++-v3/include/bits/istream.tcc *** gcc-3.1.1/libstdc++-v3/include/bits/istream.tcc Mon Jun 10 21:15:05 2002 --- gcc-3.2/libstdc++-v3/include/bits/istream.tcc Thu Aug 1 21:29:17 2002 *************** namespace std *** 54,66 **** __int_type __c = __sb->sgetc(); if (__in._M_check_facet(__in._M_fctype)) ! while (__c != __eof ! && __in._M_fctype->is(ctype_base::space, __c)) __c = __sb->snextc(); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS //195. Should basic_istream::sentry's constructor ever set eofbit? ! if (__c == __eof) __in.setstate(ios_base::eofbit); #endif } --- 54,67 ---- __int_type __c = __sb->sgetc(); if (__in._M_check_facet(__in._M_fctype)) ! while (!traits_type::eq_int_type(__c, __eof) ! && __in._M_fctype->is(ctype_base::space, ! traits_type::to_char_type(__c))) __c = __sb->snextc(); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS //195. Should basic_istream::sentry's constructor ever set eofbit? ! if (traits_type::eq_int_type(__c, __eof)) __in.setstate(ios_base::eofbit); #endif } *************** namespace std *** 521,527 **** { __c = this->rdbuf()->sbumpc(); // 27.6.1.1 paragraph 3 ! if (__c != __eof) _M_gcount = 1; else this->setstate(ios_base::eofbit | ios_base::failbit); --- 522,528 ---- { __c = this->rdbuf()->sbumpc(); // 27.6.1.1 paragraph 3 ! if (!traits_type::eq_int_type(__c, __eof)) _M_gcount = 1; else this->setstate(ios_base::eofbit | ios_base::failbit); *************** namespace std *** 552,558 **** const int_type __eof = traits_type::eof(); int_type __bufval = this->rdbuf()->sbumpc(); // 27.6.1.1 paragraph 3 ! if (__bufval != __eof) { _M_gcount = 1; __c = traits_type::to_char_type(__bufval); --- 553,559 ---- const int_type __eof = traits_type::eof(); int_type __bufval = this->rdbuf()->sbumpc(); // 27.6.1.1 paragraph 3 ! if (!traits_type::eq_int_type(__bufval, __eof)) { _M_gcount = 1; __c = traits_type::to_char_type(__bufval); *************** namespace std *** 588,600 **** __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); ! while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim) { *__s++ = traits_type::to_char_type(__c); __c = __sb->snextc(); ++_M_gcount; } ! if (__c == __eof) this->setstate(ios_base::eofbit); } catch(exception& __fail) --- 589,603 ---- __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); ! while (_M_gcount + 1 < __n ! && !traits_type::eq_int_type(__c, __eof) ! && !traits_type::eq_int_type(__c, __idelim)) { *__s++ = traits_type::to_char_type(__c); __c = __sb->snextc(); ++_M_gcount; } ! if (traits_type::eq_int_type(__c, __eof)) this->setstate(ios_base::eofbit); } catch(exception& __fail) *************** namespace std *** 627,640 **** const int_type __eof = traits_type::eof(); __streambuf_type* __this_sb = this->rdbuf(); int_type __c = __this_sb->sgetc(); ! while (__c != __eof && __c != __idelim ! && (__sb.sputc(traits_type::to_char_type(__c)) != __eof)) { ++_M_gcount; __c = __this_sb->snextc(); } ! if (__c == __eof) this->setstate(ios_base::eofbit); } catch(exception& __fail) --- 630,646 ---- const int_type __eof = traits_type::eof(); __streambuf_type* __this_sb = this->rdbuf(); int_type __c = __this_sb->sgetc(); + char_type __c2 = traits_type::to_char_type(__c); ! while (!traits_type::eq_int_type(__c, __eof) ! && !traits_type::eq_int_type(__c, __idelim) ! && !traits_type::eq_int_type(__sb.sputc(__c2), __eof)) { ++_M_gcount; __c = __this_sb->snextc(); + __c2 = traits_type::to_char_type(__c); } ! if (traits_type::eq_int_type(__c, __eof)) this->setstate(ios_base::eofbit); } catch(exception& __fail) *************** namespace std *** 667,683 **** __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); ! while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim) { *__s++ = traits_type::to_char_type(__c); __c = __sb->snextc(); ++_M_gcount; } ! if (__c == __eof) this->setstate(ios_base::eofbit); else { ! if (__c == __idelim) { __sb->sbumpc(); ++_M_gcount; --- 673,691 ---- __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); ! while (_M_gcount + 1 < __n ! && !traits_type::eq_int_type(__c, __eof) ! && !traits_type::eq_int_type(__c, __idelim)) { *__s++ = traits_type::to_char_type(__c); __c = __sb->snextc(); ++_M_gcount; } ! if (traits_type::eq_int_type(__c, __eof)) this->setstate(ios_base::eofbit); else { ! if (traits_type::eq_int_type(__c, __idelim)) { __sb->sbumpc(); ++_M_gcount; *************** namespace std *** 708,714 **** { _M_gcount = 0; sentry __cerb(*this, true); ! if (__cerb) { try { --- 716,722 ---- { _M_gcount = 0; sentry __cerb(*this, true); ! if (__cerb && __n > 0) { try { *************** namespace std *** 717,730 **** int_type __c = __sb->sgetc(); __n = min(__n, numeric_limits::max()); ! while (_M_gcount < __n && __c !=__eof && __c != __delim) { __c = __sb->snextc(); ++_M_gcount; } ! if (__c == __eof) this->setstate(ios_base::eofbit); ! else if (__c == __delim) { __sb->sbumpc(); ++_M_gcount; --- 725,740 ---- int_type __c = __sb->sgetc(); __n = min(__n, numeric_limits::max()); ! while (_M_gcount < __n ! && !traits_type::eq_int_type(__c, __eof) ! && !traits_type::eq_int_type(__c, __delim)) { __c = __sb->snextc(); ++_M_gcount; } ! if (traits_type::eq_int_type(__c, __eof)) this->setstate(ios_base::eofbit); ! else if (traits_type::eq_int_type(__c, __delim)) { __sb->sbumpc(); ++_M_gcount; *************** namespace std *** 806,814 **** { try { - const int_type __eof = traits_type::eof(); streamsize __num = this->rdbuf()->in_avail(); ! if (__num != static_cast(__eof)) { __num = min(__num, __n); if (__num) --- 816,823 ---- { try { streamsize __num = this->rdbuf()->in_avail(); ! if (__num > 0) { __num = min(__num, __n); if (__num) *************** namespace std *** 843,849 **** { const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); ! if (!__sb || __sb->sputbackc(__c) == __eof) this->setstate(ios_base::badbit); } catch(exception& __fail) --- 852,859 ---- { const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); ! if (!__sb ! || traits_type::eq_int_type(__sb->sputbackc(__c), __eof)) this->setstate(ios_base::badbit); } catch(exception& __fail) *************** namespace std *** 873,879 **** { const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); ! if (!__sb || __eof == __sb->sungetc()) this->setstate(ios_base::badbit); } catch(exception& __fail) --- 883,890 ---- { const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); ! if (!__sb ! || traits_type::eq_int_type(__sb->sungetc(), __eof)) this->setstate(ios_base::badbit); } catch(exception& __fail) *************** namespace std *** 895,901 **** basic_istream<_CharT, _Traits>:: sync(void) { ! int __ret = traits_type::eof(); _M_gcount = 0; sentry __cerb(*this, true); if (__cerb) --- 906,912 ---- basic_istream<_CharT, _Traits>:: sync(void) { ! int __ret = -1; _M_gcount = 0; sentry __cerb(*this, true); if (__cerb) *************** namespace std *** 903,912 **** try { __streambuf_type* __sb = this->rdbuf(); ! if (!__sb || __ret == __sb->pubsync()) ! this->setstate(ios_base::badbit); ! else ! __ret = 0; } catch(exception& __fail) { --- 914,926 ---- try { __streambuf_type* __sb = this->rdbuf(); ! if (__sb) ! { ! if (__sb->pubsync() == -1) ! this->setstate(ios_base::badbit); ! else ! __ret = 0; ! } } catch(exception& __fail) { *************** namespace std *** 1186,1201 **** __streambuf_type* __sb = __in.rdbuf(); __int_type __c = __sb->sbumpc(); const __int_type __eof = _Traits::eof(); ! __testdelim = __c == __idelim; ! while (__extracted <= __n && __c != __eof && !__testdelim) { __str += _Traits::to_char_type(__c); ++__extracted; __c = __sb->sbumpc(); ! __testdelim = __c == __idelim; } ! if (__c == __eof) __in.setstate(ios_base::eofbit); } if (!__extracted && !__testdelim) --- 1200,1217 ---- __streambuf_type* __sb = __in.rdbuf(); __int_type __c = __sb->sbumpc(); const __int_type __eof = _Traits::eof(); ! __testdelim = _Traits::eq_int_type(__c, __idelim); ! while (__extracted <= __n ! && !_Traits::eq_int_type(__c, __eof) ! && !__testdelim) { __str += _Traits::to_char_type(__c); ++__extracted; __c = __sb->sbumpc(); ! __testdelim = _Traits::eq_int_type(__c, __idelim); } ! if (_Traits::eq_int_type(__c, __eof)) __in.setstate(ios_base::eofbit); } if (!__extracted && !__testdelim) diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/locale_facets.h gcc-3.2/libstdc++-v3/include/bits/locale_facets.h *** gcc-3.1.1/libstdc++-v3/include/bits/locale_facets.h Fri Apr 19 07:59:10 2002 --- gcc-3.2/libstdc++-v3/include/bits/locale_facets.h Thu Aug 1 21:29:17 2002 *************** namespace std *** 55,60 **** --- 55,63 ---- # define _GLIBCPP_NUM_FACETS 14 #endif + template + struct __pad; + // 22.2.1.1 Template class ctype // Include host and configuration specific ctype enums for ctype_base. #include *************** namespace std *** 652,657 **** --- 655,661 ---- virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const; *************** namespace std *** 697,702 **** --- 701,723 ---- template locale::id num_get<_CharT, _InIter>::id; + #if 0 + // Partial specialization for istreambuf_iterator, so can use traits_type. + template + class num_get<_CharT, istreambuf_iterator<_CharT> >; + + iter_type + _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&, + string& __xtrc) const; + + iter_type + _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, + string& __xtrc, int& __base) const; + + virtual iter_type + do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const; + #endif + template class num_put : public locale::facet, public __num_base { *************** namespace std *** 1357,1364 **** { _M_initialize_moneypunct(); } explicit ! moneypunct(__c_locale __cloc, size_t __refs = 0) : locale::facet(__refs) ! { _M_initialize_moneypunct(__cloc); } char_type decimal_point() const --- 1378,1386 ---- { _M_initialize_moneypunct(); } explicit ! moneypunct(__c_locale __cloc, const char* __s, size_t __refs = 0) ! : locale::facet(__refs) ! { _M_initialize_moneypunct(__cloc, __s); } char_type decimal_point() const *************** namespace std *** 1438,1444 **** // For use at construction time only. void ! _M_initialize_moneypunct(__c_locale __cloc = _S_c_locale); }; template --- 1460,1467 ---- // For use at construction time only. void ! _M_initialize_moneypunct(__c_locale __cloc = _S_c_locale, ! const char* __name = NULL); }; template *************** namespace std *** 1455,1465 **** template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc); template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc); #ifdef _GLIBCPP_USE_WCHAR_T template<> --- 1478,1488 ---- template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, const char*); template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, const char*); #ifdef _GLIBCPP_USE_WCHAR_T template<> *************** namespace std *** 1470,1480 **** template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc); template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale __cloc); #endif template --- 1493,1505 ---- template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, ! const char*); template<> void ! moneypunct::_M_initialize_moneypunct(__c_locale, ! const char*); #endif template diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/locale_facets.tcc gcc-3.2/libstdc++-v3/include/bits/locale_facets.tcc *** gcc-3.1.1/libstdc++-v3/include/bits/locale_facets.tcc Sat May 18 22:00:15 2002 --- gcc-3.2/libstdc++-v3/include/bits/locale_facets.tcc Thu Aug 1 21:29:17 2002 *************** namespace std *** 94,99 **** --- 94,100 ---- _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io, ios_base::iostate& __err, string& __xtrc) const { + typedef char_traits<_CharT> __traits_type; const locale __loc = __io.getloc(); const ctype<_CharT>& __ctype = use_facet >(__loc); const numpunct<_CharT>& __np = use_facet >(__loc); *************** namespace std *** 103,109 **** const char_type __minus = __ctype.widen('-'); int __pos = 0; char_type __c = *__beg; ! if ((__c == __plus || __c == __minus) && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); ++__pos; --- 104,111 ---- const char_type __minus = __ctype.widen('-'); int __pos = 0; char_type __c = *__beg; ! if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus)) ! && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); ++__pos; *************** namespace std *** 113,119 **** // Next, strip leading zeros. const char_type __zero = __ctype.widen(_S_atoms[_M_zero]); bool __found_zero = false; ! while (__c == __zero && __beg != __end) { __c = *(++__beg); __found_zero = true; --- 115,121 ---- // Next, strip leading zeros. const char_type __zero = __ctype.widen(_S_atoms[_M_zero]); bool __found_zero = false; ! while (__traits_type::eq(__c, __zero) && __beg != __end) { __c = *(++__beg); __found_zero = true; *************** namespace std *** 141,151 **** while (__beg != __end) { // Only look in digits. - typedef char_traits<_CharT> __traits_type; const char_type* __p = __traits_type::find(__watoms, 10, __c); // NB: strchr returns true for __c == 0x0 ! if (__p && __c) { // Try first for acceptable digit; record it if found. ++__pos; --- 143,152 ---- while (__beg != __end) { // Only look in digits. const char_type* __p = __traits_type::find(__watoms, 10, __c); // NB: strchr returns true for __c == 0x0 ! if (__p && !__traits_type::eq(__c, char_type())) { // Try first for acceptable digit; record it if found. ++__pos; *************** namespace std *** 153,159 **** ++__sep_pos; __c = *(++__beg); } ! else if (__c == __sep && __check_grouping && !__found_dec) { // NB: Thousands separator at the beginning of a string // is a no-no, as is two consecutive thousands separators. --- 154,161 ---- ++__sep_pos; __c = *(++__beg); } ! else if (__traits_type::eq(__c, __sep) ! && __check_grouping && !__found_dec) { // NB: Thousands separator at the beginning of a string // is a no-no, as is two consecutive thousands separators. *************** namespace std *** 169,175 **** break; } } ! else if (__c == __dec && !__found_dec) { // According to the standard, if no grouping chars are seen, // no grouping check is applied. Therefore __found_grouping --- 171,177 ---- break; } } ! else if (__traits_type::eq(__c, __dec) && !__found_dec) { // According to the standard, if no grouping chars are seen, // no grouping check is applied. Therefore __found_grouping *************** namespace std *** 181,187 **** __c = *(++__beg); __found_dec = true; } ! else if ((__c == __watoms[_M_e] || __c == __watoms[_M_E]) && !__found_sci && __pos) { // Scientific notation. --- 183,190 ---- __c = *(++__beg); __found_dec = true; } ! else if ((__traits_type::eq(__c, __watoms[_M_e]) ! || __traits_type::eq(__c, __watoms[_M_E])) && !__found_sci && __pos) { // Scientific notation. *************** namespace std *** 190,196 **** __c = *(++__beg); // Remove optional plus or minus sign, if they exist. ! if (__c == __plus || __c == __minus) { ++__pos; __xtrc += __ctype.narrow(__c, char()); --- 193,200 ---- __c = *(++__beg); // Remove optional plus or minus sign, if they exist. ! if (__traits_type::eq(__c, __plus) ! || __traits_type::eq(__c, __minus)) { ++__pos; __xtrc += __ctype.narrow(__c, char()); *************** namespace std *** 228,233 **** --- 232,238 ---- _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io, ios_base::iostate& __err, string& __xtrc, int& __base) const { + typedef char_traits<_CharT> __traits_type; const locale __loc = __io.getloc(); const ctype<_CharT>& __ctype = use_facet >(__loc); const numpunct<_CharT>& __np = use_facet >(__loc); *************** namespace std *** 241,250 **** else __base = 10; ! // First check for sign. int __pos = 0; char_type __c = *__beg; ! if ((__c == __ctype.widen('+') || __c == __ctype.widen('-')) && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); --- 246,258 ---- else __base = 10; ! // First check for sign. int __pos = 0; char_type __c = *__beg; ! const char_type __plus = __ctype.widen('+'); ! const char_type __minus = __ctype.widen('-'); ! ! if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus)) && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); *************** namespace std *** 259,265 **** if (__base == 10) { bool __found_zero = false; ! while (__c == __zero && __beg != __end) { __c = *(++__beg); __found_zero = true; --- 267,273 ---- if (__base == 10) { bool __found_zero = false; ! while (__traits_type::eq(__c, __zero) && __beg != __end) { __c = *(++__beg); __found_zero = true; *************** namespace std *** 270,276 **** ++__pos; if (__basefield == 0) { ! if ((__c == __x || __c == __X) && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); ++__pos; --- 278,286 ---- ++__pos; if (__basefield == 0) { ! if ((__traits_type::eq(__c, __x) ! || __traits_type::eq(__c, __X)) ! && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); ++__pos; *************** namespace std *** 284,295 **** } else if (__base == 16) { ! if (__c == __zero && __beg != __end) { __xtrc += _S_atoms[_M_zero]; ++__pos; __c = *(++__beg); ! if ((__c == __x || __c == __X) && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); ++__pos; --- 294,306 ---- } else if (__base == 16) { ! if (__traits_type::eq(__c, __zero) && __beg != __end) { __xtrc += _S_atoms[_M_zero]; ++__pos; __c = *(++__beg); ! if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X)) ! && __beg != __end) { __xtrc += __ctype.narrow(__c, char()); ++__pos; *************** namespace std *** 316,326 **** const char_type __sep = __np.thousands_sep(); while (__beg != __end) { - typedef char_traits<_CharT> __traits_type; const char_type* __p = __traits_type::find(__watoms, __len, __c); // NB: strchr returns true for __c == 0x0 ! if (__p && __c) { // Try first for acceptable digit; record it if found. __xtrc += _S_atoms[__p - __watoms]; --- 327,336 ---- const char_type __sep = __np.thousands_sep(); while (__beg != __end) { const char_type* __p = __traits_type::find(__watoms, __len, __c); // NB: strchr returns true for __c == 0x0 ! if (__p && !__traits_type::eq(__c, char_type())) { // Try first for acceptable digit; record it if found. __xtrc += _S_atoms[__p - __watoms]; *************** namespace std *** 328,334 **** ++__sep_pos; __c = *(++__beg); } ! else if (__c == __sep && __check_grouping) { // NB: Thousands separator at the beginning of a string // is a no-no, as is two consecutive thousands separators. --- 338,344 ---- ++__sep_pos; __c = *(++__beg); } ! else if (__traits_type::eq(__c, __sep) && __check_grouping) { // NB: Thousands separator at the beginning of a string // is a no-no, as is two consecutive thousands separators. *************** namespace std *** 394,400 **** // Parse bool values as alphanumeric else { ! typedef basic_string<_CharT> __string_type; locale __loc = __io.getloc(); const numpunct<_CharT>& __np = use_facet >(__loc); const __string_type __true = __np.truename(); --- 404,412 ---- // Parse bool values as alphanumeric else { ! typedef char_traits<_CharT> __traits_type; ! typedef basic_string<_CharT> __string_type; ! locale __loc = __io.getloc(); const numpunct<_CharT>& __np = use_facet >(__loc); const __string_type __true = __np.truename(); *************** namespace std *** 407,414 **** for (size_t __n = 0; __beg != __end; ++__n) { char_type __c = *__beg++; ! bool __testf = __n <= __falsen ? __c == __falses[__n] : false; ! bool __testt = __n <= __truen ? __c == __trues[__n] : false; if (!(__testf || __testt)) { __err |= ios_base::failbit; --- 419,428 ---- for (size_t __n = 0; __beg != __end; ++__n) { char_type __c = *__beg++; ! bool __testf = __n <= __falsen ! ? __traits_type::eq(__c, __falses[__n]) : false; ! bool __testt = __n <= __truen ! ? __traits_type::eq(__c, __trues[__n]) : false; if (!(__testf || __testt)) { __err |= ios_base::failbit; *************** namespace std *** 708,713 **** --- 722,728 ---- _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs, int __len) const { + typedef char_traits<_CharT> __traits_type; // [22.2.2.2.2] Stage 2, convert to char_type, using correct // numpunct.decimal_point() values for '.' and adding grouping. const locale __loc = __io.getloc(); *************** namespace std *** 723,729 **** // Replace decimal point. const _CharT* __p; const numpunct<_CharT>& __np = use_facet >(__loc); ! if (__p = char_traits<_CharT>::find(__ws, __len, __ctype.widen('.'))) __ws[__p - __ws] = __np.decimal_point(); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS --- 738,744 ---- // Replace decimal point. const _CharT* __p; const numpunct<_CharT>& __np = use_facet >(__loc); ! if (__p = __traits_type::find(__ws, __len, __ctype.widen('.'))) __ws[__p - __ws] = __np.decimal_point(); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS *************** namespace std *** 744,750 **** // Tack on decimal part. if (__p) { ! char_traits<_CharT>::copy(__p2, __p, __len - __declen); __newlen += __len - __declen; } --- 759,765 ---- // Tack on decimal part. if (__p) { ! __traits_type::copy(__p2, __p, __len - __declen); __newlen += __len - __declen; } *************** namespace std *** 816,828 **** _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws, int __len) const { // [22.2.2.2.2] Stage 3. streamsize __w = __io.width(); _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w)); if (__w > static_cast(__len)) { ! __pad(__io, __fill, __ws2, __ws, __w, __len, true); __len = static_cast(__w); // Switch strings. __ws = __ws2; --- 831,845 ---- _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws, int __len) const { + typedef char_traits<_CharT> __traits_type; // [22.2.2.2.2] Stage 3. streamsize __w = __io.width(); _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __w)); if (__w > static_cast(__len)) { ! __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws, ! __w, __len, true); __len = static_cast(__w); // Switch strings. __ws = __ws2; *************** namespace std *** 845,851 **** if ((__flags & ios_base::boolalpha) == 0) { unsigned long __uv = __v; ! __s = _M_convert_int(__s, __io, __fill, 'u', char_type(), __uv); } else { --- 862,868 ---- if ((__flags & ios_base::boolalpha) == 0) { unsigned long __uv = __v; ! __s = _M_convert_int(__s, __io, __fill, 'u', char(), __uv); } else { *************** namespace std *** 866,879 **** _OutIter num_put<_CharT, _OutIter>:: do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const ! { return _M_convert_int(__s, __io, __fill, 'd', char_type(), __v); } template _OutIter num_put<_CharT, _OutIter>:: do_put(iter_type __s, ios_base& __io, char_type __fill, unsigned long __v) const ! { return _M_convert_int(__s, __io, __fill, 'u', char_type(), __v); } #ifdef _GLIBCPP_USE_LONG_LONG template --- 883,896 ---- _OutIter num_put<_CharT, _OutIter>:: do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const ! { return _M_convert_int(__s, __io, __fill, 'd', char(), __v); } template _OutIter num_put<_CharT, _OutIter>:: do_put(iter_type __s, ios_base& __io, char_type __fill, unsigned long __v) const ! { return _M_convert_int(__s, __io, __fill, 'u', char(), __v); } #ifdef _GLIBCPP_USE_LONG_LONG template *************** namespace std *** 894,900 **** _OutIter num_put<_CharT, _OutIter>:: do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const ! { return _M_convert_float(__s, __io, __fill, char_type(), __v); } template _OutIter --- 911,917 ---- _OutIter num_put<_CharT, _OutIter>:: do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const ! { return _M_convert_float(__s, __io, __fill, char(), __v); } template _OutIter *************** namespace std *** 915,921 **** __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase)); try { ! __s = _M_convert_int(__s, __io, __fill, 'u', char_type(), reinterpret_cast(__v)); __io.flags(__flags); } --- 932,938 ---- __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase)); try { ! __s = _M_convert_int(__s, __io, __fill, 'u', char(), reinterpret_cast(__v)); __io.flags(__flags); } *************** namespace std *** 1591,1597 **** const _CharT** __names, size_t __indexlen, ios_base::iostate& __err) const { ! typedef char_traits __traits_type; int* __matches = static_cast(__builtin_alloca(sizeof(int) * __indexlen)); size_t __nmatches = 0; size_t __pos = 0; --- 1608,1614 ---- const _CharT** __names, size_t __indexlen, ios_base::iostate& __err) const { ! typedef char_traits<_CharT> __traits_type; int* __matches = static_cast(__builtin_alloca(sizeof(int) * __indexlen)); size_t __nmatches = 0; size_t __pos = 0; *************** namespace std *** 1686,1692 **** do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { ! typedef char_traits __traits_type; locale __loc = __io.getloc(); __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc); const char_type* __days[7]; --- 1703,1709 ---- do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { ! typedef char_traits<_CharT> __traits_type; locale __loc = __io.getloc(); __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc); const char_type* __days[7]; *************** namespace std *** 1729,1735 **** do_get_monthname(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { ! typedef char_traits __traits_type; locale __loc = __io.getloc(); __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc); const char_type* __months[12]; --- 1746,1752 ---- do_get_monthname(iter_type __beg, iter_type __end, ios_base& __io, ios_base::iostate& __err, tm* __tm) const { ! typedef char_traits<_CharT> __traits_type; locale __loc = __io.getloc(); __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc); const char_type* __months[12]; *************** namespace std *** 1996,2017 **** // internal-adjusted objects are padded according to the rules below // concerning 0[xX] and +-, otherwise, exactly as right-adjusted // ones are. template ! void ! __pad(ios_base& __io, _CharT __fill, _CharT* __news, const _CharT* __olds, ! const streamsize __newlen, const streamsize __oldlen, ! const bool __num) { ! typedef _CharT char_type; ! typedef _Traits traits_type; ! typedef typename traits_type::int_type int_type; ! ! int_type __plen = static_cast(__newlen - __oldlen); ! char_type* __pads = static_cast(__builtin_alloca(sizeof(char_type) * __plen)); ! traits_type::assign(__pads, __plen, __fill); ! char_type* __beg; ! char_type* __end; size_t __mod = 0; size_t __beglen; //either __plen or __oldlen ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield; --- 2013,2043 ---- // internal-adjusted objects are padded according to the rules below // concerning 0[xX] and +-, otherwise, exactly as right-adjusted // ones are. + + // NB: Of the two parameters, _CharT can be deduced from the + // function arguments. The other (_Traits) has to be explicitly specified. template ! struct __pad { ! static void ! _S_pad(ios_base& __io, _CharT __fill, _CharT* __news, ! const _CharT* __olds, const streamsize __newlen, ! const streamsize __oldlen, const bool __num); ! }; ! template ! void ! __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill, ! _CharT* __news, const _CharT* __olds, ! const streamsize __newlen, ! const streamsize __oldlen, const bool __num) ! { ! size_t __plen = static_cast(__newlen - __oldlen); ! _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __plen)); ! _Traits::assign(__pads, __plen, __fill); ! ! _CharT* __beg; ! _CharT* __end; size_t __mod = 0; size_t __beglen; //either __plen or __oldlen ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield; *************** namespace std *** 2019,2025 **** if (__adjust == ios_base::left) { // Padding last. ! __beg = const_cast(__olds); __beglen = __oldlen; __end = __pads; } --- 2045,2051 ---- if (__adjust == ios_base::left) { // Padding last. ! __beg = const_cast<_CharT*>(__olds); __beglen = __oldlen; __end = __pads; } *************** namespace std *** 2030,2041 **** // Who came up with these rules, anyway? Jeeze. locale __loc = __io.getloc(); const ctype<_CharT>& __ctype = use_facet >(__loc); ! const char_type __minus = __ctype.widen('-'); ! const char_type __plus = __ctype.widen('+'); ! bool __testsign = __olds[0] == __minus || __olds[0] == __plus; ! bool __testhex = __ctype.widen('0') == __olds[0] ! && (__ctype.widen('x') == __olds[1] ! || __ctype.widen('X') == __olds[1]); if (__testhex) { __news[0] = __olds[0]; --- 2056,2069 ---- // Who came up with these rules, anyway? Jeeze. locale __loc = __io.getloc(); const ctype<_CharT>& __ctype = use_facet >(__loc); ! const _CharT __minus = __ctype.widen('-'); ! const _CharT __plus = __ctype.widen('+'); ! bool __testsign = _Traits::eq(__olds[0], __minus) ! || _Traits::eq(__olds[0], __plus); ! ! bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0]) ! && (_Traits::eq(__ctype.widen('x'), __olds[1]) ! || _Traits::eq(__ctype.widen('X'), __olds[1])); if (__testhex) { __news[0] = __olds[0]; *************** namespace std *** 2044,2066 **** __news += 2; __beg = __pads; __beglen = __plen; ! __end = const_cast(__olds + __mod); } else if (__testsign) { ! __news[0] = __olds[0] == __plus ? __plus : __minus; ++__mod; ++__news; __beg = __pads; __beglen = __plen; ! __end = const_cast(__olds + __mod); } else { // Padding first. __beg = __pads; __beglen = __plen; ! __end = const_cast(__olds); } } else --- 2072,2094 ---- __news += 2; __beg = __pads; __beglen = __plen; ! __end = const_cast<_CharT*>(__olds + __mod); } else if (__testsign) { ! _Traits::eq((__news[0] = __olds[0]), __plus) ? __plus : __minus; ++__mod; ++__news; __beg = __pads; __beglen = __plen; ! __end = const_cast<_CharT*>(__olds + __mod); } else { // Padding first. __beg = __pads; __beglen = __plen; ! __end = const_cast<_CharT*>(__olds); } } else *************** namespace std *** 2068,2090 **** // Padding first. __beg = __pads; __beglen = __plen; ! __end = const_cast(__olds); } ! traits_type::copy(__news, __beg, __beglen); ! traits_type::copy(__news + __beglen, __end, __newlen - __beglen - __mod); ! } ! ! // NB: Can't have default argument on non-member template, and ! // num_put doesn't have a _Traits template parameter, so this ! // forwarding template adds in the default template argument. ! template ! void ! __pad(ios_base& __io, _CharT __fill, _CharT* __news, const _CharT* __olds, ! const streamsize __newlen, const streamsize __oldlen, ! const bool __num) ! { ! return __pad<_CharT, char_traits<_CharT> >(__io, __fill, __news, __olds, ! __newlen, __oldlen, __num); } // Used by both numeric and monetary facets. --- 2096,2106 ---- // Padding first. __beg = __pads; __beglen = __plen; ! __end = const_cast<_CharT*>(__olds); } ! _Traits::copy(__news, __beg, __beglen); ! _Traits::copy(__news + __beglen, __end, ! __newlen - __beglen - __mod); } // Used by both numeric and monetary facets. *************** namespace std *** 2401,2405 **** } // namespace std #endif - - --- 2417,2419 ---- diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/ostream.tcc gcc-3.2/libstdc++-v3/include/bits/ostream.tcc *** gcc-3.1.1/libstdc++-v3/include/bits/ostream.tcc Mon Jun 10 21:15:05 2002 --- gcc-3.2/libstdc++-v3/include/bits/ostream.tcc Thu Aug 1 21:29:18 2002 *************** namespace std *** 474,480 **** streamsize __len = 1; if (__w > __len) { ! __pad(__out, __out.fill(), __pads, &__c, __w, __len, false); __len = __w; } __out.write(__pads, __len); --- 474,481 ---- streamsize __len = 1; if (__w > __len) { ! __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, ! &__c, __w, __len, false); __len = __w; } __out.write(__pads, __len); *************** namespace std *** 509,515 **** streamsize __len = 1; if (__w > __len) { ! __pad(__out, __out.fill(), __pads, &__c, __w, __len, false); __len = __w; } __out.write(__pads, __len); --- 510,517 ---- streamsize __len = 1; if (__w > __len) { ! __pad::_S_pad(__out, __out.fill(), __pads, ! &__c, __w, __len, false); __len = __w; } __out.write(__pads, __len); *************** namespace std *** 542,548 **** streamsize __len = static_cast(_Traits::length(__s)); if (__w > __len) { ! __pad(__out, __out.fill(), __pads, __s, __w, __len, false); __s = __pads; __len = __w; } --- 544,551 ---- streamsize __len = static_cast(_Traits::length(__s)); if (__w > __len) { ! __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, ! __s, __w, __len, false); __s = __pads; __len = __w; } *************** namespace std *** 590,596 **** if (__w > __len) { ! __pad(__out, __out.fill(), __pads, __ws, __w, __len, false); __str = __pads; __len = __w; } --- 593,600 ---- if (__w > __len) { ! __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, ! __ws, __w, __len, false); __str = __pads; __len = __w; } *************** namespace std *** 628,634 **** if (__w > __len) { ! __pad(__out, __out.fill(), __pads, __s, __w, __len, false); __s = __pads; __len = __w; } --- 632,639 ---- if (__w > __len) { ! __pad::_S_pad(__out, __out.fill(), __pads, ! __s, __w, __len, false); __s = __pads; __len = __w; } *************** namespace std *** 668,674 **** #endif if (__w > __len) { ! __pad(__out, __out.fill(), __pads, __s, __w, __len, false); __s = __pads; __len = __w; } --- 673,680 ---- #endif if (__w > __len) { ! __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, __s, ! __w, __len, false); __s = __pads; __len = __w; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/sstream.tcc gcc-3.2/libstdc++-v3/include/bits/sstream.tcc *** gcc-3.1.1/libstdc++-v3/include/bits/sstream.tcc Tue Apr 9 08:48:49 2002 --- gcc-3.2/libstdc++-v3/include/bits/sstream.tcc Thu Aug 1 21:29:18 2002 *************** namespace std *** 95,107 **** __len *= 2; if (__testwrite) ! __ret = this->sputc(__c); else if (__len <= _M_string.max_size()) { // Force-allocate, re-sync. _M_string = this->str(); _M_string.reserve(__len); ! _M_buf_size = static_cast(__len); _M_really_sync(_M_in_cur - _M_in_beg, _M_out_cur - _M_out_beg); *_M_out_cur = traits_type::to_char_type(__c); --- 95,107 ---- __len *= 2; if (__testwrite) ! __ret = this->sputc(traits_type::to_char_type(__c)); else if (__len <= _M_string.max_size()) { // Force-allocate, re-sync. _M_string = this->str(); _M_string.reserve(__len); ! _M_buf_size = __len; _M_really_sync(_M_in_cur - _M_in_beg, _M_out_cur - _M_out_beg); *_M_out_cur = traits_type::to_char_type(__c); *************** namespace std *** 184,190 **** if (_M_buf_size) { ! off_type __pos = __sp._M_position(); char_type* __beg = NULL; char_type* __end = NULL; bool __testin = (ios_base::in & _M_mode & __mode) != 0; --- 184,190 ---- if (_M_buf_size) { ! off_type __pos = __sp; // Use streamoff operator to do conversion. char_type* __beg = NULL; char_type* __end = NULL; bool __testin = (ios_base::in & _M_mode & __mode) != 0; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/stl_deque.h gcc-3.2/libstdc++-v3/include/bits/stl_deque.h *** gcc-3.1.1/libstdc++-v3/include/bits/stl_deque.h Thu Apr 18 02:58:15 2002 --- gcc-3.2/libstdc++-v3/include/bits/stl_deque.h Fri Jul 26 23:23:44 2002 *************** struct _Deque_iterator *** 130,140 **** reference operator*() const { return *_M_cur; } pointer operator->() const { return _M_cur; } - difference_type operator-(const _Self& __x) const { - return difference_type(_S_buffer_size()) * (_M_node - __x._M_node - 1) + - (_M_cur - _M_first) + (__x._M_last - __x._M_cur); - } - _Self& operator++() { ++_M_cur; if (_M_cur == _M_last) { --- 130,135 ---- *************** struct _Deque_iterator *** 194,209 **** reference operator[](difference_type __n) const { return *(*this + __n); } - bool operator==(const _Self& __x) const { return _M_cur == __x._M_cur; } - bool operator!=(const _Self& __x) const { return !(*this == __x); } - bool operator<(const _Self& __x) const { - return (_M_node == __x._M_node) ? - (_M_cur < __x._M_cur) : (_M_node < __x._M_node); - } - bool operator>(const _Self& __x) const { return __x < *this; } - bool operator<=(const _Self& __x) const { return !(__x < *this); } - bool operator>=(const _Self& __x) const { return !(*this < __x); } - /** @if maint * Prepares to traverse new_node. Sets everything except _M_cur, which * should therefore be set by the caller immediately afterwards, based on --- 189,194 ---- *************** struct _Deque_iterator *** 217,222 **** --- 202,324 ---- } }; + // Note: we also provide overloads whose operands are of the same type in + // order to avoid ambiguos overload resolution when std::rel_ops operators + // are in scope (for additional details, see libstdc++/3628) + template + inline bool + operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, + const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) + { + return __x._M_cur == __y._M_cur; + } + + template + inline bool + operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + { + return __x._M_cur == __y._M_cur; + } + + template + inline bool + operator!=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, + const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) + { + return !(__x == __y); + } + + template + inline bool + operator!=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + { + return !(__x == __y); + } + + template + inline bool + operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, + const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) + { + return (__x._M_node == __y._M_node) ? + (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); + } + + template + inline bool + operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + { + return (__x._M_node == __y._M_node) ? + (__x._M_cur < __y._M_cur) : (__x._M_node < __y._M_node); + } + + template + inline bool + operator>(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, + const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) + { + return __y < __x; + } + + template + inline bool + operator>(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + { + return __y < __x; + } + + template + inline bool + operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, + const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) + { + return !(__y < __x); + } + + template + inline bool + operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + { + return !(__y < __x); + } + + template + inline bool + operator>=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x, + const _Deque_iterator<_Tp, _Ref, _Ptr>& __y) + { + return !(__x < __y); + } + + template + inline bool + operator>=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + { + return !(__x < __y); + } + + // _GLIBCPP_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + template + inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type + operator-(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x, + const _Deque_iterator<_Tp, _RefR, _PtrR>& __y) + { + return _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type + (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size()) * + (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first) + + (__y._M_last - __y._M_cur); + } + template inline _Deque_iterator<_Tp, _Ref, _Ptr> operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x) diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/stl_iterator.h gcc-3.2/libstdc++-v3/include/bits/stl_iterator.h *** gcc-3.1.1/libstdc++-v3/include/bits/stl_iterator.h Tue Apr 16 02:53:20 2002 --- gcc-3.2/libstdc++-v3/include/bits/stl_iterator.h Fri Jul 26 23:23:44 2002 *************** namespace __gnu_cxx *** 629,638 **** operator-(const difference_type& __n) const { return __normal_iterator(_M_current - __n); } - difference_type - operator-(const __normal_iterator& __i) const - { return _M_current - __i._M_current; } - const _Iterator& base() const { return _M_current; } }; --- 629,634 ---- *************** namespace __gnu_cxx *** 719,724 **** --- 715,730 ---- const __normal_iterator<_Iterator, _Container>& __rhs) { return __lhs.base() >= __rhs.base(); } + // _GLIBCPP_RESOLVE_LIB_DEFECTS + // According to the resolution of DR179 not only the various comparison + // operators but also operator- must accept mixed iterator/const_iterator + // parameters. + template + inline typename __normal_iterator<_IteratorL, _Container>::difference_type + operator-(const __normal_iterator<_IteratorL, _Container>& __lhs, + const __normal_iterator<_IteratorR, _Container>& __rhs) + { return __lhs.base() - __rhs.base(); } + template inline __normal_iterator<_Iterator, _Container> operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n, diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/streambuf.tcc gcc-3.2/libstdc++-v3/include/bits/streambuf.tcc *** gcc-3.1.1/libstdc++-v3/include/bits/streambuf.tcc Sun Apr 21 04:18:41 2002 --- gcc-3.2/libstdc++-v3/include/bits/streambuf.tcc Fri Jul 26 23:23:44 2002 *************** *** 40,46 **** namespace std { template ! const typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::_S_pback_size; template --- 40,46 ---- namespace std { template ! const size_t basic_streambuf<_CharT, _Traits>::_S_pback_size; template *************** namespace std *** 138,144 **** if (__ret < __n) { int_type __c = this->uflow(); ! if (__c != traits_type::eof()) { traits_type::assign(*__s++, traits_type::to_char_type(__c)); ++__ret; --- 138,144 ---- if (__ret < __n) { int_type __c = this->uflow(); ! if (!traits_type::eq_int_type(__c, traits_type::eof())) { traits_type::assign(*__s++, traits_type::to_char_type(__c)); ++__ret; *************** namespace std *** 177,183 **** if (__ret < __n) { int_type __c = this->overflow(traits_type::to_int_type(*__s)); ! if (__c != traits_type::eof()) { ++__ret; ++__s; --- 177,183 ---- if (__ret < __n) { int_type __c = this->overflow(traits_type::to_int_type(*__s)); ! if (!traits_type::eq_int_type(__c, traits_type::eof())) { ++__ret; ++__s; *************** namespace std *** 214,220 **** __sbin->_M_in_cur_move(__xtrct); if (__xtrct == __bufsize) { ! if (__sbin->sgetc() == _Traits::eof()) break; __bufsize = __sbin->in_avail(); } --- 214,220 ---- __sbin->_M_in_cur_move(__xtrct); if (__xtrct == __bufsize) { ! if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof())) break; __bufsize = __sbin->in_avail(); } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/bits/streambuf_iterator.h gcc-3.2/libstdc++-v3/include/bits/streambuf_iterator.h *** gcc-3.1.1/libstdc++-v3/include/bits/streambuf_iterator.h Thu May 2 00:29:01 2002 --- gcc-3.2/libstdc++-v3/include/bits/streambuf_iterator.h Thu Aug 1 21:29:18 2002 *************** namespace std *** 69,81 **** public: istreambuf_iterator() throw() ! : _M_sbuf(0), _M_c(-2) { } istreambuf_iterator(istream_type& __s) throw() ! : _M_sbuf(__s.rdbuf()), _M_c(-2) { } istreambuf_iterator(streambuf_type* __s) throw() ! : _M_sbuf(__s), _M_c(-2) { } // NB: The result of operator*() on an end of stream is undefined. char_type --- 69,81 ---- public: istreambuf_iterator() throw() ! : _M_sbuf(0), _M_c(traits_type::eof()) { } istreambuf_iterator(istream_type& __s) throw() ! : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { } istreambuf_iterator(streambuf_type* __s) throw() ! : _M_sbuf(__s), _M_c(traits_type::eof()) { } // NB: The result of operator*() on an end of stream is undefined. char_type *************** namespace std *** 85,105 **** istreambuf_iterator& operator++() { ! if (_M_sbuf && _M_sbuf->sbumpc() == traits_type::eof()) _M_sbuf = 0; else ! _M_c = -2; return *this; } istreambuf_iterator operator++(int) { istreambuf_iterator __old = *this; ! if (_M_sbuf && (__old._M_c = _M_sbuf->sbumpc()) == traits_type::eof()) _M_sbuf = 0; else ! _M_c = -2; return __old; } --- 85,109 ---- istreambuf_iterator& operator++() { ! const int_type __eof = traits_type::eof(); ! if (_M_sbuf && traits_type::eq_int_type(_M_sbuf->sbumpc(), __eof)) _M_sbuf = 0; else ! _M_c = __eof; return *this; } istreambuf_iterator operator++(int) { + const int_type __eof = traits_type::eof(); istreambuf_iterator __old = *this; ! if (_M_sbuf ! && traits_type::eq_int_type((__old._M_c = _M_sbuf->sbumpc()), ! __eof)) _M_sbuf = 0; else ! _M_c = __eof; return __old; } *************** namespace std *** 110,117 **** equal(const istreambuf_iterator& __b) const { const int_type __eof = traits_type::eof(); ! bool __thiseof = _M_get() == __eof; ! bool __beof = __b._M_get() == __eof; return (__thiseof && __beof || (!__thiseof && !__beof)); } #endif --- 114,121 ---- equal(const istreambuf_iterator& __b) const { const int_type __eof = traits_type::eof(); ! bool __thiseof = traits_type::eq_int_type(_M_get(), __eof); ! bool __beof = traits_type::eq_int_type(__b._M_get(), __eof); return (__thiseof && __beof || (!__thiseof && !__beof)); } #endif *************** namespace std *** 120,132 **** int_type _M_get() const { ! int_type __ret = traits_type::eof(); if (_M_sbuf) { ! if (_M_c != static_cast(-2)) __ret = _M_c; else ! if ((__ret = _M_sbuf->sgetc()) == traits_type::eof()) _M_sbuf = 0; } return __ret; --- 124,137 ---- int_type _M_get() const { ! const int_type __eof = traits_type::eof(); ! int_type __ret = __eof; if (_M_sbuf) { ! if (!traits_type::eq_int_type(_M_c, __eof)) __ret = _M_c; else ! if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), __eof)) _M_sbuf = 0; } return __ret; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/std/std_fstream.h gcc-3.2/libstdc++-v3/include/std/std_fstream.h *** gcc-3.1.1/libstdc++-v3/include/std/std_fstream.h Tue Apr 30 19:05:45 2002 --- gcc-3.2/libstdc++-v3/include/std/std_fstream.h Thu Aug 1 21:29:18 2002 *************** namespace std *** 286,292 **** --- 286,301 ---- } }; + // Explicit specializations. + template<> + basic_filebuf::int_type + basic_filebuf::_M_underflow_common(bool __bump); + #ifdef _GLIBCPP_USE_WCHAR_T + template<> + basic_filebuf::int_type + basic_filebuf::_M_underflow_common(bool __bump); + #endif // 27.8.1.5 Template class basic_ifstream /** diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/std/std_istream.h gcc-3.2/libstdc++-v3/include/std/std_istream.h *** gcc-3.1.1/libstdc++-v3/include/std/std_istream.h Sat Feb 16 00:19:13 2002 --- gcc-3.2/libstdc++-v3/include/std/std_istream.h Fri Jul 26 23:23:44 2002 *************** namespace std *** 261,266 **** --- 261,276 ---- public basic_ostream<_CharT, _Traits> { public: + #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS + // 271. basic_iostream missing typedefs + // Types (inherited): + typedef _CharT char_type; + typedef typename _Traits::int_type int_type; + typedef typename _Traits::pos_type pos_type; + typedef typename _Traits::off_type off_type; + typedef _Traits traits_type; + #endif + // Non-standard Types: typedef basic_istream<_CharT, _Traits> __istream_type; typedef basic_ostream<_CharT, _Traits> __ostream_type; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/include/std/std_streambuf.h gcc-3.2/libstdc++-v3/include/std/std_streambuf.h *** gcc-3.1.1/libstdc++-v3/include/std/std_streambuf.h Mon Apr 22 20:28:34 2002 --- gcc-3.2/libstdc++-v3/include/std/std_streambuf.h Thu Aug 1 21:29:18 2002 *************** namespace std *** 71,76 **** --- 71,77 ---- // Non-standard Types: typedef ctype __ctype_type; typedef basic_streambuf __streambuf_type; + typedef typename traits_type::state_type __state_type; friend class basic_ios; friend class basic_istream; *************** namespace std *** 91,100 **** char_type* _M_buf; // Actual size of allocated internal buffer, in bytes. ! int_type _M_buf_size; // Optimal or preferred size of internal buffer, in bytes. ! int_type _M_buf_size_opt; // True iff _M_in_* and _M_out_* buffers should always point to // the same place. True for fstreams, false for sstreams. --- 92,101 ---- char_type* _M_buf; // Actual size of allocated internal buffer, in bytes. ! size_t _M_buf_size; // Optimal or preferred size of internal buffer, in bytes. ! size_t _M_buf_size_opt; // True iff _M_in_* and _M_out_* buffers should always point to // the same place. True for fstreams, false for sstreams. *************** namespace std *** 126,137 **** // requirements. The only basic_streambuf member function that // needs access to these data members is in_avail... // NB: pbacks of over one character are not currently supported. ! static const int_type _S_pback_size = 1; char_type _M_pback[_S_pback_size]; char_type* _M_pback_cur_save; char_type* _M_pback_end_save; bool _M_pback_init; // Initializes pback buffers, and moves normal buffers to safety. // Assumptions: // _M_in_cur has already been moved back --- 127,141 ---- // requirements. The only basic_streambuf member function that // needs access to these data members is in_avail... // NB: pbacks of over one character are not currently supported. ! static const size_t _S_pback_size = 1; char_type _M_pback[_S_pback_size]; char_type* _M_pback_cur_save; char_type* _M_pback_end_save; bool _M_pback_init; + // Yet unused. + fpos<__state_type> _M_pos; + // Initializes pback buffers, and moves normal buffers to safety. // Assumptions: // _M_in_cur has already been moved back *************** namespace std *** 140,147 **** { if (!_M_pback_init) { ! int_type __dist = _M_in_end - _M_in_cur; ! int_type __len = min(_S_pback_size, __dist); traits_type::copy(_M_pback, _M_in_cur, __len); _M_pback_cur_save = _M_in_cur; _M_pback_end_save = _M_in_end; --- 144,151 ---- { if (!_M_pback_init) { ! size_t __dist = _M_in_end - _M_in_cur; ! size_t __len = min(_S_pback_size, __dist); traits_type::copy(_M_pback, _M_in_cur, __len); _M_pback_cur_save = _M_in_cur; _M_pback_end_save = _M_in_end; *************** namespace std *** 159,170 **** if (_M_pback_init) { // Length _M_in_cur moved in the pback buffer. ! int_type __off_cur = _M_in_cur - _M_pback; // For in | out buffers, the end can be pushed back... ! int_type __off_end = 0; ! int_type __pback_len = _M_in_end - _M_pback; ! int_type __save_len = _M_pback_end_save - _M_buf; if (__pback_len > __save_len) __off_end = __pback_len - __save_len; --- 163,174 ---- if (_M_pback_init) { // Length _M_in_cur moved in the pback buffer. ! size_t __off_cur = _M_in_cur - _M_pback; // For in | out buffers, the end can be pushed back... ! size_t __off_end = 0; ! size_t __pback_len = _M_in_end - _M_pback; ! size_t __save_len = _M_pback_end_save - _M_buf; if (__pback_len > __save_len) __off_end = __pback_len - __save_len; *************** namespace std *** 288,295 **** { if (_M_pback_init) { ! int_type __save_len = _M_pback_end_save - _M_pback_cur_save; ! int_type __pback_len = _M_in_cur - _M_pback; __ret = __save_len - __pback_len; } else --- 292,299 ---- { if (_M_pback_init) { ! size_t __save_len = _M_pback_end_save - _M_pback_cur_save; ! size_t __pback_len = _M_in_cur - _M_pback; __ret = __save_len - __pback_len; } else *************** namespace std *** 304,310 **** snextc() { int_type __eof = traits_type::eof(); ! return (this->sbumpc() == __eof ? __eof : this->sgetc()); } int_type --- 308,315 ---- snextc() { int_type __eof = traits_type::eof(); ! return (traits_type::eq_int_type(this->sbumpc(), __eof) ! ? __eof : this->sgetc()); } int_type *************** namespace std *** 342,351 **** protected: basic_streambuf() ! : _M_buf(NULL), _M_buf_size(0), ! _M_buf_size_opt(static_cast(BUFSIZ)), _M_buf_unified(false), ! _M_in_beg(0), _M_in_cur(0), _M_in_end(0), _M_out_beg(0), _M_out_cur(0), ! _M_out_end(0), _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), _M_buf_locale_init(false), _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false) { } --- 347,356 ---- protected: basic_streambuf() ! : _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(BUFSIZ), ! _M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0), ! _M_out_beg(0), _M_out_cur(0), _M_out_end(0), ! _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), _M_buf_locale_init(false), _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false) { } *************** namespace std *** 438,444 **** uflow() { int_type __ret = traits_type::eof(); ! bool __testeof = this->underflow() == __ret; bool __testpending = _M_in_cur && _M_in_cur < _M_in_end; if (!__testeof && __testpending) { --- 443,449 ---- uflow() { int_type __ret = traits_type::eof(); ! bool __testeof = traits_type::eq_int_type(this->underflow(), __ret); bool __testpending = _M_in_cur && _M_in_cur < _M_in_end; if (!__testeof && __testpending) { diff -Nrc3pad gcc-3.1.1/libstdc++-v3/libio/ChangeLog gcc-3.2/libstdc++-v3/libio/ChangeLog *** gcc-3.1.1/libstdc++-v3/libio/ChangeLog Thu Jul 25 23:40:25 2002 --- gcc-3.2/libstdc++-v3/libio/ChangeLog Wed Aug 14 09:01:10 2002 *************** *** 1,3 **** --- 1,7 ---- + 2002-08-14 Release Manager + + * GCC 3.2 Released. + 2002-07-25 Release Manager * GCC 3.1.1 Released. diff -Nrc3pad gcc-3.1.1/libstdc++-v3/libsupc++/cxxabi.h gcc-3.2/libstdc++-v3/libsupc++/cxxabi.h *** gcc-3.1.1/libstdc++-v3/libsupc++/cxxabi.h Fri Nov 23 16:29:02 2001 --- gcc-3.2/libstdc++-v3/libsupc++/cxxabi.h Thu Aug 1 21:29:18 2002 *************** *** 1,6 **** // new abi support -*- C++ -*- ! // Copyright (C) 2000 Free Software Foundation, Inc. // // This file is part of GNU CC. // --- 1,6 ---- // new abi support -*- C++ -*- ! // Copyright (C) 2000, 2002 Free Software Foundation, Inc. // // This file is part of GNU CC. // *************** class __pbase_type_info *** 117,123 **** { /* abi defined member variables */ public: ! unsigned int __qualifier_flags; /* qualification of the target object */ const std::type_info *__pointee; /* type of pointed to object */ /* abi defined member functions */ --- 117,123 ---- { /* abi defined member variables */ public: ! unsigned int __flags; /* qualification of the target object */ const std::type_info *__pointee; /* type of pointed to object */ /* abi defined member functions */ *************** public: *** 127,138 **** explicit __pbase_type_info (const char *__n, int __quals, const std::type_info *__type) ! : std::type_info (__n), __qualifier_flags (__quals), __pointee (__type) { } /* implementation defined types */ public: ! enum __qualifier_masks { __const_mask = 0x1, __volatile_mask = 0x2, __restrict_mask = 0x4, --- 127,138 ---- explicit __pbase_type_info (const char *__n, int __quals, const std::type_info *__type) ! : std::type_info (__n), __flags (__quals), __pointee (__type) { } /* implementation defined types */ public: ! enum __masks { __const_mask = 0x1, __volatile_mask = 0x2, __restrict_mask = 0x4, *************** class __pointer_to_member_type_info *** 181,187 **** { /* abi defined member variables */ public: ! __class_type_info *__context_class; /* class of the member */ /* abi defined member functions */ public: --- 181,187 ---- { /* abi defined member variables */ public: ! __class_type_info *__context; /* class of the member */ /* abi defined member functions */ public: *************** public: *** 191,197 **** int __quals, const std::type_info *__type, __class_type_info *__klass) ! : __pbase_type_info (__n, __quals, __type), __context_class (__klass) { } /* implementation defined member functions */ --- 191,197 ---- int __quals, const std::type_info *__type, __class_type_info *__klass) ! : __pbase_type_info (__n, __quals, __type), __context (__klass) { } /* implementation defined member functions */ *************** protected: *** 204,214 **** class __class_type_info; /* helper class for __vmi_class_type */ ! class __base_class_info { /* abi defined member variables */ public: ! const __class_type_info *__base; /* base class type */ long __offset_flags; /* offset and info */ /* implementation defined types */ --- 204,214 ---- class __class_type_info; /* helper class for __vmi_class_type */ ! class __base_class_type_info { /* abi defined member variables */ public: ! const __class_type_info* __base_type; /* base class type */ long __offset_flags; /* offset and info */ /* implementation defined types */ *************** public: *** 216,223 **** enum __offset_flags_masks { __virtual_mask = 0x1, __public_mask = 0x2, ! hwm_bit = 2, ! offset_shift = 8 /* bits to shift offset by */ }; /* implementation defined member functions */ --- 216,223 ---- enum __offset_flags_masks { __virtual_mask = 0x1, __public_mask = 0x2, ! __hwm_bit = 2, ! __offset_shift = 8 /* bits to shift offset by */ }; /* implementation defined member functions */ *************** public: *** 230,236 **** { // This shift, being of a signed type, is implementation defined. GCC // implements such shifts as arithmetic, which is what we want. ! return static_cast<__PTRDIFF_TYPE__> (__offset_flags) >> offset_shift; } }; --- 230,236 ---- { // This shift, being of a signed type, is implementation defined. GCC // implements such shifts as arithmetic, which is what we want. ! return static_cast<__PTRDIFF_TYPE__> (__offset_flags) >> __offset_shift; } }; *************** public: *** 259,267 **** /* publicly) */ __contained_ambig, /* contained ambiguously */ ! __contained_virtual_mask = __base_class_info::__virtual_mask, /* via a virtual path */ ! __contained_public_mask = __base_class_info::__public_mask, /* via a public path */ ! __contained_mask = 1 << __base_class_info::hwm_bit, /* contained within us */ __contained_private = __contained_mask, __contained_public = __contained_mask | __contained_public_mask --- 259,267 ---- /* publicly) */ __contained_ambig, /* contained ambiguously */ ! __contained_virtual_mask = __base_class_type_info::__virtual_mask, /* via a virtual path */ ! __contained_public_mask = __base_class_type_info::__public_mask, /* via a public path */ ! __contained_mask = 1 << __base_class_type_info::__hwm_bit, /* contained within us */ __contained_private = __contained_mask, __contained_public = __contained_mask | __contained_public_mask *************** class __vmi_class_type_info : public __c *** 365,371 **** public: unsigned int __flags; /* details about the class hierarchy */ unsigned int __base_count; /* number of direct bases */ ! __base_class_info const __base_info[1]; /* array of bases */ /* The array of bases uses the trailing array struct hack so this class is not constructable with a normal constructor. It is internally generated by the compiler. */ --- 365,371 ---- public: unsigned int __flags; /* details about the class hierarchy */ unsigned int __base_count; /* number of direct bases */ ! __base_class_type_info __base_info[1]; /* array of bases */ /* The array of bases uses the trailing array struct hack so this class is not constructable with a normal constructor. It is internally generated by the compiler. */ diff -Nrc3pad gcc-3.1.1/libstdc++-v3/libsupc++/new gcc-3.2/libstdc++-v3/libsupc++/new *** gcc-3.1.1/libstdc++-v3/libsupc++/new Tue Jul 16 20:26:29 2002 --- gcc-3.2/libstdc++-v3/libsupc++/new Fri Jul 26 23:23:45 2002 *************** void operator delete[](void*, const std: *** 88,93 **** --- 88,97 ---- // Default placement versions of operator new. inline void* operator new(std::size_t, void* __p) throw() { return __p; } inline void* operator new[](std::size_t, void* __p) throw() { return __p; } + + // Default placement versions of operator delete. + inline void operator delete (void*, void*) throw() { }; + inline void operator delete[](void*, void*) throw() { }; //@} } // extern "C++" diff -Nrc3pad gcc-3.1.1/libstdc++-v3/libsupc++/tinfo.cc gcc-3.2/libstdc++-v3/libsupc++/tinfo.cc *** gcc-3.1.1/libstdc++-v3/libsupc++/tinfo.cc Wed Jan 9 20:39:27 2002 --- gcc-3.2/libstdc++-v3/libsupc++/tinfo.cc Thu Aug 1 21:29:18 2002 *************** __do_find_public_src (ptrdiff_t src2dst, *** 295,301 **** } base = convert_to_base (base, is_virtual, offset); ! __sub_kind base_kind = __base_info[i].__base->__do_find_public_src (src2dst, base, src_type, src_ptr); if (contained_p (base_kind)) { --- 295,301 ---- } base = convert_to_base (base, is_virtual, offset); ! __sub_kind base_kind = __base_info[i].__base_type->__do_find_public_src (src2dst, base, src_type, src_ptr); if (contained_p (base_kind)) { *************** __do_dyncast (ptrdiff_t src2dst, *** 432,438 **** } bool result2_ambig ! = __base_info[i].__base->__do_dyncast (src2dst, base_access, dst_type, base, src_type, src_ptr, result2); result.whole2src = __sub_kind (result.whole2src | result2.whole2src); --- 432,438 ---- } bool result2_ambig ! = __base_info[i].__base_type->__do_dyncast (src2dst, base_access, dst_type, base, src_type, src_ptr, result2); result.whole2src = __sub_kind (result.whole2src | result2.whole2src); *************** __do_upcast (const __class_type_info *ds *** 616,625 **** if (base) base = convert_to_base (base, is_virtual, offset); ! if (__base_info[i].__base->__do_upcast (dst, base, result2)) { if (result2.base_type == nonvirtual_base_type && is_virtual) ! result2.base_type = __base_info[i].__base; if (contained_p (result2.part2dst) && !is_public) result2.part2dst = __sub_kind (result2.part2dst & ~__contained_public_mask); --- 616,625 ---- if (base) base = convert_to_base (base, is_virtual, offset); ! if (__base_info[i].__base_type->__do_upcast (dst, base, result2)) { if (result2.base_type == nonvirtual_base_type && is_virtual) ! result2.base_type = __base_info[i].__base_type; if (contained_p (result2.part2dst) && !is_public) result2.part2dst = __sub_kind (result2.part2dst & ~__contained_public_mask); diff -Nrc3pad gcc-3.1.1/libstdc++-v3/libsupc++/tinfo2.cc gcc-3.2/libstdc++-v3/libsupc++/tinfo2.cc *** gcc-3.1.1/libstdc++-v3/libsupc++/tinfo2.cc Wed Mar 28 11:04:50 2001 --- gcc-3.2/libstdc++-v3/libsupc++/tinfo2.cc Thu Aug 1 21:29:18 2002 *************** *** 1,6 **** // Methods for type_info for -*- C++ -*- Run Time Type Identification. ! // Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001 // Free Software Foundation // // This file is part of GNU CC. --- 1,6 ---- // Methods for type_info for -*- C++ -*- Run Time Type Identification. ! // Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002 // Free Software Foundation // // This file is part of GNU CC. *************** __do_catch (const type_info *thr_type, *** 116,126 **** const __pbase_type_info *thrown_type = static_cast (thr_type); ! if (thrown_type->__qualifier_flags & ~__qualifier_flags) // We're less qualified. return false; ! if (!(__qualifier_flags & __const_mask)) outer &= ~1; return __pointer_catch (thrown_type, thr_obj, outer); --- 116,126 ---- const __pbase_type_info *thrown_type = static_cast (thr_type); ! if (thrown_type->__flags & ~__flags) // We're less qualified. return false; ! if (!(__flags & __const_mask)) outer &= ~1; return __pointer_catch (thrown_type, thr_obj, outer); *************** __pointer_catch (const __pbase_type_info *** 158,164 **** const __pointer_to_member_type_info *thrown_type = static_cast (thr_type); ! if (*__context_class != *thrown_type->__context_class) return false; // not pointers to member of same class return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer); --- 158,164 ---- const __pointer_to_member_type_info *thrown_type = static_cast (thr_type); ! if (*__context != *thrown_type->__context) return false; // not pointers to member of same class return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer); diff -Nrc3pad gcc-3.1.1/libstdc++-v3/src/Makefile.am gcc-3.2/libstdc++-v3/src/Makefile.am *** gcc-3.1.1/libstdc++-v3/src/Makefile.am Fri Jun 28 08:22:39 2002 --- gcc-3.2/libstdc++-v3/src/Makefile.am Thu Aug 1 21:29:14 2002 *************** sources = \ *** 69,76 **** collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \ concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \ string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc \ ! fstream-inst.cc io-inst.cc istream-inst.cc ostream-inst.cc \ ! streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) --- 69,76 ---- collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \ concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \ string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc \ ! fstream.cc fstream-inst.cc io-inst.cc istream-inst.cc \ ! ostream-inst.cc streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) diff -Nrc3pad gcc-3.1.1/libstdc++-v3/src/Makefile.in gcc-3.2/libstdc++-v3/src/Makefile.in *** gcc-3.1.1/libstdc++-v3/src/Makefile.in Fri Jun 28 08:22:40 2002 --- gcc-3.2/libstdc++-v3/src/Makefile.in Thu Aug 1 21:29:15 2002 *************** sources = \ *** 174,181 **** collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \ concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \ string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc \ ! fstream-inst.cc io-inst.cc istream-inst.cc ostream-inst.cc \ ! streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) --- 174,181 ---- collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \ concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \ string-inst.cc wstring-inst.cc valarray-inst.cc ext-inst.cc \ ! fstream.cc fstream-inst.cc io-inst.cc istream-inst.cc \ ! ostream-inst.cc streambuf-inst.cc sstream-inst.cc VPATH = $(top_srcdir)/src:$(top_srcdir) *************** ios.lo strstream.lo bitset.lo functexcep *** 258,265 **** c++locale.lo locale.lo localename.lo codecvt.lo collate.lo ctype.lo \ messages.lo monetary.lo numeric.lo time.lo concept-inst.lo \ locale-inst.lo misc-inst.lo stl-inst.lo string-inst.lo wstring-inst.lo \ ! valarray-inst.lo ext-inst.lo fstream-inst.lo io-inst.lo istream-inst.lo \ ! ostream-inst.lo streambuf-inst.lo sstream-inst.lo CXXFLAGS = @CXXFLAGS@ CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) --- 258,265 ---- c++locale.lo locale.lo localename.lo codecvt.lo collate.lo ctype.lo \ messages.lo monetary.lo numeric.lo time.lo concept-inst.lo \ locale-inst.lo misc-inst.lo stl-inst.lo string-inst.lo wstring-inst.lo \ ! valarray-inst.lo ext-inst.lo fstream.lo fstream-inst.lo io-inst.lo \ ! istream-inst.lo ostream-inst.lo streambuf-inst.lo sstream-inst.lo CXXFLAGS = @CXXFLAGS@ CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) diff -Nrc3pad gcc-3.1.1/libstdc++-v3/src/fstream.cc gcc-3.2/libstdc++-v3/src/fstream.cc *** gcc-3.1.1/libstdc++-v3/src/fstream.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/src/fstream.cc Thu Aug 1 21:29:15 2002 *************** *** 0 **** --- 1,193 ---- + // File based streams -*- C++ -*- + + // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 + // Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // + // ISO C++ 14882: 27.8 File-based streams + // + + #include + + namespace std + { + template<> + basic_filebuf::int_type + basic_filebuf::_M_underflow_common(bool __bump) + { + int_type __ret = traits_type::eof(); + bool __testin = _M_mode & ios_base::in; + bool __testout = _M_mode & ios_base::out; + + if (__testin) + { + // Check for pback madness, and if so swich back to the + // normal buffers and jet outta here before expensive + // fileops happen... + if (_M_pback_init) + { + _M_pback_destroy(); + if (_M_in_cur < _M_in_end) + return traits_type::to_int_type(*_M_in_cur); + } + + // Sync internal and external buffers. + // NB: __testget -> __testput as _M_buf_unified here. + bool __testget = _M_in_cur && _M_in_beg < _M_in_cur; + bool __testinit = _M_is_indeterminate(); + if (__testget) + { + if (__testout) + _M_really_overflow(); + else if (_M_in_cur != _M_filepos) + _M_file.seekoff(_M_in_cur - _M_filepos, + ios_base::cur, ios_base::in); + } + + if (__testinit || __testget) + { + streamsize __elen = 0; + streamsize __ilen = 0; + __elen = _M_file.xsgetn(reinterpret_cast(_M_in_beg), + _M_buf_size); + __ilen = __elen; + + if (0 < __ilen) + { + _M_set_determinate(__ilen); + if (__testout) + _M_out_cur = _M_in_cur; + __ret = traits_type::to_int_type(*_M_in_cur); + if (__bump) + _M_in_cur_move(1); + else if (_M_buf_size == 1) + { + // If we are synced with stdio, we have to unget the + // character we just read so that the file pointer + // doesn't move. + _M_file.sys_ungetc(traits_type::to_int_type(*_M_in_cur)); + _M_set_indeterminate(); + } + } + } + } + _M_last_overflowed = false; + return __ret; + } + + #ifdef _GLIBCPP_USE_WCHAR_T + template<> + basic_filebuf::int_type + basic_filebuf::_M_underflow_common(bool __bump) + { + int_type __ret = traits_type::eof(); + bool __testin = _M_mode & ios_base::in; + bool __testout = _M_mode & ios_base::out; + + if (__testin) + { + // Check for pback madness, and if so swich back to the + // normal buffers and jet outta here before expensive + // fileops happen... + if (_M_pback_init) + { + _M_pback_destroy(); + if (_M_in_cur < _M_in_end) + return traits_type::to_int_type(*_M_in_cur); + } + + // Sync internal and external buffers. + // NB: __testget -> __testput as _M_buf_unified here. + bool __testget = _M_in_cur && _M_in_beg < _M_in_cur; + bool __testinit = _M_is_indeterminate(); + if (__testget) + { + if (__testout) + _M_really_overflow(); + else if (_M_in_cur != _M_filepos) + _M_file.seekoff(_M_in_cur - _M_filepos, + ios_base::cur, ios_base::in); + } + + if (__testinit || __testget) + { + const locale __loc = this->getloc(); + const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc); + + streamsize __elen = 0; + streamsize __ilen = 0; + if (__cvt.always_noconv()) + { + __elen = _M_file.xsgetn(reinterpret_cast(_M_in_beg), + _M_buf_size); + __ilen = __elen; + } + else + { + char* __buf = static_cast(__builtin_alloca(_M_buf_size)); + __elen = _M_file.xsgetn(__buf, _M_buf_size); + + const char* __eend; + char_type* __iend; + __res_type __r = __cvt.in(_M_state_cur, __buf, + __buf + __elen, __eend, _M_in_beg, + _M_in_beg + _M_buf_size, __iend); + if (__r == codecvt_base::ok) + __ilen = __iend - _M_in_beg; + else + { + // Unwind. + __ilen = 0; + _M_file.seekoff(-__elen, ios_base::cur, ios_base::in); + } + } + + if (0 < __ilen) + { + _M_set_determinate(__ilen); + if (__testout) + _M_out_cur = _M_in_cur; + __ret = traits_type::to_int_type(*_M_in_cur); + if (__bump) + _M_in_cur_move(1); + else if (_M_buf_size == 1) + { + // If we are synced with stdio, we have to unget the + // character we just read so that the file pointer + // doesn't move. + _M_file.sys_ungetc(traits_type::to_int_type(*_M_in_cur)); + _M_set_indeterminate(); + } + } + } + } + _M_last_overflowed = false; + return __ret; + } + #endif + } // namespace std diff -Nrc3pad gcc-3.1.1/libstdc++-v3/src/locale-inst.cc gcc-3.2/libstdc++-v3/src/locale-inst.cc *** gcc-3.1.1/libstdc++-v3/src/locale-inst.cc Mon Jun 10 21:15:01 2002 --- gcc-3.2/libstdc++-v3/src/locale-inst.cc Thu Aug 1 21:29:15 2002 *************** namespace std *** 420,434 **** bool __verify_grouping(const basic_string&, basic_string&); ! template ! void ! __pad(ios_base&, char, char*, const char *, streamsize, ! streamsize, const bool); ! ! template ! void ! __pad >(ios_base&, char, char*, const char *, ! streamsize, streamsize, const bool); #ifdef _GLIBCPP_USE_WCHAR_T template --- 420,426 ---- bool __verify_grouping(const basic_string&, basic_string&); ! template class __pad >; #ifdef _GLIBCPP_USE_WCHAR_T template *************** namespace std *** 440,468 **** __verify_grouping(const basic_string&, basic_string&); ! template ! void ! __pad(ios_base&, wchar_t, wchar_t*, const wchar_t*, ! streamsize, streamsize, const bool); ! ! template ! void ! __pad >(ios_base&, wchar_t, wchar_t*, ! const wchar_t*, streamsize, ! streamsize, const bool); ! #endif // _GLIBCPP_USE_WCHAR_T template int ! __convert_from_v(char*, const int, const char*, double, const __c_locale&, int); template int ! __convert_from_v(char*, const int, const char*, long double, const __c_locale&, int); template int ! __convert_from_v(char*, const int, const char*, long, const __c_locale&, int); template int --- 432,454 ---- __verify_grouping(const basic_string&, basic_string&); ! template class __pad >; ! #endif template int ! __convert_from_v(char*, const int, const char*, double, ! const __c_locale&, int); template int ! __convert_from_v(char*, const int, const char*, long double, ! const __c_locale&, int); template int ! __convert_from_v(char*, const int, const char*, long, ! const __c_locale&, int); template int *************** namespace std *** 471,477 **** template int ! __convert_from_v(char*, const int, const char*, long long, const __c_locale&, int); template int --- 457,464 ---- template int ! __convert_from_v(char*, const int, const char*, long long, ! const __c_locale&, int); template int diff -Nrc3pad gcc-3.1.1/libstdc++-v3/src/locale.cc gcc-3.2/libstdc++-v3/src/locale.cc *** gcc-3.1.1/libstdc++-v3/src/locale.cc Fri Apr 19 08:28:18 2002 --- gcc-3.2/libstdc++-v3/src/locale.cc Thu Aug 1 21:29:15 2002 *************** namespace std *** 202,208 **** if (strcmp(__s, "C") == 0 || strcmp(__s, "POSIX") == 0) (_M_impl = _S_classic)->_M_add_reference(); else if (strcmp(__s, "") == 0) ! _M_impl = new _Impl(setlocale(LC_ALL, __s), 1); else _M_impl = new _Impl(__s, 1); } --- 202,208 ---- if (strcmp(__s, "C") == 0 || strcmp(__s, "POSIX") == 0) (_M_impl = _S_classic)->_M_add_reference(); else if (strcmp(__s, "") == 0) ! _M_impl = new _Impl(setlocale(LC_ALL, NULL), 1); else _M_impl = new _Impl(__s, 1); } *************** namespace std *** 284,294 **** const locale& locale::classic() { - static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER; - _STL_auto_lock __auto(__lock); - if (!_S_classic) { try { // 26 Standard facets, 2 references. --- 284,294 ---- const locale& locale::classic() { if (!_S_classic) { + static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER; + _STL_auto_lock __auto(__lock); + try { // 26 Standard facets, 2 references. diff -Nrc3pad gcc-3.1.1/libstdc++-v3/src/localename.cc gcc-3.2/libstdc++-v3/src/localename.cc *** gcc-3.1.1/libstdc++-v3/src/localename.cc Sat May 18 14:37:48 2002 --- gcc-3.2/libstdc++-v3/src/localename.cc Fri Jul 26 23:23:42 2002 *************** namespace std *** 132,139 **** _M_init_facet(new num_get); _M_init_facet(new num_put); _M_init_facet(new std::collate(__cloc)); ! _M_init_facet(new moneypunct(__cloc)); ! _M_init_facet(new moneypunct(__cloc)); _M_init_facet(new money_get); _M_init_facet(new money_put); _M_init_facet(new __timepunct(__cloc, __s)); --- 132,139 ---- _M_init_facet(new num_get); _M_init_facet(new num_put); _M_init_facet(new std::collate(__cloc)); ! _M_init_facet(new moneypunct(__cloc, __s)); ! _M_init_facet(new moneypunct(__cloc, __s)); _M_init_facet(new money_get); _M_init_facet(new money_put); _M_init_facet(new __timepunct(__cloc, __s)); *************** namespace std *** 148,155 **** _M_init_facet(new num_get); _M_init_facet(new num_put); _M_init_facet(new std::collate(__cloc)); ! _M_init_facet(new moneypunct(__cloc)); ! _M_init_facet(new moneypunct(__cloc)); _M_init_facet(new money_get); _M_init_facet(new money_put); _M_init_facet(new __timepunct(__cloc, __s)); --- 148,155 ---- _M_init_facet(new num_get); _M_init_facet(new num_put); _M_init_facet(new std::collate(__cloc)); ! _M_init_facet(new moneypunct(__cloc, __s)); ! _M_init_facet(new moneypunct(__cloc, __s)); _M_init_facet(new money_get); _M_init_facet(new money_put); _M_init_facet(new __timepunct(__cloc, __s)); diff -Nrc3pad gcc-3.1.1/libstdc++-v3/src/strstream.cc gcc-3.2/libstdc++-v3/src/strstream.cc *** gcc-3.1.1/libstdc++-v3/src/strstream.cc Sat Jun 8 15:15:43 2002 --- gcc-3.2/libstdc++-v3/src/strstream.cc Wed Aug 7 05:13:08 2002 *************** *** 47,53 **** // MAY BE REMOVED in a future standard revision. You should use the // header instead. ! #include #include #include #include --- 47,53 ---- // MAY BE REMOVED in a future standard revision. You should use the // header instead. ! #include #include #include #include *************** namespace std *** 60,71 **** : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), _M_frozen(false), _M_constant(false) { ! _M_buf_size = _M_buf_size_opt = max(initial_capacity, streamsize(16)); ! _M_buf = _M_alloc(_M_buf_size); ! if (_M_buf) { ! setp(_M_buf, _M_buf + _M_buf_size); ! setg(_M_buf, _M_buf, _M_buf); } } --- 60,72 ---- : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), _M_frozen(false), _M_constant(false) { ! streamsize n = max(initial_capacity, streamsize(16)); ! ! char* buf = _M_alloc(n); ! if (buf) { ! setp(buf, buf + n); ! setg(buf, buf, buf); } } *************** namespace std *** 73,84 **** : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true), _M_frozen(false), _M_constant(false) { ! _M_buf_size = _M_buf_size_opt = 16; ! _M_buf = _M_alloc(_M_buf_size); ! if (_M_buf) { ! setp(_M_buf, _M_buf + _M_buf_size); ! setg(_M_buf, _M_buf, _M_buf); } } --- 74,86 ---- : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true), _M_frozen(false), _M_constant(false) { ! streamsize n = 16; ! ! char* buf = _M_alloc(n); ! if (buf) { ! setp(buf, buf + n); ! setg(buf, buf, buf); } } *************** namespace std *** 116,129 **** strstreambuf::~strstreambuf() { if (_M_dynamic && !_M_frozen) ! { ! char* p = this->eback(); ! _M_free(p); ! if (p == _M_buf) ! _M_buf = 0; ! } ! if (_M_buf) ! _M_free(_M_buf); } void --- 118,124 ---- strstreambuf::~strstreambuf() { if (_M_dynamic && !_M_frozen) ! _M_free(eback()); } void *************** namespace std *** 169,176 **** old_get_offset = gptr() - eback(); } - _M_buf = buf; - _M_buf_size = _M_buf_size_opt = new_size; setp(buf, buf + new_size); pbump(old_size); --- 164,169 ---- diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/18_support/new_delete_placement.cc gcc-3.2/libstdc++-v3/testsuite/18_support/new_delete_placement.cc *** gcc-3.1.1/libstdc++-v3/testsuite/18_support/new_delete_placement.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/18_support/new_delete_placement.cc Fri Jul 26 23:23:43 2002 *************** *** 0 **** --- 1,40 ---- + // 2002-07-24 Benjamin Kosnik + + // Copyright (C) 2002 Free Software Foundation + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 18.4.1.3 - Placement forms + + #include + #include + + // libstdc++/7286 + void test01() + { + void* pc = new char; + void* pa = new char[10]; + void* tmp; + operator delete(pc, tmp); + operator delete[](pa, tmp); + } + + int main() + { + test01(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc gcc-3.2/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc *** gcc-3.1.1/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc Fri Apr 19 08:28:20 2002 --- gcc-3.2/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc Wed Aug 7 05:13:08 2002 *************** public: *** 58,64 **** void test03() { bool test = true; - try { throw fuzzy_logic(); } catch(const fuzzy_logic& obj) --- 58,63 ---- *************** void allocate_on_stack(void) *** 79,84 **** --- 78,84 ---- } void test04() { + bool test = true; const std::string s("CA ISO emergency once again:immediate power down"); const char* strlit1 = "wish I lived in Palo Alto"; const char* strlit2 = "...or Santa Barbara"; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/21_strings/capacity.cc gcc-3.2/libstdc++-v3/testsuite/21_strings/capacity.cc *** gcc-3.1.1/libstdc++-v3/testsuite/21_strings/capacity.cc Fri Apr 19 08:28:22 2002 --- gcc-3.2/libstdc++-v3/testsuite/21_strings/capacity.cc Thu Aug 1 21:29:15 2002 *************** template *** 36,41 **** --- 36,128 ---- struct B { }; + // char_traits specialization + namespace std + { + template<> + struct char_traits > + { + typedef A char_type; + // Unsigned as wint_t in unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return lt(__s1[__i], __s2[__i]) ? -1 : 1; + return 0; + } + + static size_t + length(const char_type* __s) + { + const char_type* __p = __s; + while (__p) + ++__p; + return (__p - __s); + } + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) + if (*__p == __a) return __p; + return 0; + } + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (char_type* __p = __s; __p < __s + __n; ++__p) + assign(*__p, __a); + return __s; + } + + static char_type + to_char_type(const int_type& __c) + { return char_type(); } + + static int_type + to_int_type(const char_type& __c) { return int_type(); } + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type + eof() { return static_cast(-1); } + + static int_type + not_eof(const int_type& __c) + { return eq_int_type(__c, eof()) ? int_type(0) : __c; } + }; + } // namespace std + void test01() { // 1 POD types : resize, capacity, reserve diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc gcc-3.2/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc *** gcc-3.1.1/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc Tue Mar 26 00:39:06 2002 --- gcc-3.2/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc Thu Aug 1 21:29:16 2002 *************** *** 23,32 **** #include #include ! using namespace std; #ifdef _GLIBCPP_USE___ENC_TRAITS /* > how do I check that these conversions are correct? Very easy. Since all the characters are from ASCII you simply --- 23,93 ---- #include #include ! #ifdef _GLIBCPP_USE___ENC_TRAITS + // Need some char_traits specializations for this to work. + typedef unsigned short unicode_t; + + namespace std + { + template<> + struct char_traits + { + typedef unicode_t char_type; + // Unsigned as wint_t is unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { return memcmp(__s1, __s2, __n); } + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return static_cast(memcpy(__s1, __s2, __n)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; + } + /* > how do I check that these conversions are correct? Very easy. Since all the characters are from ASCII you simply *************** it shows that the other byte-order is us *** 51,57 **** void ! initialize_state(__enc_traits& state) { state._M_init(); } // Partial specialization using __enc_traits. --- 112,118 ---- void ! initialize_state(std::__enc_traits& state) { state._M_init(); } // Partial specialization using __enc_traits. *************** initialize_state(__enc_traits& state) *** 59,66 **** // UNICODE - UCS2 (big endian) void test01() { typedef codecvt_base::result result; - typedef unsigned short unicode_t; typedef unicode_t int_type; typedef char ext_type; typedef __enc_traits enc_type; --- 120,127 ---- // UNICODE - UCS2 (big endian) void test01() { + using namespace std; typedef codecvt_base::result result; typedef unicode_t int_type; typedef char ext_type; typedef __enc_traits enc_type; *************** void test01() *** 146,151 **** --- 207,213 ---- // UNICODE - UCS2 (little endian) void test02() { + using namespace std; typedef codecvt_base::result result; typedef unsigned short unicode_t; typedef unicode_t int_type; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc gcc-3.2/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc *** gcc-3.1.1/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc Thu Mar 28 19:22:40 2002 --- gcc-3.2/libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc Thu Aug 1 21:29:16 2002 *************** *** 1,6 **** // 2000-08-23 Benjamin Kosnik ! // Copyright (C) 2000, 2001 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,6 ---- // 2000-08-23 Benjamin Kosnik ! // Copyright (C) 2000, 2001, 2002 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** *** 23,43 **** #include #include - using namespace std; - #ifdef _GLIBCPP_USE___ENC_TRAITS #ifdef _GLIBCPP_USE_WCHAR_T void ! initialize_state(__enc_traits& state) { state._M_init(); } // Partial specialization using __enc_traits. // codecvt void test01() { typedef codecvt_base::result result; - typedef unsigned short unicode_t; typedef unicode_t int_type; typedef wchar_t ext_type; typedef __enc_traits enc_type; --- 23,102 ---- #include #include #ifdef _GLIBCPP_USE___ENC_TRAITS #ifdef _GLIBCPP_USE_WCHAR_T + // Need some char_traits specializations for this to work. + typedef unsigned short unicode_t; + + namespace std + { + template<> + struct char_traits + { + typedef unicode_t char_type; + // Unsigned as wint_t is unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { return memcmp(__s1, __s2, __n); } + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return static_cast(memcpy(__s1, __s2, __n)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; + } + void ! initialize_state(std::__enc_traits& state) { state._M_init(); } // Partial specialization using __enc_traits. // codecvt void test01() { + using namespace std; typedef codecvt_base::result result; typedef unicode_t int_type; typedef wchar_t ext_type; typedef __enc_traits enc_type; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc gcc-3.2/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc *** gcc-3.1.1/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc Thu Jan 17 22:29:44 2002 --- gcc-3.2/libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc Thu Aug 1 21:29:16 2002 *************** *** 25,31 **** #include #include - void test00() { // Should be able to do this as the first thing that happens in a --- 25,30 ---- *************** public: *** 49,59 **** std::locale::id gnu_facet::id; void test01() { using namespace std; - - typedef unsigned short unicode_t; typedef unicode_t int_type; typedef char ext_type; typedef __enc_traits enc_type; --- 48,117 ---- std::locale::id gnu_facet::id; + // Need some char_traits specializations for this to work. + typedef unsigned short unicode_t; + + namespace std + { + template<> + struct char_traits + { + typedef unicode_t char_type; + // Unsigned as wint_t is unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { return memcmp(__s1, __s2, __n); } + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return static_cast(memcpy(__s1, __s2, __n)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; + } + void test01() { using namespace std; typedef unicode_t int_type; typedef char ext_type; typedef __enc_traits enc_type; *************** void test01() *** 238,244 **** } #endif // _GLIBCPP_USE___ENC_TRAITS ! int main () { test00(); --- 296,316 ---- } #endif // _GLIBCPP_USE___ENC_TRAITS ! // libstdc++/7222 ! void test02() ! { ! bool test = true; ! std::locale loc_c1("C"); ! std::locale loc_c2 ("C"); ! ! std::locale loc_1(""); ! std::locale loc_2(""); ! ! VERIFY( loc_c1 == loc_c2 ); ! VERIFY( loc_1 == loc_2 ); ! } ! ! int main() { test00(); *************** int main () *** 246,250 **** --- 318,324 ---- test01(); #endif + test02(); + return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/23_containers/deque_operators.cc gcc-3.2/libstdc++-v3/testsuite/23_containers/deque_operators.cc *** gcc-3.1.1/libstdc++-v3/testsuite/23_containers/deque_operators.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/23_containers/deque_operators.cc Fri Jul 26 23:23:43 2002 *************** *** 0 **** --- 1,85 ---- + // 2002-05-18 Paolo Carlini + + // Copyright (C) 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // 23.2.1 deque operators + + #include + #include + + // libstdc++/6503 + void test01() + { + bool test = true; + + std::deque d(2); + typedef std::deque::iterator iter; + typedef std::deque::const_iterator constiter; + + iter beg = d.begin(); + iter end = d.end(); + constiter constbeg = d.begin(); + constiter constend = d.end(); + + VERIFY( beg == constbeg ); + VERIFY( constend == end ); + + VERIFY( beg != constend ); + VERIFY( constbeg != end ); + + VERIFY( beg < constend ); + VERIFY( constbeg < end ); + + VERIFY( end > constbeg ); + VERIFY( constend > beg ); + + VERIFY( end >= constend ); + VERIFY( constbeg >= beg ); + + VERIFY( beg <= constbeg ); + VERIFY( constend <= end ); + } + + // libstdc++/7186 + void test02() + { + bool test = true; + + std::deque d(2); + typedef std::deque::iterator iter; + typedef std::deque::const_iterator constiter; + + iter beg = d.begin(); + iter end = d.end(); + constiter constbeg = d.begin(); + constiter constend = d.end(); + + VERIFY( beg - constbeg == 0 ); + VERIFY( constend - end == 0 ); + + VERIFY( end - constbeg > 0 ); + VERIFY( constend - beg > 0 ); + } + + int main() + { + test01(); + test02(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/24_iterators/iterator.cc gcc-3.2/libstdc++-v3/testsuite/24_iterators/iterator.cc *** gcc-3.1.1/libstdc++-v3/testsuite/24_iterators/iterator.cc Fri Nov 23 16:29:01 2001 --- gcc-3.2/libstdc++-v3/testsuite/24_iterators/iterator.cc Fri Jul 26 23:23:43 2002 *************** wrong_stuff() *** 577,582 **** --- 577,593 ---- return failures; } + // libstdc++/6642 + int + test6642() + { + std::string s; + std::string::iterator it = s.begin(); + std::string::const_iterator cit = s.begin(); + + return it - cit; + } + int main(int argc, char **argv) { *************** main(int argc, char **argv) *** 590,595 **** --- 601,608 ---- failures += wrong_stuff(); + failures += test6642(); + #ifdef DEBUG_ASSERT assert (failures == 0); #endif diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/filebuf.cc gcc-3.2/libstdc++-v3/testsuite/27_io/filebuf.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/filebuf.cc Sat Jan 26 01:55:09 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/filebuf.cc Thu Aug 1 21:29:16 2002 *************** *** 19,40 **** // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. ! // NB: this test assumes that _M_buf_size == 40, and not the usual ! // buffer_size length of BUFSIZ (8192), so that overflow/underflow can be ! // simulated a bit more readily. #include #include // { dg-do compile } // test05 // libstdc++/1886 // should be able to instantiate basic_filebuf for non-standard types. ! template class std::basic_filebuf >; int main() { return 0; } --- 19,108 ---- // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. ! // 27.8.1.1 - Template class basic_filebuf ! // NB: This file is for testing basic_filebuf with NO OTHER INCLUDES. #include #include // { dg-do compile } + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::filebuf test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + // test05 // libstdc++/1886 // should be able to instantiate basic_filebuf for non-standard types. ! namespace test ! { ! using namespace std; ! typedef short type_t; ! template class basic_filebuf >; ! template class basic_filebuf >; ! } // test ! ! ! // test07 ! // libstdc++/2020 ! // should be able to use custom char_type ! class gnu_char_type ! { ! unsigned long character; ! public: ! // operator == ! bool ! operator==(const gnu_char_type& __lhs) ! { return character == __lhs.character; } ! ! // operator < ! bool ! operator<(const gnu_char_type& __lhs) ! { return character < __lhs.character; } ! ! // default ctor ! gnu_char_type() { } ! ! // to_char_type ! gnu_char_type(const unsigned long& __l) : character(__l) { } ! ! // to_int_type ! operator unsigned long() const { return character; } ! }; ! ! void test07() ! { ! bool test = true; ! typedef std::basic_filebuf gnu_filebuf; ! ! try ! { gnu_filebuf obj; } ! catch(std::exception& obj) ! { ! test = false; ! VERIFY( test ); ! } ! } ! ! #if !__GXX_WEAK__ ! // Explicitly instantiate for systems with no COMDAT or weak support. ! template ! std::basic_streambuf::int_type ! std::basic_streambuf::_S_pback_size; ! #endif int main() { + test01(); + test07(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc gcc-3.2/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc Mon Apr 22 20:28:37 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc Thu Aug 1 21:29:16 2002 *************** void test06() *** 514,567 **** VERIFY( buffer[0] == 'a' ); } - // test06 - // libstdc++/2020 - // should be able to use custom char_type - class gnu_char_type - { - unsigned long character; - public: - // operator == - bool - operator==(const gnu_char_type& __lhs) - { return character == __lhs.character; } - - // operator < - bool - operator<(const gnu_char_type& __lhs) - { return character < __lhs.character; } - - // default ctor - gnu_char_type() { } - - // to_char_type - gnu_char_type(const unsigned long& __l) : character(__l) { } - - // to_int_type - operator unsigned long() const { return character; } - }; - - void test07() - { - bool test = true; - typedef std::basic_filebuf gnu_filebuf; - - try - { gnu_filebuf obj; } - catch(std::exception& obj) - { - test = false; - VERIFY( test ); - } - } - - #if !__GXX_WEAK__ - // Explicitly instantiate for systems with no COMDAT or weak support. - template - std::basic_streambuf::int_type - std::basic_streambuf::_S_pback_size; - #endif - main() { test01(); --- 514,519 ---- *************** main() *** 571,577 **** test04(); test05(); test06(); - test07(); return 0; } --- 523,528 ---- diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/fstream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/fstream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/fstream.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/fstream.cc Thu Aug 1 21:29:16 2002 *************** *** 0 **** --- 1,62 ---- + // 2002-07-25 Benjamin Kosnik + + // Copyright (C) 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 27.8.1.11 - Template class basic_fstream + // NB: This file is for testing basic_fstream with NO OTHER INCLUDES. + + #include + #include + + // { dg-do compile } + + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::fstream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + + namespace test + { + using namespace std; + typedef short type_t; + template class basic_fstream >; + template class basic_fstream >; + } // test + + int main() + { + test01(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/ifstream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/ifstream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/ifstream.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/ifstream.cc Fri Jul 26 23:23:44 2002 *************** *** 0 **** --- 1,60 ---- + // 2002-07-25 Benjamin Kosnik + + // Copyright (C) 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 27.8.1.5 - Template class basic_ifstream + // NB: This file is for testing basic_ifstream with NO OTHER INCLUDES. + + #include + + // { dg-do compile } + + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::ifstream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + + namespace test + { + using namespace std; + typedef short type_t; + template class basic_ifstream >; + } // test + + int main() + { + test01(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/ios.cc gcc-3.2/libstdc++-v3/testsuite/27_io/ios.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/ios.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/ios.cc Fri Jul 26 23:23:44 2002 *************** *** 0 **** --- 1,60 ---- + // 2002-07-25 Benjamin Kosnik + + // Copyright (C) 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 27.4.4 - Template class basic_ios + // NB: This file is for testing basic_ios with NO OTHER INCLUDES. + + #include + + // { dg-do compile } + + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::ios test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + + namespace test + { + using namespace std; + typedef short type_t; + template class basic_ios >; + } // test + + int main() + { + test01(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/ios_init.cc gcc-3.2/libstdc++-v3/testsuite/27_io/ios_init.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/ios_init.cc Thu Apr 4 05:34:56 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/ios_init.cc Thu Aug 1 21:29:16 2002 *************** *** 34,39 **** --- 34,209 ---- #include #include + // char_traits specialization + namespace std + { + template<> + struct char_traits + { + typedef unsigned short char_type; + // Unsigned as wint_t in unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return lt(__s1[__i], __s2[__i]) ? -1 : 1; + return 0; + } + + static size_t + length(const char_type* __s) + { + const char_type* __p = __s; + while (__p) + ++__p; + return (__p - __s); + } + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) + if (*__p == __a) return __p; + return 0; + } + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (char_type* __p = __s; __p < __s + __n; ++__p) + assign(*__p, __a); + return __s; + } + + static char_type + to_char_type(const int_type& __c) + { return char_type(); } + + static int_type + to_int_type(const char_type& __c) { return int_type(); } + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type + eof() { return static_cast(-1); } + + static int_type + not_eof(const int_type& __c) + { return eq_int_type(__c, eof()) ? int_type(0) : __c; } + }; + + template<> + struct char_traits + { + typedef unsigned char char_type; + // Unsigned as wint_t in unsigned. + typedef unsigned long int_type; + typedef streampos pos_type; + typedef streamoff off_type; + typedef mbstate_t state_type; + + static void + assign(char_type& __c1, const char_type& __c2) + { __c1 = __c2; } + + static bool + eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + + static bool + lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n) + { + for (size_t __i = 0; __i < __n; ++__i) + if (!eq(__s1[__i], __s2[__i])) + return lt(__s1[__i], __s2[__i]) ? -1 : 1; + return 0; + } + + static size_t + length(const char_type* __s) + { + const char_type* __p = __s; + while (__p && *__p) + ++__p; + return (__p - __s); + } + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a) + { + for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p) + if (*__p == __a) return __p; + return 0; + } + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n) + { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } + + static char_type* + assign(char_type* __s, size_t __n, char_type __a) + { + for (char_type* __p = __s; __p < __s + __n; ++__p) + assign(*__p, __a); + return __s; + } + + static char_type + to_char_type(const int_type& __c) + { return char_type(); } + + static int_type + to_int_type(const char_type& __c) { return int_type(); } + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } + + static int_type + eof() { return static_cast(-1); } + + static int_type + not_eof(const int_type& __c) + { return eq_int_type(__c, eof()) ? int_type(0) : __c; } + }; + } // namespace std + class gnu_filebuf: public std::filebuf { int i; diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/iostream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/iostream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/iostream.cc Sat Jan 26 01:55:09 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/iostream.cc Fri Jul 26 23:23:43 2002 *************** *** 34,39 **** --- 34,51 ---- #include + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::iostream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + namespace test { using namespace std; *************** namespace test *** 43,47 **** --- 55,60 ---- int main() { + test01(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/istream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/istream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/istream.cc Sat Jan 26 01:55:09 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/istream.cc Thu Aug 1 21:29:16 2002 *************** *** 31,47 **** --- 31,62 ---- // NB: This file is for testing istream with NO OTHER INCLUDES. #include + #include // { dg-do compile } + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::istream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + namespace test { using namespace std; typedef short type_t; template class basic_istream >; + template class basic_istream >; } // test int main() { + test01(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/istream_unformatted.cc gcc-3.2/libstdc++-v3/testsuite/27_io/istream_unformatted.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/istream_unformatted.cc Mon Apr 22 19:11:00 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/istream_unformatted.cc Fri Jul 26 23:23:44 2002 *************** test09() *** 514,519 **** --- 514,556 ---- VERIFY( test ); } + // libstdc++/70220 + void + test10() + { + using namespace std; + bool test = true; + typedef string string_type; + typedef stringbuf stringbuf_type; + typedef istream istream_type; + + int res = 0; + streamsize n; + string_type input("abcdefg\n"); + stringbuf_type sbuf(input); + istream_type istr(&sbuf); + + istr.ignore(0); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(0, 'b'); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(); // Advance to next position. + istr.ignore(0, 'b'); + if ((n=istr.gcount()) != 0) + test = false; + VERIFY( test ); + + if (istr.peek() != 'b') + test = false; + VERIFY( test ); + } + int main() { *************** main() *** 526,531 **** --- 563,569 ---- test07(); test08(); test09(); + test10(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/istringstream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/istringstream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/istringstream.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/istringstream.cc Fri Jul 26 23:23:44 2002 *************** *** 0 **** --- 1,60 ---- + // 2002-07-25 Benjamin Kosnik + + // Copyright (C) 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 27.7.2 - Template class basic_istringstream + // NB: This file is for testing basic_istringstream with NO OTHER INCLUDES. + + #include + + // { dg-do compile } + + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::istringstream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + + namespace test + { + using namespace std; + typedef short type_t; + template class basic_istringstream >; + } // test + + int main() + { + test01(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/ofstream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/ofstream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/ofstream.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/ofstream.cc Fri Jul 26 23:23:44 2002 *************** *** 0 **** --- 1,60 ---- + // 2002-07-25 Benjamin Kosnik + + // Copyright (C) 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 27.8.1.8 - Template class basic_ofstream + // NB: This file is for testing basic_ofstream with NO OTHER INCLUDES. + + #include + + // { dg-do compile } + + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::ifstream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + + namespace test + { + using namespace std; + typedef short type_t; + template class basic_ifstream >; + } // test + + int main() + { + test01(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/ostream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/ostream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/ostream.cc Sat Jan 26 01:55:09 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/ostream.cc Thu Aug 1 21:29:16 2002 *************** *** 31,47 **** --- 31,62 ---- // NB: This file is for testing ostream with NO OTHER INCLUDES. #include + #include // { dg-do compile } + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::ostream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + namespace test { using namespace std; typedef short type_t; template class basic_ostream >; + template class basic_ostream >; } // test int main() { + test01(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/ostringstream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/ostringstream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/ostringstream.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/ostringstream.cc Fri Jul 26 23:23:44 2002 *************** *** 0 **** --- 1,60 ---- + // 2002-07-25 Benjamin Kosnik + + // Copyright (C) 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 27.7.3 - Class basic_ostringstream + // NB: This file is for testing basic_ostringstream with NO OTHER INCLUDES. + + #include + + // { dg-do compile } + + // libstdc++/7216 + void test01() + { + // Check for required typedefs + typedef std::ostringstream test_type; + typedef test_type::char_type char_type; + typedef test_type::traits_type traits_type; + typedef test_type::int_type int_type; + typedef test_type::pos_type pos_type; + typedef test_type::off_type off_type; + } + + namespace test + { + using namespace std; + typedef short type_t; + template class basic_ostringstream >; + } // test + + int main() + { + test01(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/ostringstream_members.cc gcc-3.2/libstdc++-v3/testsuite/27_io/ostringstream_members.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/ostringstream_members.cc Tue Aug 7 03:38:33 2001 --- gcc-3.2/libstdc++-v3/testsuite/27_io/ostringstream_members.cc Fri Jul 26 23:23:43 2002 *************** *** 1,6 **** // 2001-05-23 Benjamin Kosnik ! // Copyright (C) 2001 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,6 ---- // 2001-05-23 Benjamin Kosnik ! // Copyright (C) 2001, 2002 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** void test02() *** 97,105 **** --- 97,157 ---- // These semantics are a joke, a serious defect, and incredibly lame. } + // 03: sanity checks for strings, stringbufs + void + test03() + { + bool test = false; + + // Empty string sanity check. + std::string str01; + std::string::iterator __i_start = str01.begin(); + std::string::iterator __i_end = str01.end(); + std::string::size_type len = str01.size(); + test = __i_start == __i_end; + VERIFY( len == 0 ); + + // Full string sanity check. + std::string str02("these golden days, i spend waiting for you:\n" + "Betty Carter on Verve with I'm Yours and You're Mine."); + __i_start = str02.begin(); + __i_end = str02.end(); + len = str02.size(); + VERIFY( __i_start != __i_end ); + VERIFY( len != 0 ); + + // Test an empty ostringstream for sanity. + std::ostringstream ostrstream0; + std::string str03 = ostrstream0.str(); + __i_start = str03.begin(); + __i_end = str03.end(); + len = str03.size(); + VERIFY( __i_start == __i_end ); + VERIFY( len == 0 ); + VERIFY( str01 == str03 ); + } + + // user-reported error + class derived_oss: public std::ostringstream + { + public: + derived_oss() : std::ostringstream() { } + }; + + void + test04() + { + bool test = true; + derived_oss yy; + yy << "buena vista social club\n"; + VERIFY( yy.str() == std::string("buena vista social club\n") ); + } + int main() { test01(); test02(); + test03(); + test04(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/streambuf.cc gcc-3.2/libstdc++-v3/testsuite/27_io/streambuf.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/streambuf.cc Thu Mar 28 03:15:29 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/streambuf.cc Thu Aug 1 21:29:16 2002 *************** *** 1,6 **** ! // 1999-10-11 bkoz ! // Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,6 ---- ! // 2002-07-25 Benjamin Kosnik ! // Copyright (C) 2002 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** *** 27,378 **** // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. ! // 27.5.2 template class basic_streambuf - #include // for memset, memcmp #include - #include - #include #include ! class testbuf : public std::streambuf ! { ! public: ! ! // Typedefs: ! typedef std::streambuf::traits_type traits_type; ! typedef std::streambuf::char_type char_type; ! ! testbuf(): std::streambuf() ! { _M_mode = (std::ios_base::in | std::ios_base::out); } ! ! bool ! check_pointers() ! { ! bool test = true; ! VERIFY( this->eback() == NULL ); ! VERIFY( this->gptr() == NULL ); ! VERIFY( this->egptr() == NULL ); ! VERIFY( this->pbase() == NULL ); ! VERIFY( this->pptr() == NULL ); ! VERIFY( this->epptr() == NULL ); ! return test; ! } ! ! int_type ! pub_uflow() ! { return (this->uflow()); } ! ! int_type ! pub_overflow(int_type __c = traits_type::eof()) ! { return (this->overflow(__c)); } ! ! int_type ! pub_pbackfail(int_type __c) ! { return (this->pbackfail(__c)); } ! ! void ! pub_setg(char* beg, char* cur, char *end) ! { this->setg(beg, cur, end); } ! ! void ! pub_setp(char* beg, char* end) ! { this->setp(beg, end); } ! ! protected: ! int_type ! underflow() ! { ! int_type __retval = traits_type::eof(); ! if (this->gptr() < this->egptr()) ! __retval = traits_type::not_eof(0); ! return __retval; ! } ! }; void test01() { ! typedef testbuf::traits_type traits_type; ! typedef testbuf::int_type int_type; ! ! bool test = true; ! char* lit01 = "chicago underground trio/possible cube on delmark"; ! testbuf buf01; ! ! // 27.5.2.1 basic_streambuf ctors ! // default ctor initializes ! // - all pointer members to null pointers ! // - locale to current global locale ! VERIFY( buf01.check_pointers() ); ! VERIFY( buf01.getloc() == std::locale() ); ! ! // 27.5.2.3.1 get area ! // 27.5.2.2.3 get area ! // 27.5.2.4.3 get area ! int i01 = 3; ! buf01.pub_setg(lit01, lit01, (lit01 + i01)); ! VERIFY( i01 == buf01.in_avail() ); ! ! VERIFY( buf01.pub_uflow() == lit01[0] ); ! VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[1]) ); ! VERIFY( buf01.pub_uflow() == lit01[1] ); ! VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[2]) ); ! VERIFY( buf01.pub_uflow() == lit01[2] ); ! VERIFY( buf01.sgetc() == traits_type::eof() ); ! ! // pbackfail ! buf01.pub_setg(lit01, lit01, (lit01 + i01)); ! VERIFY( i01 == buf01.in_avail() ); ! int_type intt01 = traits_type::to_int_type('b'); ! VERIFY( traits_type::eof() == buf01.pub_pbackfail(intt01) ); ! ! // overflow ! VERIFY( traits_type::eof() == buf01.pub_overflow(intt01) ); ! VERIFY( traits_type::eof() == buf01.pub_overflow() ); ! VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[0]) ); ! ! // sputn/xsputn ! char* lit02 = "isotope 217: the unstable molecule on thrill jockey"; ! int i02 = std::strlen(lit02); ! char carray[i02 + 1]; ! std::memset(carray, 0, i02 + 1); ! ! buf01.pub_setp(carray, (carray + i02)); ! buf01.sputn(lit02, 0); ! VERIFY( carray[0] == 0 ); ! VERIFY( lit02[0] == 'i' ); ! buf01.sputn(lit02, 1); ! VERIFY( lit02[0] == carray[0] ); ! VERIFY( lit02[1] == 's' ); ! VERIFY( carray[1] == 0 ); ! buf01.sputn(lit02 + 1, 10); ! VERIFY( std::memcmp(lit02, carray, 10) == 0 ); ! buf01.sputn(lit02 + 11, 20); ! VERIFY( std::memcmp(lit02, carray, 30) == 0 ); ! ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! } ! ! void test02() ! { ! typedef testbuf::traits_type traits_type; ! typedef testbuf::int_type int_type; ! ! bool test = true; ! char* lit01 = "chicago underground trio/possible cube on delmark"; ! testbuf buf01; ! ! // 27.5.2.1 basic_streambuf ctors ! // default ctor initializes ! // - all pointer members to null pointers ! // - locale to current global locale ! VERIFY( buf01.check_pointers() ); ! VERIFY( buf01.getloc() == std::locale() ); ! ! // 27.5.2.2.5 Put area ! size_t i01 = traits_type::length(lit01); ! char carray01[i01]; ! std::memset(carray01, 0, i01); ! ! buf01.pub_setg(lit01, lit01, lit01 + i01); ! buf01.sgetn(carray01, 0); ! VERIFY( carray01[0] == 0 ); ! buf01.sgetn(carray01, 1); ! VERIFY( carray01[0] == 'c' ); ! buf01.sgetn(carray01 + 1, i01 - 1); ! VERIFY( carray01[0] == 'c' ); ! VERIFY( carray01[1] == 'h' ); ! VERIFY( carray01[i01 - 1] == 'k' ); ! ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! } ! ! // test03 ! // http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00151.html ! template > ! class basic_nullbuf : public std::basic_streambuf ! { ! protected: ! typedef typename ! std::basic_streambuf::int_type int_type; ! virtual int_type ! overflow(int_type c) ! { return traits::not_eof(c); } ! }; ! ! typedef basic_nullbuf nullbuf; ! typedef basic_nullbuf wnullbuf; ! ! template ! char ! print(const T& x) ! { ! nullbuf ob; ! std::ostream out(&ob); ! out << x << std::endl; ! return (!out ? '0' : '1'); ! } ! ! void test03() ! { ! bool test = true; ! const std::string control01("11111"); ! std::string test01; ! ! test01 += print(true); ! test01 += print(3.14159); ! test01 += print(10); ! test01 += print('x'); ! test01 += print("pipo"); ! ! VERIFY( test01 == control01 ); ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! } ! ! class setpbuf : public std::streambuf ! { ! char buffer[4]; ! std::string result; ! ! public: ! ! std::string& ! get_result() ! { return result; } ! ! setpbuf() ! { ! char foo [32]; ! setp(foo, foo + 32); ! setp(buffer, buffer + 4); ! } ! ! ~setpbuf() ! { sync(); } ! ! virtual int_type ! overflow(int_type n) ! { ! if (sync() != 0) ! return traits_type::eof(); ! ! result += traits_type::to_char_type(n); ! ! return n; ! } ! ! virtual int ! sync() ! { ! result.append(pbase(), pptr()); ! setp(buffer, buffer + 4); ! return 0; ! } ! }; ! ! // libstdc++/1057 ! void test04() ! { ! bool test = true; ! std::string text = "abcdefghijklmn"; ! ! // 01 ! setpbuf sp1; ! // Here xsputn writes over sp1.result ! sp1.sputn(text.c_str(), text.length()); ! ! // This crashes when result is accessed ! sp1.pubsync(); ! VERIFY( sp1.get_result() == text ); ! ! ! // 02 ! setpbuf sp2; ! for (std::string::size_type i = 0; i < text.length(); ++i) ! { ! // sputc also writes over result ! sp2.sputc(text[i]); ! } ! ! // Crash here ! sp2.pubsync(); ! VERIFY( sp2.get_result() == text ); ! } ! ! class nullsetpbuf : public std::streambuf ! { ! char foo[64]; ! public: ! nullsetpbuf() ! { ! setp(foo, foo + 64); ! setp(NULL, NULL); ! } ! }; ! ! // libstdc++/1057 ! void test05() ! { ! std::string text1 = "abcdefghijklmn"; ! ! nullsetpbuf nsp; ! // Immediate crash as xsputn writes to null pointer ! nsp.sputn(text1.c_str(), text1.length()); ! // ditto ! nsp.sputc('a'); ! } ! ! // test06 ! namespace gnu ! { ! class something_derived; } ! class gnu::something_derived : std::streambuf { }; ! ! // libstdc++/3599 ! class testbuf2 : public std::streambuf ! { ! public: ! typedef std::streambuf::traits_type traits_type; ! ! testbuf2() : std::streambuf() { } ! ! protected: ! int_type ! overflow(int_type c = traits_type::eof()) ! { return traits_type::not_eof(0); } ! }; ! ! void ! test07() { ! bool test = true; ! testbuf2 ob; ! std::ostream out(&ob); ! ! out << "gasp"; ! VERIFY(out.good()); ! ! out << std::endl; ! VERIFY(out.good()); ! } int main() { test01(); - test02(); - test03(); - - test04(); - test05(); - - test07(); return 0; } --- 27,62 ---- // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. ! // 27.5.2 - Template class basic_streambuf ! // NB: This file is for testing basic_streambuf with NO OTHER INCLUDES. #include #include ! // { dg-do compile } + // libstdc++/7216 void test01() { ! // Check for required typedefs ! typedef std::streambuf test_type; ! typedef test_type::char_type char_type; ! typedef test_type::traits_type traits_type; ! typedef test_type::int_type int_type; ! typedef test_type::pos_type pos_type; ! typedef test_type::off_type off_type; } ! namespace test { ! using namespace std; ! typedef short type_t; ! template class basic_streambuf >; ! template class basic_streambuf >; ! } // test int main() { test01(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/streambuf_members.cc gcc-3.2/libstdc++-v3/testsuite/27_io/streambuf_members.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/streambuf_members.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/streambuf_members.cc Fri Jul 26 23:23:44 2002 *************** *** 0 **** --- 1,378 ---- + // 1999-10-11 bkoz + + // Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + // As a special exception, you may use this file as part of a free software + // library without restriction. Specifically, if other files instantiate + // templates or use macros or inline functions from this file, or you compile + // this file and link it with other files to produce an executable, this + // file does not by itself cause the resulting executable to be covered by + // the GNU General Public License. This exception does not however + // invalidate any other reasons why the executable file might be covered by + // the GNU General Public License. + + // 27.5.2 template class basic_streambuf + + #include // for memset, memcmp + #include + #include + #include + #include + + class testbuf : public std::streambuf + { + public: + + // Typedefs: + typedef std::streambuf::traits_type traits_type; + typedef std::streambuf::char_type char_type; + + testbuf(): std::streambuf() + { _M_mode = (std::ios_base::in | std::ios_base::out); } + + bool + check_pointers() + { + bool test = true; + VERIFY( this->eback() == NULL ); + VERIFY( this->gptr() == NULL ); + VERIFY( this->egptr() == NULL ); + VERIFY( this->pbase() == NULL ); + VERIFY( this->pptr() == NULL ); + VERIFY( this->epptr() == NULL ); + return test; + } + + int_type + pub_uflow() + { return (this->uflow()); } + + int_type + pub_overflow(int_type __c = traits_type::eof()) + { return (this->overflow(__c)); } + + int_type + pub_pbackfail(int_type __c) + { return (this->pbackfail(__c)); } + + void + pub_setg(char* beg, char* cur, char *end) + { this->setg(beg, cur, end); } + + void + pub_setp(char* beg, char* end) + { this->setp(beg, end); } + + protected: + int_type + underflow() + { + int_type __retval = traits_type::eof(); + if (this->gptr() < this->egptr()) + __retval = traits_type::not_eof(0); + return __retval; + } + }; + + void test01() + { + typedef testbuf::traits_type traits_type; + typedef testbuf::int_type int_type; + + bool test = true; + char* lit01 = "chicago underground trio/possible cube on delmark"; + testbuf buf01; + + // 27.5.2.1 basic_streambuf ctors + // default ctor initializes + // - all pointer members to null pointers + // - locale to current global locale + VERIFY( buf01.check_pointers() ); + VERIFY( buf01.getloc() == std::locale() ); + + // 27.5.2.3.1 get area + // 27.5.2.2.3 get area + // 27.5.2.4.3 get area + int i01 = 3; + buf01.pub_setg(lit01, lit01, (lit01 + i01)); + VERIFY( i01 == buf01.in_avail() ); + + VERIFY( buf01.pub_uflow() == lit01[0] ); + VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[1]) ); + VERIFY( buf01.pub_uflow() == lit01[1] ); + VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[2]) ); + VERIFY( buf01.pub_uflow() == lit01[2] ); + VERIFY( buf01.sgetc() == traits_type::eof() ); + + // pbackfail + buf01.pub_setg(lit01, lit01, (lit01 + i01)); + VERIFY( i01 == buf01.in_avail() ); + int_type intt01 = traits_type::to_int_type('b'); + VERIFY( traits_type::eof() == buf01.pub_pbackfail(intt01) ); + + // overflow + VERIFY( traits_type::eof() == buf01.pub_overflow(intt01) ); + VERIFY( traits_type::eof() == buf01.pub_overflow() ); + VERIFY( buf01.sgetc() == traits_type::to_int_type(lit01[0]) ); + + // sputn/xsputn + char* lit02 = "isotope 217: the unstable molecule on thrill jockey"; + int i02 = std::strlen(lit02); + char carray[i02 + 1]; + std::memset(carray, 0, i02 + 1); + + buf01.pub_setp(carray, (carray + i02)); + buf01.sputn(lit02, 0); + VERIFY( carray[0] == 0 ); + VERIFY( lit02[0] == 'i' ); + buf01.sputn(lit02, 1); + VERIFY( lit02[0] == carray[0] ); + VERIFY( lit02[1] == 's' ); + VERIFY( carray[1] == 0 ); + buf01.sputn(lit02 + 1, 10); + VERIFY( std::memcmp(lit02, carray, 10) == 0 ); + buf01.sputn(lit02 + 11, 20); + VERIFY( std::memcmp(lit02, carray, 30) == 0 ); + + #ifdef DEBUG_ASSERT + assert(test); + #endif + } + + void test02() + { + typedef testbuf::traits_type traits_type; + typedef testbuf::int_type int_type; + + bool test = true; + char* lit01 = "chicago underground trio/possible cube on delmark"; + testbuf buf01; + + // 27.5.2.1 basic_streambuf ctors + // default ctor initializes + // - all pointer members to null pointers + // - locale to current global locale + VERIFY( buf01.check_pointers() ); + VERIFY( buf01.getloc() == std::locale() ); + + // 27.5.2.2.5 Put area + size_t i01 = traits_type::length(lit01); + char carray01[i01]; + std::memset(carray01, 0, i01); + + buf01.pub_setg(lit01, lit01, lit01 + i01); + buf01.sgetn(carray01, 0); + VERIFY( carray01[0] == 0 ); + buf01.sgetn(carray01, 1); + VERIFY( carray01[0] == 'c' ); + buf01.sgetn(carray01 + 1, i01 - 1); + VERIFY( carray01[0] == 'c' ); + VERIFY( carray01[1] == 'h' ); + VERIFY( carray01[i01 - 1] == 'k' ); + + #ifdef DEBUG_ASSERT + assert(test); + #endif + } + + // test03 + // http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00151.html + template > + class basic_nullbuf : public std::basic_streambuf + { + protected: + typedef typename + std::basic_streambuf::int_type int_type; + virtual int_type + overflow(int_type c) + { return traits::not_eof(c); } + }; + + typedef basic_nullbuf nullbuf; + typedef basic_nullbuf wnullbuf; + + template + char + print(const T& x) + { + nullbuf ob; + std::ostream out(&ob); + out << x << std::endl; + return (!out ? '0' : '1'); + } + + void test03() + { + bool test = true; + const std::string control01("11111"); + std::string test01; + + test01 += print(true); + test01 += print(3.14159); + test01 += print(10); + test01 += print('x'); + test01 += print("pipo"); + + VERIFY( test01 == control01 ); + #ifdef DEBUG_ASSERT + assert(test); + #endif + } + + class setpbuf : public std::streambuf + { + char buffer[4]; + std::string result; + + public: + + std::string& + get_result() + { return result; } + + setpbuf() + { + char foo [32]; + setp(foo, foo + 32); + setp(buffer, buffer + 4); + } + + ~setpbuf() + { sync(); } + + virtual int_type + overflow(int_type n) + { + if (sync() != 0) + return traits_type::eof(); + + result += traits_type::to_char_type(n); + + return n; + } + + virtual int + sync() + { + result.append(pbase(), pptr()); + setp(buffer, buffer + 4); + return 0; + } + }; + + // libstdc++/1057 + void test04() + { + bool test = true; + std::string text = "abcdefghijklmn"; + + // 01 + setpbuf sp1; + // Here xsputn writes over sp1.result + sp1.sputn(text.c_str(), text.length()); + + // This crashes when result is accessed + sp1.pubsync(); + VERIFY( sp1.get_result() == text ); + + + // 02 + setpbuf sp2; + for (std::string::size_type i = 0; i < text.length(); ++i) + { + // sputc also writes over result + sp2.sputc(text[i]); + } + + // Crash here + sp2.pubsync(); + VERIFY( sp2.get_result() == text ); + } + + class nullsetpbuf : public std::streambuf + { + char foo[64]; + public: + nullsetpbuf() + { + setp(foo, foo + 64); + setp(NULL, NULL); + } + }; + + // libstdc++/1057 + void test05() + { + std::string text1 = "abcdefghijklmn"; + + nullsetpbuf nsp; + // Immediate crash as xsputn writes to null pointer + nsp.sputn(text1.c_str(), text1.length()); + // ditto + nsp.sputc('a'); + } + + // test06 + namespace gnu + { + class something_derived; + } + + class gnu::something_derived : std::streambuf { }; + + // libstdc++/3599 + class testbuf2 : public std::streambuf + { + public: + typedef std::streambuf::traits_type traits_type; + + testbuf2() : std::streambuf() { } + + protected: + int_type + overflow(int_type c = traits_type::eof()) + { return traits_type::not_eof(0); } + }; + + void + test07() + { + bool test = true; + testbuf2 ob; + std::ostream out(&ob); + + out << "gasp"; + VERIFY(out.good()); + + out << std::endl; + VERIFY(out.good()); + } + + int main() + { + test01(); + test02(); + test03(); + + test04(); + test05(); + + test07(); + return 0; + } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringbuf.cc gcc-3.2/libstdc++-v3/testsuite/27_io/stringbuf.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringbuf.cc Sun Mar 3 17:50:56 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/stringbuf.cc Thu Aug 1 21:29:16 2002 *************** *** 1,7 **** ! // 981208 bkoz test functionality of basic_stringbuf for char_type == char ! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 ! // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,6 ---- ! // 2002-07-25 Benjamin Kosnik ! // Copyright (C) 2002 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** *** 19,490 **** // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. ! #include ! #include ! ! std::string str_01("mykonos. . . or what?"); ! std::string str_02("paris, or sainte-maxime?"); ! std::string str_03; ! std::stringbuf strb_01(str_01); ! std::stringbuf strb_02(str_02, std::ios_base::in); ! std::stringbuf strb_03(str_03, std::ios_base::out); ! ! ! // test the underlying allocator ! bool test01() { ! bool test = false; ! std::allocator alloc_01; ! std::allocator::size_type size_01 = alloc_01.max_size(); ! std::allocator::pointer p_01 = alloc_01.allocate(32); ! ! return true; ! } ! ! ! // test the streambuf/stringbuf locale settings ! bool test02() { ! std::locale loc_tmp; ! loc_tmp = strb_01.getloc(); ! strb_01.pubimbue(loc_tmp); //This should initialize _M_init to true ! strb_01.getloc(); //This should just return _M_locale ! ! return true; ! } ! ! ! // test member functions ! bool test03() { ! bool test = true; ! ! //stringbuf::str() ! VERIFY( strb_01.str() == str_01 ); ! VERIFY( strb_02.str() == str_02 ); ! VERIFY( strb_03.str() == str_03 ); ! ! //stringbuf::str(string&) ! strb_03.str("none of the above, go to the oberoi in cairo, egypt."); ! strb_03.str(str_01); ! std::streamsize d1 = strb_01.in_avail(); ! std::streamsize d2 = strb_03.in_avail(); ! VERIFY( d1 ); // non-zero ! VERIFY( !d2 ); // zero, cuz ios_base::out ! VERIFY( d1 != d2 ); //these should be the same ! VERIFY( str_01.length() == d1 ); ! VERIFY( strb_01.str() == strb_03.str() ); //ditto ! ! // stringbuf::str(string&) and stringbuf::stringbuf(string&), where the ! // string in question contains embedded NUL characters. Note that in this ! // embedded-NUL situation, the size must be passed to the string ctor. ! std::string str_nulls ("eschew \0 obfuscation", 20); // tested in 21_strings ! std::stringbuf strb_normal (str_01); ! std::stringbuf strb_nulls (str_nulls); ! strb_normal.str(str_nulls); // tried using 'strb_01' rather than declaring ! // another variable, but then test04 broke! ! VERIFY( strb_nulls.in_avail() == str_nulls.size() ); ! VERIFY( strb_nulls.str().size() == 20 ); ! VERIFY( strb_normal.in_avail() == str_nulls.size() ); ! ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! ! return test; ! } ! ! ! // test overloaded virtual functions ! bool test04() { ! bool test = true; ! std::string str_tmp; ! std::stringbuf strb_tmp; ! std::streamsize strmsz_1, strmsz_2; ! std::streamoff strmof_1(-1), strmof_2; ! typedef std::stringbuf::int_type int_type; ! typedef std::stringbuf::traits_type traits_type; ! typedef std::stringbuf::pos_type pos_type; ! typedef std::stringbuf::off_type off_type; ! ! // GET ! // int in_avail() ! strmof_1 = strb_01.in_avail(); ! strmof_2 = strb_02.in_avail(); ! VERIFY( strmof_1 != strmof_2 ); ! VERIFY( strmof_1 == str_01.length() ); ! VERIFY( strmof_2 == str_02.length() ); ! strmof_1 = strb_03.in_avail(); ! VERIFY( strmof_1 == 0 ); // zero cuz write-only, or eof()? zero, from showmany ! ! // int_type sbumpc() ! // if read_cur not avail, return uflow(), else return *read_cur & increment ! int_type c1 = strb_01.sbumpc(); ! int_type c2 = strb_02.sbumpc(); ! VERIFY( c1 != c2 ); ! VERIFY( c1 == str_01[0] ); ! VERIFY( c2 == str_02[0] ); //should equal first letter at this point ! int_type c3 = strb_01.sbumpc(); ! int_type c4 = strb_02.sbumpc(); ! VERIFY( c1 != c2 ); ! VERIFY( c1 != c3 ); ! VERIFY( c2 != c4 ); ! int_type c5 = strb_03.sbumpc(); ! VERIFY( c5 == traits_type::eof() ); ! ! // int_type sgetc() ! // if read_cur not avail, return uflow(), else return *read_cur ! int_type c6 = strb_01.sgetc(); ! int_type c7 = strb_02.sgetc(); ! VERIFY( c6 != c3 ); ! VERIFY( c7 != c4 ); ! int_type c8 = strb_01.sgetc(); ! int_type c9 = strb_02.sgetc(); ! VERIFY( c6 == c8 ); ! VERIFY( c7 == c9 ); ! c5 = strb_03.sgetc(); ! VERIFY( c5 == traits_type::eof() ); ! ! // int_type snextc() ! // calls sbumpc and if sbumpc != eof, return sgetc ! c6 = strb_01.snextc(); ! c7 = strb_02.snextc(); ! VERIFY( c6 != c8 ); ! VERIFY( c7 != c9 ); ! VERIFY( c6 == str_01[3] ); ! VERIFY( c7 == str_02[3] ); //should equal fourth letter at this point ! c5 = strb_03.snextc(); ! VERIFY( c5 == traits_type::eof() ); ! ! // int showmanyc ! // streamsize sgetn(char_type *s, streamsize n) ! // streamsize xsgetn(char_type *s, streamsize n) ! // assign up to n chars to s from input sequence, indexing in_cur as ! // approp and returning the number of chars assigned ! strmsz_1 = strb_01.in_avail(); ! strmsz_2 = strb_02.in_avail(); ! test = strmsz_1 != strmsz_2; ! VERIFY( strmsz_1 != str_01.length() ); ! VERIFY( strmsz_2 != str_02.length() ); //because now we've moved into string ! char carray1[11] = ""; ! strmsz_1 = strb_01.sgetn(carray1, 10); ! char carray2[20] = ""; ! strmsz_2 = strb_02.sgetn(carray2, 10); ! VERIFY( strmsz_1 == strmsz_2 ); ! VERIFY( strmsz_1 == 10 ); ! c1 = strb_01.sgetc(); ! c2 = strb_02.sgetc(); ! VERIFY( c6 == c1 ); //just by co-incidence both o's ! VERIFY( c7 != c2 ); // n != i ! VERIFY( c1 == str_01[13] ); ! VERIFY( c2 == str_02[13] ); //should equal fourteenth letter at this point ! strmsz_1 = strb_03.sgetn(carray1, 10); ! VERIFY( !strmsz_1 ); //zero ! strmsz_1 = strb_02.in_avail(); ! strmsz_2 = strb_02.sgetn(carray2, strmsz_1 + 5); ! VERIFY( strmsz_1 == strmsz_2 ); //write off the end ! c4 = strb_02.sgetc(); // should be EOF ! VERIFY( c4 == traits_type::eof() ); ! ! // PUT ! // int_type sputc(char_type c) ! // if out_cur not avail, return overflow. Else, stores c at out_cur, ! // increments out_cur, and returns c as int_type ! strb_03.str(str_01); //reset ! std::string::size_type sz1 = strb_03.str().length(); ! c1 = strb_03.sputc('a'); ! std::string::size_type sz2 = strb_03.str().length(); ! VERIFY( sz1 == sz2 ); //cuz inserting at out_cur, which is at beg to start ! c2 = strb_03.sputc('b'); ! VERIFY( c1 != c2 ); ! VERIFY( strb_03.str() != str_01 ); ! c3 = strb_02.sputc('a'); // should be EOF because this is read-only ! VERIFY( c3 == traits_type::eof() ); ! ! // streamsize sputn(const char_typs* s, streamsize n) ! // write up to n chars to out_cur from s, returning number assigned ! // NB *sputn will happily put '\0' into your stream if you give it a chance* ! str_tmp = strb_03.str(); ! sz1 = str_tmp.length(); ! strmsz_1 = strb_03.sputn("racadabras", 10);//"abracadabras or what?" ! sz2 = strb_03.str().length(); ! VERIFY( sz1 == sz2 ); //shouldn't have changed length ! VERIFY( strmsz_1 == 10 ); ! VERIFY( str_tmp != strb_03.str() ); ! strmsz_2 = strb_03.sputn(", i wanna reach out and", 10); ! VERIFY( strmsz_1 == strmsz_2 ); // should re-allocate, copy 10 chars. ! VERIFY( strmsz_1 == 10 ); ! VERIFY( strmsz_2 == 10 ); ! sz2 = strb_03.str().length(); ! VERIFY( sz1 != sz2 ); // need to change length ! VERIFY( str_tmp != strb_03.str() ); ! str_tmp = strb_02.str(); ! strmsz_1 = strb_02.sputn("racadabra", 10); ! VERIFY( strmsz_1 == 0 ); ! VERIFY( str_tmp == strb_02.str() ); ! ! // PUTBACK ! // int_type pbfail(int_type c) ! // called when gptr() null, gptr() == eback(), or traits::eq(*gptr, c) false ! // "pending sequence" is: ! // 1) everything as defined in underflow ! // 2) + if (traits::eq_int_type(c, traits::eof()), then input ! // sequence is backed up one char before the pending sequence is ! // determined. ! // 3) + if (not 2) then c is prepended. Left unspecified is ! // whether the input sequence is backedup or modified in any way ! // returns traits::eof() for failure, unspecified other value for success ! ! // int_type sputbackc(char_type c) ! // if in_cur not avail || ! traits::eq(c, gptr() [-1]), return pbfail ! // otherwise decrements in_cur and returns *gptr() ! strmsz_1 = strb_01.in_avail(); ! str_tmp = strb_01.str(); ! c1 = strb_01.sgetc(); //"mykonos. . . 'o'r what?" ! c2 = strb_01.sputbackc('z');//"mykonos. . .zor what?" ! c3 = strb_01.sgetc(); ! VERIFY( c1 != c2 ); ! VERIFY( c3 == c2 ); ! VERIFY( strb_01.str() == std::string("mykonos. . .zor what?") ); ! VERIFY( str_tmp.size() == strb_01.str().size() ); ! //test for _in_cur == _in_beg ! strb_01.str(str_tmp); ! strmsz_1 = strb_01.in_avail(); ! c1 = strb_01.sgetc(); //"'m'ykonos. . . or what?" ! c2 = strb_01.sputbackc('z');//"mykonos. . . or what?" ! c3 = strb_01.sgetc(); ! VERIFY( c1 != c2 ); ! VERIFY( c3 != c2 ); ! VERIFY( c1 == c3 ); ! VERIFY( c2 == traits_type::eof() ); ! VERIFY( strb_01.str() == str_tmp ); ! VERIFY( str_tmp.size() == strb_01.str().size() ); ! // test for replacing char with identical one ! strb_01.str(str_01); //reset ! strmsz_1 = strb_01.in_avail(); ! strb_01.sbumpc(); ! strb_01.sbumpc(); ! c1 = strb_01.sgetc(); //"my'k'onos. . . or what?" ! c2 = strb_01.sputbackc('y');//"mykonos. . . or what?" ! c3 = strb_01.sgetc(); ! VERIFY( c1 != c2 ); ! VERIFY( c3 == c2 ); ! VERIFY( c1 != c3 ); ! VERIFY( strb_01.str() == str_01 ); ! VERIFY( str_01.size() == strb_01.str().size() ); ! //test for ios_base::out ! strmsz_2 = strb_03.in_avail(); ! c4 = strb_03.sputbackc('x'); ! VERIFY( c4 == traits_type::eof() ); ! ! // int_type sungetc() ! // if in_cur not avail, return pbackfail(), else decrement and ! // return to_int_type(*gptr()) ! for (int i = 0; i<12; ++i) ! strb_01.sbumpc(); ! strmsz_1 = strb_01.in_avail(); ! str_tmp = strb_01.str(); ! c1 = strb_01.sgetc(); //"mykonos. . . 'o'r what?" ! c2 = strb_01.sungetc();//"mykonos. . . or what?" ! c3 = strb_01.sgetc(); ! VERIFY( c1 != c2 ); ! VERIFY( c3 == c2 ); ! VERIFY( c1 != c3 ); ! VERIFY( c2 == ' ' ); ! VERIFY( strb_01.str() == str_01 ); ! VERIFY( str_01.size() == strb_01.str().size() ); ! //test for _in_cur == _in_beg ! strb_01.str(str_tmp); ! strmsz_1 = strb_01.in_avail(); ! c1 = strb_01.sgetc(); //"'m'ykonos. . . or what?" ! c2 = strb_01.sungetc();//"mykonos. . . or what?" ! c3 = strb_01.sgetc(); ! VERIFY( c1 != c2 ); ! VERIFY( c3 != c2 ); ! VERIFY( c1 == c3 ); ! VERIFY( c2 == traits_type::eof() ); ! VERIFY( strb_01.str() == str_01 ); ! VERIFY( str_01.size() == strb_01.str().size() ); ! // test for replacing char with identical one ! strb_01.str(str_01); //reset ! strmsz_1 = strb_01.in_avail(); ! strb_01.sbumpc(); ! strb_01.sbumpc(); ! c1 = strb_01.sgetc(); //"my'k'onos. . . or what?" ! c2 = strb_01.sungetc();//"mykonos. . . or what?" ! c3 = strb_01.sgetc(); ! VERIFY( c1 != c2 ); ! VERIFY( c3 == c2 ); ! VERIFY( c1 != c3 ); ! VERIFY( strb_01.str() == str_01 ); ! VERIFY( str_01.size() == strb_01.str().size() ); ! //test for ios_base::out ! strmsz_2 = strb_03.in_avail(); ! c4 = strb_03.sungetc(); ! VERIFY( c4 == traits_type::eof() ); ! ! // BUFFER MANAGEMENT & POSITIONING ! // sync ! // pubsync ! strb_01.pubsync(); ! strb_02.pubsync(); ! strb_03.pubsync(); ! ! // setbuf ! // pubsetbuf(char_type* s, streamsize n) ! str_tmp = std::string("naaaah, go to cebu"); ! strb_01.pubsetbuf(const_cast (str_tmp.c_str()), str_tmp.size()); ! VERIFY( strb_01.str() == str_tmp ); ! strb_01.pubsetbuf(0,0); ! VERIFY( strb_01.str() == str_tmp ); ! ! // seekoff ! // pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which) ! // alters the stream position to off ! pos_type pt_1(off_type(-1)); ! pos_type pt_2(off_type(0)); ! off_type off_1 = 0; ! off_type off_2 = 0; ! strb_01.str(str_01); //in|out ("mykonos. . . or what?"); ! strb_02.str(str_02); //in ("paris, or sainte-maxime?"); ! strb_03.str(str_03); //out ("") ! //IN|OUT ! //beg ! pt_1 = strb_01.pubseekoff(2, std::ios_base::beg); ! off_1 = pt_1; ! VERIFY( off_1 >= 0 ); ! c1 = strb_01.snextc(); //current in pointer +1 ! VERIFY( c1 == 'o' ); ! c2 = strb_01.sputc('x'); //test current out pointer ! str_tmp = std::string("myxonos. . . or what?"); ! VERIFY( strb_01.str() == str_tmp ); ! //cur ! pt_1 = strb_01.pubseekoff(2, std::ios_base::cur); ! off_1 = pt_1; ! VERIFY( off_1 == -1 ); // can't seekoff for in and out + cur in sstreams ! pt_1 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in); ! off_1 = pt_1; ! pt_2 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in); ! off_2 = pt_2; ! VERIFY( off_2 == off_1 + 2 ); ! c1 = strb_01.snextc(); //current in pointer + 1 ! VERIFY( c1 == ' ' ); ! c2 = strb_01.sputc('x'); //test current out pointer ! str_tmp = std::string("myxxnos. . . or what?"); ! VERIFY( strb_01.str() == str_tmp ); ! //end ! pt_2 = strb_01.pubseekoff(2, std::ios_base::end); ! off_1 = pt_2; ! VERIFY( off_1 == -1 ); // not a valid position ! VERIFY( strb_01.str() == str_tmp ); ! // end part two (from the filebuf tests) ! strb_01.pubseekoff(0, std::ios_base::end); ! strmsz_1 = strb_01.in_avail(); // 0 cuz at the end ! c1 = strb_01.sgetc(); ! c2 = strb_01.sungetc(); ! strmsz_2 = strb_01.in_avail(); // 1 ! c3 = strb_01.sgetc(); ! VERIFY( c1 != c2 ); ! VERIFY( strmsz_2 != strmsz_1 ); ! VERIFY( strmsz_2 == 1 ); ! // end part three ! strmsz_1 = strb_01.str().size(); ! strmsz_2 = strb_01.sputn(" ravi shankar meets carlos santana in LoHa", 90); ! strb_01.pubseekoff(0, std::ios_base::end); ! strb_01.sputc('<'); ! str_tmp = strb_01.str(); ! VERIFY( str_tmp.size() == strmsz_1 + strmsz_2 + 1 ); ! // IN ! // OUT ! ! // seekpos ! // pubseekpos(pos_type sp, ios_base::openmode) ! // alters the stream position to sp ! strb_01.str(str_01); //in|out ("mykonos. . . or what?"); ! strb_02.str(str_02); //in ("paris, or sainte-maxime?"); ! strb_03.str(str_03); //out ("") ! //IN|OUT ! //beg ! pt_1 = strb_01.pubseekoff(2, std::ios_base::beg); ! off_1 = pt_1; ! VERIFY( off_1 >= 0 ); ! pt_1 = strb_01.pubseekoff(0, std::ios_base::cur, std::ios_base::out); ! off_1 = pt_1; ! c1 = strb_01.snextc(); //current in pointer +1 ! VERIFY( c1 == 'o' ); ! c2 = strb_01.sputc('x'); //test current out pointer ! str_tmp = std::string("myxonos. . . or what?"); ! VERIFY( strb_01.str() == str_tmp ); ! strb_01.pubsync(); //resets pointers ! pt_2 = strb_01.pubseekpos(pt_1, std::ios_base::in|std::ios_base::out); ! off_2 = pt_2; ! VERIFY( off_1 == off_2 ); ! c3 = strb_01.snextc(); //current in pointer +1 ! VERIFY( c1 == c3 ); ! c2 = strb_01.sputc('x'); //test current out pointer ! str_tmp = std::string("myxonos. . . or what?"); ! VERIFY( strb_01.str() == str_tmp ); ! ! // VIRTUALS (indirectly tested) ! // underflow ! // if read position avail, returns *gptr() ! ! // pbackfail(int_type c) ! // put c back into input sequence ! ! // overflow ! // appends c to output seq ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! return test; ! } ! // libstdc++/3955 -- ios_base::app overwrites from the beginning ! bool test05() { ! bool test = true; ! ! std::ostringstream os ("foo"); ! os << "bar"; ! ! test = os.str() == "bar"; ! ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! ! return test; } ! bool test06() { ! bool test = true; ! ! std::ostringstream os ("foo", std::ios_base::app); ! os << "bar"; ! ! test = os.str() == "foobar"; ! ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! ! return test; ! } ! int main() { test01(); - test02(); - test03(); - test04(); - test05(); - test06(); - return 0; } - - - - // more candy!!! --- 18,62 ---- // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. ! // As a special exception, you may use this file as part of a free software ! // library without restriction. Specifically, if other files instantiate ! // templates or use macros or inline functions from this file, or you compile ! // this file and link it with other files to produce an executable, this ! // file does not by itself cause the resulting executable to be covered by ! // the GNU General Public License. This exception does not however ! // invalidate any other reasons why the executable file might be covered by ! // the GNU General Public License. ! // 27.7.1 - Template class basic_stringbuf ! // NB: This file is for testing basic_stringbuf with NO OTHER INCLUDES. ! #include ! #include + // { dg-do compile } ! // libstdc++/7216 ! void test01() { ! // Check for required typedefs ! typedef std::stringbuf test_type; ! typedef test_type::char_type char_type; ! typedef test_type::traits_type traits_type; ! typedef test_type::int_type int_type; ! typedef test_type::pos_type pos_type; ! typedef test_type::off_type off_type; } ! namespace test { ! using namespace std; ! typedef short type_t; ! template class basic_stringbuf >; ! template class basic_stringbuf >; ! } // test ! int main() { test01(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringbuf_members.cc gcc-3.2/libstdc++-v3/testsuite/27_io/stringbuf_members.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringbuf_members.cc Thu Jan 1 00:00:00 1970 --- gcc-3.2/libstdc++-v3/testsuite/27_io/stringbuf_members.cc Fri Jul 26 23:23:44 2002 *************** *** 0 **** --- 1,490 ---- + // 981208 bkoz test functionality of basic_stringbuf for char_type == char + + // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 + // Free Software Foundation, Inc. + // + // This file is part of the GNU ISO C++ Library. This library 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. + + // This library 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 this library; see the file COPYING. If not, write to the Free + // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, + // USA. + + #include + #include + + std::string str_01("mykonos. . . or what?"); + std::string str_02("paris, or sainte-maxime?"); + std::string str_03; + std::stringbuf strb_01(str_01); + std::stringbuf strb_02(str_02, std::ios_base::in); + std::stringbuf strb_03(str_03, std::ios_base::out); + + + // test the underlying allocator + bool test01() { + bool test = false; + std::allocator alloc_01; + std::allocator::size_type size_01 = alloc_01.max_size(); + std::allocator::pointer p_01 = alloc_01.allocate(32); + + return true; + } + + + // test the streambuf/stringbuf locale settings + bool test02() { + std::locale loc_tmp; + loc_tmp = strb_01.getloc(); + strb_01.pubimbue(loc_tmp); //This should initialize _M_init to true + strb_01.getloc(); //This should just return _M_locale + + return true; + } + + + // test member functions + bool test03() { + bool test = true; + + //stringbuf::str() + VERIFY( strb_01.str() == str_01 ); + VERIFY( strb_02.str() == str_02 ); + VERIFY( strb_03.str() == str_03 ); + + //stringbuf::str(string&) + strb_03.str("none of the above, go to the oberoi in cairo, egypt."); + strb_03.str(str_01); + std::streamsize d1 = strb_01.in_avail(); + std::streamsize d2 = strb_03.in_avail(); + VERIFY( d1 ); // non-zero + VERIFY( !d2 ); // zero, cuz ios_base::out + VERIFY( d1 != d2 ); //these should be the same + VERIFY( str_01.length() == d1 ); + VERIFY( strb_01.str() == strb_03.str() ); //ditto + + // stringbuf::str(string&) and stringbuf::stringbuf(string&), where the + // string in question contains embedded NUL characters. Note that in this + // embedded-NUL situation, the size must be passed to the string ctor. + std::string str_nulls ("eschew \0 obfuscation", 20); // tested in 21_strings + std::stringbuf strb_normal (str_01); + std::stringbuf strb_nulls (str_nulls); + strb_normal.str(str_nulls); // tried using 'strb_01' rather than declaring + // another variable, but then test04 broke! + VERIFY( strb_nulls.in_avail() == str_nulls.size() ); + VERIFY( strb_nulls.str().size() == 20 ); + VERIFY( strb_normal.in_avail() == str_nulls.size() ); + + #ifdef DEBUG_ASSERT + assert(test); + #endif + + return test; + } + + + // test overloaded virtual functions + bool test04() { + bool test = true; + std::string str_tmp; + std::stringbuf strb_tmp; + std::streamsize strmsz_1, strmsz_2; + std::streamoff strmof_1(-1), strmof_2; + typedef std::stringbuf::int_type int_type; + typedef std::stringbuf::traits_type traits_type; + typedef std::stringbuf::pos_type pos_type; + typedef std::stringbuf::off_type off_type; + + // GET + // int in_avail() + strmof_1 = strb_01.in_avail(); + strmof_2 = strb_02.in_avail(); + VERIFY( strmof_1 != strmof_2 ); + VERIFY( strmof_1 == str_01.length() ); + VERIFY( strmof_2 == str_02.length() ); + strmof_1 = strb_03.in_avail(); + VERIFY( strmof_1 == 0 ); // zero cuz write-only, or eof()? zero, from showmany + + // int_type sbumpc() + // if read_cur not avail, return uflow(), else return *read_cur & increment + int_type c1 = strb_01.sbumpc(); + int_type c2 = strb_02.sbumpc(); + VERIFY( c1 != c2 ); + VERIFY( c1 == str_01[0] ); + VERIFY( c2 == str_02[0] ); //should equal first letter at this point + int_type c3 = strb_01.sbumpc(); + int_type c4 = strb_02.sbumpc(); + VERIFY( c1 != c2 ); + VERIFY( c1 != c3 ); + VERIFY( c2 != c4 ); + int_type c5 = strb_03.sbumpc(); + VERIFY( c5 == traits_type::eof() ); + + // int_type sgetc() + // if read_cur not avail, return uflow(), else return *read_cur + int_type c6 = strb_01.sgetc(); + int_type c7 = strb_02.sgetc(); + VERIFY( c6 != c3 ); + VERIFY( c7 != c4 ); + int_type c8 = strb_01.sgetc(); + int_type c9 = strb_02.sgetc(); + VERIFY( c6 == c8 ); + VERIFY( c7 == c9 ); + c5 = strb_03.sgetc(); + VERIFY( c5 == traits_type::eof() ); + + // int_type snextc() + // calls sbumpc and if sbumpc != eof, return sgetc + c6 = strb_01.snextc(); + c7 = strb_02.snextc(); + VERIFY( c6 != c8 ); + VERIFY( c7 != c9 ); + VERIFY( c6 == str_01[3] ); + VERIFY( c7 == str_02[3] ); //should equal fourth letter at this point + c5 = strb_03.snextc(); + VERIFY( c5 == traits_type::eof() ); + + // int showmanyc + // streamsize sgetn(char_type *s, streamsize n) + // streamsize xsgetn(char_type *s, streamsize n) + // assign up to n chars to s from input sequence, indexing in_cur as + // approp and returning the number of chars assigned + strmsz_1 = strb_01.in_avail(); + strmsz_2 = strb_02.in_avail(); + test = strmsz_1 != strmsz_2; + VERIFY( strmsz_1 != str_01.length() ); + VERIFY( strmsz_2 != str_02.length() ); //because now we've moved into string + char carray1[11] = ""; + strmsz_1 = strb_01.sgetn(carray1, 10); + char carray2[20] = ""; + strmsz_2 = strb_02.sgetn(carray2, 10); + VERIFY( strmsz_1 == strmsz_2 ); + VERIFY( strmsz_1 == 10 ); + c1 = strb_01.sgetc(); + c2 = strb_02.sgetc(); + VERIFY( c6 == c1 ); //just by co-incidence both o's + VERIFY( c7 != c2 ); // n != i + VERIFY( c1 == str_01[13] ); + VERIFY( c2 == str_02[13] ); //should equal fourteenth letter at this point + strmsz_1 = strb_03.sgetn(carray1, 10); + VERIFY( !strmsz_1 ); //zero + strmsz_1 = strb_02.in_avail(); + strmsz_2 = strb_02.sgetn(carray2, strmsz_1 + 5); + VERIFY( strmsz_1 == strmsz_2 ); //write off the end + c4 = strb_02.sgetc(); // should be EOF + VERIFY( c4 == traits_type::eof() ); + + // PUT + // int_type sputc(char_type c) + // if out_cur not avail, return overflow. Else, stores c at out_cur, + // increments out_cur, and returns c as int_type + strb_03.str(str_01); //reset + std::string::size_type sz1 = strb_03.str().length(); + c1 = strb_03.sputc('a'); + std::string::size_type sz2 = strb_03.str().length(); + VERIFY( sz1 == sz2 ); //cuz inserting at out_cur, which is at beg to start + c2 = strb_03.sputc('b'); + VERIFY( c1 != c2 ); + VERIFY( strb_03.str() != str_01 ); + c3 = strb_02.sputc('a'); // should be EOF because this is read-only + VERIFY( c3 == traits_type::eof() ); + + // streamsize sputn(const char_typs* s, streamsize n) + // write up to n chars to out_cur from s, returning number assigned + // NB *sputn will happily put '\0' into your stream if you give it a chance* + str_tmp = strb_03.str(); + sz1 = str_tmp.length(); + strmsz_1 = strb_03.sputn("racadabras", 10);//"abracadabras or what?" + sz2 = strb_03.str().length(); + VERIFY( sz1 == sz2 ); //shouldn't have changed length + VERIFY( strmsz_1 == 10 ); + VERIFY( str_tmp != strb_03.str() ); + strmsz_2 = strb_03.sputn(", i wanna reach out and", 10); + VERIFY( strmsz_1 == strmsz_2 ); // should re-allocate, copy 10 chars. + VERIFY( strmsz_1 == 10 ); + VERIFY( strmsz_2 == 10 ); + sz2 = strb_03.str().length(); + VERIFY( sz1 != sz2 ); // need to change length + VERIFY( str_tmp != strb_03.str() ); + str_tmp = strb_02.str(); + strmsz_1 = strb_02.sputn("racadabra", 10); + VERIFY( strmsz_1 == 0 ); + VERIFY( str_tmp == strb_02.str() ); + + // PUTBACK + // int_type pbfail(int_type c) + // called when gptr() null, gptr() == eback(), or traits::eq(*gptr, c) false + // "pending sequence" is: + // 1) everything as defined in underflow + // 2) + if (traits::eq_int_type(c, traits::eof()), then input + // sequence is backed up one char before the pending sequence is + // determined. + // 3) + if (not 2) then c is prepended. Left unspecified is + // whether the input sequence is backedup or modified in any way + // returns traits::eof() for failure, unspecified other value for success + + // int_type sputbackc(char_type c) + // if in_cur not avail || ! traits::eq(c, gptr() [-1]), return pbfail + // otherwise decrements in_cur and returns *gptr() + strmsz_1 = strb_01.in_avail(); + str_tmp = strb_01.str(); + c1 = strb_01.sgetc(); //"mykonos. . . 'o'r what?" + c2 = strb_01.sputbackc('z');//"mykonos. . .zor what?" + c3 = strb_01.sgetc(); + VERIFY( c1 != c2 ); + VERIFY( c3 == c2 ); + VERIFY( strb_01.str() == std::string("mykonos. . .zor what?") ); + VERIFY( str_tmp.size() == strb_01.str().size() ); + //test for _in_cur == _in_beg + strb_01.str(str_tmp); + strmsz_1 = strb_01.in_avail(); + c1 = strb_01.sgetc(); //"'m'ykonos. . . or what?" + c2 = strb_01.sputbackc('z');//"mykonos. . . or what?" + c3 = strb_01.sgetc(); + VERIFY( c1 != c2 ); + VERIFY( c3 != c2 ); + VERIFY( c1 == c3 ); + VERIFY( c2 == traits_type::eof() ); + VERIFY( strb_01.str() == str_tmp ); + VERIFY( str_tmp.size() == strb_01.str().size() ); + // test for replacing char with identical one + strb_01.str(str_01); //reset + strmsz_1 = strb_01.in_avail(); + strb_01.sbumpc(); + strb_01.sbumpc(); + c1 = strb_01.sgetc(); //"my'k'onos. . . or what?" + c2 = strb_01.sputbackc('y');//"mykonos. . . or what?" + c3 = strb_01.sgetc(); + VERIFY( c1 != c2 ); + VERIFY( c3 == c2 ); + VERIFY( c1 != c3 ); + VERIFY( strb_01.str() == str_01 ); + VERIFY( str_01.size() == strb_01.str().size() ); + //test for ios_base::out + strmsz_2 = strb_03.in_avail(); + c4 = strb_03.sputbackc('x'); + VERIFY( c4 == traits_type::eof() ); + + // int_type sungetc() + // if in_cur not avail, return pbackfail(), else decrement and + // return to_int_type(*gptr()) + for (int i = 0; i<12; ++i) + strb_01.sbumpc(); + strmsz_1 = strb_01.in_avail(); + str_tmp = strb_01.str(); + c1 = strb_01.sgetc(); //"mykonos. . . 'o'r what?" + c2 = strb_01.sungetc();//"mykonos. . . or what?" + c3 = strb_01.sgetc(); + VERIFY( c1 != c2 ); + VERIFY( c3 == c2 ); + VERIFY( c1 != c3 ); + VERIFY( c2 == ' ' ); + VERIFY( strb_01.str() == str_01 ); + VERIFY( str_01.size() == strb_01.str().size() ); + //test for _in_cur == _in_beg + strb_01.str(str_tmp); + strmsz_1 = strb_01.in_avail(); + c1 = strb_01.sgetc(); //"'m'ykonos. . . or what?" + c2 = strb_01.sungetc();//"mykonos. . . or what?" + c3 = strb_01.sgetc(); + VERIFY( c1 != c2 ); + VERIFY( c3 != c2 ); + VERIFY( c1 == c3 ); + VERIFY( c2 == traits_type::eof() ); + VERIFY( strb_01.str() == str_01 ); + VERIFY( str_01.size() == strb_01.str().size() ); + // test for replacing char with identical one + strb_01.str(str_01); //reset + strmsz_1 = strb_01.in_avail(); + strb_01.sbumpc(); + strb_01.sbumpc(); + c1 = strb_01.sgetc(); //"my'k'onos. . . or what?" + c2 = strb_01.sungetc();//"mykonos. . . or what?" + c3 = strb_01.sgetc(); + VERIFY( c1 != c2 ); + VERIFY( c3 == c2 ); + VERIFY( c1 != c3 ); + VERIFY( strb_01.str() == str_01 ); + VERIFY( str_01.size() == strb_01.str().size() ); + //test for ios_base::out + strmsz_2 = strb_03.in_avail(); + c4 = strb_03.sungetc(); + VERIFY( c4 == traits_type::eof() ); + + // BUFFER MANAGEMENT & POSITIONING + // sync + // pubsync + strb_01.pubsync(); + strb_02.pubsync(); + strb_03.pubsync(); + + // setbuf + // pubsetbuf(char_type* s, streamsize n) + str_tmp = std::string("naaaah, go to cebu"); + strb_01.pubsetbuf(const_cast (str_tmp.c_str()), str_tmp.size()); + VERIFY( strb_01.str() == str_tmp ); + strb_01.pubsetbuf(0,0); + VERIFY( strb_01.str() == str_tmp ); + + // seekoff + // pubseekoff(off_type off, ios_base::seekdir way, ios_base::openmode which) + // alters the stream position to off + pos_type pt_1(off_type(-1)); + pos_type pt_2(off_type(0)); + off_type off_1 = 0; + off_type off_2 = 0; + strb_01.str(str_01); //in|out ("mykonos. . . or what?"); + strb_02.str(str_02); //in ("paris, or sainte-maxime?"); + strb_03.str(str_03); //out ("") + //IN|OUT + //beg + pt_1 = strb_01.pubseekoff(2, std::ios_base::beg); + off_1 = pt_1; + VERIFY( off_1 >= 0 ); + c1 = strb_01.snextc(); //current in pointer +1 + VERIFY( c1 == 'o' ); + c2 = strb_01.sputc('x'); //test current out pointer + str_tmp = std::string("myxonos. . . or what?"); + VERIFY( strb_01.str() == str_tmp ); + //cur + pt_1 = strb_01.pubseekoff(2, std::ios_base::cur); + off_1 = pt_1; + VERIFY( off_1 == -1 ); // can't seekoff for in and out + cur in sstreams + pt_1 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in); + off_1 = pt_1; + pt_2 = strb_01.pubseekoff(2, std::ios_base::cur, std::ios_base::in); + off_2 = pt_2; + VERIFY( off_2 == off_1 + 2 ); + c1 = strb_01.snextc(); //current in pointer + 1 + VERIFY( c1 == ' ' ); + c2 = strb_01.sputc('x'); //test current out pointer + str_tmp = std::string("myxxnos. . . or what?"); + VERIFY( strb_01.str() == str_tmp ); + //end + pt_2 = strb_01.pubseekoff(2, std::ios_base::end); + off_1 = pt_2; + VERIFY( off_1 == -1 ); // not a valid position + VERIFY( strb_01.str() == str_tmp ); + // end part two (from the filebuf tests) + strb_01.pubseekoff(0, std::ios_base::end); + strmsz_1 = strb_01.in_avail(); // 0 cuz at the end + c1 = strb_01.sgetc(); + c2 = strb_01.sungetc(); + strmsz_2 = strb_01.in_avail(); // 1 + c3 = strb_01.sgetc(); + VERIFY( c1 != c2 ); + VERIFY( strmsz_2 != strmsz_1 ); + VERIFY( strmsz_2 == 1 ); + // end part three + strmsz_1 = strb_01.str().size(); + strmsz_2 = strb_01.sputn(" ravi shankar meets carlos santana in LoHa", 90); + strb_01.pubseekoff(0, std::ios_base::end); + strb_01.sputc('<'); + str_tmp = strb_01.str(); + VERIFY( str_tmp.size() == strmsz_1 + strmsz_2 + 1 ); + // IN + // OUT + + // seekpos + // pubseekpos(pos_type sp, ios_base::openmode) + // alters the stream position to sp + strb_01.str(str_01); //in|out ("mykonos. . . or what?"); + strb_02.str(str_02); //in ("paris, or sainte-maxime?"); + strb_03.str(str_03); //out ("") + //IN|OUT + //beg + pt_1 = strb_01.pubseekoff(2, std::ios_base::beg); + off_1 = pt_1; + VERIFY( off_1 >= 0 ); + pt_1 = strb_01.pubseekoff(0, std::ios_base::cur, std::ios_base::out); + off_1 = pt_1; + c1 = strb_01.snextc(); //current in pointer +1 + VERIFY( c1 == 'o' ); + c2 = strb_01.sputc('x'); //test current out pointer + str_tmp = std::string("myxonos. . . or what?"); + VERIFY( strb_01.str() == str_tmp ); + strb_01.pubsync(); //resets pointers + pt_2 = strb_01.pubseekpos(pt_1, std::ios_base::in|std::ios_base::out); + off_2 = pt_2; + VERIFY( off_1 == off_2 ); + c3 = strb_01.snextc(); //current in pointer +1 + VERIFY( c1 == c3 ); + c2 = strb_01.sputc('x'); //test current out pointer + str_tmp = std::string("myxonos. . . or what?"); + VERIFY( strb_01.str() == str_tmp ); + + // VIRTUALS (indirectly tested) + // underflow + // if read position avail, returns *gptr() + + // pbackfail(int_type c) + // put c back into input sequence + + // overflow + // appends c to output seq + + #ifdef DEBUG_ASSERT + assert(test); + #endif + + return test; + } + + + // libstdc++/3955 -- ios_base::app overwrites from the beginning + bool test05() + { + bool test = true; + + std::ostringstream os ("foo"); + os << "bar"; + + test = os.str() == "bar"; + + #ifdef DEBUG_ASSERT + assert(test); + #endif + + return test; + } + + bool test06() + { + bool test = true; + + std::ostringstream os ("foo", std::ios_base::app); + os << "bar"; + + test = os.str() == "foobar"; + + #ifdef DEBUG_ASSERT + assert(test); + #endif + + return test; + } + + int main() + { + test01(); + test02(); + test03(); + test04(); + test05(); + test06(); + + return 0; + } + + + + // more candy!!! diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringstream.cc gcc-3.2/libstdc++-v3/testsuite/27_io/stringstream.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringstream.cc Wed Jan 16 19:57:39 2002 --- gcc-3.2/libstdc++-v3/testsuite/27_io/stringstream.cc Thu Aug 1 21:29:16 2002 *************** *** 1,7 **** ! // 981015 bkoz ! // i,o,stringstream usage ! // Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,6 ---- ! // 2002-07-25 Benjamin Kosnik ! // Copyright (C) 2002 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** *** 28,160 **** // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. ! #include ! #include #include #include ! // 01: sanity checks for strings, stringbufs ! std::string ! test01() ! { ! bool test = false; ! ! // Empty string sanity check. ! std::string str01; ! std::string::iterator __i_start = str01.begin(); ! std::string::iterator __i_end = str01.end(); ! std::string::size_type len = str01.size(); ! test = __i_start == __i_end; ! VERIFY( len == 0 ); ! ! // Full string sanity check. ! std::string str02("these golden days, i spend waiting for you:\n" ! "Betty Carter on Verve with I'm Yours and You're Mine."); ! __i_start = str02.begin(); ! __i_end = str02.end(); ! len = str02.size(); ! VERIFY( __i_start != __i_end ); ! VERIFY( len != 0 ); ! ! // Test an empty ostring stream for sanity. ! std::ostringstream ostrstream0; ! std::string str03 = ostrstream0.str(); ! __i_start = str03.begin(); ! __i_end = str03.end(); ! len = str03.size(); ! VERIFY( __i_start == __i_end ); ! VERIFY( len == 0 ); ! VERIFY( str01 == str03 ); ! ! return str02; ! } ! ! int ! test02() { ! bool test = true; ! ! // ! // 1: Automatic formatting of a compound string ! // ! int i = 1024; ! int *pi = &i; ! double d = 3.14159; ! double *pd = &d; ! std::string blank; ! std::ostringstream ostrst01; ! std::ostringstream ostrst02(blank); ! ! // No buffer,so should be created. ! ostrst01 << "i: " << i << " i's address: " << pi << "\n" ! << "d: " << d << " d's address: " << pd << std::endl; ! // Buffer, so existing buffer should be overwritten. ! ostrst02 << "i: " << i << " i's address: " << pi << "\n" ! << "d: " << d << " d's address: " << pd << std::endl; ! ! std::string msg01 = ostrst01.str(); ! std::string msg02 = ostrst02.str(); ! VERIFY( msg01 == msg02 ); ! VERIFY( msg02 != blank ); ! ! // ! // 2: istringstream ! // ! // extracts the stored ascii values, placing them in turn in the four vars ! #if 0 ! int i2 = 0; ! int *pi2 = &i2; ! double d2 = 0.0; ! double *pd2 = &d2; ! std::istringstream istrst01(ostrst02.str()); ! ! istrst01 >> i2 >> pi2 >> d2 >> pd2; ! //istrst01 >> i2; ! //istrst01 >> pi2; ! VERIFY( i2 == i ); ! VERIFY( d2 == d ); ! VERIFY( pd2 == pd ); ! VERIFY( pi2 == pi ); ! #endif ! ! // stringstream ! std::string str1(""); ! std::string str3("this is a somewhat string"); ! std::stringstream ss1(str1, std::ios_base::in|std::ios_base::out); ! std::stringstream ss2(str3, std::ios_base::in|std::ios_base::out); ! ! return 0; } ! // user-reported error ! class derived_oss: public std::ostringstream ! { ! public: ! derived_oss() : std::ostringstream() {} ! }; ! ! int ! test03() { ! bool test = true; ! derived_oss yy; ! yy << "buena vista social club\n"; ! VERIFY( yy.str() == std::string("buena vista social club\n") ); ! ! #ifdef DEBUG_ASSERT ! assert(test); ! #endif ! ! return 0; ! } ! int ! main() { test01(); - test02(); - test03(); - return 0; } --- 27,62 ---- // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. ! // 27.7.4 - Template class basic_stringstream ! // NB: This file is for testing basic_stringstream with NO OTHER INCLUDES. ! #include #include ! // { dg-do compile } ! // libstdc++/7216 ! void test01() { ! // Check for required typedefs ! typedef std::stringstream test_type; ! typedef test_type::char_type char_type; ! typedef test_type::traits_type traits_type; ! typedef test_type::int_type int_type; ! typedef test_type::pos_type pos_type; ! typedef test_type::off_type off_type; } ! namespace test { ! using namespace std; ! typedef short type_t; ! template class basic_stringstream >; ! template class basic_stringstream >; ! } // test ! int main() { test01(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringstream_members.cc gcc-3.2/libstdc++-v3/testsuite/27_io/stringstream_members.cc *** gcc-3.1.1/libstdc++-v3/testsuite/27_io/stringstream_members.cc Tue Aug 7 03:38:33 2001 --- gcc-3.2/libstdc++-v3/testsuite/27_io/stringstream_members.cc Fri Jul 26 23:23:43 2002 *************** *** 1,6 **** // 2001-05-24 Benjamin Kosnik ! // Copyright (C) 2001 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the --- 1,6 ---- // 2001-05-24 Benjamin Kosnik ! // Copyright (C) 2001, 2002 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the *************** void test02() *** 120,131 **** // These semantics are a joke, a serious defect, and incredibly lame. } int main() { test01(); test02(); return 0; } - - - --- 120,186 ---- // These semantics are a joke, a serious defect, and incredibly lame. } + void + test03() + { + bool test = true; + + // + // 1: Automatic formatting of a compound string + // + int i = 1024; + int *pi = &i; + double d = 3.14159; + double *pd = &d; + std::string blank; + std::ostringstream ostrst01; + std::ostringstream ostrst02(blank); + + // No buffer, so should be created. + ostrst01 << "i: " << i << " i's address: " << pi << "\n" + << "d: " << d << " d's address: " << pd << std::endl; + // Buffer, so existing buffer should be overwritten. + ostrst02 << "i: " << i << " i's address: " << pi << "\n" + << "d: " << d << " d's address: " << pd << std::endl; + + std::string msg01 = ostrst01.str(); + std::string msg02 = ostrst02.str(); + VERIFY( msg01 == msg02 ); + VERIFY( msg02 != blank ); + + // + // 2: istringstream + // + // extracts the stored ascii values, placing them in turn in the four vars + #if 0 + int i2 = 0; + //int* pi2 = &i2; + void* pi2 = &i2; + double d2 = 0.0; + // double* pd2 = &d2; + void* pd2 = &d2; + std::istringstream istrst01(ostrst02.str()); + + istrst01 >> i2 >> pi2 >> d2 >> pd2; + //istrst01 >> i2; + //istrst01 >> pi2; + VERIFY( i2 == i ); + VERIFY( d2 == d ); + VERIFY( pd2 == pd ); + VERIFY( pi2 == pi ); + #endif + + // stringstream + std::string str1(""); + std::string str3("this is a somewhat string"); + std::stringstream ss1(str1, std::ios_base::in|std::ios_base::out); + std::stringstream ss2(str3, std::ios_base::in|std::ios_base::out); + } + int main() { test01(); test02(); + test03(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/backward/strstream_members.cc gcc-3.2/libstdc++-v3/testsuite/backward/strstream_members.cc *** gcc-3.1.1/libstdc++-v3/testsuite/backward/strstream_members.cc Sat Jun 8 15:15:44 2002 --- gcc-3.2/libstdc++-v3/testsuite/backward/strstream_members.cc Wed Aug 7 05:13:08 2002 *************** *** 18,40 **** // backward strstream members ! #include #include // { dg-options "-Wno-deprecated" } int test01() { ! strstream s; for (unsigned i=0 ; i!= 1000 ; ++i) s << i << std::endl; s << std::ends; - return 0; } int main() { test01(); return 0; } --- 18,49 ---- // backward strstream members ! #include #include // { dg-options "-Wno-deprecated" } int test01() { ! std::strstream s; for (unsigned i=0 ; i!= 1000 ; ++i) s << i << std::endl; s << std::ends; return 0; } + + int test02() + { + std::ostrstream buf; + buf << std::ends; + char *s = buf.str (); + delete [] s; + } + int main() { test01(); + test02(); return 0; } diff -Nrc3pad gcc-3.1.1/libstdc++-v3/testsuite/testsuite_hooks.h gcc-3.2/libstdc++-v3/testsuite/testsuite_hooks.h *** gcc-3.1.1/libstdc++-v3/testsuite/testsuite_hooks.h Thu May 23 17:01:30 2002 --- gcc-3.2/libstdc++-v3/testsuite/testsuite_hooks.h Thu Aug 1 21:29:17 2002 *************** *** 46,55 **** --- 46,61 ---- // which starts at zero, increments on instance construction, and decrements // on instance destruction. "assert_count(n)" can be called to VERIFY() // that the count equals N. + // + // 4) gnu_char, gnu_char_traits, abstract character classes and + // char_traits specializations for testing instantiations. #ifndef _GLIBCPP_TESTSUITE_HOOKS_H #define _GLIBCPP_TESTSUITE_HOOKS_H + #include + #include + #ifdef DEBUG_ASSERT # include # define VERIFY(fn) assert(fn) *************** *** 57,64 **** # define VERIFY(fn) test &= (fn) #endif - #include - // Defined in GLIBCPP_CONFIGURE_TESTSUITE. #ifndef _GLIBCPP_MEM_LIMITS --- 63,68 ---- *************** struct gnu_counting_struct *** 130,135 **** --- 134,213 ---- gnu_counting_struct::size_type gnu_counting_struct::count = 0; + struct gnu_char + { + unsigned long c; + }; + + struct gnu_int + { + unsigned long i; + }; + + struct gnu_state + { + unsigned long l; + unsigned long l2; + }; + + // char_traits specialization + namespace std + { + template + struct char_traits; + + template<> + struct char_traits + { + typedef gnu_char char_type; + typedef gnu_int int_type; + typedef long pos_type; + typedef unsigned long off_type; + typedef gnu_state state_type; + + static void + assign(char_type& __c1, const char_type& __c2); + + static bool + eq(const char_type& __c1, const char_type& __c2); + + static bool + lt(const char_type& __c1, const char_type& __c2); + + static int + compare(const char_type* __s1, const char_type* __s2, size_t __n); + + static size_t + length(const char_type* __s); + + static const char_type* + find(const char_type* __s, size_t __n, const char_type& __a); + + static char_type* + move(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + copy(char_type* __s1, const char_type* __s2, size_t __n); + + static char_type* + assign(char_type* __s, size_t __n, char_type __a); + + static char_type + to_char_type(const int_type& __c); + + static int_type + to_int_type(const char_type& __c); + + static bool + eq_int_type(const int_type& __c1, const int_type& __c2); + + static int_type + eof(); + + static int_type + not_eof(const int_type& __c); + }; + } // namespace std #endif // _GLIBCPP_TESTSUITE_HOOKS_H