diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 39b294dc3f8..aea2a4c372d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,43 @@ +2003-01-16 Mark Mitchell + + * cp-tree.h (lang_type_class): Remove is_partial_instantiation. + (PARTIAL_INSTANTIATION_P): Remove. + (IMPLICIT_TYPENAME_P): Likewise. + (IMPLICIT_TYPENAME_TYPE_DECL_P): Likewise. + (build_typename_type): Remove declaration. + (parmlist_is_exprlist): Likewise. + * decl.c (build_typename_type): Make it static, remove third + parameter. + (push_class_binding): Don't do implicit typename stuff. + (make_typename_type): Likewise. + (lookup_name_real): Likewise. + (grokdeclarator): Don't try to convert declarations into + initializations. Don't do implicit typename stuff. + (parmlist_is_exprlist): Remove. + (xref_basetypes): Simplify. + * decl2.c (grokfield): Don't try to convert declarations into + initializations. + (build_anon_union_vars): Do this while processing templates, too. + (finish_anon_union): Likewise. + * error.c (dump_type): Remove implicit typename handling. + * parser.c (cp_parser_diagnose_invalid_type_name): New method. + (cp_parser_primary_expression): Correct handling of names not + found by unqualified name lookup in templates. + (cp_parser_nested_name_specifier_opt): Avoid checking dependency + of types when possible. + (cp_parser_simple_declaration): Complain intelligently about some + invalid declarations. + (cp_parser_member_declaration): Likewise. + (cp_parser_constructor_declarator_p): Don't check when we're in a + function scope. + * pt.c (instantiate_class_template): Remove + PARTIAL_INSTANTIATION_P gunk. + * search.c (lookup_field_r): Don't build implicit typenames. + (marked_pushdecls_p): Don't enter dependent base types. + (unmarked_pushdecls_p): Likewise. + * semantics.c (begin_class_definition): Remove implicit typename + stuff. + 2003-01-16 Nathan Sidwell PR c++/9212 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 612fd568a73..90c2e598f8a 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1133,6 +1133,7 @@ struct lang_type_class GTY(()) unsigned has_arrow_overloaded : 1; unsigned interface_only : 1; unsigned interface_unknown : 1; + unsigned contains_empty_class_p : 1; unsigned marks: 6; unsigned vec_new_uses_cookie : 1; @@ -1152,13 +1153,11 @@ struct lang_type_class GTY(()) unsigned has_complex_assign_ref : 1; unsigned has_abstract_assign_ref : 1; unsigned non_aggregate : 1; - unsigned is_partial_instantiation : 1; unsigned java_interface : 1; - unsigned anon_aggr : 1; + unsigned non_zero_init : 1; unsigned empty_p : 1; - unsigned contains_empty_class_p : 1; /* When adding a flag here, consider whether or not it ought to apply to a template instance if it applies to the template. If @@ -1167,7 +1166,7 @@ struct lang_type_class GTY(()) /* There are some bits left to fill out a 32-bit word. Keep track of this by updating the size of this bitfield whenever you add or remove a flag. */ - unsigned dummy : 5; + unsigned dummy : 6; tree primary_base; tree vfields; @@ -2412,17 +2411,6 @@ struct lang_decl GTY(()) TEMPLATE_ID_EXPR if we had something like `typename X::Y'. */ #define TYPENAME_TYPE_FULLNAME(NODE) (TYPE_FIELDS (NODE)) -/* Nonzero if NODE is an implicit typename. */ -#define IMPLICIT_TYPENAME_P(NODE) \ - (TREE_CODE (NODE) == TYPENAME_TYPE && TREE_TYPE (NODE)) - -/* Nonzero if NODE is a TYPE_DECL that should not be visible because - it is from a dependent base class. */ -#define IMPLICIT_TYPENAME_TYPE_DECL_P(NODE) \ - (TREE_CODE (NODE) == TYPE_DECL \ - && DECL_ARTIFICIAL (NODE) \ - && IMPLICIT_TYPENAME_P (TREE_TYPE (NODE))) - /* Nonzero in INTEGER_CST means that this int is negative by dint of using a twos-complement negated operand. */ #define TREE_NEGATED_INT(NODE) TREE_LANG_FLAG_0 (INTEGER_CST_CHECK (NODE)) @@ -2908,12 +2896,6 @@ struct lang_decl GTY(()) #define DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION(DECL) \ (DECL_TEMPLATE_INFO (DECL) && !DECL_USE_TEMPLATE (DECL)) -/* Nonzero if TYPE is a partial instantiation of a template class, - i.e., an instantiation whose instantiation arguments involve - template types. */ -#define PARTIAL_INSTANTIATION_P(TYPE) \ - (LANG_TYPE_CLASS_CHECK (TYPE)->is_partial_instantiation) - /* Nonzero iff we are currently processing a declaration for an entity with its own template parameter list, and which is not a full specialization. */ @@ -3765,7 +3747,6 @@ extern tree binding_for_name (tree, tree); extern tree namespace_binding (tree, tree); extern void set_namespace_binding (tree, tree, tree); extern tree lookup_namespace_name (tree, tree); -extern tree build_typename_type (tree, tree, tree, tree); extern tree make_typename_type (tree, tree, tsubst_flags_t); extern tree make_unbound_class_template (tree, tree, tsubst_flags_t); extern tree lookup_name_nonclass (tree); @@ -3800,7 +3781,6 @@ extern int complete_array_type (tree, tree, int); extern tree build_ptrmemfunc_type (tree); extern tree build_ptrmem_type (tree, tree); /* the grokdeclarator prototype is in decl.h */ -extern int parmlist_is_exprlist (tree); extern int copy_fn_p (tree); extern tree get_scope_of_declarator (tree); extern void grok_special_member_properties (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 42bbdc87af2..4f3d9ed0c18 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -147,6 +147,7 @@ static void initialize_local_var (tree, tree); static void expand_static_init (tree, tree); static tree next_initializable_field (tree); static tree reshape_init (tree, tree *); +static tree build_typename_type (tree, tree, tree); #if defined (DEBUG_BINDING_LEVELS) static void indent (void); @@ -1093,27 +1094,18 @@ push_class_binding (tree id, tree decl) binding = IDENTIFIER_BINDING (id); if (BINDING_VALUE (binding) == decl && TREE_CODE (decl) != TREE_LIST) { - /* Any implicit typename must be from a base-class. The - context for an implicit typename declaration is always - the derived class in which the lookup was done, so the checks - based on the context of DECL below will not trigger. */ - if (IMPLICIT_TYPENAME_TYPE_DECL_P (decl)) - INHERITED_VALUE_BINDING_P (binding) = 1; + if (TREE_CODE (decl) == OVERLOAD) + context = CP_DECL_CONTEXT (OVL_CURRENT (decl)); else { - if (TREE_CODE (decl) == OVERLOAD) - context = CP_DECL_CONTEXT (OVL_CURRENT (decl)); - else - { - my_friendly_assert (DECL_P (decl), 0); - context = context_for_name_lookup (decl); - } - - if (is_properly_derived_from (current_class_type, context)) - INHERITED_VALUE_BINDING_P (binding) = 1; - else - INHERITED_VALUE_BINDING_P (binding) = 0; + my_friendly_assert (DECL_P (decl), 0); + context = context_for_name_lookup (decl); } + + if (is_properly_derived_from (current_class_type, context)) + INHERITED_VALUE_BINDING_P (binding) = 1; + else + INHERITED_VALUE_BINDING_P (binding) = 0; } else if (BINDING_VALUE (binding) == decl) /* We only encounter a TREE_LIST when push_class_decls detects an @@ -5437,7 +5429,7 @@ typename_compare (const void * k1, const void * k2) static GTY ((param_is (union tree_node))) htab_t typename_htab; tree -build_typename_type (tree context, tree name, tree fullname, tree base_type) +build_typename_type (tree context, tree name, tree fullname) { tree t; tree d; @@ -5453,7 +5445,6 @@ build_typename_type (tree context, tree name, tree fullname, tree base_type) t = make_aggr_type (TYPENAME_TYPE); TYPE_CONTEXT (t) = FROB_CONTEXT (context); TYPENAME_TYPE_FULLNAME (t) = fullname; - TREE_TYPE (t) = base_type; /* Build the corresponding TYPE_DECL. */ d = build_decl (TYPE_DECL, name, t); @@ -5586,16 +5577,6 @@ make_typename_type (tree context, tree name, tsubst_flags_t complain) if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl)) t = TREE_TYPE (t); - if (IMPLICIT_TYPENAME_P (t)) - { - /* Lookup found an implicit typename that we had - injected into the current scope. Doing things - properly would have located the exact same type, - so there is no error here. We must remove the - implicitness so that we do not warn about it. */ - t = copy_node (t); - TREE_TYPE (t) = NULL_TREE; - } return t; } @@ -5611,7 +5592,7 @@ make_typename_type (tree context, tree name, tsubst_flags_t complain) return error_mark_node; } - return build_typename_type (context, name, fullname, NULL_TREE); + return build_typename_type (context, name, fullname); } /* Resolve `CONTEXT::template NAME'. Returns an appropriate type, @@ -5935,7 +5916,6 @@ lookup_name_real (tree name, { tree t; tree val = NULL_TREE; - int val_is_implicit_typename = 0; /* Conversion operators are handled specially because ordinary unqualified name lookup will not find template conversion @@ -5990,29 +5970,19 @@ lookup_name_real (tree name, else binding = NULL_TREE; - if (binding - && (!val || !IMPLICIT_TYPENAME_TYPE_DECL_P (binding))) + if (binding) { - if (val_is_implicit_typename) - warn_about_implicit_typename_lookup (val, binding); val = binding; - val_is_implicit_typename - = IMPLICIT_TYPENAME_TYPE_DECL_P (val); - if (!val_is_implicit_typename) - break; + break; } } /* Now lookup in namespace scopes. */ - if (!val || val_is_implicit_typename) + if (!val) { t = unqualified_namespace_lookup (name, flags, 0); if (t) - { - if (val_is_implicit_typename) - warn_about_implicit_typename_lookup (val, t); - val = t; - } + val = t; } if (val) @@ -9723,9 +9693,6 @@ grokdeclarator (tree declarator, /* See the code below that used this. */ tree decl_attr = NULL_TREE; #endif - /* Set this to error_mark_node for FIELD_DECLs we could not handle properly. - All FIELD_DECLs we build here have `init' put into their DECL_INITIAL. */ - tree init = NULL_TREE; /* Keep track of what sort of function is being processed so that we can warn about default return values, or explicit @@ -9825,46 +9792,6 @@ grokdeclarator (tree declarator, break; case CALL_EXPR: - if (parmlist_is_exprlist (CALL_DECLARATOR_PARMS (decl))) - { - /* This is actually a variable declaration using - constructor syntax. We need to call start_decl and - cp_finish_decl so we can get the variable - initialized... */ - - tree attributes; - - if (decl_context != NORMAL) - { - error ("variable declaration is not allowed here"); - return error_mark_node; - } - - *next = TREE_OPERAND (decl, 0); - init = CALL_DECLARATOR_PARMS (decl); - - if (attrlist) - { - attributes = *attrlist; - } - else - { - attributes = NULL_TREE; - } - - decl = start_decl (declarator, declspecs, 1, - attributes, NULL_TREE); - if (decl) - { - /* Look for __unused__ attribute */ - if (TREE_USED (TREE_TYPE (decl))) - TREE_USED (decl) = 1; - finish_decl (decl, init, NULL_TREE); - } - else - error ("invalid declarator"); - return NULL_TREE; - } innermost_code = TREE_CODE (decl); if (decl_context == FIELD && ctype == NULL_TREE) ctype = current_class_type; @@ -10294,21 +10221,6 @@ grokdeclarator (tree declarator, type = integer_type_node; } - if (type && IMPLICIT_TYPENAME_P (type)) - { - /* The implicit typename extension is deprecated and will be - removed. Warn about its use now. */ - warning ("`%T' is implicitly a typename", type); - cp_deprecated ("implicit typename"); - - /* Now remove its implicitness, so that we don't warn again. - For instance this might be a typedef, and we do not want to - warn on uses of the typedef itself. Simply clearing the - TREE_TYPE is insufficient. */ - type = copy_node (type); - TREE_TYPE (type) = NULL_TREE; - } - ctype = NULL_TREE; /* Now process the modifiers that were specified @@ -11903,32 +11815,6 @@ grokdeclarator (tree declarator, } } -/* Tell if a parmlist/exprlist looks like an exprlist or a parmlist. - An empty exprlist is a parmlist. An exprlist which - contains only identifiers at the global level - is a parmlist. Otherwise, it is an exprlist. */ - -int -parmlist_is_exprlist (tree exprs) -{ - if (exprs == NULL_TREE || TREE_PARMLIST (exprs)) - return 0; - - if (toplevel_bindings_p ()) - { - /* At the global level, if these are all identifiers, - then it is a parmlist. */ - while (exprs) - { - if (TREE_CODE (TREE_VALUE (exprs)) != IDENTIFIER_NODE) - return 1; - exprs = TREE_CHAIN (exprs); - } - return 0; - } - return 1; -} - /* Subroutine of start_function. Ensure that each of the parameter types (as listed in PARMS) is complete, as is required for a function definition. */ @@ -12963,9 +12849,9 @@ xref_basetypes (tree ref, tree binfo) /* In the declaration `A : X, Y, ... Z' we mark all the types (A, X, Y, ..., Z) so we can check for duplicates. */ tree binfos; - tree base; + tree *basep; - int i, len; + int i; enum tag_types tag_code; if (TREE_CODE (ref) == UNION_TYPE) @@ -12976,17 +12862,25 @@ xref_basetypes (tree ref, tree binfo) tag_code = (CLASSTYPE_DECLARED_CLASS (ref) ? class_type : record_type); - len = list_length (binfo); - /* First, make sure that any templates in base-classes are instantiated. This ensures that if we call ourselves recursively we do not get confused about which classes are marked and which are not. */ - for (base = binfo; base; base = TREE_CHAIN (base)) - complete_type (TREE_VALUE (base)); + basep = &binfo; + while (*basep) + { + tree basetype = TREE_VALUE (*basep); + if (!(processing_template_decl && uses_template_parms (basetype)) + && !complete_type_or_else (basetype, NULL)) + /* An incomplete type. Remove it form the list. */ + *basep = TREE_CHAIN (*basep); + else + basep = &TREE_CHAIN (*basep); + } SET_CLASSTYPE_MARKED (ref); - BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos = make_tree_vec (len); + BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos + = make_tree_vec (list_length (binfo)); for (i = 0; binfo; binfo = TREE_CHAIN (binfo)) { @@ -13021,85 +12915,74 @@ xref_basetypes (tree ref, tree binfo) continue; } - /* This code replaces similar code in layout_basetypes. - We put the complete_type first for implicit `typename'. */ - if (!COMPLETE_TYPE_P (basetype) - && ! (current_template_parms && uses_template_parms (basetype))) + if (CLASSTYPE_MARKED (basetype)) { - error ("base class `%T' has incomplete type", basetype); + if (basetype == ref) + error ("recursive type `%T' undefined", basetype); + else + error ("duplicate base type `%T' invalid", basetype); continue; } - else + + if (TYPE_FOR_JAVA (basetype) + && (current_lang_depth () == 0)) + TYPE_FOR_JAVA (ref) = 1; + + /* Note that the BINFO records which describe individual + inheritances are *not* shared in the lattice! They + cannot be shared because a given baseclass may be + inherited with different `accessibility' by different + derived classes. (Each BINFO record describing an + individual inheritance contains flags which say what + the `accessibility' of that particular inheritance is.) */ + + base_binfo + = make_binfo (size_zero_node, basetype, + CLASS_TYPE_P (basetype) + ? TYPE_BINFO_VTABLE (basetype) : NULL_TREE, + CLASS_TYPE_P (basetype) + ? TYPE_BINFO_VIRTUALS (basetype) : NULL_TREE); + + TREE_VEC_ELT (binfos, i) = base_binfo; + TREE_VIA_PUBLIC (base_binfo) = via_public; + TREE_VIA_PROTECTED (base_binfo) = via_protected; + TREE_VIA_VIRTUAL (base_binfo) = via_virtual; + BINFO_INHERITANCE_CHAIN (base_binfo) = TYPE_BINFO (ref); + + /* We need to unshare the binfos now so that lookups during class + definition work. */ + unshare_base_binfos (base_binfo); + + SET_CLASSTYPE_MARKED (basetype); + + /* We are free to modify these bits because they are meaningless + at top level, and BASETYPE is a top-level type. */ + if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype)) { - if (CLASSTYPE_MARKED (basetype)) - { - if (basetype == ref) - error ("recursive type `%T' undefined", basetype); - else - error ("duplicate base type `%T' invalid", basetype); - continue; - } - - if (TYPE_FOR_JAVA (basetype) - && (current_lang_depth () == 0)) - TYPE_FOR_JAVA (ref) = 1; - - /* Note that the BINFO records which describe individual - inheritances are *not* shared in the lattice! They - cannot be shared because a given baseclass may be - inherited with different `accessibility' by different - derived classes. (Each BINFO record describing an - individual inheritance contains flags which say what - the `accessibility' of that particular inheritance is.) */ - - base_binfo - = make_binfo (size_zero_node, basetype, - CLASS_TYPE_P (basetype) - ? TYPE_BINFO_VTABLE (basetype) : NULL_TREE, - CLASS_TYPE_P (basetype) - ? TYPE_BINFO_VIRTUALS (basetype) : NULL_TREE); - - TREE_VEC_ELT (binfos, i) = base_binfo; - TREE_VIA_PUBLIC (base_binfo) = via_public; - TREE_VIA_PROTECTED (base_binfo) = via_protected; - TREE_VIA_VIRTUAL (base_binfo) = via_virtual; - BINFO_INHERITANCE_CHAIN (base_binfo) = TYPE_BINFO (ref); - - /* We need to unshare the binfos now so that lookups during class - definition work. */ - unshare_base_binfos (base_binfo); - - SET_CLASSTYPE_MARKED (basetype); - - /* We are free to modify these bits because they are meaningless - at top level, and BASETYPE is a top-level type. */ - if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype)) - { - TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1; - /* Converting to a virtual base class requires looking - up the offset of the virtual base. */ - TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) = 1; - } - - if (CLASS_TYPE_P (basetype)) - { - TYPE_HAS_NEW_OPERATOR (ref) - |= TYPE_HAS_NEW_OPERATOR (basetype); - TYPE_HAS_ARRAY_NEW_OPERATOR (ref) - |= TYPE_HAS_ARRAY_NEW_OPERATOR (basetype); - TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype); - /* If the base-class uses multiple inheritance, so do we. */ - TYPE_USES_MULTIPLE_INHERITANCE (ref) - |= TYPE_USES_MULTIPLE_INHERITANCE (basetype); - /* Likewise, if converting to a base of the base may require - code, then we may need to generate code to convert to a - base as well. */ - TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) - |= TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype); - } - - i += 1; + TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1; + /* Converting to a virtual base class requires looking + up the offset of the virtual base. */ + TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) = 1; } + + if (CLASS_TYPE_P (basetype)) + { + TYPE_HAS_NEW_OPERATOR (ref) + |= TYPE_HAS_NEW_OPERATOR (basetype); + TYPE_HAS_ARRAY_NEW_OPERATOR (ref) + |= TYPE_HAS_ARRAY_NEW_OPERATOR (basetype); + TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype); + /* If the base-class uses multiple inheritance, so do we. */ + TYPE_USES_MULTIPLE_INHERITANCE (ref) + |= TYPE_USES_MULTIPLE_INHERITANCE (basetype); + /* Likewise, if converting to a base of the base may require + code, then we may need to generate code to convert to a + base as well. */ + TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (ref) + |= TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype); + } + + i += 1; } if (i) TREE_VEC_LENGTH (binfos) = i; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 6179df62656..4401dccb20f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -846,35 +846,6 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree, const char *asmspec = 0; int flags = LOOKUP_ONLYCONVERTING; - /* Convert () initializers to = initializers. */ - if (init == NULL_TREE && declarator != NULL_TREE - && TREE_CODE (declarator) == CALL_EXPR - && TREE_OPERAND (declarator, 0) - && (TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE - || TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF) - && parmlist_is_exprlist (CALL_DECLARATOR_PARMS (declarator))) - { - /* It's invalid to try to initialize a data member using a - functional notation, e.g.: - - struct S { - static int i (3); - }; - - Explain that to the user. */ - static int explained; - - error ("invalid data member initialization"); - if (!explained) - { - error ("(use `=' to initialize static data members)"); - explained = 1; - } - - declarator = TREE_OPERAND (declarator, 0); - flags = 0; - } - if (declspecs == NULL_TREE && TREE_CODE (declarator) == SCOPE_REF && TREE_CODE (TREE_OPERAND (declarator, 1)) == IDENTIFIER_NODE) @@ -1280,8 +1251,11 @@ build_anon_union_vars (tree object) else if (TREE_PROTECTED (field)) cp_pedwarn_at ("protected member `%#D' in anonymous union", field); - ref = build_class_member_access_expr (object, field, NULL_TREE, - false); + if (processing_template_decl) + ref = build_min_nt (COMPONENT_REF, object, DECL_NAME (field)); + else + ref = build_class_member_access_expr (object, field, NULL_TREE, + false); if (DECL_NAME (field)) { @@ -1327,16 +1301,15 @@ finish_anon_union (tree anon_union_decl) return; } + main_decl = build_anon_union_vars (anon_union_decl); + if (main_decl == NULL_TREE) + { + warning ("anonymous union with no members"); + return; + } + if (!processing_template_decl) { - main_decl = build_anon_union_vars (anon_union_decl); - - if (main_decl == NULL_TREE) - { - warning ("anonymous union with no members"); - return; - } - /* Use main_decl to set the mangled name. */ DECL_NAME (anon_union_decl) = DECL_NAME (main_decl); mangle_decl (anon_union_decl); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 37a7f672b92..d9bc5528ab8 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -454,8 +454,7 @@ dump_type (t, flags) break; } case TYPENAME_TYPE: - if (!IMPLICIT_TYPENAME_P (t)) - output_add_string (scratch_buffer, "typename "); + output_add_string (scratch_buffer, "typename "); dump_typename (t, flags); break; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 07b35a28fb5..75d7a6456de 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1758,6 +1758,8 @@ static bool cp_parser_simulate_error PARAMS ((cp_parser *)); static void cp_parser_check_type_definition PARAMS ((cp_parser *)); +static bool cp_parser_diagnose_invalid_type_name + (cp_parser *); static bool cp_parser_skip_to_closing_parenthesis PARAMS ((cp_parser *)); static bool cp_parser_skip_to_closing_parenthesis_or_comma @@ -2201,6 +2203,83 @@ cp_parser_check_type_definition (parser) error ("%s", parser->type_definition_forbidden_message); } +/* Check for a common situation where a type-name should be present, + but is not, and issue a sensible error message. Returns true if an + invalid type-name was detected. */ + +static bool +cp_parser_diagnose_invalid_type_name (cp_parser *parser) +{ + /* If the next two tokens are both identifiers, the code is + erroneous. The usual cause of this situation is code like: + + T t; + + where "T" should name a type -- but does not. */ + if (cp_lexer_next_token_is (parser->lexer, CPP_NAME) + && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_NAME) + { + tree name; + + /* If parsing tenatively, we should commit; we really are + looking at a declaration. */ + /* Consume the first identifier. */ + name = cp_lexer_consume_token (parser->lexer)->value; + /* Issue an error message. */ + error ("`%s' does not name a type", IDENTIFIER_POINTER (name)); + /* If we're in a template class, it's possible that the user was + referring to a type from a base class. For example: + + template struct A { typedef T X; }; + template struct B : public A { X x; }; + + The user should have said "typename A::X". */ + if (processing_template_decl && current_class_type) + { + tree b; + + for (b = TREE_CHAIN (TYPE_BINFO (current_class_type)); + b; + b = TREE_CHAIN (b)) + { + tree base_type = BINFO_TYPE (b); + if (CLASS_TYPE_P (base_type) + && cp_parser_dependent_type_p (base_type)) + { + tree field; + /* Go from a particular instantiation of the + template (which will have an empty TYPE_FIELDs), + to the main version. */ + if (CLASSTYPE_USE_TEMPLATE (base_type)) + base_type = (TREE_TYPE + (DECL_TEMPLATE_RESULT + (DECL_PRIMARY_TEMPLATE + (CLASSTYPE_TI_TEMPLATE (base_type))))); + for (field = TYPE_FIELDS (base_type); + field; + field = TREE_CHAIN (field)) + if (TREE_CODE (field) == TYPE_DECL + && DECL_NAME (field) == name) + { + error ("(perhaps `typename %T::%s' was intended)", + BINFO_TYPE (b), IDENTIFIER_POINTER (name)); + break; + } + if (field) + break; + } + } + } + /* Skip to the end of the declaration; there's no point in + trying to process it. */ + cp_parser_skip_to_end_of_statement (parser); + + return true; + } + + return false; +} + /* Consume tokens up to, and including, the next non-nested closing `)'. Returns TRUE iff we found a closing `)'. */ @@ -2744,15 +2823,21 @@ cp_parser_primary_expression (cp_parser *parser, } } - /* If unqualified name lookup fails while processing a - template, that just means that we need to do name - lookup again when the template is instantiated. */ if (!parser->scope && decl == error_mark_node && processing_template_decl) { + /* Unqualified name lookup failed while processing a + template. */ *idk = CP_PARSER_ID_KIND_UNQUALIFIED; - return build_min_nt (LOOKUP_EXPR, id_expression); + /* If the next token is a parenthesis, assume that + Koenig lookup will succeed when instantiating the + template. */ + if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) + return build_min_nt (LOOKUP_EXPR, id_expression); + /* If we're not doing Koenig lookup, issue an error. */ + error ("`%D' has not been declared", id_expression); + return error_mark_node; } else if (decl == error_mark_node && !processing_template_decl) @@ -3521,7 +3606,12 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, : new_scope); /* If it is a class scope, try to complete it; we are about to be looking up names inside the class. */ - if (TYPE_P (parser->scope)) + if (TYPE_P (parser->scope) + /* Since checking types for dependency can be expensive, + avoid doing it if the type is already complete. */ + && !COMPLETE_TYPE_P (parser->scope) + /* Do not try to complete dependent types. */ + && !cp_parser_dependent_type_p (parser->scope)) complete_type (parser->scope); } @@ -6656,6 +6746,21 @@ cp_parser_simple_declaration (parser, function_definition_allowed_p) /* We no longer need to defer access checks. */ stop_deferring_access_checks (); + /* If the next two tokens are both identifiers, the code is + erroneous. The usual cause of this situation is code like: + + T t; + + where "T" should name a type -- but does not. */ + if (cp_parser_diagnose_invalid_type_name (parser)) + { + /* If parsing tenatively, we should commit; we really are + looking at a declaration. */ + cp_parser_commit_to_tentative_parse (parser); + /* Give up. */ + return; + } + /* Keep going until we hit the `;' at the end of the simple declaration. */ saw_declarator = false; @@ -12061,6 +12166,9 @@ cp_parser_member_declaration (parser) CP_PARSER_FLAGS_OPTIONAL, &prefix_attributes, &declares_class_or_enum); + /* Check for an invalid type-name. */ + if (cp_parser_diagnose_invalid_type_name (parser)) + return; /* If there is no declarator, then the decl-specifier-seq should specify a type. */ if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) @@ -13818,7 +13926,11 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) cp_token *next_token; /* The common case is that this is not a constructor declarator, so - try to avoid doing lots of work if at all possible. */ + try to avoid doing lots of work if at all possible. It's not + valid declare a constructor at function scope. */ + if (at_function_scope_p ()) + return false; + /* And only certain tokens can begin a constructor declarator. */ next_token = cp_lexer_peek_token (parser->lexer); if (next_token->type != CPP_NAME && next_token->type != CPP_SCOPE @@ -13853,7 +13965,7 @@ cp_parser_constructor_declarator_p (cp_parser *parser, bool friend_p) { /* If we have: - template struct S { S(); } + template struct S { S(); }; template S::S (); we must recognize that the nested `S' names a class. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 133318d169c..91cf89cb5f6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5152,63 +5152,26 @@ instantiate_class_template (type) /* Figure out which arguments are being used to do the instantiation. */ args = CLASSTYPE_TI_ARGS (type); - PARTIAL_INSTANTIATION_P (type) = uses_template_parms (args); - - if (pedantic && PARTIAL_INSTANTIATION_P (type)) - /* If this is a partial instantiation, then we can't instantiate - the type; there's no telling whether or not one of the - template parameters might eventually be instantiated to some - value that results in a specialization being used. For - example, consider: - - template - struct S {}; - - template - void f(S); - - template <> - struct S {}; - - Now, the `S' in `f' is the specialization, not an - instantiation of the original template. */ - return type; /* Determine what specialization of the original template to instantiate. */ - if (PARTIAL_INSTANTIATION_P (type)) - /* There's no telling which specialization is appropriate at this - point. Since all peeking at the innards of this partial - instantiation are extensions (like the "implicit typename" - extension, which allows users to omit the keyword `typename' on - names that are declared as types in template base classes), we - are free to do what we please. - - Trying to figure out which partial instantiation to use can - cause a crash. (Some of the template arguments don't even have - types.) So, we just use the most general version. */ - t = NULL_TREE; - else + t = most_specialized_class (template, args); + if (t == error_mark_node) { - t = most_specialized_class (template, args); - - if (t == error_mark_node) + const char *str = "candidates are:"; + error ("ambiguous class template instantiation for `%#T'", type); + for (t = DECL_TEMPLATE_SPECIALIZATIONS (template); t; + t = TREE_CHAIN (t)) { - const char *str = "candidates are:"; - error ("ambiguous class template instantiation for `%#T'", type); - for (t = DECL_TEMPLATE_SPECIALIZATIONS (template); t; - t = TREE_CHAIN (t)) + if (get_class_bindings (TREE_VALUE (t), TREE_PURPOSE (t), + args)) { - if (get_class_bindings (TREE_VALUE (t), TREE_PURPOSE (t), - args)) - { - cp_error_at ("%s %+#T", str, TREE_TYPE (t)); - str = " "; - } + cp_error_at ("%s %+#T", str, TREE_TYPE (t)); + str = " "; } - TYPE_BEING_DEFINED (type) = 1; - return error_mark_node; } + TYPE_BEING_DEFINED (type) = 1; + return error_mark_node; } if (t) @@ -5221,26 +5184,6 @@ instantiate_class_template (type) if (!COMPLETE_TYPE_P (pattern)) return type; - /* If this is a partial instantiation, don't tsubst anything. We will - only use this type for implicit typename, so the actual contents don't - matter. All that matters is whether a particular name is a type. */ - if (PARTIAL_INSTANTIATION_P (type)) - { - /* The fields set here must be kept in sync with those cleared - in begin_class_definition. */ - TYPE_BINFO_BASETYPES (type) = TYPE_BINFO_BASETYPES (pattern); - TYPE_FIELDS (type) = TYPE_FIELDS (pattern); - TYPE_METHODS (type) = TYPE_METHODS (pattern); - CLASSTYPE_DECL_LIST (type) = CLASSTYPE_DECL_LIST (pattern); - CLASSTYPE_TAGS (type) = CLASSTYPE_TAGS (pattern); - CLASSTYPE_VBASECLASSES (type) = CLASSTYPE_VBASECLASSES (pattern); - - /* Pretend that the type is complete, so that we will look - inside it during name lookup and such. */ - TYPE_SIZE (type) = bitsize_zero_node; - return type; - } - /* If we've recursively instantiated too many templates, stop. */ if (! push_tinst_level (type)) return type; diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 0895a76567f..29ee667d1fb 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1350,7 +1350,7 @@ lookup_field_r (binfo, data) } else { - if (from_dep_base_p && TREE_CODE (nval) != TYPE_DECL + if (from_dep_base_p && TREE_CODE (nval) == TYPE_DECL /* We need to return a member template class so we can define partial specializations. Is there a better way? */ @@ -1500,9 +1500,7 @@ lookup_member (xbasetype, name, protect, want_type) /* If the thing we found was found via the implicit typename extension, build the typename type. */ if (rval && lfi.from_dep_base_p && !DECL_CLASS_TEMPLATE_P (rval)) - rval = TYPE_STUB_DECL (build_typename_type (BINFO_TYPE (basetype_path), - name, name, - TREE_TYPE (rval))); + abort (); if (rval && is_overloaded_fn (rval)) rval = build_baselink (rval_binfo, basetype_path, rval, @@ -2187,6 +2185,7 @@ marked_pushdecls_p (binfo, data) void *data ATTRIBUTE_UNUSED; { return (CLASS_TYPE_P (BINFO_TYPE (binfo)) + && !dependent_base_p (binfo) && BINFO_PUSHDECLS_MARKED (binfo)) ? binfo : NULL_TREE; } @@ -2196,6 +2195,7 @@ unmarked_pushdecls_p (binfo, data) void *data ATTRIBUTE_UNUSED; { return (CLASS_TYPE_P (BINFO_TYPE (binfo)) + && !dependent_base_p (binfo) && !BINFO_PUSHDECLS_MARKED (binfo)) ? binfo : NULL_TREE; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e3ae9be7a9a..adba8a5172a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1797,11 +1797,6 @@ begin_class_definition (t) error ("definition of `%#T' inside template parameter list", t); return error_mark_node; } - - /* In a definition of a member class template, we will get here with - an implicit typename. */ - if (IMPLICIT_TYPENAME_P (t)) - t = TREE_TYPE (t); /* A non-implicit typename comes from code like: template struct A { @@ -1820,56 +1815,9 @@ begin_class_definition (t) pushtag (make_anon_name (), t, 0); } - /* If we generated a partial instantiation of this type, but now - we're seeing a real definition, we're actually looking at a - partial specialization. Consider: - - template - struct Y {}; - - template - struct X {}; - - template - void f() - { - typename X >::A a; - } - - template - struct X > - { - }; - - We have to undo the effects of the previous partial - instantiation. */ - if (PARTIAL_INSTANTIATION_P (t)) - { - if (!pedantic) - { - /* Unfortunately, when we're not in pedantic mode, we - attempt to actually fill in some of the fields of the - partial instantiation, in order to support the implicit - typename extension. Clear those fields now, in - preparation for the definition here. The fields cleared - here must match those set in instantiate_class_template. - Look for a comment mentioning begin_class_definition - there. */ - TYPE_BINFO_BASETYPES (t) = NULL_TREE; - TYPE_FIELDS (t) = NULL_TREE; - TYPE_METHODS (t) = NULL_TREE; - CLASSTYPE_DECL_LIST (t) = NULL_TREE; - CLASSTYPE_TAGS (t) = NULL_TREE; - CLASSTYPE_VBASECLASSES (t) = NULL_TREE; - TYPE_SIZE (t) = NULL_TREE; - } - - /* This isn't a partial instantiation any more. */ - PARTIAL_INSTANTIATION_P (t) = 0; - } /* If this type was already complete, and we see another definition, that's an error. */ - else if (COMPLETE_TYPE_P (t)) + if (COMPLETE_TYPE_P (t)) duplicate_tag_error (t); /* Update the location of the decl. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f40783f0488..55e4028613f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,33 @@ +2003-01-16 Mark Mitchell + + * gcc/testsuite/g++.dg/ext/typename1.C: Add typename keyword. + * gcc/testsuite/g++.dg/template/crash1.C: Update error messages. + * gcc/testsuite/g++.dg/template/crash2.C: Remove error message. + * gcc/testsuite/g++.dg/parse/typename2.C: New test. + * gcc/testsuite/g++.dg/template/typename2.C: Change implicit + typename warning into error. + * gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C: Issue more + error messages. + * gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C: Fix typos. + * gcc/testsuite/g++.old-deja/g++.brendan/crash56.C: Add this->. + * gcc/testsuite/g++.old-deja/g++.law/visibility13.C: Remove error + messages. + * gcc/testsuite/g++.old-deja/g++.ns/template17.C: Reorder code to + make declaration visible in template. + * gcc/testsuite/g++.old-deja/g++.pt/crash3.C: Fix typos. + * gcc/testsuite/g++.old-deja/g++.pt/crash36.C: Issue more error + messages. + * gcc/testsuite/g++.old-deja/g++.pt/crash5.C: Improve error + message. + * gcc/testsuite/g++.old-deja/g++.pt/crash67.C: Remove warning. + * gcc/testsuite/g++.old-deja/g++.pt/inherit1.C: Add this->. + * gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C: Add error message. + * gcc/testsuite/g++.old-deja/g++.pt/typename16.C: Replace implicit + typename warning with error message. + * gcc/testsuite/g++.old-deja/g++.pt/typename19.C: Remove warning. + * gcc/testsuite/g++.old-deja/g++.robertl/eb112.C: Fix typo. + * gcc/testsuite/g++.old-deja/g++.robertl/eb24.C: Use this->. + 2003-01-16 Nathan Sidwell * g++.dg/parse/ambig2.C: New test. diff --git a/gcc/testsuite/g++.dg/ext/typename1.C b/gcc/testsuite/g++.dg/ext/typename1.C index f66210ff506..cb9f4a7fc6c 100644 --- a/gcc/testsuite/g++.dg/ext/typename1.C +++ b/gcc/testsuite/g++.dg/ext/typename1.C @@ -3,5 +3,5 @@ template struct A { typedef int X; }; template struct B { typedef A Y; void f (typename Y::X); }; -template struct C : public B { void g (typename Y::X); }; +template struct C : public B { void g (typename B::Y::X); }; template class B; diff --git a/gcc/testsuite/g++.dg/parse/typename2.C b/gcc/testsuite/g++.dg/parse/typename2.C new file mode 100644 index 00000000000..8878497ad2f --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/typename2.C @@ -0,0 +1,17 @@ +template +struct UnaryReturn { + typedef T Type_t; +}; + +struct foo +{ + template + typename UnaryReturn::Type_t + bar(); +}; + +template +struct UnaryReturn { + typedef bool Type_t; +}; + diff --git a/gcc/testsuite/g++.dg/template/crash1.C b/gcc/testsuite/g++.dg/template/crash1.C index 3879ad5abda..16d584e0fbb 100644 --- a/gcc/testsuite/g++.dg/template/crash1.C +++ b/gcc/testsuite/g++.dg/template/crash1.C @@ -1,6 +1,6 @@ // { dg-do compile } -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 29 Dec 2001 // PR 5125. ICE @@ -12,6 +12,6 @@ class S }; template -void S::Foo(int (*f)(TYPO&o) ) // { dg-error "Foo" } +void S::Foo(int (*f)(TYPO&o) ) // { dg-error "Foo|f|TYPO|o" } { // { dg-error "expected `;'" } } diff --git a/gcc/testsuite/g++.dg/template/crash2.C b/gcc/testsuite/g++.dg/template/crash2.C index e6cc965ff03..a02787a46fa 100644 --- a/gcc/testsuite/g++.dg/template/crash2.C +++ b/gcc/testsuite/g++.dg/template/crash2.C @@ -17,7 +17,7 @@ enum E { max = 5 }; struct B { - A a; // { dg-error "" } + A a; }; } diff --git a/gcc/testsuite/g++.dg/template/typename2.C b/gcc/testsuite/g++.dg/template/typename2.C index 0ca1163f425..644c62a7f4c 100644 --- a/gcc/testsuite/g++.dg/template/typename2.C +++ b/gcc/testsuite/g++.dg/template/typename2.C @@ -1,7 +1,7 @@ // { dg-do compile } // { dg-options "" } -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 21 Mar 2002 // PR 5507. Overzealous implicit typename warning @@ -21,5 +21,5 @@ class ctype : public __ctype_abstract_base<_CharT> template class ctype2 : public __ctype_abstract_base<_CharT> { - typedef mask mask; // { dg-warning "(implicitly a typename)|(implicit typename)" "" } + typedef mask mask; // { dg-error "" } }; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C index 1dae2a97eae..80490e92551 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C @@ -127,7 +127,7 @@ public: friend bool foo(T161 u) { Xseven obj; // ERROR - .* - return (obj.inst == u.inst); + return (obj.inst == u.inst); // ERROR - .* } }; @@ -192,10 +192,10 @@ template // ERROR - .* struct Xthirteen { template long comp_ge(long test) {// ERROR - . long local_value; - if (local_value > value) + if (local_value > value) // ERROR - .* return local_value; else - return value; + return value; // ERROR - .* } }; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C index 0330d0bbd0a..3c01be739bc 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C @@ -115,7 +115,7 @@ protected: template struct Xtwenty { void f(){ T17 my_type; //ok - for (int j = 0; j < 5; ++l) + for (int j = 0; j < 5; ++j) { T17 my_type; //ok ++my_type; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C index fc6af32938c..0523f1fe31b 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem05.C @@ -51,7 +51,7 @@ unsigned short X_one::ret_id() { export template // WARNING - bool compare_ge(T2 test) { - if (test > type) + if (test > type) // ERROR - .* return true; return false; } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C index 739dfcba030..78c291bf4c5 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash56.C @@ -273,10 +273,10 @@ template void SetLD::remove(const T& item) { - typename ListD::Action a = NORMAL; + typename ListD::Action a = this->NORMAL; Vix x; - for (first(x); 0 != x && REMOVE_CURRENT != a; next(x, a)) - a = operator()(x) == item ? REMOVE_CURRENT: NORMAL;// ERROR - .* + for (first(x); 0 != x && this->REMOVE_CURRENT != a; next(x, a)) + a = operator()(x) == item ? this->REMOVE_CURRENT: this->NORMAL; // ERROR - .* } template bool diff --git a/gcc/testsuite/g++.old-deja/g++.law/visibility13.C b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C index 472d5a2da81..2a741512423 100644 --- a/gcc/testsuite/g++.old-deja/g++.law/visibility13.C +++ b/gcc/testsuite/g++.old-deja/g++.law/visibility13.C @@ -25,8 +25,8 @@ public: virtual Type& operator[](int ix) { return ia[ix]; } private: void init(const Type*, int); - int size; // ERROR - private - int *ia; // ERROR - private + int size; + int *ia; }; template diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template17.C b/gcc/testsuite/g++.old-deja/g++.ns/template17.C index 11f21c921e1..a441ebe5b2a 100644 --- a/gcc/testsuite/g++.old-deja/g++.ns/template17.C +++ b/gcc/testsuite/g++.old-deja/g++.ns/template17.C @@ -1,6 +1,6 @@ // Build don't link: // -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 29 Apr 2001 // Bug 2258. We failed to implement using directives inside template @@ -16,6 +16,11 @@ namespace whatever template void fn (T, T (*)(T)); +namespace whatever +{ + template T end3 (T); +} + template void mycout(const T& data) { using namespace thing; @@ -25,11 +30,6 @@ template void mycout(const T& data) fn (data, end3); } -namespace whatever -{ - template T end3 (T); -} - int main() { double data = 5.0; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash3.C b/gcc/testsuite/g++.old-deja/g++.pt/crash3.C index 0d2a7cd935d..a6133e17344 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash3.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash3.C @@ -5,12 +5,12 @@ class CVector { public: CVector f() const { - CVector v(n); + CVector v(); return v; } CVector g() const { - CVector v(n); + CVector v(); return v; } }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C index f9cbed2c60e..938591fd13e 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C @@ -29,7 +29,7 @@ struct list { reverse_iterator > rbegin() { return reverse_iterator > // ERROR - no type|instantiated here - (list_iterator(Head->next())); } + (list_iterator(Head->next())); } // ERROR - not declared }; template class list; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash5.C b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C index 99a77916287..c36f5d786c3 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash5.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash5.C @@ -1,12 +1,12 @@ // Build don't link: template -struct K { // ERROR - forward declaration +struct K { void f(); }; template void -K::f() -{ // ERROR - template parameters +K::f() // ERROR - i has not been declared +{ } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash67.C b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C index b532e3d22e9..646763a4be7 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash67.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash67.C @@ -1,7 +1,7 @@ // Build don't link: // Special g++ Options: // -// Copyright (C) 2001 Free Software Foundation, Inc. +// Copyright (C) 2001, 2003 Free Software Foundation, Inc. // Contributed by Nathan Sidwell 6 May 2001 // Bug 2526. We ICE'd after diagnosing dependent name confusion in @@ -16,5 +16,5 @@ struct B template struct D : B { - friend class Mother; // WARNING - defines namespace class + friend class Mother; }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C b/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C index 6ae70c1bb9e..3fb56565435 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/inherit1.C @@ -14,7 +14,7 @@ template class FinalClass : public Derived { public: FinalClass () { - if (&local1 != &local2) + if (&this->local1 != &this->local2) i = 0; } }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C b/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C index 027f2ae9595..131964b4375 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C @@ -1,6 +1,6 @@ // Build don't link: -struct A { +struct A { // ERROR - forward declaration friend struct B : A { // ERROR - int x; }; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename16.C b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C index 225cc894a05..f40a6a28229 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename16.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename16.C @@ -11,7 +11,7 @@ struct D1 : public B { template struct D2 : public D1 { - I i; // WARNING - implicit typename + I i; // ERROR - not a type }; template <> @@ -27,5 +27,5 @@ void f(double) {} int main() { D2 d2i; - f(d2i.i); + f(d2i.i); // ERROR - no member i } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/typename19.C b/gcc/testsuite/g++.old-deja/g++.pt/typename19.C index be93a983267..332f294d7cf 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/typename19.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/typename19.C @@ -12,7 +12,7 @@ struct S { template struct I : public O { - static X x; // WARNING - lookup finds S::X + static X x; }; }; diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C index 3233287ff10..c0231b70955 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb112.C @@ -4,8 +4,7 @@ setback(MEMBER *bp, MEMBER STRUCT::*offset) { // The implementation of this function may be platform dependend if(!bp) return 0; // NULL pointers remain NULL - union { int i; MEMBER STRUCT::*of; } u; // Switch types. Casting won't -+work. + union { int i; MEMBER STRUCT::*of; } u; // Switch types. Casting won't work. u.of = offset; return (STRUCT *) ((int) bp - u.i); } diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C index 7ea7b41205b..528af4c4dee 100644 --- a/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C +++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb24.C @@ -19,5 +19,5 @@ class Y : public X using X::x; - void f () { std::cout << x << std::endl; } + void f () { std::cout << this->x << std::endl; } }; diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c25586edf8d..901776ef834 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,29 @@ +2003-01-16 Mark Mitchell + Jeffrey Oldham + + * config/locale/gnu/messages_members.h: Use this-> to refer to + unqualified members of base clasess. + * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Likewise. + * include/bits/codecvt.h: Likewise. + * include/bits/deque.tcc: Likewise. + * include/bits/fstream.tcc: Likewise. + * include/bits/istream.tcc: Likewise. + * include/bits/list.tcc: Likewise. + * include/bits/locale_facets.h: Likewise. + * include/bits/ostream.tcc: Likewise. + * include/bits/sstream.tcc: Likewise. + * include/bits/stl_bvector.h: Likewise. + * include/bits/stl_deque.h: Likewise. + * include/bits/stl_list.h: Likewise. + * include/bits/stl_tree.h: Likewise. + * include/bits/stl_vector.h: Likewise. + * include/bits/vector.tcc: Likewise. + * include/ext/ropeimpl.h: Likewise. + * include/ext/stdio_filebuf.h: Likewise. + * include/ext/stl_rope.h: Likewise. + * include/std/std_fstream.h: Likewise. + * include/std/std_sstream.h: Likewise. + 2003-01-15 Phil Edwards * include/bits/basic_string.tcc (_S_string_copy): Unused, remove. diff --git a/libstdc++-v3/config/locale/gnu/messages_members.h b/libstdc++-v3/config/locale/gnu/messages_members.h index c8d62ade4ce..8cab730acfa 100644 --- a/libstdc++-v3/config/locale/gnu/messages_members.h +++ b/libstdc++-v3/config/locale/gnu/messages_members.h @@ -99,11 +99,11 @@ : messages<_CharT>(__refs) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - if (_S_c_name != _M_name_messages) - delete [] _M_name_messages; - _M_name_messages = new char[strlen(__s) + 1]; - strcpy(_M_name_messages, __s); + if (this->_S_c_name != this->_M_name_messages) + delete [] this->_M_name_messages; + this->_M_name_messages = new char[strlen(__s) + 1]; + strcpy(this->_M_name_messages, __s); #endif - _S_destroy_c_locale(_M_c_locale_messages); - _S_create_c_locale(_M_c_locale_messages, __s); + _S_destroy_c_locale(this->_M_c_locale_messages); + _S_create_c_locale(this->_M_c_locale_messages, __s); } diff --git a/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h b/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h index 2dee9d6390b..1921905dfe5 100644 --- a/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h +++ b/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h @@ -1,6 +1,6 @@ // Locale support (codecvt) -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003 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 @@ -260,7 +260,7 @@ extern_type* __to, extern_type* __to_end, extern_type*& __to_next) const { - result __ret = error; + result __ret = codecvt_base::error; if (__state._M_good()) { typedef state_type::__desc_type __desc_type; @@ -304,7 +304,7 @@ { __from_next = reinterpret_cast(__cfrom); __to_next = reinterpret_cast(__cto); - __ret = ok; + __ret = codecvt_base::ok; } else { @@ -312,10 +312,10 @@ { __from_next = reinterpret_cast(__cfrom); __to_next = reinterpret_cast(__cto); - __ret = partial; + __ret = codecvt_base::partial; } else - __ret = error; + __ret = codecvt_base::error; } } return __ret; @@ -327,7 +327,7 @@ do_unshift(state_type& __state, extern_type* __to, extern_type* __to_end, extern_type*& __to_next) const { - result __ret = error; + result __ret = codecvt_base::error; if (__state._M_good()) { typedef state_type::__desc_type __desc_type; @@ -345,14 +345,14 @@ { __to_next = reinterpret_cast(__cto); if (__tlen == __tmultiple * (__to_end - __to)) - __ret = noconv; + __ret = codecvt_base::noconv; else if (__tlen == 0) - __ret = ok; + __ret = codecvt_base::ok; else - __ret = partial; + __ret = codecvt_base::partial; } else - __ret = error; + __ret = codecvt_base::error; } return __ret; } @@ -365,7 +365,7 @@ intern_type* __to, intern_type* __to_end, intern_type*& __to_next) const { - result __ret = error; + result __ret = codecvt_base::error; if (__state._M_good()) { typedef state_type::__desc_type __desc_type; @@ -410,7 +410,7 @@ { __from_next = reinterpret_cast(__cfrom); __to_next = reinterpret_cast(__cto); - __ret = ok; + __ret = codecvt_base::ok; } else { @@ -418,10 +418,10 @@ { __from_next = reinterpret_cast(__cfrom); __to_next = reinterpret_cast(__cto); - __ret = partial; + __ret = codecvt_base::partial; } else - __ret = error; + __ret = codecvt_base::error; } } return __ret; diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h index 92b0f0e8a7d..c88c29d2cd0 100644 --- a/libstdc++-v3/include/bits/codecvt.h +++ b/libstdc++-v3/include/bits/codecvt.h @@ -1,6 +1,6 @@ // Locale support (codecvt) -*- C++ -*- -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003 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 @@ -341,9 +341,9 @@ codecvt_byname(const char* __s, size_t __refs = 0) : codecvt<_InternT, _ExternT, _StateT>(__refs) { - if (_M_c_locale_codecvt != _S_c_locale) - _S_destroy_c_locale(_M_c_locale_codecvt); - _S_create_c_locale(_M_c_locale_codecvt, __s); + if (this->_M_c_locale_codecvt != this->_S_c_locale) + _S_destroy_c_locale(this->_M_c_locale_codecvt); + _S_create_c_locale(this->_M_c_locale_codecvt, __s); } protected: diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index 347027f2aeb..d4143f4f155 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -1,6 +1,6 @@ // Deque implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -72,12 +72,12 @@ namespace std if (&__x != this) { if (__len >= __x.size()) - erase(copy(__x.begin(), __x.end(), _M_start), _M_finish); + erase(copy(__x.begin(), __x.end(), this->_M_start), this->_M_finish); else { const_iterator __mid = __x.begin() + difference_type(__len); - copy(__x.begin(), __mid, _M_start); - insert(_M_finish, __mid, __x.end()); + copy(__x.begin(), __mid, this->_M_start); + insert(this->_M_finish, __mid, __x.end()); } } return *this; @@ -88,15 +88,15 @@ namespace std deque<_Tp,_Alloc>:: insert(iterator position, const value_type& __x) { - if (position._M_cur == _M_start._M_cur) + if (position._M_cur == this->_M_start._M_cur) { push_front(__x); - return _M_start; + return this->_M_start; } - else if (position._M_cur == _M_finish._M_cur) + else if (position._M_cur == this->_M_finish._M_cur) { push_back(__x); - iterator __tmp = _M_finish; + iterator __tmp = this->_M_finish; --__tmp; return __tmp; } @@ -111,18 +111,18 @@ namespace std { iterator __next = __position; ++__next; - size_type __index = __position - _M_start; + size_type __index = __position - this->_M_start; if (__index < (size() >> 1)) { - copy_backward(_M_start, __position, __next); + copy_backward(this->_M_start, __position, __next); pop_front(); } else { - copy(__next, _M_finish, __position); + copy(__next, this->_M_finish, __position); pop_back(); } - return _M_start + __index; + return this->_M_start + __index; } template @@ -130,32 +130,33 @@ namespace std deque<_Tp,_Alloc>:: erase(iterator __first, iterator __last) { - if (__first == _M_start && __last == _M_finish) + if (__first == this->_M_start && __last == this->_M_finish) { clear(); - return _M_finish; + return this->_M_finish; } else { difference_type __n = __last - __first; - difference_type __elems_before = __first - _M_start; + difference_type __elems_before = __first - this->_M_start; if (static_cast(__elems_before) < (size() - __n) / 2) { - copy_backward(_M_start, __first, __last); - iterator __new_start = _M_start + __n; - _Destroy(_M_start, __new_start); - _M_destroy_nodes(_M_start._M_node, __new_start._M_node); - _M_start = __new_start; + copy_backward(this->_M_start, __first, __last); + iterator __new_start = this->_M_start + __n; + _Destroy(this->_M_start, __new_start); + _M_destroy_nodes(this->_M_start._M_node, __new_start._M_node); + this->_M_start = __new_start; } else { - copy(__last, _M_finish, __first); - iterator __new_finish = _M_finish - __n; - _Destroy(__new_finish, _M_finish); - _M_destroy_nodes(__new_finish._M_node + 1, _M_finish._M_node + 1); - _M_finish = __new_finish; + copy(__last, this->_M_finish, __first); + iterator __new_finish = this->_M_finish - __n; + _Destroy(__new_finish, this->_M_finish); + _M_destroy_nodes(__new_finish._M_node + 1, + this->_M_finish._M_node + 1); + this->_M_finish = __new_finish; } - return _M_start + __elems_before; + return this->_M_start + __elems_before; } } @@ -164,24 +165,24 @@ namespace std deque<_Tp,_Alloc>:: clear() { - for (_Map_pointer __node = _M_start._M_node + 1; - __node < _M_finish._M_node; + for (_Map_pointer __node = this->_M_start._M_node + 1; + __node < this->_M_finish._M_node; ++__node) { _Destroy(*__node, *__node + _S_buffer_size()); _M_deallocate_node(*__node); } - if (_M_start._M_node != _M_finish._M_node) + if (this->_M_start._M_node != this->_M_finish._M_node) { - _Destroy(_M_start._M_cur, _M_start._M_last); - _Destroy(_M_finish._M_first, _M_finish._M_cur); - _M_deallocate_node(_M_finish._M_first); + _Destroy(this->_M_start._M_cur, this->_M_start._M_last); + _Destroy(this->_M_finish._M_first, this->_M_finish._M_cur); + _M_deallocate_node(this->_M_finish._M_first); } else - _Destroy(_M_start._M_cur, _M_finish._M_cur); + _Destroy(this->_M_start._M_cur, this->_M_finish._M_cur); - _M_finish = _M_start; + this->_M_finish = this->_M_start; } template @@ -204,31 +205,32 @@ namespace std deque<_Tp,_Alloc>:: _M_fill_insert(iterator __pos, size_type __n, const value_type& __x) { - if (__pos._M_cur == _M_start._M_cur) + if (__pos._M_cur == this->_M_start._M_cur) { iterator __new_start = _M_reserve_elements_at_front(__n); try { - uninitialized_fill(__new_start, _M_start, __x); - _M_start = __new_start; + uninitialized_fill(__new_start, this->_M_start, __x); + this->_M_start = __new_start; } catch(...) { - _M_destroy_nodes(__new_start._M_node, _M_start._M_node); + _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); __throw_exception_again; } } - else if (__pos._M_cur == _M_finish._M_cur) + else if (__pos._M_cur == this->_M_finish._M_cur) { iterator __new_finish = _M_reserve_elements_at_back(__n); try { - uninitialized_fill(_M_finish, __new_finish, __x); - _M_finish = __new_finish; + uninitialized_fill(this->_M_finish, __new_finish, __x); + this->_M_finish = __new_finish; } catch(...) { - _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1); + _M_destroy_nodes(this->_M_finish._M_node + 1, + __new_finish._M_node + 1); __throw_exception_again; } } @@ -244,13 +246,17 @@ namespace std _Map_pointer __cur; try { - for (__cur = _M_start._M_node; __cur < _M_finish._M_node; ++__cur) + for (__cur = this->_M_start._M_node; + __cur < this->_M_finish._M_node; + ++__cur) uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value); - uninitialized_fill(_M_finish._M_first, _M_finish._M_cur, __value); + uninitialized_fill(this->_M_finish._M_first, + this->_M_finish._M_cur, + __value); } catch(...) { - _Destroy(_M_start, iterator(*__cur, __cur)); + _Destroy(this->_M_start, iterator(*__cur, __cur)); __throw_exception_again; } } @@ -288,8 +294,8 @@ namespace std _Map_pointer __cur_node; try { - for (__cur_node = _M_start._M_node; - __cur_node < _M_finish._M_node; + for (__cur_node = this->_M_start._M_node; + __cur_node < this->_M_finish._M_node; ++__cur_node) { _ForwardIterator __mid = __first; @@ -297,11 +303,11 @@ namespace std uninitialized_copy(__first, __mid, *__cur_node); __first = __mid; } - uninitialized_copy(__first, __last, _M_finish._M_first); + uninitialized_copy(__first, __last, this->_M_finish._M_first); } catch(...) { - _Destroy(_M_start, iterator(*__cur_node, __cur_node)); + _Destroy(this->_M_start, iterator(*__cur_node, __cur_node)); __throw_exception_again; } } @@ -314,16 +320,16 @@ namespace std { value_type __t_copy = __t; _M_reserve_map_at_back(); - *(_M_finish._M_node + 1) = _M_allocate_node(); + *(this->_M_finish._M_node + 1) = _M_allocate_node(); try { - _Construct(_M_finish._M_cur, __t_copy); - _M_finish._M_set_node(_M_finish._M_node + 1); - _M_finish._M_cur = _M_finish._M_first; + _Construct(this->_M_finish._M_cur, __t_copy); + this->_M_finish._M_set_node(this->_M_finish._M_node + 1); + this->_M_finish._M_cur = this->_M_finish._M_first; } catch(...) { - _M_deallocate_node(*(_M_finish._M_node + 1)); + _M_deallocate_node(*(this->_M_finish._M_node + 1)); __throw_exception_again; } } @@ -336,17 +342,17 @@ namespace std { value_type __t_copy = __t; _M_reserve_map_at_front(); - *(_M_start._M_node - 1) = _M_allocate_node(); + *(this->_M_start._M_node - 1) = _M_allocate_node(); try { - _M_start._M_set_node(_M_start._M_node - 1); - _M_start._M_cur = _M_start._M_last - 1; - _Construct(_M_start._M_cur, __t_copy); + this->_M_start._M_set_node(this->_M_start._M_node - 1); + this->_M_start._M_cur = this->_M_start._M_last - 1; + _Construct(this->_M_start._M_cur, __t_copy); } catch(...) { - ++_M_start; - _M_deallocate_node(*(_M_start._M_node - 1)); + ++this->_M_start; + _M_deallocate_node(*(this->_M_start._M_node - 1)); __throw_exception_again; } } @@ -356,10 +362,10 @@ namespace std void deque<_Tp,_Alloc>:: _M_pop_back_aux() { - _M_deallocate_node(_M_finish._M_first); - _M_finish._M_set_node(_M_finish._M_node - 1); - _M_finish._M_cur = _M_finish._M_last - 1; - _Destroy(_M_finish._M_cur); + _M_deallocate_node(this->_M_finish._M_first); + this->_M_finish._M_set_node(this->_M_finish._M_node - 1); + this->_M_finish._M_cur = this->_M_finish._M_last - 1; + _Destroy(this->_M_finish._M_cur); } // Called only if _M_start._M_cur == _M_start._M_last - 1. Note that @@ -370,10 +376,10 @@ namespace std void deque<_Tp,_Alloc>:: _M_pop_front_aux() { - _Destroy(_M_start._M_cur); - _M_deallocate_node(_M_start._M_first); - _M_start._M_set_node(_M_start._M_node + 1); - _M_start._M_cur = _M_start._M_first; + _Destroy(this->_M_start._M_cur); + _M_deallocate_node(this->_M_start._M_first); + this->_M_start._M_set_node(this->_M_start._M_node + 1); + this->_M_start._M_cur = this->_M_start._M_first; } template @@ -396,31 +402,32 @@ namespace std forward_iterator_tag) { size_type __n = std::distance(__first, __last); - if (__pos._M_cur == _M_start._M_cur) + if (__pos._M_cur == this->_M_start._M_cur) { iterator __new_start = _M_reserve_elements_at_front(__n); try { uninitialized_copy(__first, __last, __new_start); - _M_start = __new_start; + this->_M_start = __new_start; } catch(...) { - _M_destroy_nodes(__new_start._M_node, _M_start._M_node); + _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); __throw_exception_again; } } - else if (__pos._M_cur == _M_finish._M_cur) + else if (__pos._M_cur == this->_M_finish._M_cur) { iterator __new_finish = _M_reserve_elements_at_back(__n); try { - uninitialized_copy(__first, __last, _M_finish); - _M_finish = __new_finish; + uninitialized_copy(__first, __last, this->_M_finish); + this->_M_finish = __new_finish; } catch(...) { - _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1); + _M_destroy_nodes(this->_M_finish._M_node + 1, + __new_finish._M_node + 1); __throw_exception_again; } } @@ -433,16 +440,16 @@ namespace std deque<_Tp,_Alloc>:: _M_insert_aux(iterator __pos, const value_type& __x) { - difference_type __index = __pos - _M_start; + difference_type __index = __pos - this->_M_start; value_type __x_copy = __x; // XXX copy if (static_cast(__index) < size() / 2) { push_front(front()); - iterator __front1 = _M_start; + iterator __front1 = this->_M_start; ++__front1; iterator __front2 = __front1; ++__front2; - __pos = _M_start + __index; + __pos = this->_M_start + __index; iterator __pos1 = __pos; ++__pos1; copy(__front2, __pos1, __front1); @@ -450,11 +457,11 @@ namespace std else { push_back(back()); - iterator __back1 = _M_finish; + iterator __back1 = this->_M_finish; --__back1; iterator __back2 = __back1; --__back2; - __pos = _M_start + __index; + __pos = this->_M_start + __index; copy_backward(__pos, __back2, __back1); } *__pos = __x_copy; @@ -466,66 +473,68 @@ namespace std deque<_Tp,_Alloc>:: _M_insert_aux(iterator __pos, size_type __n, const value_type& __x) { - const difference_type __elems_before = __pos - _M_start; + const difference_type __elems_before = __pos - this->_M_start; size_type __length = this->size(); value_type __x_copy = __x; if (__elems_before < difference_type(__length / 2)) { iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elems_before; + iterator __old_start = this->_M_start; + __pos = this->_M_start + __elems_before; try { if (__elems_before >= difference_type(__n)) { - iterator __start_n = _M_start + difference_type(__n); - uninitialized_copy(_M_start, __start_n, __new_start); - _M_start = __new_start; + iterator __start_n = this->_M_start + difference_type(__n); + uninitialized_copy(this->_M_start, __start_n, __new_start); + this->_M_start = __new_start; copy(__start_n, __pos, __old_start); fill(__pos - difference_type(__n), __pos, __x_copy); } else { - __uninitialized_copy_fill(_M_start, __pos, __new_start, - _M_start, __x_copy); - _M_start = __new_start; + __uninitialized_copy_fill(this->_M_start, __pos, __new_start, + this->_M_start, __x_copy); + this->_M_start = __new_start; fill(__old_start, __pos, __x_copy); } } catch(...) { - _M_destroy_nodes(__new_start._M_node, _M_start._M_node); + _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); __throw_exception_again; } } else { iterator __new_finish = _M_reserve_elements_at_back(__n); - iterator __old_finish = _M_finish; + iterator __old_finish = this->_M_finish; const difference_type __elems_after = difference_type(__length) - __elems_before; - __pos = _M_finish - __elems_after; + __pos = this->_M_finish - __elems_after; try { if (__elems_after > difference_type(__n)) { - iterator __finish_n = _M_finish - difference_type(__n); - uninitialized_copy(__finish_n, _M_finish, _M_finish); - _M_finish = __new_finish; + iterator __finish_n = this->_M_finish - difference_type(__n); + uninitialized_copy(__finish_n, this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; copy_backward(__pos, __finish_n, __old_finish); fill(__pos, __pos + difference_type(__n), __x_copy); } else { - __uninitialized_fill_copy(_M_finish, __pos + difference_type(__n), - __x_copy, __pos, _M_finish); - _M_finish = __new_finish; + __uninitialized_fill_copy(this->_M_finish, + __pos + difference_type(__n), + __x_copy, __pos, this->_M_finish); + this->_M_finish = __new_finish; fill(__pos, __old_finish, __x_copy); } } catch(...) { - _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1); + _M_destroy_nodes(this->_M_finish._M_node + 1, + __new_finish._M_node + 1); __throw_exception_again; } } @@ -539,20 +548,20 @@ namespace std _ForwardIterator __first, _ForwardIterator __last, size_type __n) { - const difference_type __elemsbefore = __pos - _M_start; + const difference_type __elemsbefore = __pos - this->_M_start; size_type __length = size(); if (static_cast(__elemsbefore) < __length / 2) { iterator __new_start = _M_reserve_elements_at_front(__n); - iterator __old_start = _M_start; - __pos = _M_start + __elemsbefore; + iterator __old_start = this->_M_start; + __pos = this->_M_start + __elemsbefore; try { if (__elemsbefore >= difference_type(__n)) { - iterator __start_n = _M_start + difference_type(__n); - uninitialized_copy(_M_start, __start_n, __new_start); - _M_start = __new_start; + iterator __start_n = this->_M_start + difference_type(__n); + uninitialized_copy(this->_M_start, __start_n, __new_start); + this->_M_start = __new_start; copy(__start_n, __pos, __old_start); copy(__first, __last, __pos - difference_type(__n)); } @@ -560,32 +569,34 @@ namespace std { _ForwardIterator __mid = __first; advance(__mid, difference_type(__n) - __elemsbefore); - __uninitialized_copy_copy(_M_start, __pos, __first, __mid, - __new_start); - _M_start = __new_start; + __uninitialized_copy_copy(this->_M_start, __pos, + __first, __mid, __new_start); + this->_M_start = __new_start; copy(__mid, __last, __old_start); } } catch(...) { - _M_destroy_nodes(__new_start._M_node, _M_start._M_node); + _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node); __throw_exception_again; } } else { iterator __new_finish = _M_reserve_elements_at_back(__n); - iterator __old_finish = _M_finish; + iterator __old_finish = this->_M_finish; const difference_type __elemsafter = difference_type(__length) - __elemsbefore; - __pos = _M_finish - __elemsafter; + __pos = this->_M_finish - __elemsafter; try { if (__elemsafter > difference_type(__n)) { - iterator __finish_n = _M_finish - difference_type(__n); - uninitialized_copy(__finish_n, _M_finish, _M_finish); - _M_finish = __new_finish; + iterator __finish_n = this->_M_finish - difference_type(__n); + uninitialized_copy(__finish_n, + this->_M_finish, + this->_M_finish); + this->_M_finish = __new_finish; copy_backward(__pos, __finish_n, __old_finish); copy(__first, __last, __pos); } @@ -594,14 +605,15 @@ namespace std _ForwardIterator __mid = __first; advance(__mid, __elemsafter); __uninitialized_copy_copy(__mid, __last, __pos, - _M_finish, _M_finish); - _M_finish = __new_finish; + this->_M_finish, this->_M_finish); + this->_M_finish = __new_finish; copy(__first, __mid, __pos); } } catch(...) { - _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1); + _M_destroy_nodes(this->_M_finish._M_node + 1, + __new_finish._M_node + 1); __throw_exception_again; } } @@ -619,12 +631,12 @@ namespace std try { for (__i = 1; __i <= __new_nodes; ++__i) - *(_M_start._M_node - __i) = _M_allocate_node(); + *(this->_M_start._M_node - __i) = _M_allocate_node(); } catch(...) { for (size_type __j = 1; __j < __i; ++__j) - _M_deallocate_node(*(_M_start._M_node - __j)); + _M_deallocate_node(*(this->_M_start._M_node - __j)); __throw_exception_again; } } @@ -641,12 +653,12 @@ namespace std try { for (__i = 1; __i <= __new_nodes; ++__i) - *(_M_finish._M_node + __i) = _M_allocate_node(); + *(this->_M_finish._M_node + __i) = _M_allocate_node(); } catch(...) { for (size_type __j = 1; __j < __i; ++__j) - _M_deallocate_node(*(_M_finish._M_node + __j)); + _M_deallocate_node(*(this->_M_finish._M_node + __j)); __throw_exception_again; } } @@ -656,37 +668,44 @@ namespace std deque<_Tp,_Alloc>:: _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front) { - size_type __old_num_nodes = _M_finish._M_node - _M_start._M_node + 1; + size_type __old_num_nodes + = this->_M_finish._M_node - this->_M_start._M_node + 1; size_type __new_num_nodes = __old_num_nodes + __nodes_to_add; _Map_pointer __new_nstart; - if (_M_map_size > 2 * __new_num_nodes) + if (this->_M_map_size > 2 * __new_num_nodes) { - __new_nstart = _M_map + (_M_map_size - __new_num_nodes) / 2 - + (__add_at_front ? __nodes_to_add : 0); - if (__new_nstart < _M_start._M_node) - copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart); + __new_nstart + = this->_M_map + (this->_M_map_size - __new_num_nodes) / 2 + + (__add_at_front ? __nodes_to_add : 0); + if (__new_nstart < this->_M_start._M_node) + copy(this->_M_start._M_node, + this->_M_finish._M_node + 1, + __new_nstart); else - copy_backward(_M_start._M_node, _M_finish._M_node + 1, + copy_backward(this->_M_start._M_node, + this->_M_finish._M_node + 1, __new_nstart + __old_num_nodes); } else { size_type __new_map_size = - _M_map_size + std::max(_M_map_size, __nodes_to_add) + 2; + this->_M_map_size + std::max(this->_M_map_size, __nodes_to_add) + 2; _Map_pointer __new_map = _M_allocate_map(__new_map_size); __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2 + (__add_at_front ? __nodes_to_add : 0); - copy(_M_start._M_node, _M_finish._M_node + 1, __new_nstart); - _M_deallocate_map(_M_map, _M_map_size); + copy(this->_M_start._M_node, + this->_M_finish._M_node + 1, + __new_nstart); + _M_deallocate_map(this->_M_map, this->_M_map_size); - _M_map = __new_map; - _M_map_size = __new_map_size; + this->_M_map = __new_map; + this->_M_map_size = __new_map_size; } - _M_start._M_set_node(__new_nstart); - _M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); + this->_M_start._M_set_node(__new_nstart); + this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1); } } // namespace std diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index e4bc382a74c..1865a92f2f4 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -1,6 +1,6 @@ // File based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -44,12 +44,12 @@ namespace std basic_filebuf<_CharT, _Traits>:: _M_allocate_internal_buffer() { - if (!_M_buf && _M_buf_size_opt) + if (!this->_M_buf && this->_M_buf_size_opt) { - _M_buf_size = _M_buf_size_opt; + this->_M_buf_size = this->_M_buf_size_opt; // Allocate internal buffer. - _M_buf = new char_type[_M_buf_size]; + this->_M_buf = new char_type[this->_M_buf_size]; _M_buf_allocated = true; } } @@ -62,8 +62,8 @@ namespace std { if (_M_buf_allocated) { - delete [] _M_buf; - _M_buf = NULL; + delete [] this->_M_buf; + this->_M_buf = NULL; _M_buf_allocated = false; this->setg(NULL, NULL, NULL); this->setp(NULL, NULL); @@ -75,7 +75,7 @@ namespace std basic_filebuf() : __streambuf_type(), _M_file(&_M_lock), _M_state_cur(__state_type()), _M_state_beg(__state_type()), _M_buf_allocated(false), _M_last_overflowed(false) - { _M_buf_unified = true; } + { this->_M_buf_unified = true; } template typename basic_filebuf<_CharT, _Traits>::__filebuf_type* @@ -89,7 +89,7 @@ namespace std if (this->is_open()) { _M_allocate_internal_buffer(); - _M_mode = __mode; + this->_M_mode = __mode; // Setup initial position of buffer. _M_set_indeterminate(); @@ -120,13 +120,14 @@ namespace std if (this->is_open()) { const int_type __eof = traits_type::eof(); - bool __testput = _M_out_cur && _M_out_beg < _M_out_end; + bool __testput = this->_M_out_cur + && this->_M_out_beg < this->_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... - _M_mode = ios_base::openmode(0); + this->_M_mode = ios_base::openmode(0); _M_destroy_internal_buffer(); _M_pback_destroy(); @@ -153,10 +154,10 @@ namespace std showmanyc() { streamsize __ret = -1; - bool __testin = _M_mode & ios_base::in; + bool __testin = this->_M_mode & ios_base::in; if (__testin && this->is_open()) - __ret = _M_in_end - _M_in_cur; + __ret = this->_M_in_end - this->_M_in_cur; _M_last_overflowed = false; return __ret; } @@ -167,42 +168,42 @@ namespace std pbackfail(int_type __i) { int_type __ret = traits_type::eof(); - bool __testin = _M_mode & ios_base::in; + bool __testin = this->_M_mode & ios_base::in; if (__testin) { - bool __testpb = _M_in_beg < _M_in_cur; + bool __testpb = this->_M_in_beg < this->_M_in_cur; char_type __c = traits_type::to_char_type(__i); bool __testeof = traits_type::eq_int_type(__i, __ret); if (__testpb) { - bool __testout = _M_mode & ios_base::out; + bool __testout = this->_M_mode & ios_base::out; bool __testeq = traits_type::eq(__c, this->gptr()[-1]); // Try to put back __c into input sequence in one of three ways. // Order these tests done in is unspecified by the standard. if (!__testeof && __testeq) { - --_M_in_cur; + --this->_M_in_cur; if (__testout) - --_M_out_cur; + --this->_M_out_cur; __ret = __i; } else if (__testeof) { - --_M_in_cur; + --this->_M_in_cur; if (__testout) - --_M_out_cur; + --this->_M_out_cur; __ret = traits_type::not_eof(__i); } else if (!__testeof) { - --_M_in_cur; + --this->_M_in_cur; if (__testout) - --_M_out_cur; + --this->_M_out_cur; _M_pback_create(); - *_M_in_cur = __c; + *this->_M_in_cur = __c; __ret = __i; } } @@ -214,10 +215,10 @@ namespace std this->underflow(); if (!__testeof) { - if (!traits_type::eq(__c, *_M_in_cur)) + if (!traits_type::eq(__c, *this->_M_in_cur)) { _M_pback_create(); - *_M_in_cur = __c; + *this->_M_in_cur = __c; } __ret = __i; } @@ -235,14 +236,15 @@ namespace std overflow(int_type __c) { int_type __ret = traits_type::eof(); - bool __testput = _M_out_cur && _M_out_cur < _M_buf + _M_buf_size; - bool __testout = _M_mode & ios_base::out; + bool __testput = this->_M_out_cur + && this->_M_out_cur < this->_M_buf + this->_M_buf_size; + bool __testout = this->_M_mode & ios_base::out; if (__testout) { if (__testput) { - *_M_out_cur = traits_type::to_char_type(__c); + *this->_M_out_cur = traits_type::to_char_type(__c); _M_out_cur_move(1); __ret = traits_type::not_eof(__c); } @@ -297,7 +299,7 @@ namespace std if (__r == codecvt_base::partial) { const char_type* __iresume = __iend; - streamsize __rlen = _M_out_end - __iend; + streamsize __rlen = this->_M_out_end - __iend; __r = __cvt.out(_M_state_cur, __iresume, __iresume + __rlen, __iend, __buf, __buf + __blen, __bend); if (__r != codecvt_base::error) @@ -319,8 +321,8 @@ namespace std _M_really_overflow(int_type __c) { int_type __ret = traits_type::eof(); - bool __testput = _M_out_cur && _M_out_beg < _M_out_end; - bool __testunbuffered = _M_file.is_open() && !_M_buf_size_opt; + bool __testput = this->_M_out_cur && this->_M_out_beg < this->_M_out_end; + bool __testunbuffered = _M_file.is_open() && !this->_M_buf_size_opt; if (__testput || __testunbuffered) { @@ -331,16 +333,17 @@ namespace std // Need to restore current position. The position of the external // byte sequence (_M_file) corresponds to _M_filepos, and we need // to move it to _M_out_beg for the write. - if (_M_filepos && _M_filepos != _M_out_beg) + if (_M_filepos && _M_filepos != this->_M_out_beg) { - off_type __off = _M_out_beg - _M_filepos; + off_type __off = this->_M_out_beg - _M_filepos; _M_file.seekoff(__off, ios_base::cur); } // Convert internal buffer to external representation, output. // NB: In the unbuffered case, no internal buffer exists. if (!__testunbuffered) - _M_convert_to_external(_M_out_beg, _M_out_end - _M_out_beg, + _M_convert_to_external(this->_M_out_beg, + this->_M_out_end - this->_M_out_beg, __elen, __plen); // Convert pending sequence to external representation, output. @@ -373,7 +376,7 @@ namespace std setbuf(char_type* __s, streamsize __n) { if (!this->is_open() && __s == 0 && __n == 0) - _M_buf_size_opt = 0; + this->_M_buf_size_opt = 0; else if (__s && __n) { // This is implementation-defined behavior, and assumes @@ -384,8 +387,8 @@ namespace std _M_destroy_internal_buffer(); // Step 2: Use the external array. - _M_buf = __s; - _M_buf_size_opt = _M_buf_size = __n; + this->_M_buf = __s; + this->_M_buf_size_opt = this->_M_buf_size = __n; _M_set_indeterminate(); } _M_last_overflowed = false; @@ -398,11 +401,11 @@ namespace std seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode) { pos_type __ret = pos_type(off_type(-1)); - bool __testin = (ios_base::in & _M_mode & __mode) != 0; - bool __testout = (ios_base::out & _M_mode & __mode) != 0; + bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; // Should probably do has_facet checks here. - int __width = use_facet<__codecvt_type>(_M_buf_locale).encoding(); + int __width = use_facet<__codecvt_type>(this->_M_buf_locale).encoding(); if (__width < 0) __width = 0; bool __testfail = __off != 0 && __width <= 0; @@ -416,8 +419,10 @@ namespace std { off_type __computed_off = __width * __off; - bool __testget = _M_in_cur && _M_in_beg < _M_in_end; - bool __testput = _M_out_cur && _M_out_beg < _M_out_end; + bool __testget = this->_M_in_cur + && this->_M_in_beg < this->_M_in_end; + bool __testput = this->_M_out_cur + && this->_M_out_beg < this->_M_out_end; // Sync the internal and external streams. // out if (__testput || _M_last_overflowed) @@ -429,7 +434,7 @@ namespace std } //in else if (__testget && __way == ios_base::cur) - __computed_off += _M_in_cur - _M_filepos; + __computed_off += this->_M_in_cur - _M_filepos; __ret = _M_file.seekoff(__computed_off, __way, __mode); _M_set_indeterminate(); @@ -439,7 +444,8 @@ namespace std else { __ret = _M_file.seekoff(__off, ios_base::cur, __mode); - __ret += std::max(_M_out_cur, _M_in_cur) - _M_filepos; + __ret += + std::max(this->_M_out_cur, this->_M_in_cur) - _M_filepos; } } _M_last_overflowed = false; @@ -470,10 +476,10 @@ namespace std { bool __testbeg = gptr() == eback() && pptr() == pbase(); - if (__testbeg && _M_buf_locale != __loc) + if (__testbeg && this->_M_buf_locale != __loc) { - _M_buf_locale = __loc; - _M_buf_locale_init = true; + this->_M_buf_locale = __loc; + this->_M_buf_locale_init = true; } // NB this may require the reconversion of previously diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 3c64fbd89e5..ea8573665ef 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -114,8 +114,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -142,8 +142,8 @@ namespace std { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); long __l; - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __l); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __l); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS // 118. basic_istream uses nonexistent num_get member functions. if (!(__err & ios_base::failbit) @@ -178,8 +178,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -206,8 +206,8 @@ namespace std { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); long __l; - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __l); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __l); #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS // 118. basic_istream uses nonexistent num_get member functions. if (!(__err & ios_base::failbit) @@ -242,8 +242,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -269,8 +269,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -296,8 +296,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -324,8 +324,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -351,8 +351,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -379,8 +379,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -406,8 +406,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -433,8 +433,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) @@ -460,8 +460,8 @@ namespace std try { ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); - if (_M_check_facet(_M_fnumget)) - _M_fnumget->get(*this, 0, *this, __err, __n); + if (_M_check_facet(this->_M_fnumget)) + this->_M_fnumget->get(*this, 0, *this, __err, __n); this->setstate(__err); } catch(exception& __fail) diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc index 898a5020c23..e4d47a2bb37 100644 --- a/libstdc++-v3/include/bits/list.tcc +++ b/libstdc++-v3/include/bits/list.tcc @@ -1,6 +1,6 @@ // List implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -69,16 +69,16 @@ namespace std __clear() { typedef _List_node<_Tp> _Node; - _Node* __cur = static_cast<_Node*>(_M_node->_M_next); - while (__cur != _M_node) + _Node* __cur = static_cast<_Node*>(this->_M_node->_M_next); + while (__cur != this->_M_node) { _Node* __tmp = __cur; __cur = static_cast<_Node*>(__cur->_M_next); _Destroy(&__tmp->_M_data); _M_put_node(__tmp); } - _M_node->_M_next = _M_node; - _M_node->_M_prev = _M_node; + this->_M_node->_M_next = this->_M_node; + this->_M_node->_M_prev = this->_M_node; } template @@ -250,7 +250,8 @@ namespace std sort() { // Do nothing if the list has length 0 or 1. - if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) + if (this->_M_node->_M_next != this->_M_node + && this->_M_node->_M_next->_M_next != this->_M_node) { list __carry; list __counter[64]; @@ -340,7 +341,8 @@ namespace std sort(_StrictWeakOrdering __comp) { // Do nothing if the list has length 0 or 1. - if (_M_node->_M_next != _M_node && _M_node->_M_next->_M_next != _M_node) + if (this->_M_node->_M_next != this->_M_node && + this->_M_node->_M_next->_M_next != this->_M_node) { list __carry; list __counter[64]; diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 6e42b3bb5ea..809155fe116 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -921,8 +921,8 @@ namespace std collate_byname(const char* __s, size_t __refs = 0) : collate<_CharT>(__refs) { - _S_destroy_c_locale(_M_c_locale_collate); - _S_create_c_locale(_M_c_locale_collate, __s); + _S_destroy_c_locale(this->_M_c_locale_collate); + _S_create_c_locale(this->_M_c_locale_collate, __s); } protected: diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index e42eca29192..30b16ca8dfd 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -149,8 +149,9 @@ namespace std { try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) + if (_M_check_facet(this->_M_fnumput)) + if (this->_M_fnumput->put(*this, *this, + this->fill(), __n).failed()) this->setstate(ios_base::badbit); } catch(exception& __fail) @@ -176,16 +177,18 @@ namespace std { char_type __c = this->fill(); ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; - if (_M_check_facet(_M_fnumput)) + if (_M_check_facet(this->_M_fnumput)) { bool __b = false; if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) { unsigned long __l = static_cast(__n); - __b = _M_fnumput->put(*this, *this, __c, __l).failed(); + __b = this->_M_fnumput->put(*this, *this, + __c, __l).failed(); } else - __b = _M_fnumput->put(*this, *this, __c, __n).failed(); + __b = this->_M_fnumput->put(*this, *this, + __c, __n).failed(); if (__b) this->setstate(ios_base::badbit); } @@ -211,8 +214,9 @@ namespace std { try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) + if (_M_check_facet(this->_M_fnumput)) + if (this->_M_fnumput->put(*this, *this, + this->fill(), __n).failed()) this->setstate(ios_base::badbit); } catch(exception& __fail) @@ -239,17 +243,19 @@ namespace std { char_type __c = this->fill(); ios_base::fmtflags __fmt = this->flags() & ios_base::basefield; - if (_M_check_facet(_M_fnumput)) + if (_M_check_facet(this->_M_fnumput)) { bool __b = false; if ((__fmt & ios_base::oct) || (__fmt & ios_base::hex)) { unsigned long long __l; __l = static_cast(__n); - __b = _M_fnumput->put(*this, *this, __c, __l).failed(); + __b = this->_M_fnumput->put(*this, *this, + __c, __l).failed(); } else - __b = _M_fnumput->put(*this, *this, __c, __n).failed(); + __b = this->_M_fnumput->put(*this, *this, + __c, __n).failed(); if (__b) this->setstate(ios_base::badbit); } @@ -275,8 +281,9 @@ namespace std { try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) + if (_M_check_facet(this->_M_fnumput)) + if (this->_M_fnumput->put(*this, *this, + this->fill(), __n).failed()) this->setstate(ios_base::badbit); } catch(exception& __fail) @@ -301,8 +308,9 @@ namespace std { try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) + if (_M_check_facet(this->_M_fnumput)) + if (this->_M_fnumput->put(*this, *this, + this->fill(), __n).failed()) this->setstate(ios_base::badbit); } catch(exception& __fail) @@ -326,8 +334,9 @@ namespace std { try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) + if (_M_check_facet(this->_M_fnumput)) + if (this->_M_fnumput->put(*this, *this, + this->fill(), __n).failed()) this->setstate(ios_base::badbit); } catch(exception& __fail) @@ -351,8 +360,9 @@ namespace std { try { - if (_M_check_facet(_M_fnumput)) - if (_M_fnumput->put(*this, *this, this->fill(), __n).failed()) + if (_M_check_facet(this->_M_fnumput)) + if (this->_M_fnumput->put(*this, *this, + this->fill(), __n).failed()) this->setstate(ios_base::badbit); } catch(exception& __fail) diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc index b5848d858bd..32014bc396e 100644 --- a/libstdc++-v3/include/bits/sstream.tcc +++ b/libstdc++-v3/include/bits/sstream.tcc @@ -48,7 +48,7 @@ namespace std { int_type __ret = traits_type::eof(); bool __testeof = traits_type::eq_int_type(__c, traits_type::eof()); - bool __testpos = _M_in_cur && _M_in_beg < _M_in_cur; + bool __testpos = this->_M_in_cur && this->_M_in_beg < this->_M_in_cur; // Try to put back __c into input sequence in one of three ways. // Order these tests done in is unspecified by the standard. @@ -57,18 +57,18 @@ namespace std if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]) && !__testeof) { - --_M_in_cur; + --this->_M_in_cur; __ret = __c; } else if (!__testeof) { - --_M_in_cur; - *_M_in_cur = traits_type::to_char_type(__c); + --this->_M_in_cur; + *this->_M_in_cur = traits_type::to_char_type(__c); __ret = __c; } else if (__testeof) { - --_M_in_cur; + --this->_M_in_cur; __ret = traits_type::not_eof(__c); } } @@ -82,8 +82,8 @@ namespace std { int_type __ret = traits_type::eof(); bool __testeof = traits_type::eq_int_type(__c, __ret); - bool __testwrite = _M_out_cur < _M_buf + _M_buf_size; - bool __testout = _M_mode & ios_base::out; + bool __testwrite = this->_M_out_cur < this->_M_buf + this->_M_buf_size; + bool __testout = this->_M_mode & ios_base::out; // Try to append __c into output sequence in one of two ways. // Order these tests done in is unspecified by the standard. @@ -91,7 +91,8 @@ namespace std { if (!__testeof) { - __size_type __len = std::max(_M_buf_size, _M_buf_size_opt); + __size_type __len = std::max(this->_M_buf_size, + this->_M_buf_size_opt); __len *= 2; if (__testwrite) @@ -101,10 +102,10 @@ namespace std // 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); + this->_M_buf_size = __len; + _M_really_sync(this->_M_in_cur - this->_M_in_beg, + this->_M_out_cur - this->_M_out_beg); + *this->_M_out_cur = traits_type::to_char_type(__c); _M_out_cur_move(1); __ret = __c; } @@ -121,15 +122,15 @@ namespace std seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode) { pos_type __ret = pos_type(off_type(-1)); - bool __testin = (ios_base::in & _M_mode & __mode) != 0; - bool __testout = (ios_base::out & _M_mode & __mode) != 0; + bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; bool __testboth = __testin && __testout && __way != ios_base::cur; __testin &= !(__mode & ios_base::out); __testout &= !(__mode & ios_base::in); - if (_M_buf_size && (__testin || __testout || __testboth)) + if (this->_M_buf_size && (__testin || __testout || __testboth)) { - char_type* __beg = _M_buf; + char_type* __beg = this->_M_buf; char_type* __curi = NULL; char_type* __curo = NULL; char_type* __endi = NULL; @@ -162,13 +163,13 @@ namespace std if ((__testin || __testboth) && __newoffi + __off >= 0 && __endi - __beg >= __newoffi + __off) { - _M_in_cur = __beg + __newoffi + __off; + this->_M_in_cur = __beg + __newoffi + __off; __ret = pos_type(__newoffi); } if ((__testout || __testboth) && __newoffo + __off >= 0 && __endo - __beg >= __newoffo + __off) { - _M_out_cur_move(__newoffo + __off - (_M_out_cur - __beg)); + _M_out_cur_move(__newoffo + __off - (this->_M_out_cur - __beg)); __ret = pos_type(__newoffo); } } @@ -182,13 +183,13 @@ namespace std { pos_type __ret = pos_type(off_type(-1)); - if (_M_buf_size) + if (this->_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; - bool __testout = (ios_base::out & _M_mode & __mode) != 0; + bool __testin = (ios_base::in & this->_M_mode & __mode) != 0; + bool __testout = (ios_base::out & this->_M_mode & __mode) != 0; bool __testboth = __testin && __testout; __testin &= !(__mode & ios_base::out); __testout &= !(__mode & ios_base::in); @@ -206,16 +207,16 @@ namespace std if (__testout || __testboth) { __beg = this->pbase(); - __end = _M_buf + _M_buf_size; + __end = this->_M_buf + this->_M_buf_size; if (0 <= __pos && __pos <= __end - __beg) __testposo = true; } if (__testposi || __testposo) { if (__testposi) - _M_in_cur = _M_in_beg + __pos; + this->_M_in_cur = this->_M_in_beg + __pos; if (__testposo) - _M_out_cur_move((__pos) - (_M_out_cur - __beg)); + _M_out_cur_move((__pos) - (this->_M_out_cur - __beg)); __ret = pos_type(off_type(__pos)); } } diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index da72b6460ab..d334a729d23 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -1,6 +1,6 @@ // bit_vector and vector specialization -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -374,15 +374,15 @@ template protected: void _M_initialize(size_type __n) { _Bit_type * __q = _M_bit_alloc(__n); - _M_end_of_storage = __q + (__n + _M_word_bit - 1)/_M_word_bit; - _M_start = iterator(__q, 0); - _M_finish = _M_start + difference_type(__n); + this->_M_end_of_storage = __q + (__n + _M_word_bit - 1)/_M_word_bit; + this->_M_start = iterator(__q, 0); + this->_M_finish = this->_M_start + difference_type(__n); } void _M_insert_aux(iterator __position, bool __x) { - if (_M_finish._M_p != _M_end_of_storage) { - copy_backward(__position, _M_finish, _M_finish + 1); + if (this->_M_finish._M_p != this->_M_end_of_storage) { + copy_backward(__position, this->_M_finish, this->_M_finish + 1); *__position = __x; - ++_M_finish; + ++this->_M_finish; } else { size_type __len = size() @@ -390,19 +390,19 @@ template _Bit_type * __q = _M_bit_alloc(__len); iterator __i = copy(begin(), __position, iterator(__q, 0)); *__i++ = __x; - _M_finish = copy(__position, end(), __i); + this->_M_finish = copy(__position, end(), __i); _M_deallocate(); - _M_end_of_storage = __q + (__len + _M_word_bit - 1)/_M_word_bit; - _M_start = iterator(__q, 0); + this->_M_end_of_storage = __q + (__len + _M_word_bit - 1)/_M_word_bit; + this->_M_start = iterator(__q, 0); } } template void _M_initialize_range(_InputIterator __first, _InputIterator __last, input_iterator_tag) { - _M_start = iterator(); - _M_finish = iterator(); - _M_end_of_storage = 0; + this->_M_start = iterator(); + this->_M_finish = iterator(); + this->_M_end_of_storage = 0; for ( ; __first != __last; ++__first) push_back(*__first); } @@ -412,7 +412,7 @@ template forward_iterator_tag) { size_type __n = std::distance(__first, __last); _M_initialize(__n); - copy(__first, __last, _M_start); + copy(__first, __last, this->_M_start); } template @@ -432,28 +432,30 @@ template if (__first != __last) { size_type __n = std::distance(__first, __last); if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + difference_type(__n)); + copy_backward(__position, end(), + this->_M_finish + difference_type(__n)); copy(__first, __last, __position); - _M_finish += difference_type(__n); + this->_M_finish += difference_type(__n); } else { size_type __len = size() + std::max(size(), __n); _Bit_type * __q = _M_bit_alloc(__len); iterator __i = copy(begin(), __position, iterator(__q, 0)); __i = copy(__first, __last, __i); - _M_finish = copy(__position, end(), __i); + this->_M_finish = copy(__position, end(), __i); _M_deallocate(); - _M_end_of_storage = __q + (__len + _M_word_bit - 1)/_M_word_bit; - _M_start = iterator(__q, 0); + this->_M_end_of_storage + = __q + (__len + _M_word_bit - 1)/_M_word_bit; + this->_M_start = iterator(__q, 0); } } } public: - iterator begin() { return _M_start; } - const_iterator begin() const { return _M_start; } - iterator end() { return _M_finish; } - const_iterator end() const { return _M_finish; } + iterator begin() { return this->_M_start; } + const_iterator begin() const { return this->_M_start; } + iterator end() { return this->_M_finish; } + const_iterator end() const { return this->_M_finish; } reverse_iterator rbegin() { return reverse_iterator(end()); } const_reverse_iterator rbegin() const { @@ -467,7 +469,7 @@ template size_type size() const { return size_type(end() - begin()); } size_type max_size() const { return size_type(-1); } size_type capacity() const { - return size_type(const_iterator(_M_end_of_storage, 0) - begin()); + return size_type(const_iterator(this->_M_end_of_storage, 0) - begin()); } bool empty() const { return begin() == end(); } @@ -494,19 +496,19 @@ template : _Bvector_base<_Alloc>(__a) { _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, __value ? ~0 : 0); + fill(this->_M_start._M_p, this->_M_end_of_storage, __value ? ~0 : 0); } explicit vector(size_type __n) : _Bvector_base<_Alloc>(allocator_type()) { _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, 0); + fill(this->_M_start._M_p, this->_M_end_of_storage, 0); } vector(const vector& __x) : _Bvector_base<_Alloc>(__x.get_allocator()) { _M_initialize(__x.size()); - copy(__x.begin(), __x.end(), _M_start); + copy(__x.begin(), __x.end(), this->_M_start); } // Check whether it's an integral type. If so, it's not an iterator. @@ -514,7 +516,7 @@ template template void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { _M_initialize(__n); - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); + fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0); } template @@ -541,7 +543,7 @@ template _M_initialize(__x.size()); } copy(__x.begin(), __x.end(), begin()); - _M_finish = begin() + difference_type(__x.size()); + this->_M_finish = begin() + difference_type(__x.size()); return *this; } @@ -552,12 +554,12 @@ template void _M_fill_assign(size_t __n, bool __x) { if (__n > size()) { - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); + fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0); insert(end(), __n - size(), __x); } else { erase(begin() + __n, end()); - fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0); + fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0); } } @@ -608,10 +610,10 @@ template __throw_length_error("vector::reserve"); if (this->capacity() < __n) { _Bit_type * __q = _M_bit_alloc(__n); - _M_finish = copy(begin(), end(), iterator(__q, 0)); + this->_M_finish = copy(begin(), end(), iterator(__q, 0)); _M_deallocate(); - _M_start = iterator(__q, 0); - _M_end_of_storage = __q + (__n + _M_word_bit - 1)/_M_word_bit; + this->_M_start = iterator(__q, 0); + this->_M_end_of_storage = __q + (__n + _M_word_bit - 1)/_M_word_bit; } } @@ -620,15 +622,15 @@ template reference back() { return *(end() - 1); } const_reference back() const { return *(end() - 1); } void push_back(bool __x) { - if (_M_finish._M_p != _M_end_of_storage) - *_M_finish++ = __x; + if (this->_M_finish._M_p != this->_M_end_of_storage) + *this->_M_finish++ = __x; else _M_insert_aux(end(), __x); } void swap(vector& __x) { - std::swap(_M_start, __x._M_start); - std::swap(_M_finish, __x._M_finish); - std::swap(_M_end_of_storage, __x._M_end_of_storage); + std::swap(this->_M_start, __x._M_start); + std::swap(this->_M_finish, __x._M_finish); + std::swap(this->_M_end_of_storage, __x._M_end_of_storage); } // [23.2.5]/1, third-to-last entry in synopsis listing @@ -640,8 +642,9 @@ template iterator insert(iterator __position, bool __x = bool()) { difference_type __n = __position - begin(); - if (_M_finish._M_p != _M_end_of_storage && __position == end()) - *_M_finish++ = __x; + if (this->_M_finish._M_p != this->_M_end_of_storage + && __position == end()) + *this->_M_finish++ = __x; else _M_insert_aux(__position, __x); return begin() + __n; @@ -672,19 +675,20 @@ template void _M_fill_insert(iterator __position, size_type __n, bool __x) { if (__n == 0) return; if (capacity() - size() >= __n) { - copy_backward(__position, end(), _M_finish + difference_type(__n)); + copy_backward(__position, end(), + this->_M_finish + difference_type(__n)); fill(__position, __position + difference_type(__n), __x); - _M_finish += difference_type(__n); + this->_M_finish += difference_type(__n); } else { size_type __len = size() + std::max(size(), __n); _Bit_type * __q = _M_bit_alloc(__len); iterator __i = copy(begin(), __position, iterator(__q, 0)); fill_n(__i, __n, __x); - _M_finish = copy(__position, end(), __i + difference_type(__n)); + this->_M_finish = copy(__position, end(), __i + difference_type(__n)); _M_deallocate(); - _M_end_of_storage = __q + (__len + _M_word_bit - 1)/_M_word_bit; - _M_start = iterator(__q, 0); + this->_M_end_of_storage = __q + (__len + _M_word_bit - 1)/_M_word_bit; + this->_M_start = iterator(__q, 0); } } @@ -692,15 +696,15 @@ template _M_fill_insert(__position, __n, __x); } - void pop_back() { --_M_finish; } + void pop_back() { --this->_M_finish; } iterator erase(iterator __position) { if (__position + 1 != end()) copy(__position + 1, end(), __position); - --_M_finish; + --this->_M_finish; return __position; } iterator erase(iterator __first, iterator __last) { - _M_finish = copy(__last, end(), __first); + this->_M_finish = copy(__last, end(), __first); return __first; } void resize(size_type __new_size, bool __x = bool()) { @@ -710,7 +714,9 @@ template insert(end(), __new_size - size(), __x); } void flip() { - for (_Bit_type * __p = _M_start._M_p; __p != _M_end_of_storage; ++__p) + for (_Bit_type * __p = this->_M_start._M_p; + __p != this->_M_end_of_storage; + ++__p) *__p = ~*__p; } diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 65e76b39a33..916a1dc812e 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -1,6 +1,6 @@ // Deque implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -473,10 +473,10 @@ namespace std template _Deque_base<_Tp,_Alloc>::~_Deque_base() { - if (_M_map) + if (this->_M_map) { _M_destroy_nodes(_M_start._M_node, _M_finish._M_node + 1); - _M_deallocate_map(_M_map, _M_map_size); + _M_deallocate_map(this->_M_map, this->_M_map_size); } } @@ -497,23 +497,24 @@ namespace std size_t __num_nodes = __num_elements / __deque_buf_size(sizeof(_Tp)) + 1; - _M_map_size = std::max((size_t) _S_initial_map_size, __num_nodes + 2); - _M_map = _M_allocate_map(_M_map_size); + this->_M_map_size + = std::max((size_t) _S_initial_map_size, __num_nodes + 2); + this->_M_map = _M_allocate_map(this->_M_map_size); // For "small" maps (needing less than _M_map_size nodes), allocation // starts in the middle elements and grows outwards. So nstart may be the // beginning of _M_map, but for small maps it may be as far in as _M_map+3. - _Tp** __nstart = _M_map + (_M_map_size - __num_nodes) / 2; + _Tp** __nstart = this->_M_map + (this->_M_map_size - __num_nodes) / 2; _Tp** __nfinish = __nstart + __num_nodes; try { _M_create_nodes(__nstart, __nfinish); } catch(...) { - _M_deallocate_map(_M_map, _M_map_size); - _M_map = 0; - _M_map_size = 0; + _M_deallocate_map(this->_M_map, this->_M_map_size); + this->_M_map = 0; + this->_M_map_size = 0; __throw_exception_again; } @@ -722,7 +723,7 @@ namespace std */ deque(const deque& __x) : _Base(__x.get_allocator(), __x.size()) - { uninitialized_copy(__x.begin(), __x.end(), _M_start); } + { uninitialized_copy(__x.begin(), __x.end(), this->_M_start); } /** * @brief Builds a %deque from a range. @@ -752,7 +753,7 @@ namespace std * themselves are pointers, the pointed-to memory is not touched in any * way. Managing the pointer is the user's responsibilty. */ - ~deque() { _Destroy(_M_start, _M_finish); } + ~deque() { _Destroy(this->_M_start, this->_M_finish); } /** * @brief %Deque assignment operator. @@ -807,42 +808,42 @@ namespace std * %deque. Iteration is done in ordinary element order. */ iterator - begin() { return _M_start; } + begin() { return this->_M_start; } /** * Returns a read-only (constant) iterator that points to the first element * in the %deque. Iteration is done in ordinary element order. */ const_iterator - begin() const { return _M_start; } + begin() const { return this->_M_start; } /** * Returns a read/write iterator that points one past the last element in * the %deque. Iteration is done in ordinary element order. */ iterator - end() { return _M_finish; } + end() { return this->_M_finish; } /** * Returns a read-only (constant) iterator that points one past the last * element in the %deque. Iteration is done in ordinary element order. */ const_iterator - end() const { return _M_finish; } + end() const { return this->_M_finish; } /** * Returns a read/write reverse iterator that points to the last element in * the %deque. Iteration is done in reverse element order. */ reverse_iterator - rbegin() { return reverse_iterator(_M_finish); } + rbegin() { return reverse_iterator(this->_M_finish); } /** * Returns a read-only (constant) reverse iterator that points to the last * element in the %deque. Iteration is done in reverse element order. */ const_reverse_iterator - rbegin() const { return const_reverse_iterator(_M_finish); } + rbegin() const { return const_reverse_iterator(this->_M_finish); } /** * Returns a read/write reverse iterator that points to one before the @@ -850,7 +851,7 @@ namespace std * order. */ reverse_iterator - rend() { return reverse_iterator(_M_start); } + rend() { return reverse_iterator(this->_M_start); } /** * Returns a read-only (constant) reverse iterator that points to one @@ -858,12 +859,12 @@ namespace std * element order. */ const_reverse_iterator - rend() const { return const_reverse_iterator(_M_start); } + rend() const { return const_reverse_iterator(this->_M_start); } // [23.2.1.2] capacity /** Returns the number of elements in the %deque. */ size_type - size() const { return _M_finish - _M_start; } + size() const { return this->_M_finish - this->_M_start; } /** Returns the size() of the largest possible %deque. */ size_type @@ -884,9 +885,9 @@ namespace std { const size_type __len = size(); if (__new_size < __len) - erase(_M_start + __new_size, _M_finish); + erase(this->_M_start + __new_size, this->_M_finish); else - insert(_M_finish, __new_size - __len, __x); + insert(this->_M_finish, __new_size - __len, __x); } /** @@ -904,7 +905,7 @@ namespace std /** * Returns true if the %deque is empty. (Thus begin() would equal end().) */ - bool empty() const { return _M_finish == _M_start; } + bool empty() const { return this->_M_finish == this->_M_start; } // element access /** @@ -917,7 +918,7 @@ namespace std * lookups are not defined. (For checked lookups see at().) */ reference - operator[](size_type __n) { return _M_start[difference_type(__n)]; } + operator[](size_type __n) { return this->_M_start[difference_type(__n)]; } /** * @brief Subscript access to the data contained in the %deque. @@ -929,7 +930,9 @@ namespace std * lookups are not defined. (For checked lookups see at().) */ const_reference - operator[](size_type __n) const { return _M_start[difference_type(__n)]; } + operator[](size_type __n) const { + return this->_M_start[difference_type(__n)]; + } protected: /// @if maint Safety check used only from at(). @endif @@ -972,14 +975,14 @@ namespace std * %deque. */ reference - front() { return *_M_start; } + front() { return *this->_M_start; } /** * Returns a read-only (constant) reference to the data at the first * element of the %deque. */ const_reference - front() const { return *_M_start; } + front() const { return *this->_M_start; } /** * Returns a read/write reference to the data at the last element of the @@ -988,7 +991,7 @@ namespace std reference back() { - iterator __tmp = _M_finish; + iterator __tmp = this->_M_finish; --__tmp; return *__tmp; } @@ -1000,7 +1003,7 @@ namespace std const_reference back() const { - const_iterator __tmp = _M_finish; + const_iterator __tmp = this->_M_finish; --__tmp; return *__tmp; } @@ -1017,9 +1020,9 @@ namespace std void push_front(const value_type& __x) { - if (_M_start._M_cur != _M_start._M_first) { - _Construct(_M_start._M_cur - 1, __x); - --_M_start._M_cur; + if (this->_M_start._M_cur != this->_M_start._M_first) { + _Construct(this->_M_start._M_cur - 1, __x); + --this->_M_start._M_cur; } else _M_push_front_aux(__x); @@ -1036,9 +1039,9 @@ namespace std void push_back(const value_type& __x) { - if (_M_finish._M_cur != _M_finish._M_last - 1) { - _Construct(_M_finish._M_cur, __x); - ++_M_finish._M_cur; + if (this->_M_finish._M_cur != this->_M_finish._M_last - 1) { + _Construct(this->_M_finish._M_cur, __x); + ++this->_M_finish._M_cur; } else _M_push_back_aux(__x); @@ -1055,9 +1058,9 @@ namespace std void pop_front() { - if (_M_start._M_cur != _M_start._M_last - 1) { - _Destroy(_M_start._M_cur); - ++_M_start._M_cur; + if (this->_M_start._M_cur != this->_M_start._M_last - 1) { + _Destroy(this->_M_start._M_cur); + ++this->_M_start._M_cur; } else _M_pop_front_aux(); @@ -1074,9 +1077,9 @@ namespace std void pop_back() { - if (_M_finish._M_cur != _M_finish._M_first) { - --_M_finish._M_cur; - _Destroy(_M_finish._M_cur); + if (this->_M_finish._M_cur != this->_M_finish._M_first) { + --this->_M_finish._M_cur; + _Destroy(this->_M_finish._M_cur); } else _M_pop_back_aux(); @@ -1173,10 +1176,10 @@ namespace std void swap(deque& __x) { - std::swap(_M_start, __x._M_start); - std::swap(_M_finish, __x._M_finish); - std::swap(_M_map, __x._M_map); - std::swap(_M_map_size, __x._M_map_size); + std::swap(this->_M_start, __x._M_start); + std::swap(this->_M_finish, __x._M_finish); + std::swap(this->_M_map, __x._M_map); + std::swap(this->_M_map_size, __x._M_map_size); } /** @@ -1396,19 +1399,20 @@ namespace std iterator _M_reserve_elements_at_front(size_type __n) { - size_type __vacancies = _M_start._M_cur - _M_start._M_first; + size_type __vacancies = this->_M_start._M_cur - this->_M_start._M_first; if (__n > __vacancies) _M_new_elements_at_front(__n - __vacancies); - return _M_start - difference_type(__n); + return this->_M_start - difference_type(__n); } iterator _M_reserve_elements_at_back(size_type __n) { - size_type __vacancies = (_M_finish._M_last - _M_finish._M_cur) - 1; + size_type __vacancies + = (this->_M_finish._M_last - this->_M_finish._M_cur) - 1; if (__n > __vacancies) _M_new_elements_at_back(__n - __vacancies); - return _M_finish + difference_type(__n); + return this->_M_finish + difference_type(__n); } void @@ -1432,14 +1436,15 @@ namespace std void _M_reserve_map_at_back (size_type __nodes_to_add = 1) { - if (__nodes_to_add + 1 > _M_map_size - (_M_finish._M_node - _M_map)) + if (__nodes_to_add + 1 + > this->_M_map_size - (this->_M_finish._M_node - this->_M_map)) _M_reallocate_map(__nodes_to_add, false); } void _M_reserve_map_at_front (size_type __nodes_to_add = 1) { - if (__nodes_to_add > size_type(_M_start._M_node - _M_map)) + if (__nodes_to_add > size_type(this->_M_start._M_node - this->_M_map)) _M_reallocate_map(__nodes_to_add, true); } diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index abd176745d9..b8a59e106c7 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -1,6 +1,6 @@ // List implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -301,16 +301,16 @@ namespace std _List_base(const allocator_type& __a) : _Base(__a) { - _M_node = _M_get_node(); - _M_node->_M_next = _M_node; - _M_node->_M_prev = _M_node; + this->_M_node = _M_get_node(); + this->_M_node->_M_next = this->_M_node; + this->_M_node->_M_prev = this->_M_node; } // This is what actually destroys the list. ~_List_base() { __clear(); - _M_put_node(_M_node); + _M_put_node(this->_M_node); } void @@ -566,28 +566,28 @@ namespace std * %list. Iteration is done in ordinary element order. */ iterator - begin() { return static_cast<_Node*>(_M_node->_M_next); } + begin() { return static_cast<_Node*>(this->_M_node->_M_next); } /** * Returns a read-only (constant) iterator that points to the first element * in the %list. Iteration is done in ordinary element order. */ const_iterator - begin() const { return static_cast<_Node*>(_M_node->_M_next); } + begin() const { return static_cast<_Node*>(this->_M_node->_M_next); } /** * Returns a read/write iterator that points one past the last element in * the %list. Iteration is done in ordinary element order. */ iterator - end() { return _M_node; } + end() { return this->_M_node; } /** * Returns a read-only (constant) iterator that points one past the last * element in the %list. Iteration is done in ordinary element order. */ const_iterator - end() const { return _M_node; } + end() const { return this->_M_node; } /** * Returns a read/write reverse iterator that points to the last element in @@ -625,7 +625,7 @@ namespace std * Returns true if the %list is empty. (Thus begin() would equal end().) */ bool - empty() const { return _M_node->_M_next == _M_node; } + empty() const { return this->_M_node->_M_next == this->_M_node; } /** Returns the number of elements in the %list. */ size_type @@ -853,7 +853,7 @@ namespace std * std::swap(l1,l2) will feed to this function. */ void - swap(list& __x) { std::swap(_M_node, __x._M_node); } + swap(list& __x) { std::swap(this->_M_node, __x._M_node); } /** * Erases all the elements. Note that this function only erases the diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index 42fd0b61b4d..b6050375647 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -1,6 +1,6 @@ // RB tree implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -576,8 +576,8 @@ namespace std typedef typename _Base::allocator_type allocator_type; _Rb_tree_base(const allocator_type& __a) - : _Base(__a) { _M_header = _M_get_node(); } - ~_Rb_tree_base() { _M_put_node(_M_header); } + : _Base(__a) { this->_M_header = _M_get_node(); } + ~_Rb_tree_base() { _M_put_node(this->_M_header); } }; @@ -645,13 +645,13 @@ namespace std _Compare _M_key_compare; _Link_type& - _M_root() const { return (_Link_type&) _M_header->_M_parent; } + _M_root() const { return (_Link_type&) this->_M_header->_M_parent; } _Link_type& - _M_leftmost() const { return (_Link_type&) _M_header->_M_left; } + _M_leftmost() const { return (_Link_type&) this->_M_header->_M_left; } _Link_type& - _M_rightmost() const { return (_Link_type&) _M_header->_M_right; } + _M_rightmost() const { return (_Link_type&) this->_M_header->_M_right; } static _Link_type& _S_left(_Link_type __x) { return (_Link_type&)(__x->_M_left); } @@ -737,8 +737,8 @@ namespace std _M_empty_initialize(); else { - _S_color(_M_header) = _M_red; - _M_root() = _M_copy(__x._M_root(), _M_header); + _S_color(this->_M_header) = _M_red; + _M_root() = _M_copy(__x._M_root(), this->_M_header); _M_leftmost() = _S_minimum(_M_root()); _M_rightmost() = _S_maximum(_M_root()); } @@ -753,11 +753,11 @@ namespace std private: void _M_empty_initialize() { - _S_color(_M_header) = _M_red; // used to distinguish header from + _S_color(this->_M_header) = _M_red; // used to distinguish header from // __root, in iterator.operator++ _M_root() = 0; - _M_leftmost() = _M_header; - _M_rightmost() = _M_header; + _M_leftmost() = this->_M_header; + _M_rightmost() = this->_M_header; } public: @@ -772,10 +772,10 @@ namespace std begin() const { return _M_leftmost(); } iterator - end() { return _M_header; } + end() { return this->_M_header; } const_iterator - end() const { return _M_header; } + end() const { return this->_M_header; } reverse_iterator rbegin() { return reverse_iterator(end()); } @@ -801,7 +801,7 @@ namespace std void swap(_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __t) { - std::swap(_M_header, __t._M_header); + std::swap(this->_M_header, __t._M_header); std::swap(_M_node_count, __t._M_node_count); std::swap(_M_key_compare, __t._M_key_compare); } @@ -845,9 +845,9 @@ namespace std if (_M_node_count != 0) { _M_erase(_M_root()); - _M_leftmost() = _M_header; + _M_leftmost() = this->_M_header; _M_root() = 0; - _M_rightmost() = _M_header; + _M_rightmost() = this->_M_header; _M_node_count = 0; } } @@ -955,12 +955,12 @@ namespace std if (__x._M_root() == 0) { _M_root() = 0; - _M_leftmost() = _M_header; - _M_rightmost() = _M_header; + _M_leftmost() = this->_M_header; + _M_rightmost() = this->_M_header; } else { - _M_root() = _M_copy(__x._M_root(), _M_header); + _M_root() = _M_copy(__x._M_root(), this->_M_header); _M_leftmost() = _S_minimum(_M_root()); _M_rightmost() = _S_maximum(_M_root()); _M_node_count = __x._M_node_count; @@ -979,13 +979,13 @@ namespace std _Link_type __y = (_Link_type) __y_; _Link_type __z; - if (__y == _M_header || __x != 0 || + if (__y == this->_M_header || __x != 0 || _M_key_compare(_KeyOfValue()(__v), _S_key(__y))) { __z = _M_create_node(__v); _S_left(__y) = __z; // also makes _M_leftmost() = __z // when __y == _M_header - if (__y == _M_header) + if (__y == this->_M_header) { _M_root() = __z; _M_rightmost() = __z; @@ -1004,7 +1004,7 @@ namespace std _S_parent(__z) = __y; _S_left(__z) = 0; _S_right(__z) = 0; - _Rb_tree_rebalance(__z, _M_header->_M_parent); + _Rb_tree_rebalance(__z, this->_M_header->_M_parent); ++_M_node_count; return iterator(__z); } @@ -1015,7 +1015,7 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: insert_equal(const _Val& __v) { - _Link_type __y = _M_header; + _Link_type __y = this->_M_header; _Link_type __x = _M_root(); while (__x != 0) { @@ -1033,7 +1033,7 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: insert_unique(const _Val& __v) { - _Link_type __y = _M_header; + _Link_type __y = this->_M_header; _Link_type __x = _M_root(); bool __comp = true; while (__x != 0) @@ -1060,7 +1060,7 @@ namespace std _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: insert_unique(iterator __position, const _Val& __v) { - if (__position._M_node == _M_header->_M_left) + if (__position._M_node == this->_M_header->_M_left) { // begin() if (size() > 0 && @@ -1070,7 +1070,7 @@ namespace std else return insert_unique(__v).first; } - else if (__position._M_node == _M_header) + else if (__position._M_node == this->_M_header) { // end() if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__v))) @@ -1102,7 +1102,7 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: insert_equal(iterator __position, const _Val& __v) { - if (__position._M_node == _M_header->_M_left) + if (__position._M_node == this->_M_header->_M_left) { // begin() if (size() > 0 && @@ -1112,7 +1112,7 @@ namespace std else return insert_equal(__v); } - else if (__position._M_node == _M_header) + else if (__position._M_node == this->_M_header) { // end() if (!_M_key_compare(_KeyOfValue()(__v), _S_key(_M_rightmost()))) @@ -1168,9 +1168,9 @@ namespace std { _Link_type __y = (_Link_type) _Rb_tree_rebalance_for_erase(__position._M_node, - _M_header->_M_parent, - _M_header->_M_left, - _M_header->_M_right); + this->_M_header->_M_parent, + this->_M_header->_M_left, + this->_M_header->_M_right); destroy_node(__y); --_M_node_count; } @@ -1264,7 +1264,8 @@ namespace std typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) { - _Link_type __y = _M_header; // Last node which is not less than __k. + _Link_type __y + = this->_M_header; // Last node which is not less than __k. _Link_type __x = _M_root(); // Current node. while (__x != 0) @@ -1284,7 +1285,8 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: find(const _Key& __k) const { - _Link_type __y = _M_header; // Last node which is not less than __k. + _Link_type __y + = this->_M_header; // Last node which is not less than __k. _Link_type __x = _M_root(); // Current node. while (__x != 0) @@ -1316,7 +1318,8 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: lower_bound(const _Key& __k) { - _Link_type __y = _M_header; /* Last node which is not less than __k. */ + _Link_type __y + = this->_M_header; /* Last node which is not less than __k. */ _Link_type __x = _M_root(); /* Current node. */ while (__x != 0) @@ -1334,7 +1337,8 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: lower_bound(const _Key& __k) const { - _Link_type __y = _M_header; /* Last node which is not less than __k. */ + _Link_type __y + = this->_M_header; /* Last node which is not less than __k. */ _Link_type __x = _M_root(); /* Current node. */ while (__x != 0) @@ -1352,7 +1356,8 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: upper_bound(const _Key& __k) { - _Link_type __y = _M_header; /* Last node which is greater than __k. */ + _Link_type __y + = this->_M_header; /* Last node which is greater than __k. */ _Link_type __x = _M_root(); /* Current node. */ while (__x != 0) @@ -1370,7 +1375,8 @@ namespace std _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>:: upper_bound(const _Key& __k) const { - _Link_type __y = _M_header; /* Last node which is greater than __k. */ + _Link_type __y + = this->_M_header; /* Last node which is greater than __k. */ _Link_type __x = _M_root(); /* Current node. */ while (__x != 0) @@ -1428,7 +1434,8 @@ namespace std { if (_M_node_count == 0 || begin() == end()) return _M_node_count == 0 && begin() == end() && - _M_header->_M_left == _M_header && _M_header->_M_right == _M_header; + this->_M_header->_M_left == this->_M_header + && this->_M_header->_M_right == this->_M_header; int __len = __black_count(_M_leftmost(), _M_root()); for (const_iterator __it = begin(); __it != end(); ++__it) diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index eb092e087da..f0da72adcb9 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -1,6 +1,6 @@ // Vector implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -153,13 +153,14 @@ namespace std _Vector_base(size_t __n, const allocator_type& __a) : _Base(__a) { - _M_start = _M_allocate(__n); - _M_finish = _M_start; - _M_end_of_storage = _M_start + __n; + this->_M_start = _M_allocate(__n); + this->_M_finish = this->_M_start; + this->_M_end_of_storage = this->_M_start + __n; } ~_Vector_base() - { _M_deallocate(_M_start, _M_end_of_storage - _M_start); } + { _M_deallocate(this->_M_start, + this->_M_end_of_storage - this->_M_start); } }; @@ -238,7 +239,7 @@ namespace std vector(size_type __n, const value_type& __value, const allocator_type& __a = allocator_type()) : _Base(__n, __a) - { _M_finish = uninitialized_fill_n(_M_start, __n, __value); } + { this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __value); } /** * @brief Create a %vector with default elements. @@ -250,7 +251,8 @@ namespace std explicit vector(size_type __n) : _Base(__n, allocator_type()) - { _M_finish = uninitialized_fill_n(_M_start, __n, value_type()); } + { this->_M_finish = uninitialized_fill_n(this->_M_start, + __n, value_type()); } /** * @brief %Vector copy constructor. @@ -263,7 +265,9 @@ namespace std */ vector(const vector& __x) : _Base(__x.size(), __x.get_allocator()) - { _M_finish = uninitialized_copy(__x.begin(), __x.end(), _M_start); } + { this->_M_finish = uninitialized_copy(__x.begin(), __x.end(), + this->_M_start); + } /** * @brief Builds a %vector from a range. @@ -294,7 +298,7 @@ namespace std * themselves are pointers, the pointed-to memory is not touched in any * way. Managing the pointer is the user's responsibilty. */ - ~vector() { _Destroy(_M_start, _M_finish); } + ~vector() { _Destroy(this->_M_start, this->_M_finish); } /** * @brief %Vector assignment operator. @@ -352,7 +356,7 @@ namespace std * %vector. Iteration is done in ordinary element order. */ iterator - begin() { return iterator (_M_start); } + begin() { return iterator (this->_M_start); } /** * Returns a read-only (constant) iterator that points to the @@ -360,7 +364,7 @@ namespace std * element order. */ const_iterator - begin() const { return const_iterator (_M_start); } + begin() const { return const_iterator (this->_M_start); } /** * Returns a read/write iterator that points one past the last @@ -368,14 +372,14 @@ namespace std * element order. */ iterator - end() { return iterator (_M_finish); } + end() { return iterator (this->_M_finish); } /** * Returns a read-only (constant) iterator that points one past the last * element in the %vector. Iteration is done in ordinary element order. */ const_iterator - end() const { return const_iterator (_M_finish); } + end() const { return const_iterator (this->_M_finish); } /** * Returns a read/write reverse iterator that points to the @@ -457,7 +461,7 @@ namespace std */ size_type capacity() const - { return size_type(const_iterator(_M_end_of_storage) - begin()); } + { return size_type(const_iterator(this->_M_end_of_storage) - begin()); } /** * Returns true if the %vector is empty. (Thus begin() would @@ -594,10 +598,10 @@ namespace std void push_back(const value_type& __x) { - if (_M_finish != _M_end_of_storage) + if (this->_M_finish != this->_M_end_of_storage) { - _Construct(_M_finish, __x); - ++_M_finish; + _Construct(this->_M_finish, __x); + ++this->_M_finish; } else _M_insert_aux(end(), __x); @@ -614,8 +618,8 @@ namespace std void pop_back() { - --_M_finish; - _Destroy(_M_finish); + --this->_M_finish; + _Destroy(this->_M_finish); } /** @@ -723,9 +727,9 @@ namespace std void swap(vector& __x) { - std::swap(_M_start, __x._M_start); - std::swap(_M_finish, __x._M_finish); - std::swap(_M_end_of_storage, __x._M_end_of_storage); + std::swap(this->_M_start, __x._M_start); + std::swap(this->_M_finish, __x._M_finish); + std::swap(this->_M_end_of_storage, __x._M_end_of_storage); } /** @@ -770,9 +774,9 @@ namespace std void _M_initialize_dispatch(_Integer __n, _Integer __value, __true_type) { - _M_start = _M_allocate(__n); - _M_end_of_storage = _M_start + __n; - _M_finish = uninitialized_fill_n(_M_start, __n, __value); + this->_M_start = _M_allocate(__n); + this->_M_end_of_storage = this->_M_start + __n; + this->_M_finish = uninitialized_fill_n(this->_M_start, __n, __value); } // Called by the range constructor to implement [23.1.1]/9 @@ -803,9 +807,10 @@ namespace std _ForwardIterator __last, forward_iterator_tag) { size_type __n = std::distance(__first, __last); - _M_start = _M_allocate(__n); - _M_end_of_storage = _M_start + __n; - _M_finish = uninitialized_copy(__first, __last, _M_start); + this->_M_start = _M_allocate(__n); + this->_M_end_of_storage = this->_M_start + __n; + this->_M_finish = uninitialized_copy(__first, __last, + this->_M_start); } diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 4b22af0af15..0b6724c9147 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -1,6 +1,6 @@ // Vector implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -73,12 +73,15 @@ namespace std if (this->capacity() < __n) { const size_type __old_size = size(); - pointer __tmp = _M_allocate_and_copy(__n, _M_start, _M_finish); - _Destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __tmp; - _M_finish = __tmp + __old_size; - _M_end_of_storage = _M_start + __n; + pointer __tmp = _M_allocate_and_copy(__n, + this->_M_start, + this->_M_finish); + _Destroy(this->_M_start, this->_M_finish); + _M_deallocate(this->_M_start, + this->_M_end_of_storage - this->_M_start); + this->_M_start = __tmp; + this->_M_finish = __tmp + __old_size; + this->_M_end_of_storage = this->_M_start + __n; } } @@ -88,10 +91,10 @@ namespace std insert(iterator __position, const value_type& __x) { size_type __n = __position - begin(); - if (_M_finish != _M_end_of_storage && __position == end()) + if (this->_M_finish != this->_M_end_of_storage && __position == end()) { - _Construct(_M_finish, __x); - ++_M_finish; + _Construct(this->_M_finish, __x); + ++this->_M_finish; } else _M_insert_aux(__position, __x); @@ -105,8 +108,8 @@ namespace std { if (__position + 1 != end()) copy(__position + 1, end(), __position); - --_M_finish; - _Destroy(_M_finish); + --this->_M_finish; + _Destroy(this->_M_finish); return __position; } @@ -117,7 +120,7 @@ namespace std { iterator __i(copy(__last, end(), __first)); _Destroy(__i, end()); - _M_finish = _M_finish - (__last - __first); + this->_M_finish = this->_M_finish - (__last - __first); return __first; } @@ -132,10 +135,11 @@ namespace std if (__xlen > capacity()) { pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end()); - _Destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __tmp; - _M_end_of_storage = _M_start + __xlen; + _Destroy(this->_M_start, this->_M_finish); + _M_deallocate(this->_M_start, + this->_M_end_of_storage - this->_M_start); + this->_M_start = __tmp; + this->_M_end_of_storage = this->_M_start + __xlen; } else if (size() >= __xlen) { @@ -144,10 +148,10 @@ namespace std } else { - copy(__x.begin(), __x.begin() + size(), _M_start); - uninitialized_copy(__x.begin() + size(), __x.end(), _M_finish); + copy(__x.begin(), __x.begin() + size(), this->_M_start); + uninitialized_copy(__x.begin() + size(), __x.end(), this->_M_finish); } - _M_finish = _M_start + __xlen; + this->_M_finish = this->_M_start + __xlen; } return *this; } @@ -165,7 +169,8 @@ namespace std else if (__n > size()) { fill(begin(), end(), __val); - _M_finish = uninitialized_fill_n(_M_finish, __n - size(), __val); + this->_M_finish + = uninitialized_fill_n(this->_M_finish, __n - size(), __val); } else erase(fill_n(begin(), __n, __val), end()); @@ -196,23 +201,24 @@ namespace std if (__len > capacity()) { pointer __tmp(_M_allocate_and_copy(__len, __first, __last)); - _Destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __tmp; - _M_end_of_storage = _M_finish = _M_start + __len; + _Destroy(this->_M_start, this->_M_finish); + _M_deallocate(this->_M_start, + this->_M_end_of_storage - this->_M_start); + this->_M_start = __tmp; + this->_M_end_of_storage = this->_M_finish = this->_M_start + __len; } else if (size() >= __len) { - iterator __new_finish(copy(__first, __last, _M_start)); + iterator __new_finish(copy(__first, __last, this->_M_start)); _Destroy(__new_finish, end()); - _M_finish = __new_finish.base(); + this->_M_finish = __new_finish.base(); } else { _ForwardIter __mid = __first; advance(__mid, size()); - copy(__first, __mid, _M_start); - _M_finish = uninitialized_copy(__mid, __last, _M_finish); + copy(__first, __mid, this->_M_start); + this->_M_finish = uninitialized_copy(__mid, __last, this->_M_finish); } } @@ -221,12 +227,14 @@ namespace std vector<_Tp,_Alloc>:: _M_insert_aux(iterator __position, const _Tp& __x) { - if (_M_finish != _M_end_of_storage) + if (this->_M_finish != this->_M_end_of_storage) { - _Construct(_M_finish, *(_M_finish - 1)); - ++_M_finish; + _Construct(this->_M_finish, *(this->_M_finish - 1)); + ++this->_M_finish; _Tp __x_copy = __x; - copy_backward(__position, iterator(_M_finish-2), iterator(_M_finish-1)); + copy_backward(__position, + iterator(this->_M_finish-2), + iterator(this->_M_finish-1)); *__position = __x_copy; } else @@ -237,11 +245,13 @@ namespace std iterator __new_finish(__new_start); try { - __new_finish = uninitialized_copy(iterator(_M_start), __position, + __new_finish = uninitialized_copy(iterator(this->_M_start), + __position, __new_start); _Construct(__new_finish.base(), __x); ++__new_finish; - __new_finish = uninitialized_copy(__position, iterator(_M_finish), + __new_finish = uninitialized_copy(__position, + iterator(this->_M_finish), __new_finish); } catch(...) @@ -251,10 +261,11 @@ namespace std __throw_exception_again; } _Destroy(begin(), end()); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start.base(); - _M_finish = __new_finish.base(); - _M_end_of_storage = __new_start.base() + __len; + _M_deallocate(this->_M_start, + this->_M_end_of_storage - this->_M_start); + this->_M_start = __new_start.base(); + this->_M_finish = __new_finish.base(); + this->_M_end_of_storage = __new_start.base() + __len; } } @@ -309,24 +320,28 @@ namespace std { if (__n != 0) { - if (size_type(_M_end_of_storage - _M_finish) >= __n) + if (size_type(this->_M_end_of_storage - this->_M_finish) >= __n) { value_type __x_copy = __x; const size_type __elems_after = end() - __position; - iterator __old_finish(_M_finish); + iterator __old_finish(this->_M_finish); if (__elems_after > __n) { - uninitialized_copy(_M_finish - __n, _M_finish, _M_finish); - _M_finish += __n; + uninitialized_copy(this->_M_finish - __n, + this->_M_finish, + this->_M_finish); + this->_M_finish += __n; copy_backward(__position, __old_finish - __n, __old_finish); fill(__position, __position + __n, __x_copy); } else { - uninitialized_fill_n(_M_finish, __n - __elems_after, __x_copy); - _M_finish += __n - __elems_after; - uninitialized_copy(__position, __old_finish, _M_finish); - _M_finish += __elems_after; + uninitialized_fill_n(this->_M_finish, + __n - __elems_after, + __x_copy); + this->_M_finish += __n - __elems_after; + uninitialized_copy(__position, __old_finish, this->_M_finish); + this->_M_finish += __elems_after; fill(__position, __old_finish, __x_copy); } } @@ -350,11 +365,12 @@ namespace std _M_deallocate(__new_start.base(),__len); __throw_exception_again; } - _Destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start.base(); - _M_finish = __new_finish.base(); - _M_end_of_storage = __new_start.base() + __len; + _Destroy(this->_M_start, this->_M_finish); + _M_deallocate(this->_M_start, + this->_M_end_of_storage - this->_M_start); + this->_M_start = __new_start.base(); + this->_M_finish = __new_finish.base(); + this->_M_end_of_storage = __new_start.base() + __len; } } } @@ -382,14 +398,16 @@ namespace std if (__first != __last) { size_type __n = std::distance(__first, __last); - if (size_type(_M_end_of_storage - _M_finish) >= __n) + if (size_type(this->_M_end_of_storage - this->_M_finish) >= __n) { const size_type __elems_after = end() - __position; - iterator __old_finish(_M_finish); + iterator __old_finish(this->_M_finish); if (__elems_after > __n) { - uninitialized_copy(_M_finish - __n, _M_finish, _M_finish); - _M_finish += __n; + uninitialized_copy(this->_M_finish - __n, + this->_M_finish, + this->_M_finish); + this->_M_finish += __n; copy_backward(__position, __old_finish - __n, __old_finish); copy(__first, __last, __position); } @@ -397,10 +415,10 @@ namespace std { _ForwardIterator __mid = __first; advance(__mid, __elems_after); - uninitialized_copy(__mid, __last, _M_finish); - _M_finish += __n - __elems_after; - uninitialized_copy(__position, __old_finish, _M_finish); - _M_finish += __elems_after; + uninitialized_copy(__mid, __last, this->_M_finish); + this->_M_finish += __n - __elems_after; + uninitialized_copy(__position, __old_finish, this->_M_finish); + this->_M_finish += __elems_after; copy(__first, __mid, __position); } } @@ -412,10 +430,11 @@ namespace std iterator __new_finish(__new_start); try { - __new_finish = uninitialized_copy(iterator(_M_start), + __new_finish = uninitialized_copy(iterator(this->_M_start), __position, __new_start); __new_finish = uninitialized_copy(__first, __last, __new_finish); - __new_finish = uninitialized_copy(__position, iterator(_M_finish), + __new_finish = uninitialized_copy(__position, + iterator(this->_M_finish), __new_finish); } catch(...) @@ -424,11 +443,12 @@ namespace std _M_deallocate(__new_start.base(), __len); __throw_exception_again; } - _Destroy(_M_start, _M_finish); - _M_deallocate(_M_start, _M_end_of_storage - _M_start); - _M_start = __new_start.base(); - _M_finish = __new_finish.base(); - _M_end_of_storage = __new_start.base() + __len; + _Destroy(this->_M_start, this->_M_finish); + _M_deallocate(this->_M_start, + this->_M_end_of_storage - this->_M_start); + this->_M_start = __new_start.base(); + this->_M_finish = __new_finish.base(); + this->_M_end_of_storage = __new_start.base() + __len; } } } diff --git a/libstdc++-v3/include/ext/ropeimpl.h b/libstdc++-v3/include/ext/ropeimpl.h index f3f09f5c468..91bd5e0fc9e 100644 --- a/libstdc++-v3/include/ext/ropeimpl.h +++ b/libstdc++-v3/include/ext/ropeimpl.h @@ -1,6 +1,6 @@ // SGI's rope class implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -278,12 +278,12 @@ void _Rope_iterator_base<_CharT,_Alloc>::_M_decr(size_t __n) { template void _Rope_iterator<_CharT,_Alloc>::_M_check() { - if (_M_root_rope->_M_tree_ptr != _M_root) { + if (_M_root_rope->_M_tree_ptr != this->_M_root) { // _Rope was modified. Get things fixed up. - _RopeRep::_S_unref(_M_root); - _M_root = _M_root_rope->_M_tree_ptr; - _RopeRep::_S_ref(_M_root); - _M_buf_ptr = 0; + _RopeRep::_S_unref(this->_M_root); + this->_M_root = _M_root_rope->_M_tree_ptr; + _RopeRep::_S_ref(this->_M_root); + this->_M_buf_ptr = 0; } } @@ -300,7 +300,7 @@ inline _Rope_iterator<_CharT,_Alloc>::_Rope_iterator( : _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos), _M_root_rope(&__r) { - _RopeRep::_S_ref(_M_root); + _RopeRep::_S_ref(this->_M_root); } template @@ -321,7 +321,7 @@ inline void _Rope_RopeRep<_CharT,_Alloc>::_M_free_c_string() { _CharT* __cstr = _M_c_string; if (0 != __cstr) { - size_t __size = _M_size + 1; + size_t __size = this->_M_size + 1; _Destroy(__cstr, __cstr + __size); _Data_deallocate(__cstr, __size); } @@ -960,7 +960,7 @@ size_t rope<_CharT,_Alloc>::find(_CharT __pattern, size_t __start) const { _Rope_find_char_char_consumer<_CharT> __c(__pattern); - _S_apply_to_pieces(__c, _M_tree_ptr, __start, size()); + _S_apply_to_pieces(__c, this->_M_tree_ptr, __start, size()); size_type __result_pos = __start + __c._M_count; # ifndef __STL_OLD_ROPE_SEMANTICS if (__result_pos == size()) __result_pos = npos; @@ -1436,8 +1436,8 @@ rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c, } else { __result = __remainder_rope; } - _M_tree_ptr = __result._M_tree_ptr; - _M_tree_ptr->_M_ref_nonnil(); + this->_M_tree_ptr = __result._M_tree_ptr; + this->_M_tree_ptr->_M_ref_nonnil(); } template @@ -1445,22 +1445,23 @@ template template const _CharT* rope<_CharT,_Alloc>::c_str() const { - if (0 == _M_tree_ptr) { + if (0 == this->_M_tree_ptr) { _S_empty_c_str[0] = _S_eos((_CharT*)0); // Possibly redundant, // but probably fast. return _S_empty_c_str; } - __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string; + __GC_CONST _CharT* __old_c_string = this->_M_tree_ptr->_M_c_string; if (0 != __old_c_string) return(__old_c_string); size_t __s = size(); _CharT* __result = _Data_allocate(__s + 1); - _S_flatten(_M_tree_ptr, __result); + _S_flatten(this->_M_tree_ptr, __result); __result[__s] = _S_eos((_CharT*)0); # ifdef __GC _M_tree_ptr->_M_c_string = __result; # else if ((__old_c_string = (__GC_CONST _CharT*) - std::_Atomic_swap((unsigned long *)(&(_M_tree_ptr->_M_c_string)), + std::_Atomic_swap((unsigned long *) + (&(this->_M_tree_ptr->_M_c_string)), (unsigned long)__result)) != 0) { // It must have been added in the interim. Hence it had to have been // separately allocated. Deallocate the old copy, since we just @@ -1474,20 +1475,21 @@ const _CharT* rope<_CharT,_Alloc>::c_str() const { template const _CharT* rope<_CharT,_Alloc>::replace_with_c_str() { - if (0 == _M_tree_ptr) { + if (0 == this->_M_tree_ptr) { _S_empty_c_str[0] = _S_eos((_CharT*)0); return _S_empty_c_str; } - __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string; - if (_RopeRep::_S_leaf == _M_tree_ptr->_M_tag && 0 != __old_c_string) { + __GC_CONST _CharT* __old_c_string = this->_M_tree_ptr->_M_c_string; + if (_RopeRep::_S_leaf == this->_M_tree_ptr->_M_tag + && 0 != __old_c_string) { return(__old_c_string); } size_t __s = size(); _CharT* __result = _Data_allocate(_S_rounded_up_size(__s)); - _S_flatten(_M_tree_ptr, __result); + _S_flatten(this->_M_tree_ptr, __result); __result[__s] = _S_eos((_CharT*)0); - _M_tree_ptr->_M_unref_nonnil(); - _M_tree_ptr = _S_new_RopeLeaf(__result, __s, get_allocator()); + this->_M_tree_ptr->_M_unref_nonnil(); + this->_M_tree_ptr = _S_new_RopeLeaf(__result, __s, get_allocator()); return(__result); } diff --git a/libstdc++-v3/include/ext/stdio_filebuf.h b/libstdc++-v3/include/ext/stdio_filebuf.h index 59ab41a03e5..1fb40be2b49 100644 --- a/libstdc++-v3/include/ext/stdio_filebuf.h +++ b/libstdc++-v3/include/ext/stdio_filebuf.h @@ -1,6 +1,6 @@ // File descriptor layer for filebuf -*- C++ -*- -// Copyright (C) 2002 Free Software Foundation, Inc. +// Copyright (C) 2002, 2003 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 @@ -107,7 +107,7 @@ namespace __gnu_cxx */ int fd() - { return _M_file.fd(); } + { return this->_M_file.fd(); } }; template @@ -119,20 +119,20 @@ namespace __gnu_cxx stdio_filebuf(int __fd, std::ios_base::openmode __mode, bool __del, int_type __size) { - _M_file.sys_open(__fd, __mode, __del); + this->_M_file.sys_open(__fd, __mode, __del); if (this->is_open()) { - _M_mode = __mode; + this->_M_mode = __mode; if (__size > 0 && __size < 4) { // Specify unbuffered. - _M_buf = _M_unbuf; - _M_buf_size = __size; - _M_buf_size_opt = 0; + this->_M_buf = _M_unbuf; + this->_M_buf_size = __size; + this->_M_buf_size_opt = 0; } else { - _M_buf_size_opt = __size; + this->_M_buf_size_opt = __size; _M_allocate_internal_buffer(); } _M_set_indeterminate(); @@ -144,20 +144,20 @@ namespace __gnu_cxx stdio_filebuf(std::__c_file* __f, std::ios_base::openmode __mode, int_type __size) { - _M_file.sys_open(__f, __mode); + this->_M_file.sys_open(__f, __mode); if (this->is_open()) { - _M_mode = __mode; + this->_M_mode = __mode; if (__size > 0 && __size < 4) { // Specify unbuffered. - _M_buf = _M_unbuf; - _M_buf_size = __size; - _M_buf_size_opt = 0; + this->_M_buf = _M_unbuf; + this->_M_buf_size = __size; + this->_M_buf_size_opt = 0; } else { - _M_buf_size_opt = __size; + this->_M_buf_size_opt = __size; _M_allocate_internal_buffer(); } _M_set_indeterminate(); diff --git a/libstdc++-v3/include/ext/stl_rope.h b/libstdc++-v3/include/ext/stl_rope.h index eae26133742..95c3c0c80fc 100644 --- a/libstdc++-v3/include/ext/stl_rope.h +++ b/libstdc++-v3/include/ext/stl_rope.h @@ -1,6 +1,6 @@ // SGI's rope implementation -*- C++ -*- -// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003 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 @@ -579,12 +579,13 @@ struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> { typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type allocator_type; _Rope_RopeLeaf(__GC_CONST _CharT* __d, size_t __size, allocator_type __a) - : _Rope_RopeRep<_CharT,_Alloc>(_S_leaf, 0, true, __size, __a), + : _Rope_RopeRep<_CharT,_Alloc>(_Rope_RopeRep<_CharT,_Alloc>::_S_leaf, + 0, true, __size, __a), _M_data(__d) { if (_S_is_basic_char_type((_CharT *)0)) { // already eos terminated. - _M_c_string = __d; + this->_M_c_string = __d; } } // The constructor assumes that d has been allocated with @@ -592,10 +593,10 @@ struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> { // In contrast, the destructor deallocates the data: # ifndef __GC ~_Rope_RopeLeaf() { - if (_M_data != _M_c_string) { + if (_M_data != this->_M_c_string) { _M_free_c_string(); } - __STL_FREE_STRING(_M_data, _M_size, get_allocator()); + __STL_FREE_STRING(_M_data, this->_M_size, get_allocator()); } # endif }; @@ -611,7 +612,7 @@ struct _Rope_RopeConcatenation : public _Rope_RopeRep<_CharT,_Alloc> { _Rope_RopeRep<_CharT,_Alloc>* __r, allocator_type __a) - : _Rope_RopeRep<_CharT,_Alloc>(_S_concat, + : _Rope_RopeRep<_CharT,_Alloc>(_Rope_RopeRep<_CharT,_Alloc>::_S_concat, std::max(__l->_M_depth, __r->_M_depth) + 1, false, __l->_M_size + __r->_M_size, __a), @@ -649,7 +650,8 @@ struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT,_Alloc> { allocator_type; _Rope_RopeFunction(char_producer<_CharT>* __f, size_t __size, bool __d, allocator_type __a) - : _Rope_RopeRep<_CharT,_Alloc>(_S_function, 0, true, __size, __a) + : _Rope_RopeRep<_CharT,_Alloc>(_Rope_RopeRep<_CharT,_Alloc>::_S_function, + 0, true, __size, __a) , _M_fn(__f) # ifndef __GC , _M_delete_when_done(__d) @@ -688,15 +690,15 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>, virtual void operator()(size_t __start_pos, size_t __req_len, _CharT* __buffer) { switch(_M_base->_M_tag) { - case _S_function: - case _S_substringfn: + case _Rope_RopeFunction<_CharT,_Alloc>::_S_function: + case _Rope_RopeFunction<_CharT,_Alloc>::_S_substringfn: { char_producer<_CharT>* __fn = ((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn; (*__fn)(__start_pos + _M_start, __req_len, __buffer); } break; - case _S_leaf: + case _Rope_RopeFunction<_CharT,_Alloc>::_S_leaf: { __GC_CONST _CharT* __s = ((_Rope_RopeLeaf<_CharT,_Alloc>*)_M_base)->_M_data; @@ -720,7 +722,7 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>, # ifndef __GC _M_base->_M_ref_nonnil(); # endif - _M_tag = _S_substringfn; + this->_M_tag = _Rope_RopeFunction<_CharT,_Alloc>::_S_substringfn; } virtual ~_Rope_RopeSubstring() { @@ -948,21 +950,22 @@ class _Rope_const_iterator : public _Rope_iterator_base<_CharT,_Alloc> { if (0 != __x._M_buf_ptr) { *(static_cast<_Rope_iterator_base<_CharT,_Alloc>*>(this)) = __x; } else { - _M_current_pos = __x._M_current_pos; - _M_root = __x._M_root; - _M_buf_ptr = 0; + this->_M_current_pos = __x._M_current_pos; + this->_M_root = __x._M_root; + this->_M_buf_ptr = 0; } return(*this); } reference operator*() { - if (0 == _M_buf_ptr) _S_setcache(*this); - return *_M_buf_ptr; + if (0 == this->_M_buf_ptr) _S_setcache(*this); + return *this->_M_buf_ptr; } _Rope_const_iterator& operator++() { __GC_CONST _CharT* __next; - if (0 != _M_buf_ptr && (__next = _M_buf_ptr + 1) < _M_buf_end) { - _M_buf_ptr = __next; - ++_M_current_pos; + if (0 != this->_M_buf_ptr + && (__next = this->_M_buf_ptr + 1) < this->_M_buf_end) { + this->_M_buf_ptr = __next; + ++this->_M_current_pos; } else { _M_incr(1); } @@ -989,17 +992,17 @@ class _Rope_const_iterator : public _Rope_iterator_base<_CharT,_Alloc> { return *this; } _Rope_const_iterator operator++(int) { - size_t __old_pos = _M_current_pos; + size_t __old_pos = this->_M_current_pos; _M_incr(1); - return _Rope_const_iterator<_CharT,_Alloc>(_M_root, __old_pos); + return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos); // This makes a subsequent dereference expensive. // Perhaps we should instead copy the iterator // if it has a valid cache? } _Rope_const_iterator operator--(int) { - size_t __old_pos = _M_current_pos; + size_t __old_pos = this->_M_current_pos; _M_decr(1); - return _Rope_const_iterator<_CharT,_Alloc>(_M_root, __old_pos); + return _Rope_const_iterator<_CharT,_Alloc>(this->_M_root, __old_pos); } template friend _Rope_const_iterator<_CharT2,_Alloc2> operator- @@ -1014,7 +1017,8 @@ class _Rope_const_iterator : public _Rope_iterator_base<_CharT,_Alloc> { (ptrdiff_t __n, const _Rope_const_iterator<_CharT2,_Alloc2>& __x); reference operator[](size_t __n) { - return rope<_CharT,_Alloc>::_S_fetch(_M_root, _M_current_pos + __n); + return rope<_CharT,_Alloc>::_S_fetch(this->_M_root, + this->_M_current_pos + __n); } template @@ -1047,7 +1051,8 @@ class _Rope_iterator : public _Rope_iterator_base<_CharT,_Alloc> { _Rope_iterator(rope<_CharT,_Alloc>* __r, size_t __pos) : _Rope_iterator_base<_CharT,_Alloc>(__r->_M_tree_ptr, __pos), _M_root_rope(__r) - { _RopeRep::_S_ref(_M_root); if (!(__r -> empty()))_S_setcache(*this); } + { _RopeRep::_S_ref(this->_M_root); + if (!(__r -> empty()))_S_setcache(*this); } void _M_check(); public: @@ -1057,41 +1062,41 @@ class _Rope_iterator : public _Rope_iterator_base<_CharT,_Alloc> { public: rope<_CharT,_Alloc>& container() { return *_M_root_rope; } _Rope_iterator() { - _M_root = 0; // Needed for reference counting. + this->_M_root = 0; // Needed for reference counting. }; _Rope_iterator(const _Rope_iterator& __x) : _Rope_iterator_base<_CharT,_Alloc>(__x) { _M_root_rope = __x._M_root_rope; - _RopeRep::_S_ref(_M_root); + _RopeRep::_S_ref(this->_M_root); } _Rope_iterator(rope<_CharT,_Alloc>& __r, size_t __pos); ~_Rope_iterator() { - _RopeRep::_S_unref(_M_root); + _RopeRep::_S_unref(this->_M_root); } _Rope_iterator& operator= (const _Rope_iterator& __x) { - _RopeRep* __old = _M_root; + _RopeRep* __old = this->_M_root; _RopeRep::_S_ref(__x._M_root); if (0 != __x._M_buf_ptr) { _M_root_rope = __x._M_root_rope; *(static_cast<_Rope_iterator_base<_CharT,_Alloc>*>(this)) = __x; } else { - _M_current_pos = __x._M_current_pos; - _M_root = __x._M_root; + this->_M_current_pos = __x._M_current_pos; + this->_M_root = __x._M_root; _M_root_rope = __x._M_root_rope; - _M_buf_ptr = 0; + this->_M_buf_ptr = 0; } _RopeRep::_S_unref(__old); return(*this); } reference operator*() { _M_check(); - if (0 == _M_buf_ptr) { + if (0 == this->_M_buf_ptr) { return _Rope_char_ref_proxy<_CharT,_Alloc>( - _M_root_rope, _M_current_pos); + _M_root_rope, this->_M_current_pos); } else { return _Rope_char_ref_proxy<_CharT,_Alloc>( - _M_root_rope, _M_current_pos, *_M_buf_ptr); + _M_root_rope, this->_M_current_pos, *this->_M_buf_ptr); } } _Rope_iterator& operator++() { @@ -1119,18 +1124,18 @@ class _Rope_iterator : public _Rope_iterator_base<_CharT,_Alloc> { return *this; } _Rope_iterator operator++(int) { - size_t __old_pos = _M_current_pos; + size_t __old_pos = this->_M_current_pos; _M_incr(1); return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos); } _Rope_iterator operator--(int) { - size_t __old_pos = _M_current_pos; + size_t __old_pos = this->_M_current_pos; _M_decr(1); return _Rope_iterator<_CharT,_Alloc>(_M_root_rope, __old_pos); } reference operator[](ptrdiff_t __n) { return _Rope_char_ref_proxy<_CharT,_Alloc>( - _M_root_rope, _M_current_pos + __n); + _M_root_rope, this->_M_current_pos + __n); } template @@ -1352,7 +1357,7 @@ class rope : public _Rope_base<_CharT,_Alloc> { public: void apply_to_pieces( size_t __begin, size_t __end, _Rope_char_consumer<_CharT>& __c) const { - _S_apply_to_pieces(__c, _M_tree_ptr, __begin, __end); + _S_apply_to_pieces(__c, this->_M_tree_ptr, __begin, __end); } @@ -1510,13 +1515,13 @@ class rope : public _Rope_base<_CharT,_Alloc> { static int _S_compare(const _RopeRep* __x, const _RopeRep* __y); public: - bool empty() const { return 0 == _M_tree_ptr; } + bool empty() const { return 0 == this->_M_tree_ptr; } // Comparison member function. This is public only for those // clients that need a ternary comparison. Others // should use the comparison operators below. int compare(const rope& __y) const { - return _S_compare(_M_tree_ptr, __y._M_tree_ptr); + return _S_compare(this->_M_tree_ptr, __y._M_tree_ptr); } rope(const _CharT* __s, const allocator_type& __a = allocator_type()) @@ -1556,7 +1561,7 @@ class rope : public _Rope_base<_CharT,_Alloc> { std::_Construct(__buf, __c); try { - _M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a); + this->_M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a); } catch(...) { @@ -1576,63 +1581,66 @@ class rope : public _Rope_base<_CharT,_Alloc> { const allocator_type& __a = allocator_type()) : _Base(__a) { - _M_tree_ptr = (0 == __len) ? + this->_M_tree_ptr = (0 == __len) ? 0 : _S_new_RopeFunction(__fn, __len, __delete_fn, __a); } rope(const rope& __x, const allocator_type& __a = allocator_type()) : _Base(__x._M_tree_ptr, __a) { - _S_ref(_M_tree_ptr); + _S_ref(this->_M_tree_ptr); } ~rope() { - _S_unref(_M_tree_ptr); + _S_unref(this->_M_tree_ptr); } rope& operator=(const rope& __x) { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = __x._M_tree_ptr; - _S_ref(_M_tree_ptr); + _RopeRep* __old = this->_M_tree_ptr; + this->_M_tree_ptr = __x._M_tree_ptr; + _S_ref(this->_M_tree_ptr); _S_unref(__old); return(*this); } void clear() { - _S_unref(_M_tree_ptr); - _M_tree_ptr = 0; + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = 0; } void push_back(_CharT __x) { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = _S_destr_concat_char_iter(_M_tree_ptr, &__x, 1); + _RopeRep* __old = this->_M_tree_ptr; + this->_M_tree_ptr + = _S_destr_concat_char_iter(this->_M_tree_ptr, &__x, 1); _S_unref(__old); } void pop_back() { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = - _S_substring(_M_tree_ptr, 0, _M_tree_ptr->_M_size - 1); + _RopeRep* __old = this->_M_tree_ptr; + this->_M_tree_ptr = + _S_substring(this->_M_tree_ptr, + 0, + this->_M_tree_ptr->_M_size - 1); _S_unref(__old); } _CharT back() const { - return _S_fetch(_M_tree_ptr, _M_tree_ptr->_M_size - 1); + return _S_fetch(this->_M_tree_ptr, this->_M_tree_ptr->_M_size - 1); } void push_front(_CharT __x) { - _RopeRep* __old = _M_tree_ptr; + _RopeRep* __old = this->_M_tree_ptr; _RopeRep* __left = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, get_allocator()); try { - _M_tree_ptr = _S_concat(__left, _M_tree_ptr); + this->_M_tree_ptr = _S_concat(__left, this->_M_tree_ptr); _S_unref(__old); _S_unref(__left); } @@ -1645,26 +1653,27 @@ class rope : public _Rope_base<_CharT,_Alloc> { void pop_front() { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = _S_substring(_M_tree_ptr, 1, _M_tree_ptr->_M_size); + _RopeRep* __old = this->_M_tree_ptr; + this->_M_tree_ptr + = _S_substring(this->_M_tree_ptr, 1, this->_M_tree_ptr->_M_size); _S_unref(__old); } _CharT front() const { - return _S_fetch(_M_tree_ptr, 0); + return _S_fetch(this->_M_tree_ptr, 0); } void balance() { - _RopeRep* __old = _M_tree_ptr; - _M_tree_ptr = _S_balance(_M_tree_ptr); + _RopeRep* __old = this->_M_tree_ptr; + this->_M_tree_ptr = _S_balance(this->_M_tree_ptr); _S_unref(__old); } void copy(_CharT* __buffer) const { _Destroy(__buffer, __buffer + size()); - _S_flatten(_M_tree_ptr, __buffer); + _S_flatten(this->_M_tree_ptr, __buffer); } // This is the copy function from the standard, but @@ -1678,14 +1687,14 @@ class rope : public _Rope_base<_CharT,_Alloc> { size_t __len = (__pos + __n > __size? __size - __pos : __n); _Destroy(__buffer, __buffer + __len); - _S_flatten(_M_tree_ptr, __pos, __len, __buffer); + _S_flatten(this->_M_tree_ptr, __pos, __len, __buffer); return __len; } // Print to stdout, exposing structure. May be useful for // performance debugging. void dump() { - _S_dump(_M_tree_ptr); + _S_dump(this->_M_tree_ptr); } // Convert to 0 terminated string in new allocated memory. @@ -1700,21 +1709,21 @@ class rope : public _Rope_base<_CharT,_Alloc> { // Intentionally undocumented, since it's hard to say when this // is safe for multiple threads. void delete_c_str () { - if (0 == _M_tree_ptr) return; - if (_RopeRep::_S_leaf == _M_tree_ptr->_M_tag && - ((_RopeLeaf*)_M_tree_ptr)->_M_data == - _M_tree_ptr->_M_c_string) { + if (0 == this->_M_tree_ptr) return; + if (_RopeRep::_S_leaf == this->_M_tree_ptr->_M_tag && + ((_RopeLeaf*)this->_M_tree_ptr)->_M_data == + this->_M_tree_ptr->_M_c_string) { // Representation shared return; } # ifndef __GC - _M_tree_ptr->_M_free_c_string(); + this->_M_tree_ptr->_M_free_c_string(); # endif - _M_tree_ptr->_M_c_string = 0; + this->_M_tree_ptr->_M_c_string = 0; } _CharT operator[] (size_type __pos) const { - return _S_fetch(_M_tree_ptr, __pos); + return _S_fetch(this->_M_tree_ptr, __pos); } _CharT at(size_type __pos) const { @@ -1723,24 +1732,24 @@ class rope : public _Rope_base<_CharT,_Alloc> { } const_iterator begin() const { - return(const_iterator(_M_tree_ptr, 0)); + return(const_iterator(this->_M_tree_ptr, 0)); } // An easy way to get a const iterator from a non-const container. const_iterator const_begin() const { - return(const_iterator(_M_tree_ptr, 0)); + return(const_iterator(this->_M_tree_ptr, 0)); } const_iterator end() const { - return(const_iterator(_M_tree_ptr, size())); + return(const_iterator(this->_M_tree_ptr, size())); } const_iterator const_end() const { - return(const_iterator(_M_tree_ptr, size())); + return(const_iterator(this->_M_tree_ptr, size())); } size_type size() const { - return(0 == _M_tree_ptr? 0 : _M_tree_ptr->_M_size); + return(0 == this->_M_tree_ptr? 0 : this->_M_tree_ptr->_M_size); } size_type length() const { @@ -1793,9 +1802,9 @@ class rope : public _Rope_base<_CharT,_Alloc> { // forward iterator with value_type _CharT. rope& append(const _CharT* __iter, size_t __n) { _RopeRep* __result = - _S_destr_concat_char_iter(_M_tree_ptr, __iter, __n); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + _S_destr_concat_char_iter(this->_M_tree_ptr, __iter, __n); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; return *this; } @@ -1807,9 +1816,9 @@ class rope : public _Rope_base<_CharT,_Alloc> { rope& append(const _CharT* __s, const _CharT* __e) { _RopeRep* __result = - _S_destr_concat_char_iter(_M_tree_ptr, __s, __e - __s); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + _S_destr_concat_char_iter(this->_M_tree_ptr, __s, __e - __s); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; return *this; } @@ -1817,26 +1826,26 @@ class rope : public _Rope_base<_CharT,_Alloc> { _Self_destruct_ptr __appendee(_S_substring( __s._M_root, __s._M_current_pos, __e._M_current_pos)); _RopeRep* __result = - _S_concat(_M_tree_ptr, (_RopeRep*)__appendee); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + _S_concat(this->_M_tree_ptr, (_RopeRep*)__appendee); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; return *this; } rope& append(_CharT __c) { _RopeRep* __result = - _S_destr_concat_char_iter(_M_tree_ptr, &__c, 1); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + _S_destr_concat_char_iter(this->_M_tree_ptr, &__c, 1); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; return *this; } rope& append() { return append(_CharT()); } // XXX why? rope& append(const rope& __y) { - _RopeRep* __result = _S_concat(_M_tree_ptr, __y._M_tree_ptr); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + _RopeRep* __result = _S_concat(this->_M_tree_ptr, __y._M_tree_ptr); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; return *this; } @@ -1846,8 +1855,8 @@ class rope : public _Rope_base<_CharT,_Alloc> { } void swap(rope& __b) { - _RopeRep* __tmp = _M_tree_ptr; - _M_tree_ptr = __b._M_tree_ptr; + _RopeRep* __tmp = this->_M_tree_ptr; + this->_M_tree_ptr = __b._M_tree_ptr; __b._M_tree_ptr = __tmp; } @@ -1875,9 +1884,9 @@ class rope : public _Rope_base<_CharT,_Alloc> { public: void insert(size_t __p, const rope& __r) { _RopeRep* __result = - replace(_M_tree_ptr, __p, __p, __r._M_tree_ptr); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + replace(this->_M_tree_ptr, __p, __p, __r._M_tree_ptr); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; } void insert(size_t __p, size_t __n, _CharT __c) { @@ -1886,16 +1895,17 @@ class rope : public _Rope_base<_CharT,_Alloc> { } void insert(size_t __p, const _CharT* __i, size_t __n) { - _Self_destruct_ptr __left(_S_substring(_M_tree_ptr, 0, __p)); - _Self_destruct_ptr __right(_S_substring(_M_tree_ptr, __p, size())); + _Self_destruct_ptr __left(_S_substring(this->_M_tree_ptr, 0, __p)); + _Self_destruct_ptr __right(_S_substring(this->_M_tree_ptr, + __p, size())); _Self_destruct_ptr __left_result( _S_concat_char_iter(__left, __i, __n)); // _S_ destr_concat_char_iter should be safe here. // But as it stands it's probably not a win, since __left // is likely to have additional references. _RopeRep* __result = _S_concat(__left_result, __right); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; } void insert(size_t __p, const _CharT* __c_string) { @@ -1932,9 +1942,9 @@ class rope : public _Rope_base<_CharT,_Alloc> { void replace(size_t __p, size_t __n, const rope& __r) { _RopeRep* __result = - replace(_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + replace(this->_M_tree_ptr, __p, __p + __n, __r._M_tree_ptr); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; } void replace(size_t __p, size_t __n, @@ -2005,9 +2015,9 @@ class rope : public _Rope_base<_CharT,_Alloc> { // Erase, (position, size) variant. void erase(size_t __p, size_t __n) { - _RopeRep* __result = replace(_M_tree_ptr, __p, __p + __n, 0); - _S_unref(_M_tree_ptr); - _M_tree_ptr = __result; + _RopeRep* __result = replace(this->_M_tree_ptr, __p, __p + __n, 0); + _S_unref(this->_M_tree_ptr); + this->_M_tree_ptr = __result; } // Erase, single character @@ -2091,31 +2101,35 @@ class rope : public _Rope_base<_CharT,_Alloc> { rope substr(size_t __start, size_t __len = 1) const { return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __start, __start + __len)); + _S_substring(this->_M_tree_ptr, + __start, + __start + __len)); } rope substr(iterator __start, iterator __end) const { return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __start.index(), __end.index())); + _S_substring(this->_M_tree_ptr, + __start.index(), + __end.index())); } rope substr(iterator __start) const { size_t __pos = __start.index(); return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __pos, __pos + 1)); + _S_substring(this->_M_tree_ptr, __pos, __pos + 1)); } rope substr(const_iterator __start, const_iterator __end) const { // This might eventually take advantage of the cache in the // iterator. return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __start.index(), __end.index())); + _S_substring(this->_M_tree_ptr, __start.index(), __end.index())); } rope<_CharT,_Alloc> substr(const_iterator __start) { size_t __pos = __start.index(); return rope<_CharT,_Alloc>( - _S_substring(_M_tree_ptr, __pos, __pos + 1)); + _S_substring(this->_M_tree_ptr, __pos, __pos + 1)); } static const size_type npos; diff --git a/libstdc++-v3/include/std/std_fstream.h b/libstdc++-v3/include/std/std_fstream.h index 4e2e8447f3b..0c7bf180550 100644 --- a/libstdc++-v3/include/std/std_fstream.h +++ b/libstdc++-v3/include/std/std_fstream.h @@ -1,6 +1,6 @@ // File based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -311,14 +311,15 @@ namespace std virtual int sync() { - bool __testput = _M_out_cur && _M_out_beg < _M_out_end; + bool __testput = this->_M_out_cur + && this->_M_out_beg < this->_M_out_end; // Make sure that the internal buffer resyncs its idea of // the file position with the external file. if (__testput) { // Need to restore current position after the write. - off_type __off = _M_out_cur - _M_out_end; + off_type __off = this->_M_out_cur - this->_M_out_end; _M_really_overflow(); // _M_file.sync() will be called within if (__off) _M_file.seekoff(__off, ios_base::cur); @@ -339,14 +340,14 @@ namespace std { streamsize __ret = 0; // Clear out pback buffer before going on to the real deal... - if (_M_pback_init) + if (this->_M_pback_init) { - while (__ret < __n && _M_in_cur < _M_in_end) + while (__ret < __n && this->_M_in_cur < this->_M_in_end) { - *__s = *_M_in_cur; + *__s = *this->_M_in_cur; ++__ret; ++__s; - ++_M_in_cur; + ++this->_M_in_cur; } _M_pback_destroy(); } @@ -386,11 +387,11 @@ namespace std void _M_set_indeterminate(void) { - if (_M_mode & ios_base::in) - this->setg(_M_buf, _M_buf, _M_buf); - if (_M_mode & ios_base::out) - this->setp(_M_buf, _M_buf); - _M_filepos = _M_buf; + if (this->_M_mode & ios_base::in) + this->setg(this->_M_buf, this->_M_buf, this->_M_buf); + if (this->_M_mode & ios_base::out) + this->setp(this->_M_buf, this->_M_buf); + _M_filepos = this->_M_buf; } /** @@ -401,13 +402,13 @@ namespace std void _M_set_determinate(off_type __off) { - bool __testin = _M_mode & ios_base::in; - bool __testout = _M_mode & ios_base::out; + bool __testin = this->_M_mode & ios_base::in; + bool __testout = this->_M_mode & ios_base::out; if (__testin) - this->setg(_M_buf, _M_buf, _M_buf + __off); + this->setg(this->_M_buf, this->_M_buf, this->_M_buf + __off); if (__testout) - this->setp(_M_buf, _M_buf + __off); - _M_filepos = _M_buf + __off; + this->setp(this->_M_buf, this->_M_buf + __off); + _M_filepos = this->_M_buf + __off; } /** @@ -420,12 +421,14 @@ namespace std { bool __ret = false; // Don't return true if unbuffered. - if (_M_buf) + if (this->_M_buf) { - if (_M_mode & ios_base::in) - __ret = _M_in_beg == _M_in_cur && _M_in_cur == _M_in_end; - if (_M_mode & ios_base::out) - __ret = _M_out_beg == _M_out_cur && _M_out_cur == _M_out_end; + if (this->_M_mode & ios_base::in) + __ret = this->_M_in_beg == this->_M_in_cur + && this->_M_in_cur == this->_M_in_end; + if (this->_M_mode & ios_base::out) + __ret = this->_M_out_beg == this->_M_out_cur + && this->_M_out_cur == this->_M_out_end; } return __ret; } diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h index 936481d6e05..0ad52d023c8 100644 --- a/libstdc++-v3/include/std/std_sstream.h +++ b/libstdc++-v3/include/std/std_sstream.h @@ -1,6 +1,6 @@ // String based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2002, 2003 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 @@ -133,16 +133,17 @@ namespace std __string_type str() const { - if (_M_mode & ios_base::out) + if (this->_M_mode & ios_base::out) { // This is the deal: _M_string.size() is a value that // represents the size of the initial string that makes // _M_string, and may not be the correct size of the // current stringbuf internal buffer. __size_type __len = _M_string.size(); - if (_M_out_cur > _M_out_beg) - __len = std::max(__size_type(_M_out_end - _M_out_beg), __len); - return __string_type(_M_out_beg, _M_out_beg + __len); + if (this->_M_out_cur > this->_M_out_beg) + __len = std::max(__size_type(this->_M_out_end + - this->_M_out_beg), __len); + return __string_type(this->_M_out_beg, this->_M_out_beg + __len); } else return _M_string; @@ -160,7 +161,7 @@ namespace std { // Cannot use _M_string = __s, since v3 strings are COW. _M_string.assign(__s.data(), __s.size()); - _M_stringbuf_init(_M_mode); + _M_stringbuf_init(this->_M_mode); } protected: @@ -178,16 +179,16 @@ namespace std // necessary as ostringstreams are implemented with the // streambufs having control of the allocation and // re-allocation of the internal string object, _M_string. - _M_buf_size = _M_string.size(); + this->_M_buf_size = _M_string.size(); // NB: Start ostringstream buffers at 512 bytes. This is an // experimental value (pronounced "arbitrary" in some of the // hipper english-speaking countries), and can be changed to // suit particular needs. - _M_buf_size_opt = 512; - _M_mode = __mode; - if (_M_mode & (ios_base::ate | ios_base::app)) - _M_really_sync(0, _M_buf_size); + this->_M_buf_size_opt = 512; + this->_M_mode = __mode; + if (this->_M_mode & (ios_base::ate | ios_base::app)) + _M_really_sync(0, this->_M_buf_size); else _M_really_sync(0, 0); } @@ -197,7 +198,7 @@ namespace std virtual int_type underflow() { - if (_M_in_cur && _M_in_cur < _M_in_end) + if (this->_M_in_cur && this->_M_in_cur < this->_M_in_end) return traits_type::to_int_type(*gptr()); else return traits_type::eof(); @@ -258,17 +259,17 @@ namespace std _M_really_sync(__size_type __i, __size_type __o) { char_type* __base = const_cast(_M_string.data()); - bool __testin = _M_mode & ios_base::in; - bool __testout = _M_mode & ios_base::out; + bool __testin = this->_M_mode & ios_base::in; + bool __testout = this->_M_mode & ios_base::out; __size_type __len = _M_string.size(); - _M_buf = __base; + this->_M_buf = __base; if (__testin) this->setg(__base, __base + __i, __base + __len); if (__testout) { this->setp(__base, __base + __len); - _M_out_cur += __o; + this->_M_out_cur += __o; } return 0; }