From 2f939d94068972c5b14ab98f50c6789621810a4a Mon Sep 17 00:00:00 2001 From: Theodore Papadopoulo Date: Thu, 23 Mar 2000 01:41:05 +0100 Subject: [PATCH] builtin.c (get_pointer_alignment): Use DECL_P and TYPE_P macros. * builtin.c (get_pointer_alignment): Use DECL_P and TYPE_P macros. * c-common.c (decl_attributes,check_format_info,truthvalue_conversion, c_get_alias_set): Likewise. * c-decl.c (duplicate_decls): Likewise. * c-typeck.c (default_conversion,build_unary_op): Likewise. * calls.c (initialize_argument_information): Likewise. * dwarf2out.c (decl_class_context,add_abstract_origin_attribute): Likewise. * dwarfout.c (decl_class_context,output_type): Likewise. * expr.c (get_inner_reference): Likewise. * fold-const.c (simple_operand_p,fold): Likewise. * function.c (aggregate_value_p): Likewise. * stmt.c (expand_asm_operands): Likewise. * varasm.c (named_section): Likewise. * call.c (check_dtor_name,build_new_method_call): Likewise. * decl.c (push_class_binding,poplevel,pushtag,lookup_namespace_name, make_typename_type,check_initializer,cp_finish_decl,xref_tag): Likewise. * decl2.c (grokfield,build_expr_from_tree,build_expr_from_tree, decl_namespace,arg_assoc_template_arg,arg_assoc, validate_nonmember_using_decl,do_class_using_decl): Likewise. * error.c (dump_template_argument,dump_expr,cp_file_of,cp_line_of, args_to_string): Likewise. * friend.c (is_friend): Likewise. * lex.c (note_got_semicolon,note_list_got_semicolon,is_global): Likewise. * method.c (build_overload_nested_name,build_overload_value, build_qualified_name,build_qualified_name,hack_identifier): Likewise. * parse.y (typename_sub,typename_sub1): Likewise. * pt.c (push_inline_template_parms_recursive,check_template_shadow, process_partial_specialization,convert_template_argument, template_args_equal,add_pending_template,lookup_template_class, for_each_template_parm_r,maybe_fold_nontype_arg, tsubst,instantiate_template,type_unification_real,unify, instantiate_pending_templates,set_mangled_name_for_template_decl): Likewise. * repo.c (repo_get_id,repo_template_used): Likewise. * search.c (lookup_field_1): Likewise. * tree.c (walk_tree,get_type_decl,cp_tree_equal,member_p): Likewise. * xref.c (classname): Likewise. From-SVN: r32698 --- gcc/ChangeLog | 17 +++++++++++++++++ gcc/builtins.c | 2 +- gcc/c-common.c | 12 +++++------- gcc/c-decl.c | 2 +- gcc/c-typeck.c | 6 ++---- gcc/calls.c | 4 +--- gcc/cp/ChangeLog | 27 +++++++++++++++++++++++++++ gcc/cp/call.c | 4 ++-- gcc/cp/decl.c | 20 +++++++++----------- gcc/cp/decl2.c | 19 +++++++++---------- gcc/cp/error.c | 11 +++++------ gcc/cp/friend.c | 2 +- gcc/cp/lex.c | 6 +++--- gcc/cp/method.c | 10 +++++----- gcc/cp/parse.c | 4 ++-- gcc/cp/parse.y | 4 ++-- gcc/cp/pt.c | 46 ++++++++++++++++++---------------------------- gcc/cp/repo.c | 6 +++--- gcc/cp/search.c | 2 +- gcc/cp/tree.c | 10 +++++----- gcc/cp/xref.c | 4 ++-- gcc/dwarf2out.c | 6 +++--- gcc/dwarfout.c | 4 ++-- gcc/expr.c | 2 +- gcc/fold-const.c | 6 +++--- gcc/function.c | 7 ++----- gcc/stmt.c | 4 ++-- gcc/varasm.c | 6 ++---- 28 files changed, 136 insertions(+), 117 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9f9c920..99faa4f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2000-03-22 Theodore Papadopoulo + + * builtin.c (get_pointer_alignment): Use DECL_P and TYPE_P macros. + * c-common.c (decl_attributes,check_format_info,truthvalue_conversion, + c_get_alias_set): Likewise. + * c-decl.c (duplicate_decls): Likewise. + * c-typeck.c (default_conversion,build_unary_op): Likewise. + * calls.c (initialize_argument_information): Likewise. + * dwarf2out.c (decl_class_context,add_abstract_origin_attribute): + Likewise. + * dwarfout.c (decl_class_context,output_type): Likewise. + * expr.c (get_inner_reference): Likewise. + * fold-const.c (simple_operand_p,fold): Likewise. + * function.c (aggregate_value_p): Likewise. + * stmt.c (expand_asm_operands): Likewise. + * varasm.c (named_section): Likewise. + 2000-03-22 Jason Merrill Implement dwarf2 exception handling for the ARM. diff --git a/gcc/builtins.c b/gcc/builtins.c index c4b2e76..f03b70e 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -158,7 +158,7 @@ get_pointer_alignment (exp, max_align) exp = TREE_OPERAND (exp, 0); if (TREE_CODE (exp) == FUNCTION_DECL) align = FUNCTION_BOUNDARY; - else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd') + else if (DECL_P (exp)) align = DECL_ALIGN (exp); #ifdef CONSTANT_ALIGNMENT else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c') diff --git a/gcc/c-common.c b/gcc/c-common.c index 6410e89..9ef9590 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -494,13 +494,13 @@ decl_attributes (node, attributes, prefix_attributes) if (attrtab_idx == 0) init_attributes (); - if (TREE_CODE_CLASS (TREE_CODE (node)) == 'd') + if (DECL_P (node)) { decl = node; type = TREE_TYPE (decl); is_type = TREE_CODE (node) == TYPE_DECL; } - else if (TREE_CODE_CLASS (TREE_CODE (node)) == 't') + else if (TYPE_P (node)) type = node, is_type = 1; #ifdef PRAGMA_INSERT_ATTRIBUTES @@ -1954,8 +1954,7 @@ check_format_info (info, params) && (TYPE_READONLY (cur_type) || (cur_param != 0 && (TREE_CODE_CLASS (TREE_CODE (cur_param)) == 'c' - || (TREE_CODE_CLASS (TREE_CODE (cur_param)) == 'd' - && TREE_READONLY (cur_param)))))) + || (DECL_P (cur_param) && TREE_READONLY (cur_param)))))) warning ("writing into constant object (arg %d)", arg_num); /* Check the type of the "real" argument, if there's a type we want. */ @@ -2882,7 +2881,7 @@ truthvalue_conversion (expr) case ADDR_EXPR: /* If we are taking the address of a external decl, it might be zero if it is weak, so we cannot optimize. */ - if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (expr, 0))) == 'd' + if (DECL_P (TREE_OPERAND (expr, 0)) && DECL_EXTERNAL (TREE_OPERAND (expr, 0))) break; @@ -3315,8 +3314,7 @@ c_get_alias_set (t) if (t == error_mark_node) return 0; - type = (TREE_CODE_CLASS (TREE_CODE (t)) == 't') - ? t : TREE_TYPE (t); + type = (TYPE_P (t)) ? t : TREE_TYPE (t); if (type == error_mark_node) return 0; diff --git a/gcc/c-decl.c b/gcc/c-decl.c index c3ba279..a5cc458 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1380,7 +1380,7 @@ duplicate_decls (newdecl, olddecl, different_binding_level) tree newtype = TREE_TYPE (newdecl); int errmsg = 0; - if (TREE_CODE_CLASS (TREE_CODE (olddecl)) == 'd') + if (DECL_P (olddecl)) DECL_MACHINE_ATTRIBUTES (newdecl) = merge_machine_decl_attributes (olddecl, newdecl); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index d64d566..abdd2a7 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -950,8 +950,7 @@ default_conversion (exp) int constp = 0; int volatilep = 0; - if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'r' - || TREE_CODE_CLASS (TREE_CODE (exp)) == 'd') + if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'r' || DECL_P (exp)) { constp = TREE_READONLY (exp); volatilep = TREE_THIS_VOLATILE (exp); @@ -2987,8 +2986,7 @@ build_unary_op (code, xarg, noconvert) to which the address will point. Note that you can't get a restricted pointer by taking the address of something, so we only have to deal with `const' and `volatile' here. */ - if (TREE_CODE_CLASS (TREE_CODE (arg)) == 'd' - || TREE_CODE_CLASS (TREE_CODE (arg)) == 'r') + if (DECL_P (arg) || TREE_CODE_CLASS (TREE_CODE (arg)) == 'r') { if (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg)) argtype = c_build_type_variant (argtype, diff --git a/gcc/calls.c b/gcc/calls.c index c8ef7fe..4c8d573 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1086,9 +1086,7 @@ initialize_argument_information (num_actuals, args, args_size, n_named_args, make a bitwise copy of the argument. */ if (TREE_CODE (args[i].tree_value) == TARGET_EXPR - && (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND - (args[i].tree_value, 1))) - == 'd') + && (DECL_P (TREE_OPERAND (args[i].tree_value, 1))) && ! REG_P (DECL_RTL (TREE_OPERAND (args[i].tree_value, 1)))) args[i].tree_value = TREE_OPERAND (args[i].tree_value, 1); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 33d688f..433c629 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,30 @@ +2000-03-20 Theodore Papadopoulo + + * call.c (check_dtor_name,build_new_method_call): Likewise. + * decl.c (push_class_binding,poplevel,pushtag,lookup_namespace_name, + make_typename_type,check_initializer,cp_finish_decl,xref_tag): Likewise. + * decl2.c (grokfield,build_expr_from_tree,build_expr_from_tree, + decl_namespace,arg_assoc_template_arg,arg_assoc, + validate_nonmember_using_decl,do_class_using_decl): Likewise. + * error.c (dump_template_argument,dump_expr,cp_file_of,cp_line_of, + args_to_string): Likewise. + * friend.c (is_friend): Likewise. + * lex.c (note_got_semicolon,note_list_got_semicolon,is_global): Likewise. + * method.c (build_overload_nested_name,build_overload_value, + build_qualified_name,build_qualified_name,hack_identifier): Likewise. + * parse.y (typename_sub,typename_sub1): Likewise. + * pt.c (push_inline_template_parms_recursive,check_template_shadow, + process_partial_specialization,convert_template_argument, + template_args_equal,add_pending_template,lookup_template_class, + for_each_template_parm_r,maybe_fold_nontype_arg, + tsubst,instantiate_template,type_unification_real,unify, + instantiate_pending_templates,set_mangled_name_for_template_decl): + Likewise. + * repo.c (repo_get_id,repo_template_used): Likewise. + * search.c (lookup_field_1): Likewise. + * tree.c (walk_tree,get_type_decl,cp_tree_equal,member_p): Likewise. + * xref.c (classname): Likewise. + 2000-03-22 Mark Mitchell * cp-tree.h (BINFO_FOR_VBASE): Adjust documentation. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b505b74..6e7c4fb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -189,7 +189,7 @@ check_dtor_name (basetype, name) if (TREE_CODE (name) == TYPE_DECL) name = TREE_TYPE (name); - else if (TREE_CODE_CLASS (TREE_CODE (name)) == 't') + else if (TYPE_P (name)) /* OK */; else if (TREE_CODE (name) == IDENTIFIER_NODE) { @@ -4192,7 +4192,7 @@ build_new_method_call (instance, name, args, basetype_path, flags) { explicit_targs = TREE_OPERAND (name, 1); name = TREE_OPERAND (name, 0); - if (TREE_CODE_CLASS (TREE_CODE (name)) == 'd') + if (DECL_P (name)) name = DECL_NAME (name); else { diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 813ef6f..491315a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1128,8 +1128,7 @@ push_class_binding (id, decl) context = CP_DECL_CONTEXT (OVL_CURRENT (decl)); else { - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd', - 0); + my_friendly_assert (DECL_P (decl), 0); context = CP_DECL_CONTEXT (decl); } @@ -1453,7 +1452,7 @@ poplevel (keep, reverse, functionbody) decl = link; if (TREE_CODE (decl) == TREE_LIST) decl = TREE_VALUE (decl); - if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd') + if (DECL_P (decl)) pop_binding (DECL_NAME (decl), decl); else if (TREE_CODE (decl) == OVERLOAD) pop_binding (DECL_NAME (OVL_FUNCTION (decl)), decl); @@ -2788,8 +2787,7 @@ pushtag (name, type, globalize) if (! globalize) context = cs; - else if (cs != NULL_TREE - && TREE_CODE_CLASS (TREE_CODE (cs)) == 't') + else if (cs != NULL_TREE && TYPE_P (cs)) /* When declaring a friend class of a local class, we want to inject the newly named class into the scope containing the local class, not the namespace scope. */ @@ -5229,7 +5227,7 @@ lookup_namespace_name (namespace, name) name = TREE_OPERAND (name, 0); if (TREE_CODE (name) == OVERLOAD) name = DECL_NAME (OVL_CURRENT (name)); - else if (TREE_CODE_CLASS (TREE_CODE (name)) == 'd') + else if (DECL_P (name)) name = DECL_NAME (name); } @@ -5379,7 +5377,7 @@ make_typename_type (context, name, complain) { tree fullname; - if (TREE_CODE_CLASS (TREE_CODE (name)) == 't') + if (TYPE_P (name)) { if (!(TYPE_LANG_SPECIFIC (name) && (CLASSTYPE_IS_TEMPLATE (name) @@ -7549,7 +7547,7 @@ check_initializer (decl, init) } else if (DECL_EXTERNAL (decl)) ; - else if (TREE_CODE_CLASS (TREE_CODE (type)) == 't' + else if (TYPE_P (type) && (IS_AGGR_TYPE (type) || TYPE_NEEDS_CONSTRUCTING (type))) { tree core_type = strip_array_types (type); @@ -7902,7 +7900,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags) if (type == error_mark_node) return; - + /* Add this declaration to the statement-tree. */ if (building_stmt_tree () && at_function_scope_p ()) add_decl_stmt (decl); @@ -8050,7 +8048,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags) { tree context = CP_DECL_CONTEXT (decl); if (context - && TREE_CODE_CLASS (TREE_CODE (context)) == 't' + && TYPE_P (context) && (TREE_CODE (decl) == VAR_DECL /* We also have a pushclass done that we need to undo here if we're at top level and declare a method. */ @@ -12376,7 +12374,7 @@ xref_tag (code_type_node, name, globalize) /* If a cross reference is requested, look up the type already defined for this tag and return it. */ - if (TREE_CODE_CLASS (TREE_CODE (name)) == 't') + if (TYPE_P (name)) { t = name; name = TYPE_IDENTIFIER (t); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 3d51808..5c1f7f8 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1676,8 +1676,7 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist) static, since references are initialized with the address. */ if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE || (TREE_STATIC (init) == 0 - && (TREE_CODE_CLASS (TREE_CODE (init)) != 'd' - || DECL_EXTERNAL (init) == 0))) + && (!DECL_P (init) || DECL_EXTERNAL (init) == 0))) { error ("field initializer is not constant"); init = error_mark_node; @@ -3878,7 +3877,7 @@ build_expr_from_tree (t) case ALIGNOF_EXPR: { tree r = build_expr_from_tree (TREE_OPERAND (t, 0)); - if (TREE_CODE_CLASS (TREE_CODE (r)) != 't') + if (!TYPE_P (r)) r = TREE_TYPE (r); return TREE_CODE (t) == SIZEOF_EXPR ? c_sizeof (r) : c_alignof (r); } @@ -4046,7 +4045,7 @@ build_expr_from_tree (t) } case TYPEID_EXPR: - if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t, 0))) == 't') + if (TYPE_P (TREE_OPERAND (t, 0))) return get_typeid (TREE_OPERAND (t, 0)); return build_typeid (build_expr_from_tree (TREE_OPERAND (t, 0))); @@ -4473,9 +4472,9 @@ decl_namespace (decl) decl = DECL_CONTEXT (decl); if (TREE_CODE (decl) == NAMESPACE_DECL) return decl; - if (TREE_CODE_CLASS (TREE_CODE (decl)) == 't') + if (TYPE_P (decl)) decl = TYPE_STUB_DECL (decl); - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd', 390); + my_friendly_assert (DECL_P (decl), 390); } return global_namespace; @@ -4656,7 +4655,7 @@ arg_assoc_template_arg (k, arg) } /* It's not a template template argument, but it is a type template argument. */ - else if (TREE_CODE_CLASS (TREE_CODE (arg)) == 't') + else if (TYPE_P (arg)) return arg_assoc_type (k, arg); /* It's a non-type template argument. */ else @@ -4794,7 +4793,7 @@ arg_assoc (k, n) if (n == error_mark_node) return 0; - if (TREE_CODE_CLASS (TREE_CODE (n)) == 't') + if (TYPE_P (n)) return arg_assoc_type (k, n); if (! type_unknown_p (n)) @@ -4959,7 +4958,7 @@ validate_nonmember_using_decl (decl, scope, name) } else my_friendly_abort (382); - if (TREE_CODE_CLASS (TREE_CODE (*name)) == 'd') + if (DECL_P (*name)) *name = DECL_NAME (*name); /* Make a USING_DECL. */ return push_using_decl (*scope, *name); @@ -5136,7 +5135,7 @@ do_class_using_decl (decl) tree name, value; if (TREE_CODE (decl) != SCOPE_REF - || TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (decl, 0))) != 't') + || !TYPE_P (TREE_OPERAND (decl, 0))) { cp_error ("using-declaration for non-member at class scope"); return NULL_TREE; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index e5a0872..a0be98f 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -221,8 +221,7 @@ dump_template_argument (arg, flags) tree arg; enum tree_string_flags flags; { - if (TREE_CODE_CLASS (TREE_CODE (arg)) == 't' - || TREE_CODE (arg) == TEMPLATE_DECL) + if (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL) dump_type (arg, flags & ~TS_AGGR_TAGS); else dump_expr (arg, (flags | TS_EXPR_PARENS) & ~TS_AGGR_TAGS); @@ -1965,7 +1964,7 @@ dump_expr (t, flags) my_friendly_assert (TREE_CODE (t) == ALIGNOF_EXPR, 0); OB_PUTS ("__alignof__ ("); } - if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t, 0))) == 't') + if (TYPE_P (TREE_OPERAND (t, 0))) dump_type (TREE_OPERAND (t, 0), flags); else dump_unary_op ("*", t, flags | TS_EXPR_PARENS); @@ -2165,7 +2164,7 @@ cp_file_of (t) { if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) return DECL_SOURCE_FILE (DECL_CONTEXT (t)); - else if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') + else if (TYPE_P (t)) return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t)); else if (TREE_CODE (t) == OVERLOAD) return DECL_SOURCE_FILE (OVL_FUNCTION (t)); @@ -2184,7 +2183,7 @@ cp_line_of (t) && TYPE_MAIN_DECL (TREE_TYPE (t))) t = TREE_TYPE (t); - if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') + if (TYPE_P (t)) line = DECL_SOURCE_LINE (TYPE_MAIN_DECL (t)); else if (TREE_CODE (t) == OVERLOAD) line = DECL_SOURCE_LINE (OVL_FUNCTION (t)); @@ -2365,7 +2364,7 @@ args_to_string (p, verbose) if (p == NULL_TREE) return ""; - if (TREE_CODE_CLASS (TREE_CODE (TREE_VALUE (p))) == 't') + if (TYPE_P (TREE_VALUE (p))) return type_as_string (p, flags); OB_INIT (); diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 20bb5d8..fee00a8 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -42,7 +42,7 @@ is_friend (type, supplicant) if (supplicant == NULL_TREE || type == NULL_TREE) return 0; - declp = (TREE_CODE_CLASS (TREE_CODE (supplicant)) == 'd'); + declp = DECL_P (supplicant); if (declp) /* It's a function decl. */ diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 35106dc..d90f472 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -2148,7 +2148,7 @@ void note_got_semicolon (type) tree type; { - if (TREE_CODE_CLASS (TREE_CODE (type)) != 't') + if (!TYPE_P (type)) my_friendly_abort (60); if (CLASS_TYPE_P (type)) CLASSTYPE_GOT_SEMICOLON (type) = 1; @@ -2163,7 +2163,7 @@ note_list_got_semicolon (declspecs) for (link = declspecs; link; link = TREE_CHAIN (link)) { tree type = TREE_VALUE (link); - if (TREE_CODE_CLASS (TREE_CODE (type)) == 't') + if (TYPE_P (type)) note_got_semicolon (type); } clear_anon_tags (); @@ -3418,7 +3418,7 @@ is_global (d) case OVERLOAD: d = OVL_FUNCTION (d); continue; case TREE_LIST: d = TREE_VALUE (d); continue; default: - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (d)) == 'd', 980629); + my_friendly_assert (DECL_P (d), 980629); return DECL_NAMESPACE_SCOPE_P (d); } diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 44dc3ab..9d5defc 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -446,7 +446,7 @@ build_overload_nested_name (decl) build_mangled_name_for_type (context); else { - if (TREE_CODE_CLASS (TREE_CODE (context)) == 't') + if (TYPE_P (context)) context = TYPE_NAME (context); build_overload_nested_name (context); } @@ -692,7 +692,7 @@ build_overload_value (type, value, flags) tree type, value; mangling_flags flags; { - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (type)) == 't', 0); + my_friendly_assert (TYPE_P (type), 0); while (TREE_CODE (value) == NON_LVALUE_EXPR || TREE_CODE (value) == NOP_EXPR) @@ -1044,7 +1044,7 @@ build_qualified_name (decl) tree context; int i = 1; - if (TREE_CODE_CLASS (TREE_CODE (decl)) == 't') + if (TYPE_P (decl)) decl = TYPE_NAME (decl); /* If DECL_ASSEMBLER_NAME has been set properly, use it. */ @@ -1072,7 +1072,7 @@ build_qualified_name (decl) if (check_ktype (context, FALSE) != -1) /* Found one! */ break; - if (TREE_CODE_CLASS (TREE_CODE (context)) == 't') + if (TYPE_P (context)) context = TYPE_NAME (context); } } @@ -1985,7 +1985,7 @@ hack_identifier (value, name) } } - if (TREE_CODE_CLASS (TREE_CODE (value)) == 'd' && DECL_NONLOCAL (value)) + if (DECL_P (value) && DECL_NONLOCAL (value)) { if (DECL_CLASS_SCOPE_P (value) && DECL_CONTEXT (value) != current_class_type) diff --git a/gcc/cp/parse.c b/gcc/cp/parse.c index 306bd16..01312a5 100644 --- a/gcc/cp/parse.c +++ b/gcc/cp/parse.c @@ -7295,7 +7295,7 @@ case 644: case 645: #line 2947 "parse.y" { - if (TREE_CODE_CLASS (TREE_CODE (yyvsp[-1].ttype)) == 't') + if (TYPE_P (yyvsp[-1].ttype)) yyval.ttype = make_typename_type (yyvsp[-1].ttype, yyvsp[0].ttype, /*complain=*/1); else if (TREE_CODE (yyvsp[0].ttype) == IDENTIFIER_NODE) cp_error ("`%T' is not a class or namespace", yyvsp[0].ttype); @@ -7329,7 +7329,7 @@ case 649: case 650: #line 2974 "parse.y" { - if (TREE_CODE_CLASS (TREE_CODE (yyvsp[-1].ttype)) == 't') + if (TYPE_P (yyvsp[-1].ttype)) yyval.ttype = make_typename_type (yyvsp[-1].ttype, yyvsp[0].ttype, /*complain=*/1); else if (TREE_CODE (yyvsp[0].ttype) == IDENTIFIER_NODE) cp_error ("`%T' is not a class or namespace", yyvsp[0].ttype); diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index b593c1d..a666fd8 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -2945,7 +2945,7 @@ typename_sub: typename_sub0: typename_sub1 identifier %prec EMPTY { - if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't') + if (TYPE_P ($1)) $$ = make_typename_type ($1, $2, /*complain=*/1); else if (TREE_CODE ($2) == IDENTIFIER_NODE) cp_error ("`%T' is not a class or namespace", $2); @@ -2972,7 +2972,7 @@ typename_sub1: } | typename_sub1 typename_sub2 { - if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't') + if (TYPE_P ($1)) $$ = make_typename_type ($1, $2, /*complain=*/1); else if (TREE_CODE ($2) == IDENTIFIER_NODE) cp_error ("`%T' is not a class or namespace", $2); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d4da8b2..0978ec9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -321,7 +321,7 @@ push_inline_template_parms_recursive (parmlist, levels) for (i = 0; i < TREE_VEC_LENGTH (parms); ++i) { tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i)); - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (parm)) == 'd', 0); + my_friendly_assert (DECL_P (parm), 0); switch (TREE_CODE (parm)) { @@ -1666,8 +1666,7 @@ check_template_shadow (decl) that OLDDECL might be an OVERLOAD (or perhaps even an ERROR_MARK), so we can't just blithely assume it to be a _DECL node. */ - if (TREE_CODE_CLASS (TREE_CODE (olddecl)) != 'd' - || !DECL_TEMPLATE_PARM_P (olddecl)) + if (!DECL_P (olddecl) || !DECL_TEMPLATE_PARM_P (olddecl)) return; /* We check for decl != olddecl to avoid bogus errors for using a @@ -2118,7 +2117,7 @@ process_partial_specialization (decl) { tree arg = TREE_VEC_ELT (inner_args, i); if (/* These first two lines are the `non-type' bit. */ - TREE_CODE_CLASS (TREE_CODE (arg)) != 't' + !TYPE_P (arg) && TREE_CODE (arg) != TEMPLATE_DECL /* This next line is the `argument expression is not just a simple identifier' condition and also the `specialized @@ -3166,7 +3165,7 @@ convert_template_argument (parm, arg, args, complain, i, in_decl) else if (is_tmpl_type && TREE_CODE (arg) == RECORD_TYPE) arg = CLASSTYPE_TI_TEMPLATE (arg); - is_type = TREE_CODE_CLASS (TREE_CODE (arg)) == 't' || is_tmpl_type; + is_type = TYPE_P (arg) || is_tmpl_type; if (requires_type && ! is_type && TREE_CODE (arg) == SCOPE_REF && TREE_CODE (TREE_OPERAND (arg, 0)) == TEMPLATE_TYPE_PARM) @@ -3420,7 +3419,7 @@ template_args_equal (ot, nt) if (TREE_CODE (nt) == TREE_VEC) /* For member templates */ return comp_template_args (ot, nt); - else if (TREE_CODE_CLASS (TREE_CODE (ot)) == 't') + else if (TYPE_P (ot)) return same_type_p (ot, nt); else return (cp_tree_equal (ot, nt) > 0); @@ -3575,12 +3574,7 @@ static void add_pending_template (d) tree d; { - tree ti; - - if (TREE_CODE_CLASS (TREE_CODE (d)) == 't') - ti = CLASSTYPE_TEMPLATE_INFO (d); - else - ti = DECL_TEMPLATE_INFO (d); + tree ti = (TYPE_P (d)) ? CLASSTYPE_TEMPLATE_INFO (d) : DECL_TEMPLATE_INFO (d); if (TI_PENDING_TEMPLATE_FLAG (ti)) return; @@ -3699,8 +3693,7 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope) } } else if (TREE_CODE (d1) == ENUMERAL_TYPE - || (TREE_CODE_CLASS (TREE_CODE (d1)) == 't' - && IS_AGGR_TYPE (d1))) + || (TYPE_P (d1) && IS_AGGR_TYPE (d1))) { template = TYPE_TI_TEMPLATE (d1); d1 = DECL_NAME (template); @@ -3864,8 +3857,7 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope) scopes. */ for (ctx = current_class_type; ctx; - ctx = (TREE_CODE_CLASS (TREE_CODE (ctx)) == 't') - ? TYPE_CONTEXT (ctx) : DECL_CONTEXT (ctx)) + ctx = (TYPE_P (ctx)) ? TYPE_CONTEXT (ctx) : DECL_CONTEXT (ctx)) if (same_type_p (ctx, template_type)) break; @@ -4065,7 +4057,7 @@ for_each_template_parm_r (tp, walk_subtrees, d) tree_fn_t fn = pfd->fn; void *data = pfd->data; - if (TREE_CODE_CLASS (TREE_CODE (t)) == 't' + if (TYPE_P (t) && for_each_template_parm (TYPE_CONTEXT (t), fn, data)) return error_mark_node; @@ -5136,8 +5128,7 @@ maybe_fold_nontype_arg (arg) if (! processing_template_decl) return arg; - if (TREE_CODE_CLASS (TREE_CODE (arg)) != 't' - && !uses_template_parms (arg)) + if (!TYPE_P (arg) && !uses_template_parms (arg)) { /* Sometimes, one of the args was an expression involving a template constant parameter, like N - 1. Now that we've @@ -6161,7 +6152,7 @@ tsubst (t, args, complain, in_decl) if (type == error_mark_node) return error_mark_node; - if (TREE_CODE_CLASS (TREE_CODE (t)) == 'd') + if (DECL_P (t)) return tsubst_decl (t, args, type, in_decl); switch (TREE_CODE (t)) @@ -6283,8 +6274,7 @@ tsubst (t, args, complain, in_decl) { if (TREE_CODE (t) == TEMPLATE_TYPE_PARM) { - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (arg)) - == 't', 0); + my_friendly_assert (TYPE_P (arg), 0); return cp_build_qualified_type_real (arg, CP_TYPE_QUALS (arg) | CP_TYPE_QUALS (t), complain); @@ -7430,7 +7420,7 @@ instantiate_template (tmpl, targ_ptr) while (i--) { tree t = TREE_VEC_ELT (inner_args, i); - if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') + if (TYPE_P (t)) { tree nt = target_type (t); if (IS_AGGR_TYPE (nt) && decl_function_context (TYPE_MAIN_DECL (nt))) @@ -7750,7 +7740,7 @@ type_unification_real (tparms, targs, parms, args, subr, { tree type; - if (TREE_CODE_CLASS (TREE_CODE (arg)) != 't') + if (!TYPE_P (arg)) type = TREE_TYPE (arg); else { @@ -7772,7 +7762,7 @@ type_unification_real (tparms, targs, parms, args, subr, return 1; } - if (TREE_CODE_CLASS (TREE_CODE (arg)) != 't') + if (!TYPE_P (arg)) { my_friendly_assert (TREE_TYPE (arg) != NULL_TREE, 293); if (type_unknown_p (arg)) @@ -8246,7 +8236,7 @@ unify (tparms, targs, parm, arg, strict) /* Immediately reject some pairs that won't unify because of cv-qualification mismatches. */ if (TREE_CODE (arg) == TREE_CODE (parm) - && TREE_CODE_CLASS (TREE_CODE (arg)) == 't' + && TYPE_P (arg) /* We check the cv-qualifiers when unifying with template type parameters below. We want to allow ARG `const T' to unify with PARM `T' for example, when computing which of two templates @@ -9649,7 +9639,7 @@ instantiate_pending_templates () input_filename = SRCLOC_FILE (srcloc); lineno = SRCLOC_LINE (srcloc); - if (TREE_CODE_CLASS (TREE_CODE (instantiation)) == 't') + if (TYPE_P (instantiation)) { tree fn; @@ -9960,7 +9950,7 @@ set_mangled_name_for_template_decl (decl) mangled name. Unfortunately, build_decl_overload_real does not get the decl to mangle, so it relies on the current namespace. Therefore, we set that here temporarily. */ - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd', 980702); + my_friendly_assert (DECL_P (decl), 980702); saved_namespace = current_namespace; current_namespace = CP_DECL_CONTEXT (decl); diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index 0724a45..99d53f0 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -95,7 +95,7 @@ static tree repo_get_id (t) tree t; { - if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') + if (TYPE_P (t)) { /* If we're not done setting up the class, we may not have set up the vtable, so going ahead would give the wrong answer. @@ -126,12 +126,12 @@ repo_template_used (t) if (id == NULL_TREE) return; - if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') + if (TYPE_P (t)) { if (IDENTIFIER_REPO_CHOSEN (id)) mark_class_instantiated (t, 0); } - else if (TREE_CODE_CLASS (TREE_CODE (t)) == 'd') + else if (DECL_P (t)) { if (IDENTIFIER_REPO_CHOSEN (id)) mark_decl_instantiated (t, 0); diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 314dab9..cafdfc2 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -644,7 +644,7 @@ lookup_field_1 (type, name) #ifdef GATHER_STATISTICS n_fields_searched++; #endif /* GATHER_STATISTICS */ - my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (field)) == 'd', 0); + my_friendly_assert (DECL_P (field), 0); if (DECL_NAME (field) == NULL_TREE && ANON_AGGR_TYPE_P (TREE_TYPE (field))) { diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 1409020..d1c7d2d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1262,7 +1262,7 @@ walk_tree (tp, func, data) { if (code == DECL_STMT && DECL_STMT_DECL (*tp) - && TREE_CODE_CLASS (TREE_CODE (DECL_STMT_DECL (*tp))) == 'd') + && DECL_P (DECL_STMT_DECL (*tp))) { /* Walk the DECL_INITIAL and DECL_SIZE. We don't want to walk into declarations that are just mentioned, rather than @@ -1730,7 +1730,7 @@ get_type_decl (t) { if (TREE_CODE (t) == TYPE_DECL) return t; - if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') + if (TYPE_P (t)) return TYPE_STUB_DECL (t); my_friendly_abort (42); @@ -1915,7 +1915,7 @@ cp_tree_equal (t1, t2) case ALIGNOF_EXPR: if (TREE_CODE (TREE_OPERAND (t1, 0)) != TREE_CODE (TREE_OPERAND (t2, 0))) return 0; - if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t1, 0))) == 't') + if (TYPE_P (TREE_OPERAND (t1, 0))) return same_type_p (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)); break; @@ -2051,8 +2051,8 @@ int member_p (decl) tree decl; { - tree ctx = DECL_CONTEXT (decl); - return (ctx && TREE_CODE_CLASS (TREE_CODE (ctx)) == 't'); + const tree ctx = DECL_CONTEXT (decl); + return (ctx && TYPE_P (ctx)); } /* Create a placeholder for member access where we don't actually have an diff --git a/gcc/cp/xref.c b/gcc/cp/xref.c index ff4817e..9a1fd97 100644 --- a/gcc/cp/xref.c +++ b/gcc/cp/xref.c @@ -541,9 +541,9 @@ static const char * classname (cls) tree cls; { - if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 't') + if (cls && TYPE_P (cls)) cls = TYPE_NAME (cls); - if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 'd') + if (cls && DECL_P (cls)) cls = DECL_NAME (cls); if (cls && TREE_CODE (cls) == IDENTIFIER_NODE) return IDENTIFIER_POINTER (cls); diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index f181f26..6510bc9 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -3467,7 +3467,7 @@ decl_class_context (decl) context = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))))); - if (context && TREE_CODE_CLASS (TREE_CODE (context)) != 't') + if (context && !TYPE_P (context)) context = NULL_TREE; return context; @@ -7386,9 +7386,9 @@ add_abstract_origin_attribute (die, origin) gen_abstract_function (fn); } - if (TREE_CODE_CLASS (TREE_CODE (origin)) == 'd') + if (DECL_P (origin)) origin_die = lookup_decl_die (origin); - else if (TREE_CODE_CLASS (TREE_CODE (origin)) == 't') + else if (TYPE_P (origin)) origin_die = lookup_type_die (origin); if (origin_die == NULL) diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c index 5bac906..400dc78 100644 --- a/gcc/dwarfout.c +++ b/gcc/dwarfout.c @@ -1217,7 +1217,7 @@ decl_class_context (decl) context = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))))); - if (context && TREE_CODE_CLASS (TREE_CODE (context)) != 't') + if (context && !TYPE_P (context)) context = NULL_TREE; return context; @@ -4287,7 +4287,7 @@ output_type (type, containing_scope) written out yet, writing it out will cover this one, too. */ if (TYPE_CONTEXT (type) - && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type))) == 't' + && TYPE_P (TYPE_CONTEXT (type)) && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type))) { output_type (TYPE_CONTEXT (type), containing_scope); diff --git a/gcc/expr.c b/gcc/expr.c index 3c8c269..09d4063 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5094,7 +5094,7 @@ get_inner_reference (exp, pbitsize, pbitpos, poffset, pmode, exp = TREE_OPERAND (exp, 0); } - if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd') + if (DECL_P (exp)) alignment = MIN (alignment, DECL_ALIGN (exp)); else if (TREE_TYPE (exp) != 0) alignment = MIN (alignment, TYPE_ALIGN (TREE_TYPE (exp))); diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fee1c4b..0f38f7f 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3181,7 +3181,7 @@ simple_operand_p (exp) exp = TREE_OPERAND (exp, 0); return (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c' - || (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd' + || (DECL_P (exp) && ! TREE_ADDRESSABLE (exp) && ! TREE_THIS_VOLATILE (exp) && ! DECL_NONLOCAL (exp) @@ -6968,10 +6968,10 @@ fold (expr) /* If the second operand is simpler than the third, swap them since that produces better jump optimization results. */ - if ((TREE_CONSTANT (arg1) || TREE_CODE_CLASS (TREE_CODE (arg1)) == 'd' + if ((TREE_CONSTANT (arg1) || DECL_P (arg1) || TREE_CODE (arg1) == SAVE_EXPR) && ! (TREE_CONSTANT (TREE_OPERAND (t, 2)) - || TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t, 2))) == 'd' + || DECL_P (TREE_OPERAND (t, 2)) || TREE_CODE (TREE_OPERAND (t, 2)) == SAVE_EXPR)) { /* See if this can be inverted. If it can't, possibly because diff --git a/gcc/function.c b/gcc/function.c index ae04a5c..6053592 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4013,11 +4013,8 @@ aggregate_value_p (exp) { int i, regno, nregs; rtx reg; - tree type; - if (TREE_CODE_CLASS (TREE_CODE (exp)) == 't') - type = exp; - else - type = TREE_TYPE (exp); + + tree type = (TYPE_P (exp)) ? exp : TREE_TYPE (exp); if (RETURN_IN_MEMORY (type)) return 1; diff --git a/gcc/stmt.c b/gcc/stmt.c index 837df5c..6ac6f6e 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -1514,7 +1514,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line) real_output_rtx[i] = NULL_RTX; if ((TREE_CODE (val) == INDIRECT_REF && allows_mem) - || (TREE_CODE_CLASS (TREE_CODE (val)) == 'd' + || (DECL_P (val) && (allows_mem || GET_CODE (DECL_RTL (val)) == REG) && ! (GET_CODE (DECL_RTL (val)) == REG && GET_MODE (DECL_RTL (val)) != TYPE_MODE (type))) @@ -1990,7 +1990,7 @@ warn_if_unused_value (exp) default: /* Referencing a volatile value is a side effect, so don't warn. */ - if ((TREE_CODE_CLASS (TREE_CODE (exp)) == 'd' + if ((DECL_P (exp) || TREE_CODE_CLASS (TREE_CODE (exp)) == 'r') && TREE_THIS_VOLATILE (exp)) return 0; diff --git a/gcc/varasm.c b/gcc/varasm.c index f144293..3aaca2a 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -301,8 +301,7 @@ named_section (decl, name, reloc) const char *name; int reloc ATTRIBUTE_UNUSED; { - if (decl != NULL_TREE - && TREE_CODE_CLASS (TREE_CODE (decl)) != 'd') + if (decl != NULL_TREE && !DECL_P (decl)) abort (); if (name == NULL) name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl)); @@ -1727,8 +1726,7 @@ assemble_external (decl) tree decl ATTRIBUTE_UNUSED; { #ifdef ASM_OUTPUT_EXTERNAL - if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd' - && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)) + if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl)) { rtx rtl = DECL_RTL (decl); -- 2.7.4