From 98ca843cfb0e860bf72ad2eafc34e255f633f26c Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 12 Jul 2004 19:10:03 +0000 Subject: [PATCH] parser.c (cp_parser_class_head): Remove unused variable. 2004-07-12 Eric Christopher * parser.c (cp_parser_class_head): Remove unused variable. From-SVN: r84571 --- gcc/cp/ChangeLog | 6 ++- gcc/cp/parser.c | 157 +++++++++++++++++++++++++++---------------------------- 2 files changed, 83 insertions(+), 80 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4b37be7..988c71f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2004-07-12 Eric Christopher + + * parser.c (cp_parser_class_head): Remove unused variable. + 2004-07-12 Giovanni Bajo * decl.c (grok_op_properties): Reject [de-]allocation functions @@ -9,7 +13,7 @@ * decl.c (xref_basetypes): Use make_tree_binfo directly. * tree.h (copy_base_binfos): Likewise. (make_binfo): Remove. - + * call.c (build_user_type_conversion_1, build_new_op, check_constructor_callable, build_temp, perform_direct_initialization_of_possible): Pass type directly to diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 08ee875..53e5a93 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1015,19 +1015,19 @@ clear_decl_specs (cp_decl_specifier_seq *decl_specs) Other parts of the front end that need to create entities (like VAR_DECLs or FUNCTION_DECLs) should do that directly. */ -static cp_declarator *make_id_declarator +static cp_declarator *make_id_declarator (tree); -static cp_declarator *make_call_declarator +static cp_declarator *make_call_declarator (cp_declarator *, cp_parameter_declarator *, cp_cv_quals, tree); -static cp_declarator *make_array_declarator +static cp_declarator *make_array_declarator (cp_declarator *, tree); -static cp_declarator *make_pointer_declarator +static cp_declarator *make_pointer_declarator (cp_cv_quals, cp_declarator *); -static cp_declarator *make_reference_declarator +static cp_declarator *make_reference_declarator (cp_cv_quals, cp_declarator *); -static cp_parameter_declarator *make_parameter_declarator +static cp_parameter_declarator *make_parameter_declarator (cp_decl_specifier_seq *, cp_declarator *, tree); -static cp_declarator *make_ptrmem_declarator +static cp_declarator *make_ptrmem_declarator (cp_cv_quals, tree, cp_declarator *); cp_declarator *cp_error_declarator; @@ -1066,7 +1066,7 @@ cp_declarator * make_id_declarator (tree id) { cp_declarator *declarator; - + declarator = make_declarator (cdk_id); declarator->u.id.name = id; declarator->u.id.sfk = sfk_none; @@ -1129,7 +1129,7 @@ make_ptrmem_declarator (cp_cv_quals cv_qualifiers, tree class_type, indicates what exceptions can be thrown. */ cp_declarator * -make_call_declarator (cp_declarator *target, +make_call_declarator (cp_declarator *target, cp_parameter_declarator *parms, cp_cv_quals cv_qualifiers, tree exception_specification) @@ -1166,13 +1166,13 @@ cp_parameter_declarator *no_parameters; DECLARATOR and DEFAULT_ARGUMENT. */ cp_parameter_declarator * -make_parameter_declarator (cp_decl_specifier_seq *decl_specifiers, +make_parameter_declarator (cp_decl_specifier_seq *decl_specifiers, cp_declarator *declarator, tree default_argument) { cp_parameter_declarator *parameter; - parameter = ((cp_parameter_declarator *) + parameter = ((cp_parameter_declarator *) alloc_declarator (sizeof (cp_parameter_declarator))); parameter->next = NULL; if (decl_specifiers) @@ -1650,7 +1650,7 @@ static tree cp_parser_storage_class_specifier_opt static tree cp_parser_function_specifier_opt (cp_parser *, cp_decl_specifier_seq *); static tree cp_parser_type_specifier - (cp_parser *, cp_parser_flags, cp_decl_specifier_seq *, bool, + (cp_parser *, cp_parser_flags, cp_decl_specifier_seq *, bool, int *, bool *); static tree cp_parser_simple_type_specifier (cp_parser *, cp_decl_specifier_seq *, cp_parser_flags); @@ -1874,7 +1874,7 @@ static bool cp_parser_declares_only_class_p (cp_parser *); static void cp_parser_set_storage_class (cp_decl_specifier_seq *, cp_storage_class); -static void cp_parser_set_decl_spec_type +static void cp_parser_set_decl_spec_type (cp_decl_specifier_seq *, tree, bool); static bool cp_parser_friend_p (const cp_decl_specifier_seq *); @@ -2623,7 +2623,7 @@ cp_parser_translation_unit (cp_parser* parser) static void *declarator_obstack_base; bool success; - + /* Create the declarator obstack, if necessary. */ if (!cp_error_declarator) { @@ -2645,7 +2645,7 @@ cp_parser_translation_unit (cp_parser* parser) { /* Consume the EOF token. */ cp_parser_require (parser, CPP_EOF, "end-of-file"); - + /* Finish up. */ finish_translation_unit (); @@ -3764,7 +3764,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) if (parser->integral_constant_expression_p && !dependent_type_p (type) && !INTEGRAL_OR_ENUMERATION_TYPE_P (type) - && (cp_parser_non_integral_constant_expression + && (cp_parser_non_integral_constant_expression (parser, "a cast to a type other than an integral or " "enumeration type"))) @@ -3836,7 +3836,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"); } /* `typeid' may not appear in an integral constant expression. */ - if (cp_parser_non_integral_constant_expression(parser, + if (cp_parser_non_integral_constant_expression(parser, "`typeid' operator")) return error_mark_node; /* Restore the saved message. */ @@ -3881,7 +3881,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) /* Create a TYPENAME_TYPE to represent the type to which the functional cast is being performed. */ else - type = make_typename_type (parser->scope, id, + type = make_typename_type (parser->scope, id, /*complain=*/1); postfix_expression = cp_parser_functional_cast (parser, type); @@ -4114,7 +4114,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p) postfix-expression . pseudo-destructor-name postfix-expression -> template [opt] id-expression postfix-expression -> pseudo-destructor-name */ - + /* Consume the `.' or `->' operator. */ cp_lexer_consume_token (parser->lexer); @@ -4308,7 +4308,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, parser->object_scope = NULL_TREE; } if (scope && name && BASELINK_P (name)) - adjust_result_of_qualified_name_lookup + adjust_result_of_qualified_name_lookup (name, BINFO_TYPE (BASELINK_BINFO (name)), scope); postfix_expression = finish_class_member_access_expr (postfix_expression, name); @@ -4334,7 +4334,7 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, /* Outside of offsetof, these operators may not appear in constant-expressions. */ if (!for_offsetof - && (cp_parser_non_integral_constant_expression + && (cp_parser_non_integral_constant_expression (parser, token_type == CPP_DEREF ? "'->'" : "`.'"))) postfix_expression = error_mark_node; @@ -4723,7 +4723,7 @@ cp_parser_unary_expression (cp_parser *parser, bool address_p) abort (); } - if (non_constant_p + if (non_constant_p && cp_parser_non_integral_constant_expression (parser, non_constant_p)) expression = error_mark_node; @@ -4808,7 +4808,7 @@ cp_parser_new_expression (cp_parser* parser) type = cp_parser_type_id (parser); /* Look for the closing `)'. */ cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"); - /* There should not be a direct-new-declarator in this production, + /* There should not be a direct-new-declarator in this production, but GCC used to allowed this, so we check and emit a sensible error message for this case. */ if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_SQUARE)) @@ -4902,7 +4902,7 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts) outer_declarator = declarator; declarator = declarator->declarator; } - while (declarator + while (declarator && declarator->kind == cdk_array && declarator->declarator && declarator->declarator->kind == cdk_array) @@ -4910,7 +4910,7 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts) outer_declarator = declarator; declarator = declarator->declarator; } - + if (declarator && declarator->kind == cdk_array) { *nelts = declarator->u.array.bounds; @@ -4918,7 +4918,7 @@ cp_parser_new_type_id (cp_parser* parser, tree *nelts) *nelts = integer_one_node; else if (!processing_template_decl) { - if (!build_expr_type_conversion (WANT_INT | WANT_ENUM, *nelts, + if (!build_expr_type_conversion (WANT_INT | WANT_ENUM, *nelts, false)) pedwarn ("size in array new must have integral type"); *nelts = save_expr (cp_convert (sizetype, *nelts)); @@ -5210,7 +5210,7 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p) if (parser->integral_constant_expression_p && !dependent_type_p (type) && !INTEGRAL_OR_ENUMERATION_TYPE_P (type) - && (cp_parser_non_integral_constant_expression + && (cp_parser_non_integral_constant_expression (parser, "a cast to a type other than an integral or " "enumeration type"))) @@ -6443,7 +6443,7 @@ cp_parser_iteration_statement (cp_parser* parser) finish_for_expr (expression, statement); /* Look for the `)'. */ cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"); - + /* Parse the body of the for-statement. */ parser->in_iteration_statement_p = true; cp_parser_already_scoped_statement (parser); @@ -6953,7 +6953,7 @@ cp_parser_simple_declaration (cp_parser* parser, /* In a block scope, a valid declaration must always have a decl-specifier-seq. By not trying to parse declarators, we can resolve the declaration/expression ambiguity more quickly. */ - if (!function_definition_allowed_p + if (!function_definition_allowed_p && !decl_specifiers.any_specifiers_p) { cp_parser_error (parser, "expected declaration"); @@ -7094,7 +7094,7 @@ cp_parser_simple_declaration (cp_parser* parser, (i.e., a type declaration) 2: one of the decl-specifiers is an enum-specifier or a class-specifier (i.e., a type definition) - + */ static void @@ -7124,7 +7124,7 @@ cp_parser_decl_specifier_seq (cp_parser* parser, if (token->keyword == RID_ATTRIBUTE) { /* Parse the attributes. */ - decl_specs->attributes + decl_specs->attributes = chainon (decl_specs->attributes, cp_parser_attributes_opt (parser)); continue; @@ -7225,10 +7225,10 @@ cp_parser_decl_specifier_seq (cp_parser* parser, /* Constructors are a special case. The `S' in `S()' is not a decl-specifier; it is the beginning of the declarator. */ - constructor_p + constructor_p = (!found_decl_spec && constructor_possible_p - && (cp_parser_constructor_declarator_p + && (cp_parser_constructor_declarator_p (parser, decl_specs->specs[(int) ds_friend] != 0))); /* If we don't have a DECL_SPEC yet, then we must be looking at @@ -7570,10 +7570,10 @@ cp_parser_conversion_declarator_opt (cp_parser* parser) if (cp_parser_parse_definitely (parser)) { cp_declarator *declarator; - + /* Parse another optional declarator. */ declarator = cp_parser_conversion_declarator_opt (parser); - + /* Create the representation of the declarator. */ if (class_type) declarator = make_ptrmem_declarator (cv_quals, class_type, @@ -7582,7 +7582,7 @@ cp_parser_conversion_declarator_opt (cp_parser* parser) declarator = make_pointer_declarator (cv_quals, declarator); else declarator = make_reference_declarator (cv_quals, declarator); - + return declarator; } @@ -8193,11 +8193,11 @@ cp_parser_template_parameter (cp_parser* parser, bool *is_non_type) parameter_declarator = cp_parser_parameter_declaration (parser, /*template_parm_p=*/true, /*parenthesized_p=*/NULL); - return (build_tree_list + return (build_tree_list (parameter_declarator->default_argument, grokdeclarator (parameter_declarator->declarator, ¶meter_declarator->decl_specifiers, - PARM, /*initialized=*/0, + PARM, /*initialized=*/0, /*attrlist=*/NULL))); } @@ -8690,7 +8690,7 @@ cp_parser_template_name (cp_parser* parser, (and must) do name-lookup normally. */ if (template_keyword_p && (!parser->scope - || (TYPE_P (parser->scope) + || (TYPE_P (parser->scope) && dependent_type_p (parser->scope)))) return identifier; } @@ -9045,7 +9045,7 @@ cp_parser_explicit_instantiation (cp_parser* parser) extension_specifier = cp_parser_storage_class_specifier_opt (parser); if (!extension_specifier) - extension_specifier + extension_specifier = cp_parser_function_specifier_opt (parser, /*decl_specs=*/NULL); } @@ -9252,8 +9252,8 @@ cp_parser_type_specifier (cp_parser* parser, case RID_TYPENAME: /* Look for an elaborated-type-specifier. */ - type_spec - = (cp_parser_elaborated_type_specifier + type_spec + = (cp_parser_elaborated_type_specifier (parser, decl_specs && decl_specs->specs[(int) ds_friend], is_declaration)); @@ -9272,7 +9272,7 @@ cp_parser_type_specifier (cp_parser* parser, if (is_cv_qualifier) *is_cv_qualifier = true; break; - + case RID_VOLATILE: ds = ds_volatile; if (is_cv_qualifier) @@ -9307,7 +9307,7 @@ cp_parser_type_specifier (cp_parser* parser, /* If we do not already have a type-specifier, assume we are looking at a simple-type-specifier. */ - type_spec = cp_parser_simple_type_specifier (parser, + type_spec = cp_parser_simple_type_specifier (parser, decl_specs, flags); @@ -9349,7 +9349,7 @@ cp_parser_type_specifier (cp_parser* parser, appropriately updated. */ static tree -cp_parser_simple_type_specifier (cp_parser* parser, +cp_parser_simple_type_specifier (cp_parser* parser, cp_decl_specifier_seq *decl_specs, cp_parser_flags flags) { @@ -9420,7 +9420,7 @@ cp_parser_simple_type_specifier (cp_parser* parser, if (decl_specs) cp_parser_set_decl_spec_type (decl_specs, type, /*user_defined_p=*/true); - + return type; default: @@ -9438,7 +9438,7 @@ cp_parser_simple_type_specifier (cp_parser* parser, && token->keyword != RID_UNSIGNED && token->keyword != RID_SHORT && token->keyword != RID_LONG)) - cp_parser_set_decl_spec_type (decl_specs, + cp_parser_set_decl_spec_type (decl_specs, type, /*user_defined=*/false); if (decl_specs) @@ -9498,9 +9498,9 @@ cp_parser_simple_type_specifier (cp_parser* parser, else type = cp_parser_type_name (parser); /* Keep track of all name-lookups performed in class scopes. */ - if (type + if (type && !qualified_p - && TREE_CODE (type) == TYPE_DECL + && TREE_CODE (type) == TYPE_DECL && TREE_CODE (DECL_NAME (type)) == IDENTIFIER_NODE) maybe_note_name_used_in_class (DECL_NAME (type), type); /* If it didn't work out, we don't have a TYPE. */ @@ -11149,12 +11149,12 @@ cp_parser_direct_declarator (cp_parser* parser, if (ctor_dtor_or_conv_p && declarator->u.id.sfk != sfk_none) *ctor_dtor_or_conv_p = -1; if (TREE_CODE (id) == SCOPE_REF - && TREE_CODE (unqualified_name) == TYPE_DECL + && TREE_CODE (unqualified_name) == TYPE_DECL && CLASSTYPE_USE_TEMPLATE (TREE_TYPE (unqualified_name))) { error ("invalid use of constructor as a template"); inform ("use `%T::%D' instead of `%T::%T' to name the " - "constructor in a qualified name", class_type, + "constructor in a qualified name", class_type, DECL_NAME (TYPE_TI_TEMPLATE (class_type)), class_type, class_type); } @@ -11299,7 +11299,7 @@ cp_parser_ptr_operator (cp_parser* parser, GNU Extension: cv-qualifier: - __restrict__ + __restrict__ Returns a bitmask representing the cv-qualifiers. */ @@ -11312,7 +11312,7 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser) { cp_token *token; cp_cv_quals cv_qualifier; - + /* Peek at the next token. */ token = cp_lexer_peek_token (parser->lexer); /* See if it's a cv-qualifier. */ @@ -11321,20 +11321,20 @@ cp_parser_cv_qualifier_seq_opt (cp_parser* parser) case RID_CONST: cv_qualifier = TYPE_QUAL_CONST; break; - + case RID_VOLATILE: cv_qualifier = TYPE_QUAL_VOLATILE; break; - + case RID_RESTRICT: cv_qualifier = TYPE_QUAL_RESTRICT; break; - + default: cv_qualifier = TYPE_UNQUALIFIED; break; } - + if (!cv_qualifier) break; @@ -11461,7 +11461,7 @@ cp_parser_type_specifier_seq (cp_parser* parser, /* Check for attributes first. */ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_ATTRIBUTE)) { - type_specifier_seq->attributes = + type_specifier_seq->attributes = chainon (type_specifier_seq->attributes, cp_parser_attributes_opt (parser)); continue; @@ -11576,7 +11576,7 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) /* Finish the parameter list. */ if (parameters && ellipsis_p) parameters->ellipsis_p = true; - + return parameters; } @@ -11782,7 +11782,7 @@ cp_parser_parameter_declaration (cp_parser *parser, parser->default_arg_ok_p = saved_default_arg_ok_p; /* After the declarator, allow more attributes. */ decl_specifiers.attributes - = chainon (decl_specifiers.attributes, + = chainon (decl_specifiers.attributes, cp_parser_attributes_opt (parser)); } @@ -12040,7 +12040,7 @@ cp_parser_initializer_clause (cp_parser* parser, bool* non_constant_p) assignment-expression. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE)) { - initializer + initializer = cp_parser_constant_expression (parser, /*allow_non_constant_p=*/true, non_constant_p); @@ -12338,14 +12338,14 @@ cp_parser_class_specifier (cp_parser* parser) if (nested_name_specifier_p) pop_p = push_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (type))); type = begin_class_definition (type); - + if (type == error_mark_node) /* If the type is erroneous, skip the entire body of the class. */ cp_parser_skip_to_closing_brace (parser); else /* Parse the member-specification. */ cp_parser_member_specification_opt (parser); - + /* Look for the trailing `}'. */ cp_parser_require (parser, CPP_CLOSE_BRACE, "`}'"); /* We get better error messages by noticing a common problem: a @@ -12482,7 +12482,6 @@ cp_parser_class_head (cp_parser* parser, bool* nested_name_specifier_p, tree *attributes_p) { - cp_token *token; tree nested_name_specifier; enum tag_types class_key; tree id = NULL_TREE; @@ -12771,13 +12770,13 @@ cp_parser_class_head (cp_parser* parser, is valid. */ if (nested_name_specifier) pop_p = push_scope (nested_name_specifier); - + bases = NULL_TREE; - + /* Get the list of base-classes, if there is one. */ if (cp_lexer_next_token_is (parser->lexer, CPP_COLON)) bases = cp_parser_base_clause (parser); - + /* Process the base classes. */ xref_basetypes (type, bases); @@ -12988,7 +12987,7 @@ cp_parser_member_declaration (cp_parser* parser) A::B will be represented by a TYPENAME_TYPE, and therefore not recognized by check_tag_decl. */ - if (!type + if (!type && decl_specifiers.type && TYPE_P (decl_specifiers.type)) type = decl_specifiers.type; @@ -13069,7 +13068,7 @@ cp_parser_member_declaration (cp_parser* parser) attributes = chainon (prefix_attributes, attributes); /* Create the bitfield declaration. */ - decl = grokbitfield (identifier + decl = grokbitfield (identifier ? make_id_declarator (identifier) : NULL, &decl_specifiers, @@ -14418,7 +14417,7 @@ cp_parser_check_declarator_template_parameters (cp_parser* parser, case cdk_pointer: case cdk_reference: case cdk_ptrmem: - return (cp_parser_check_declarator_template_parameters + return (cp_parser_check_declarator_template_parameters (parser, declarator->declarator)); case cdk_error: @@ -14513,7 +14512,7 @@ cp_parser_binary_expression (cp_parser* parser, /* Parse the right-hand side of the expression. */ rhs = (*fn) (parser); /* Build the binary tree node. */ - lhs = build_x_binary_op (map_node->tree_type, lhs, rhs, + lhs = build_x_binary_op (map_node->tree_type, lhs, rhs, &overloaded_p); /* If the binary operator required the use of an overloaded operator, then this expression cannot be an @@ -14522,7 +14521,7 @@ cp_parser_binary_expression (cp_parser* parser, permissible in an integral constant-expression if at least one of the operands is of enumeration type. */ if (overloaded_p - && (cp_parser_non_integral_constant_expression + && (cp_parser_non_integral_constant_expression (parser, "calls to overloaded operators"))) lhs = error_mark_node; break; @@ -14883,13 +14882,13 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p) /* There are no access checks when parsing a template, as we do not know if a specialization will be a friend. */ push_deferring_access_checks (dk_no_check); - + decl = cp_parser_single_declaration (parser, member_p, &friend_p); pop_deferring_access_checks (); - + /* If this is a member template declaration, let the front end know. */ if (member_p && !friend_p && decl) @@ -15024,10 +15023,10 @@ cp_parser_functional_cast (cp_parser* parser, tree type) cast = build_functional_cast (type, expression_list); /* [expr.const]/1: In an integral constant expression "only type conversions to integral or enumeration type can be used". */ - if (cast != error_mark_node && !type_dependent_expression_p (type) + if (cast != error_mark_node && !type_dependent_expression_p (type) && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (type))) { - if (cp_parser_non_integral_constant_expression + if (cp_parser_non_integral_constant_expression (parser, "a call to a constructor")) return error_mark_node; } @@ -15442,12 +15441,12 @@ cp_parser_set_decl_spec_type (cp_decl_specifier_seq *decl_specs, bool user_defined_p) { decl_specs->any_specifiers_p = true; - + /* If the user tries to redeclare a built-in type (with, for example, in "typedef int wchar_t;") we remember that this is what happened. In system headers, we ignore these declarations so that G++ can work with system headers that are not C++-safe. */ - if (decl_specs->specs[(int) ds_typedef] + if (decl_specs->specs[(int) ds_typedef] && !user_defined_p && (decl_specs->type || decl_specs->specs[(int) ds_long] @@ -15805,7 +15804,7 @@ cp_parser_cache_group (cp_parser *parser, c_lex_string_translate = -1; cp_parser_cache_group_1 (parser, cache, end, depth); - + c_lex_string_translate = saved_c_lex_string_translate; } -- 2.7.4