From 5a6ccc943fa6c7f121a47e96a19d73a7531de311 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Fri, 29 Mar 2013 16:09:35 +0000 Subject: [PATCH] tree.h (VAR_P): New. * tree.h (VAR_P): New. cp/ * call.c (build_java_interface_fn_ref): Likewise. (make_temporary_var_for_ref_to_temp): Likewise. * class.c (check_field_decls): Likewise. (layout_class_type): Likewise. (finish_struct_1): Likewise. (fixed_type_or_null): Likewise. (get_vtbl_decl_for_binfo): Likewise. * cp-gimplify.c (omp_var_to_track): Likewise. (cp_genericize_r): Likewise. * cp-objcp-common.c (cxx_warn_unused_global_decl): Likewise. * cp-tree.h (LANG_DECL_HAS_MIN): Likewise. (DECL_DISCRIMINATOR_P): Likewise. * decl.c (poplevel): Likewise. (decls_match): Likewise. (duplicate_decls): Likewise. (decl_jump_unsafe): Likewise. (start_decl): Likewise. (check_for_uninitialized_const_var): Likewise. (make_rtl_for_nonlocal_decl): Likewise. (cp_finish_decl): Likewise. (expand_static_init): Likewise. (local_variable_p): Likewise. (maybe_register_incomplete_var): Likewise. * decl2.c (grokfield): Likewise. (comdat_linkage): Likewise. (determine_visibility): Likewise. (import_export_decl): Likewise. (prune_vars_needing_no_initialization): Likewise. (decl_maybe_constant_var_p): Likewise. * error.c (dump_simple_decl): Likewise. (dump_template_decl): Likewise. (cp_printer): Likewise. * except.c (build_throw): Likewise. * init.c (build_vtbl_address): Likewise. (member_init_ok_or_else): Likewise. (build_aggr_init): Likewise. (expand_aggr_init_1): Likewise. (build_offset_ref): Likewise. (constant_value_1): Likewise. * mangle.c (write_mangled_name): Likewise. (write_prefix): Likewise. * name-lookup.c (supplement_binding_1): Likewise. (add_decl_to_level): Likewise. (pushdecl_maybe_friend_1): Likewise. (check_for_out_of_scope_variable): Likewise. (validate_nonmember_using_decl): Likewise. (lookup_name_innermost_nonclass_level_1): Likewise. (lookup_arg_dependent_1): Likewise. * parser.c (cp_parser_lambda_introducer): Likewise. (cp_parser_template_argument): Likewise. (cp_parser_single_declaration): Likewise. * pt.c (convert_nontype_argument): Likewise. (instantiate_class_template_1): Likewise. (tsubst_decl): Likewise. (tsubst_expr): Likewise. (do_decl_instantiation): Likewise. (do_type_instantiation): Likewise. (regenerate_decl_from_template): Likewise. (always_instantiate_p): Likewise. (instantiate_decl): Likewise. (type_dependent_expression_p): Likewise. (build_non_dependent_expr): Likewise. * repo.c (repo_emit_p): Likewise. * rtti.c (build_dynamic_cast_1): Likewise. * search.c (shared_member_p): Likewise. * semantics.c (outer_var_p): Likewise. (finish_id_expression): Likewise. (finish_omp_clauses): Likewise. (finish_decltype_type): Likewise. (ensure_literal_type_for_constexpr_object): Likewise. * tree.c (lvalue_kind): Likewise. (bot_replace): Likewise. (cp_tree_equal): Likewise. (handle_init_priority_attribute): Likewise. (decl_storage_duration): Likewise. * typeck.c (cxx_sizeof_expr): Likewise. (cxx_alignof_expr): Likewise. (decay_conversion): Likewise. (build_class_member_access_expr): Likewise. (cp_build_array_ref): Likewise. (cxx_mark_addressable): Likewise. (maybe_warn_about_returning_address_of_local): Likewise. (check_return_expr): Likewise. * typeck2.c (cxx_readonly_error): Likewise. (abstract_virtuals_error_sfinae): Likewise. (cxx_incomplete_type_diagnostic): Likewise. From-SVN: r197240 --- gcc/ChangeLog | 4 +++ gcc/cp/ChangeLog | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ gcc/cp/call.c | 4 +-- gcc/cp/class.c | 12 +++---- gcc/cp/cp-gimplify.c | 6 ++-- gcc/cp/cp-objcp-common.c | 2 +- gcc/cp/cp-tree.h | 6 ++-- gcc/cp/decl.c | 66 +++++++++++++++++------------------ gcc/cp/decl2.c | 30 ++++++++-------- gcc/cp/error.c | 6 ++-- gcc/cp/except.c | 2 +- gcc/cp/init.c | 12 +++---- gcc/cp/mangle.c | 4 +-- gcc/cp/name-lookup.c | 36 ++++++++++---------- gcc/cp/parser.c | 8 ++--- gcc/cp/pt.c | 48 +++++++++++++------------- gcc/cp/repo.c | 2 +- gcc/cp/rtti.c | 6 ++-- gcc/cp/search.c | 2 +- gcc/cp/semantics.c | 30 ++++++++-------- gcc/cp/tree.c | 12 +++---- gcc/cp/typeck.c | 18 +++++----- gcc/cp/typeck2.c | 8 ++--- gcc/tree.h | 4 +++ 24 files changed, 256 insertions(+), 161 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ec3f9f29683..0fd0f954e41 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2013-03-29 Gabriel Dos Reis + + * tree.h (VAR_P): New. + 2013-03-29 Paolo Carlini PR lto/56777 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e68d8eee2e7..224c5a2fe2e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,92 @@ +2013-03-29 Gabriel Dos Reis + + * call.c (build_java_interface_fn_ref): Likewise. + (make_temporary_var_for_ref_to_temp): Likewise. + * class.c (check_field_decls): Likewise. + (layout_class_type): Likewise. + (finish_struct_1): Likewise. + (fixed_type_or_null): Likewise. + (get_vtbl_decl_for_binfo): Likewise. + * cp-gimplify.c (omp_var_to_track): Likewise. + (cp_genericize_r): Likewise. + * cp-objcp-common.c (cxx_warn_unused_global_decl): Likewise. + * cp-tree.h (LANG_DECL_HAS_MIN): Likewise. + (DECL_DISCRIMINATOR_P): Likewise. + * decl.c (poplevel): Likewise. + (decls_match): Likewise. + (duplicate_decls): Likewise. + (decl_jump_unsafe): Likewise. + (start_decl): Likewise. + (check_for_uninitialized_const_var): Likewise. + (make_rtl_for_nonlocal_decl): Likewise. + (cp_finish_decl): Likewise. + (expand_static_init): Likewise. + (local_variable_p): Likewise. + (maybe_register_incomplete_var): Likewise. + * decl2.c (grokfield): Likewise. + (comdat_linkage): Likewise. + (determine_visibility): Likewise. + (import_export_decl): Likewise. + (prune_vars_needing_no_initialization): Likewise. + (decl_maybe_constant_var_p): Likewise. + * error.c (dump_simple_decl): Likewise. + (dump_template_decl): Likewise. + (cp_printer): Likewise. + * except.c (build_throw): Likewise. + * init.c (build_vtbl_address): Likewise. + (member_init_ok_or_else): Likewise. + (build_aggr_init): Likewise. + (expand_aggr_init_1): Likewise. + (build_offset_ref): Likewise. + (constant_value_1): Likewise. + * mangle.c (write_mangled_name): Likewise. + (write_prefix): Likewise. + * name-lookup.c (supplement_binding_1): Likewise. + (add_decl_to_level): Likewise. + (pushdecl_maybe_friend_1): Likewise. + (check_for_out_of_scope_variable): Likewise. + (validate_nonmember_using_decl): Likewise. + (lookup_name_innermost_nonclass_level_1): Likewise. + (lookup_arg_dependent_1): Likewise. + * parser.c (cp_parser_lambda_introducer): Likewise. + (cp_parser_template_argument): Likewise. + (cp_parser_single_declaration): Likewise. + * pt.c (convert_nontype_argument): Likewise. + (instantiate_class_template_1): Likewise. + (tsubst_decl): Likewise. + (tsubst_expr): Likewise. + (do_decl_instantiation): Likewise. + (do_type_instantiation): Likewise. + (regenerate_decl_from_template): Likewise. + (always_instantiate_p): Likewise. + (instantiate_decl): Likewise. + (type_dependent_expression_p): Likewise. + (build_non_dependent_expr): Likewise. + * repo.c (repo_emit_p): Likewise. + * rtti.c (build_dynamic_cast_1): Likewise. + * search.c (shared_member_p): Likewise. + * semantics.c (outer_var_p): Likewise. + (finish_id_expression): Likewise. + (finish_omp_clauses): Likewise. + (finish_decltype_type): Likewise. + (ensure_literal_type_for_constexpr_object): Likewise. + * tree.c (lvalue_kind): Likewise. + (bot_replace): Likewise. + (cp_tree_equal): Likewise. + (handle_init_priority_attribute): Likewise. + (decl_storage_duration): Likewise. + * typeck.c (cxx_sizeof_expr): Likewise. + (cxx_alignof_expr): Likewise. + (decay_conversion): Likewise. + (build_class_member_access_expr): Likewise. + (cp_build_array_ref): Likewise. + (cxx_mark_addressable): Likewise. + (maybe_warn_about_returning_address_of_local): Likewise. + (check_return_expr): Likewise. + * typeck2.c (cxx_readonly_error): Likewise. + (abstract_virtuals_error_sfinae): Likewise. + (cxx_incomplete_type_diagnostic): Likewise. + 2013-03-28 Lawrence Crowl * Make-lang.in diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 4542500315f..d1777a0ce28 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7162,7 +7162,7 @@ build_java_interface_fn_ref (tree fn, tree instance) /* Get the java.lang.Class pointer for the interface being called. */ iface = DECL_CONTEXT (fn); iface_ref = lookup_field (iface, get_identifier ("class$"), 0, false); - if (!iface_ref || TREE_CODE (iface_ref) != VAR_DECL + if (!iface_ref || !VAR_P (iface_ref) || DECL_CONTEXT (iface_ref) != iface) { error ("could not find class$ field in java interface type %qT", @@ -9009,7 +9009,7 @@ make_temporary_var_for_ref_to_temp (tree decl, tree type) var = create_temporary_var (type); /* Register the variable. */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (TREE_STATIC (decl) || DECL_THREAD_LOCAL_P (decl))) { /* Namespace-scope or local static; give it a mangled name. */ diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 956d5aa9e27..e9f8bbac3a5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3327,7 +3327,7 @@ check_field_decls (tree t, tree *access_decls, If a union contains a static data member, or a member of reference type, the program is ill-formed. */ - if (TREE_CODE (x) == VAR_DECL) + if (VAR_P (x)) { error ("%q+D may not be static because it is a member of a union", x); continue; @@ -3359,7 +3359,7 @@ check_field_decls (tree t, tree *access_decls, if (type == error_mark_node) continue; - if (TREE_CODE (x) == CONST_DECL || TREE_CODE (x) == VAR_DECL) + if (TREE_CODE (x) == CONST_DECL || VAR_P (x)) continue; /* Now it can only be a FIELD_DECL. */ @@ -5826,7 +5826,7 @@ layout_class_type (tree t, tree *virtuals_p) At this point, finish_record_layout will be called, but S1 is still incomplete.) */ - if (TREE_CODE (field) == VAR_DECL) + if (VAR_P (field)) { maybe_register_incomplete_var (field); /* The visibility of static data members is determined @@ -6327,7 +6327,7 @@ finish_struct_1 (tree t) /* Complete the rtl for any static member objects of the type we're working on. */ for (x = TYPE_FIELDS (t); x; x = DECL_CHAIN (x)) - if (TREE_CODE (x) == VAR_DECL && TREE_STATIC (x) + if (VAR_P (x) && TREE_STATIC (x) && TREE_TYPE (x) != error_mark_node && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (x)), t)) DECL_MODE (x) = TYPE_MODE (t); @@ -6700,7 +6700,7 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) /* Enter the INSTANCE in a table to prevent recursion; a variable's initializer may refer to the variable itself. */ - if (TREE_CODE (instance) == VAR_DECL + if (VAR_P (instance) && DECL_INITIAL (instance) && !type_dependent_expression_p_push (DECL_INITIAL (instance)) && !fixed_type_or_null_ref_ht.find (instance)) @@ -7766,7 +7766,7 @@ get_vtbl_decl_for_binfo (tree binfo) decl = TREE_OPERAND (TREE_OPERAND (decl, 0), 0); } if (decl) - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); return decl; } diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 765fb2f67da..38ef87868a8 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -759,7 +759,7 @@ omp_var_to_track (tree decl) type = TREE_TYPE (type); if (type == error_mark_node || !CLASS_TYPE_P (type)) return false; - if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) + if (VAR_P (decl) && DECL_THREAD_LOCAL_P (decl)) return false; if (cxx_omp_predetermined_sharing (decl) != OMP_CLAUSE_DEFAULT_UNSPECIFIED) return false; @@ -838,7 +838,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) /* If in an OpenMP context, note var uses. */ if (__builtin_expect (wtd->omp_ctx != NULL, 0) - && (TREE_CODE (stmt) == VAR_DECL + && (VAR_P (stmt) || TREE_CODE (stmt) == PARM_DECL || TREE_CODE (stmt) == RESULT_DECL) && omp_var_to_track (stmt)) @@ -998,7 +998,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) { tree decl; for (decl = BIND_EXPR_VARS (stmt); decl; decl = DECL_CHAIN (decl)) - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && !DECL_EXTERNAL (decl) && omp_var_to_track (decl)) { diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index fe96757bc07..bccd884f5c1 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -62,7 +62,7 @@ cxx_warn_unused_global_decl (const_tree decl) return false; /* Const variables take the place of #defines in C++. */ - if (TREE_CODE (decl) == VAR_DECL && TREE_READONLY (decl)) + if (VAR_P (decl) && TREE_READONLY (decl)) return false; return true; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f24dcb35f53..edf46d4c262 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1918,9 +1918,8 @@ struct GTY(()) lang_decl_base { /* True for DECL codes which have template info and access. */ #define LANG_DECL_HAS_MIN(NODE) \ - (TREE_CODE (NODE) == FUNCTION_DECL \ + (VAR_OR_FUNCTION_DECL_P (NODE) \ || TREE_CODE (NODE) == FIELD_DECL \ - || TREE_CODE (NODE) == VAR_DECL \ || TREE_CODE (NODE) == CONST_DECL \ || TREE_CODE (NODE) == TYPE_DECL \ || TREE_CODE (NODE) == TEMPLATE_DECL \ @@ -2200,8 +2199,7 @@ struct GTY((variable_size)) lang_decl { /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS. */ #define DECL_DISCRIMINATOR_P(NODE) \ - (TREE_CODE (NODE) == VAR_DECL \ - && DECL_FUNCTION_SCOPE_P (NODE)) + (VAR_P (NODE) && DECL_FUNCTION_SCOPE_P (NODE)) /* Discriminator for name mangling. */ #define DECL_DISCRIMINATOR(NODE) (LANG_DECL_U2_CHECK (NODE, 1)->discriminator) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d5e86a05fad..25fa34b2149 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -622,7 +622,7 @@ poplevel (int keep, int reverse, int functionbody) push_local_binding where the list of decls returned by getdecls is built. */ decl = TREE_CODE (d) == TREE_LIST ? TREE_VALUE (d) : d; - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (! TREE_USED (decl) || !DECL_READ_P (decl)) && ! DECL_IN_SYSTEM_HEADER (decl) && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl) @@ -646,7 +646,7 @@ poplevel (int keep, int reverse, int functionbody) /* Remove declarations for all the DECLs in this level. */ for (link = decls; link; link = TREE_CHAIN (link)) { - if (leaving_for_scope && TREE_CODE (link) == VAR_DECL + if (leaving_for_scope && VAR_P (link) /* It's hard to make this ARM compatibility hack play nicely with lambdas, and it really isn't necessary in C++11 mode. */ && cxx_dialect < cxx0x @@ -1084,7 +1084,7 @@ decls_match (tree newdecl, tree olddecl) { /* Need to check scope for variable declaration (VAR_DECL). For typedef (TYPE_DECL), scope is ignored. */ - if (TREE_CODE (newdecl) == VAR_DECL + if (VAR_P (newdecl) && CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl) /* [dcl.link] Two declarations for an object with C language linkage @@ -1866,7 +1866,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) && newtype == DECL_ORIGINAL_TYPE (newdecl)) newtype = oldtype; - if (TREE_CODE (newdecl) == VAR_DECL) + if (VAR_P (newdecl)) { DECL_THIS_EXTERN (newdecl) |= DECL_THIS_EXTERN (olddecl); DECL_INITIALIZED_P (newdecl) |= DECL_INITIALIZED_P (olddecl); @@ -1903,7 +1903,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) && !(processing_template_decl && uses_template_parms (newdecl))) layout_type (TREE_TYPE (newdecl)); - if ((TREE_CODE (newdecl) == VAR_DECL + if ((VAR_P (newdecl) || TREE_CODE (newdecl) == PARM_DECL || TREE_CODE (newdecl) == RESULT_DECL || TREE_CODE (newdecl) == FIELD_DECL @@ -1973,7 +1973,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) /* Keep the old RTL. */ COPY_DECL_RTL (olddecl, newdecl); } - else if (TREE_CODE (newdecl) == VAR_DECL + else if (VAR_P (newdecl) && (DECL_SIZE (olddecl) || !DECL_SIZE (newdecl))) { /* Keep the old RTL. We cannot keep the old RTL if the old @@ -2080,7 +2080,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) SET_DECL_THUNKS (newdecl, DECL_THUNKS (olddecl)); } /* Only variables have this field. */ - else if (TREE_CODE (newdecl) == VAR_DECL + else if (VAR_P (newdecl) && VAR_HAD_UNKNOWN_BOUND (olddecl)) SET_VAR_HAD_UNKNOWN_BOUND (newdecl); } @@ -2256,7 +2256,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } /* Init priority used to be merged from newdecl to olddecl by the memcpy, so keep this behavior. */ - if (TREE_CODE (newdecl) == VAR_DECL && DECL_HAS_INIT_PRIORITY_P (newdecl)) + if (VAR_P (newdecl) && DECL_HAS_INIT_PRIORITY_P (newdecl)) { SET_DECL_INIT_PRIORITY (olddecl, DECL_INIT_PRIORITY (newdecl)); DECL_HAS_INIT_PRIORITY_P (olddecl) = 1; @@ -2285,7 +2285,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) TREE_USED (newdecl) = 1; else if (TREE_USED (newdecl)) TREE_USED (olddecl) = 1; - if (TREE_CODE (newdecl) == VAR_DECL) + if (VAR_P (newdecl)) { if (DECL_READ_P (olddecl)) DECL_READ_P (newdecl) = 1; @@ -2396,7 +2396,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) flags and attributes. */ if (DECL_RTL_SET_P (olddecl) && (TREE_CODE (olddecl) == FUNCTION_DECL - || (TREE_CODE (olddecl) == VAR_DECL + || (VAR_P (olddecl) && TREE_STATIC (olddecl)))) make_decl_rtl (olddecl); @@ -2539,7 +2539,7 @@ redeclaration_error_message (tree newdecl, tree olddecl) return NULL; } - else if (TREE_CODE (newdecl) == VAR_DECL + else if (VAR_P (newdecl) && DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl) && (! DECL_LANG_SPECIFIC (olddecl) || ! CP_DECL_THREADPRIVATE_P (olddecl) @@ -2564,8 +2564,8 @@ redeclaration_error_message (tree newdecl, tree olddecl) union { int i; }; is invalid. */ - if ((TREE_CODE (newdecl) == VAR_DECL && DECL_ANON_UNION_VAR_P (newdecl)) - || (TREE_CODE (olddecl) == VAR_DECL && DECL_ANON_UNION_VAR_P (olddecl))) + if ((VAR_P (newdecl) && DECL_ANON_UNION_VAR_P (newdecl)) + || (VAR_P (olddecl) && DECL_ANON_UNION_VAR_P (olddecl))) return G_("redeclaration of %q#D"); /* If at least one declaration is a reference, there is no conflict. For example: @@ -2717,7 +2717,7 @@ decl_jump_unsafe (tree decl) preceding types and is declared without an initializer (8.5). */ tree type = TREE_TYPE (decl); - if (TREE_CODE (decl) != VAR_DECL || TREE_STATIC (decl) + if (!VAR_P (decl) || TREE_STATIC (decl) || type == error_mark_node) return 0; @@ -4529,10 +4529,10 @@ start_decl (const cp_declarator *declarator, if (TYPE_P (context) && COMPLETE_TYPE_P (complete_type (context))) { - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { tree field = lookup_field (context, DECL_NAME (decl), 0, false); - if (field == NULL_TREE || TREE_CODE (field) != VAR_DECL) + if (field == NULL_TREE || !VAR_P (field)) error ("%q#D is not a static member of %q#T", decl, context); else { @@ -4609,7 +4609,7 @@ start_decl (const cp_declarator *declarator, if (decl == error_mark_node) return error_mark_node; - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && DECL_NAMESPACE_SCOPE_P (decl) && !TREE_PUBLIC (decl) && !was_public && !DECL_THIS_STATIC (decl) && !DECL_ARTIFICIAL (decl)) { @@ -4620,7 +4620,7 @@ start_decl (const cp_declarator *declarator, DECL_THIS_STATIC (decl) = 1; } - if (!processing_template_decl && TREE_CODE (decl) == VAR_DECL) + if (!processing_template_decl && VAR_P (decl)) start_decl_1 (decl, initialized); return decl; @@ -4645,7 +4645,7 @@ start_decl_1 (tree decl, bool initialized) if (error_operand_p (decl)) return; - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); type = TREE_TYPE (decl); complete_p = COMPLETE_TYPE_P (type); @@ -4991,7 +4991,7 @@ check_for_uninitialized_const_var (tree decl) /* ``Unless explicitly declared extern, a const object does not have external linkage and must be initialized. ($8.4; $12.1)'' ARM 7.1.6 */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && TREE_CODE (type) != REFERENCE_TYPE && CP_TYPE_CONST_P (type) && !DECL_INITIAL (decl)) @@ -5778,7 +5778,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) /* The `register' keyword, when used together with an asm-specification, indicates that the variable should be placed in a particular register. */ - if (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) + if (VAR_P (decl) && DECL_REGISTER (decl)) { set_user_assembler_name (decl, asmspec); DECL_HARD_REGISTER (decl) = 1; @@ -5793,7 +5793,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) } /* Handle non-variables up front. */ - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) { rest_of_decl_compilation (decl, toplev, at_eof); return; @@ -5911,7 +5911,7 @@ initialize_local_var (tree decl, tree init) tree cleanup; int already_used; - gcc_assert (TREE_CODE (decl) == VAR_DECL + gcc_assert (VAR_P (decl) || TREE_CODE (decl) == RESULT_DECL); gcc_assert (!TREE_STATIC (decl)); @@ -6147,7 +6147,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, if (!ensure_literal_type_for_constexpr_object (decl)) DECL_DECLARED_CONSTEXPR_P (decl) = 0; - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && DECL_CLASS_SCOPE_P (decl) && DECL_INITIALIZED_IN_CLASS_P (decl)) check_static_variable_definition (decl, type); @@ -6178,7 +6178,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, } } - if (init && TREE_CODE (decl) == VAR_DECL) + if (init && VAR_P (decl)) { DECL_NONTRIVIALLY_INITIALIZED_P (decl) = 1; /* If DECL is a reference, then we want to know whether init is a @@ -6217,7 +6217,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, then it can be used in future constant expressions, so its value must be available. */ - if (TREE_CODE (decl) != VAR_DECL || dependent_type_p (type)) + if (!VAR_P (decl) || dependent_type_p (type)) /* We can't do anything if the decl has dependent type. */; else if (init && init_const_expr_p @@ -6288,7 +6288,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, TREE_READONLY (decl) = 0; } - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { /* If this is a local variable that will need a mangled name, register it now. We must do this before processing the @@ -6409,7 +6409,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, static data members in uninstantiated class templates. */ if (VAR_OR_FUNCTION_DECL_P (decl)) { - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { layout_var_decl (decl); maybe_commonize_var (decl); @@ -6875,7 +6875,7 @@ register_dtor_fn (tree decl) static void expand_static_init (tree decl, tree init) { - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); gcc_assert (TREE_STATIC (decl)); /* Some variables require no dynamic initialization. */ @@ -10749,7 +10749,7 @@ grokdeclarator (const cp_declarator *declarator, DECL_THIS_STATIC (decl) = 1; /* Set constexpr flag on vars (functions got it in grokfndecl). */ - if (constexpr_p && TREE_CODE (decl) == VAR_DECL) + if (constexpr_p && VAR_P (decl)) DECL_DECLARED_CONSTEXPR_P (decl) = true; /* Record constancy and volatility on the DECL itself . There's @@ -10791,7 +10791,7 @@ require_complete_types_for_parms (tree parms) int local_variable_p (const_tree t) { - if ((TREE_CODE (t) == VAR_DECL + if ((VAR_P (t) /* A VAR_DECL with a context that is a _TYPE is a static data member. */ && !TYPE_P (CP_DECL_CONTEXT (t)) @@ -14036,7 +14036,7 @@ grokmethod (cp_decl_specifier_seq *declspecs, void maybe_register_incomplete_var (tree var) { - gcc_assert (TREE_CODE (var) == VAR_DECL); + gcc_assert (VAR_P (var)); /* Keep track of variables with incomplete types. */ if (!processing_template_decl && TREE_TYPE (var) != error_mark_node @@ -14295,7 +14295,7 @@ cxx_comdat_group (tree decl) /* Virtual tables, construction virtual tables, and virtual table tables all go in a single COMDAT group, named after the primary virtual table. */ - if (TREE_CODE (decl) == VAR_DECL && DECL_VTABLE_OR_VTT_P (decl)) + if (VAR_P (decl) && DECL_VTABLE_OR_VTT_P (decl)) name = DECL_ASSEMBLER_NAME (CLASSTYPE_VTABLES (DECL_CONTEXT (decl))); /* For all other DECLs, the COMDAT group is the mangled name of the declaration itself. */ diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 60fad44eecd..ea290b9e6f4 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -931,7 +931,7 @@ grokfield (const cp_declarator *declarator, } else if (TREE_CODE (value) == FIELD_DECL) /* C++11 NSDMI, keep going. */; - else if (TREE_CODE (value) != VAR_DECL) + else if (!VAR_P (value)) gcc_unreachable (); else if (!processing_template_decl) { @@ -1603,7 +1603,7 @@ comdat_linkage (tree decl) if (flag_weak) make_decl_one_only (decl, cxx_comdat_group (decl)); else if (TREE_CODE (decl) == FUNCTION_DECL - || (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl))) + || (VAR_P (decl) && DECL_ARTIFICIAL (decl))) /* We can just emit function and compiler-generated variables statically; having multiple copies is (for the most part) only a waste of space. @@ -1674,7 +1674,7 @@ maybe_make_one_only (tree decl) { make_decl_one_only (decl, cxx_comdat_group (decl)); - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { DECL_COMDAT (decl) = 1; /* Mark it needed so we don't forget to emit it. */ @@ -2075,7 +2075,7 @@ determine_visibility (tree decl) /* Virtual tables have DECL_CONTEXT set to their associated class, so they are automatically handled above. */ - gcc_assert (TREE_CODE (decl) != VAR_DECL + gcc_assert (!VAR_P (decl) || !DECL_VTABLE_OR_VTT_P (decl)); if (DECL_FUNCTION_SCOPE_P (decl) && ! DECL_VISIBILITY_SPECIFIED (decl)) @@ -2112,7 +2112,7 @@ determine_visibility (tree decl) but have no TEMPLATE_INFO, so don't try to check it. */ use_template = 0; } - else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl) + else if (VAR_P (decl) && DECL_TINFO_P (decl) && flag_visibility_ms_compat) { /* Under -fvisibility-ms-compat, types are visible by default, @@ -2126,7 +2126,7 @@ determine_visibility (tree decl) else DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; } - else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl)) + else if (VAR_P (decl) && DECL_TINFO_P (decl)) { /* tinfo visibility is based on the type it's for. */ constrain_visibility @@ -2244,7 +2244,7 @@ determine_visibility (tree decl) symbol flags are updated. */ if ((DECL_VISIBILITY (decl) != orig_visibility || DECL_VISIBILITY_SPECIFIED (decl) != orig_visibility_specified) - && ((TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)) + && ((VAR_P (decl) && TREE_STATIC (decl)) || TREE_CODE (decl) == FUNCTION_DECL) && DECL_RTL_SET_P (decl)) make_decl_rtl (decl); @@ -2271,7 +2271,7 @@ determine_visibility_from_class (tree decl, tree class_type) /* Give the target a chance to override the visibility associated with DECL. */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && (DECL_TINFO_P (decl) || (DECL_VTABLE_OR_VTT_P (decl) /* Construction virtual tables are not exported because @@ -2447,7 +2447,7 @@ import_export_decl (tree decl) { /* The repository indicates that this entity should be defined here. Make sure the back end honors that request. */ - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) mark_needed (decl); else if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl) || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) @@ -2468,7 +2468,7 @@ import_export_decl (tree decl) /* We have already decided what to do with this DECL; there is no need to check anything further. */ ; - else if (TREE_CODE (decl) == VAR_DECL && DECL_VTABLE_OR_VTT_P (decl)) + else if (VAR_P (decl) && DECL_VTABLE_OR_VTT_P (decl)) { class_type = DECL_CONTEXT (decl); import_export_class (class_type); @@ -2534,7 +2534,7 @@ import_export_decl (tree decl) else comdat_p = true; } - else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl)) + else if (VAR_P (decl) && DECL_TINFO_P (decl)) { tree type = TREE_TYPE (DECL_NAME (decl)); if (CLASS_TYPE_P (type)) @@ -3267,7 +3267,7 @@ fix_temporary_vars_context_r (tree *node, tree var; for (var = BIND_EXPR_VARS (*node); var; var = DECL_CHAIN (var)) - if (TREE_CODE (var) == VAR_DECL + if (VAR_P (var) && !DECL_NAME (var) && DECL_ARTIFICIAL (var) && !DECL_CONTEXT (var)) @@ -3516,7 +3516,7 @@ prune_vars_needing_no_initialization (tree *vars) } /* The only things that can be initialized are variables. */ - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); /* If this object is not defined, we don't need to do anything here. */ @@ -3796,7 +3796,7 @@ decl_defined_p (tree decl) return (DECL_INITIAL (decl) != NULL_TREE); else { - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); return !DECL_EXTERNAL (decl); } } @@ -3838,7 +3838,7 @@ bool decl_maybe_constant_var_p (tree decl) { tree type = TREE_TYPE (decl); - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) return false; if (DECL_DECLARED_CONSTEXPR_P (decl)) return true; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 15746504b4d..2af900ded8b 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -916,7 +916,7 @@ dump_simple_decl (tree t, tree type, int flags) { if (flags & TFF_DECL_SPECIFIERS) { - if (TREE_CODE (t) == VAR_DECL + if (VAR_P (t) && DECL_DECLARED_CONSTEXPR_P (t)) pp_cxx_ws_string (cxx_pp, "constexpr"); dump_type_prefix (type, flags & ~TFF_UNQUALIFIED_NAME); @@ -1249,7 +1249,7 @@ dump_template_decl (tree t, int flags) ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0))); else if (DECL_TEMPLATE_RESULT (t) - && (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL + && (VAR_P (DECL_TEMPLATE_RESULT (t)) /* Alias template. */ || DECL_TYPE_TEMPLATE_P (t))) dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME); @@ -3283,7 +3283,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, case 'D': { tree temp = next_tree; - if (TREE_CODE (temp) == VAR_DECL + if (VAR_P (temp) && DECL_HAS_DEBUG_EXPR_P (temp)) { temp = DECL_DEBUG_EXPR (temp); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 52ba1cdeae5..0f295b006bc 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -828,7 +828,7 @@ build_throw (tree exp) treated as an rvalue for the purposes of overload resolution to favor move constructors over copy constructors. */ if (/* Must be a local, automatic variable. */ - TREE_CODE (exp) == VAR_DECL + VAR_P (exp) && DECL_CONTEXT (exp) == current_function_decl && ! TREE_STATIC (exp) /* The variable must not have the `volatile' qualifier. */ diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 32f242c3275..000f514a43c 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1131,7 +1131,7 @@ build_vtbl_address (tree binfo) /* Now compute the address to use when initializing the vptr. */ vtbl = unshare_expr (BINFO_VTABLE (binfo_for)); - if (TREE_CODE (vtbl) == VAR_DECL) + if (VAR_P (vtbl)) vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl); return vtbl; @@ -1293,7 +1293,7 @@ member_init_ok_or_else (tree field, tree type, tree member_name) member_name); return 0; } - if (TREE_CODE (field) == VAR_DECL) + if (VAR_P (field)) { error ("%q#D is a static data member; it can only be " "initialized at its definition", @@ -1515,7 +1515,7 @@ build_aggr_init (tree exp, tree init, int flags, tsubst_flags_t complain) return stmt_expr; } - if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == PARM_DECL) + if (VAR_P (exp) || TREE_CODE (exp) == PARM_DECL) /* Just know that we've seen something for this node. */ TREE_USED (exp) = 1; @@ -1728,7 +1728,7 @@ expand_aggr_init_1 (tree binfo, tree true_exp, tree exp, tree init, int flags, in and expand the constructor. Constructors now come as TARGET_EXPRs. */ - if (init && TREE_CODE (exp) == VAR_DECL + if (init && VAR_P (exp) && COMPOUND_LITERAL_P (init)) { vec *cleanups = NULL; @@ -1849,7 +1849,7 @@ build_offset_ref (tree type, tree member, bool address_p) processing. */ if (TREE_CODE (member) == TYPE_DECL) return member; - if (TREE_CODE (member) == VAR_DECL || TREE_CODE (member) == CONST_DECL) + if (VAR_P (member) || TREE_CODE (member) == CONST_DECL) return convert_from_reference (member); if (TREE_CODE (member) == FIELD_DECL && DECL_C_BIT_FIELD (member)) @@ -1964,7 +1964,7 @@ constant_value_1 (tree decl, bool integral_p, bool return_aggregate_cst_ok_p) while (TREE_CODE (decl) == CONST_DECL || (integral_p ? decl_constant_var_p (decl) - : (TREE_CODE (decl) == VAR_DECL + : (VAR_P (decl) && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl))))) { tree init; diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index a672d4e3c23..08bfa22e0fa 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -663,7 +663,7 @@ write_mangled_name (const tree decl, bool top_level) write_source_name (DECL_NAME (decl)); } } - else if (TREE_CODE (decl) == VAR_DECL + else if (VAR_P (decl) /* The names of non-static global variables aren't mangled. */ && DECL_EXTERNAL_LINKAGE_P (decl) && (CP_DECL_CONTEXT (decl) == global_namespace @@ -1042,7 +1042,7 @@ write_prefix (const tree node) { write_prefix (decl_mangling_context (decl)); write_unqualified_name (decl); - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) || TREE_CODE (decl) == FIELD_DECL) { /* := M */ diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 88a516a4282..b25db14f1e1 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -509,8 +509,8 @@ supplement_binding_1 (cxx_binding *binding, tree decl) A member shall not be declared twice in the member-specification. */ - else if (TREE_CODE (target_decl) == VAR_DECL - && TREE_CODE (target_bval) == VAR_DECL + else if (VAR_P (target_decl) + && VAR_P (target_bval) && DECL_EXTERNAL (target_decl) && DECL_EXTERNAL (target_bval) && !DECL_CLASS_SCOPE_P (target_decl)) { @@ -574,7 +574,7 @@ add_decl_to_level (tree decl, cp_binding_level *b) { /* We used to record virtual tables as if they were ordinary variables, but no longer do so. */ - gcc_assert (!(TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl))); + gcc_assert (!(VAR_P (decl) && DECL_VIRTUAL_P (decl))); if (TREE_CODE (decl) == NAMESPACE_DECL && !DECL_NAMESPACE_ALIAS (decl)) @@ -594,7 +594,7 @@ add_decl_to_level (tree decl, cp_binding_level *b) static later. It's OK for this list to contain a few false positives. */ if (b->kind == sk_namespace) - if ((TREE_CODE (decl) == VAR_DECL + if ((VAR_P (decl) && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))) || (TREE_CODE (decl) == FUNCTION_DECL && (!TREE_PUBLIC (decl) || DECL_DECLARED_INLINE_P (decl)))) @@ -636,7 +636,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) /* A local declaration for an `extern' variable is in the scope of the current namespace, not the current function. */ - && !(TREE_CODE (x) == VAR_DECL && DECL_EXTERNAL (x)) + && !(VAR_P (x) && DECL_EXTERNAL (x)) /* When parsing the parameter list of a function declarator, don't set DECL_CONTEXT to an enclosing function. When we push the PARM_DECLs in order to process the function body, @@ -973,7 +973,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) if (!(TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x) && t != NULL_TREE) && (TREE_CODE (x) == TYPE_DECL - || TREE_CODE (x) == VAR_DECL + || VAR_P (x) || TREE_CODE (x) == NAMESPACE_DECL || TREE_CODE (x) == CONST_DECL || TREE_CODE (x) == TEMPLATE_DECL)) @@ -1021,7 +1021,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) tree d = oldlocal; while (oldlocal - && TREE_CODE (oldlocal) == VAR_DECL + && VAR_P (oldlocal) && DECL_DEAD_FOR_LOCAL (oldlocal)) oldlocal = DECL_SHADOWED_FOR_VAR (oldlocal); @@ -1065,7 +1065,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) /* Inline decls shadow nothing. */ && !DECL_FROM_INLINE (x) && (TREE_CODE (oldlocal) == PARM_DECL - || TREE_CODE (oldlocal) == VAR_DECL + || VAR_P (oldlocal) /* If the old decl is a type decl, only warn if the old decl is an explicit typedef or if both the old and new decls are type decls. */ @@ -1125,7 +1125,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) outermost block of the controlled statement. Redeclaring a variable from a for or while condition is detected elsewhere. */ - else if (TREE_CODE (oldlocal) == VAR_DECL + else if (VAR_P (oldlocal) && oldscope == current_binding_level->level_chain && (oldscope->kind == sk_cond || oldscope->kind == sk_for)) @@ -1179,7 +1179,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) x); } else if (oldglobal != NULL_TREE - && (TREE_CODE (oldglobal) == VAR_DECL + && (VAR_P (oldglobal) /* If the old decl is a type decl, only warn if the old decl is an explicit typedef or if both the old and new decls are type decls. */ @@ -1196,7 +1196,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) } } - if (TREE_CODE (x) == VAR_DECL) + if (VAR_P (x)) maybe_register_incomplete_var (x); } @@ -1309,12 +1309,12 @@ check_for_out_of_scope_variable (tree decl) tree shadowed; /* We only care about out of scope variables. */ - if (!(TREE_CODE (decl) == VAR_DECL && DECL_DEAD_FOR_LOCAL (decl))) + if (!(VAR_P (decl) && DECL_DEAD_FOR_LOCAL (decl))) return decl; shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (decl) ? DECL_SHADOWED_FOR_VAR (decl) : NULL_TREE ; - while (shadowed != NULL_TREE && TREE_CODE (shadowed) == VAR_DECL + while (shadowed != NULL_TREE && VAR_P (shadowed) && DECL_DEAD_FOR_LOCAL (shadowed)) shadowed = DECL_HAS_SHADOWED_FOR_VAR_P (shadowed) ? DECL_SHADOWED_FOR_VAR (shadowed) : NULL_TREE; @@ -2435,7 +2435,7 @@ validate_nonmember_using_decl (tree decl, tree scope, tree name) if (using_decl == NULL_TREE && at_function_scope_p () - && TREE_CODE (decl) == VAR_DECL) + && VAR_P (decl)) /* C++11 7.3.3/10. */ error ("%qD is already declared in this scope", name); @@ -3061,7 +3061,7 @@ push_class_level_binding_1 (tree name, tree x) (Non-static data members were also forbidden to have the same name as T until TC1.) */ - if ((TREE_CODE (x) == VAR_DECL + if ((VAR_P (x) || TREE_CODE (x) == CONST_DECL || (TREE_CODE (x) == TYPE_DECL && !DECL_SELF_REFERENCE_P (x)) @@ -4955,7 +4955,7 @@ lookup_name_innermost_nonclass_level_1 (tree name) while (1) { if (binding->scope == b - && !(TREE_CODE (binding->value) == VAR_DECL + && !(VAR_P (binding->value) && DECL_DEAD_FOR_LOCAL (binding->value))) return binding->value; @@ -4994,7 +4994,7 @@ is_local_extern (tree decl) if (TREE_CODE (decl) == FUNCTION_DECL) return DECL_LOCAL_FUNCTION_P (decl); - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) return false; if (!current_function_decl) return false; @@ -5554,7 +5554,7 @@ lookup_arg_dependent_1 (tree name, tree fns, vec *args, fns = k.functions; if (fns - && TREE_CODE (fns) != VAR_DECL + && !VAR_P (fns) && !is_overloaded_fn (fns)) { error ("argument dependent lookup finds %q+D", fns); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ff2ef3dd43e..09c5dff7cea 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8479,7 +8479,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr) continue; } else if (DECL_P (capture_init_expr) - && (TREE_CODE (capture_init_expr) != VAR_DECL + && (!VAR_P (capture_init_expr) && TREE_CODE (capture_init_expr) != PARM_DECL)) { error_at (capture_token->location, @@ -8488,7 +8488,7 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr) inform (0, "%q+#D declared here", capture_init_expr); continue; } - if (TREE_CODE (capture_init_expr) == VAR_DECL + if (VAR_P (capture_init_expr) && decl_storage_duration (capture_init_expr) != dk_auto) { pedwarn (capture_token->location, 0, "capture of variable " @@ -13332,7 +13332,7 @@ cp_parser_template_argument (cp_parser* parser) probe = argument; if (TREE_CODE (probe) == SCOPE_REF) probe = TREE_OPERAND (probe, 1); - if (TREE_CODE (probe) == VAR_DECL) + if (VAR_P (probe)) { /* A variable without external linkage might still be a valid constant-expression, so no error is issued here @@ -22146,7 +22146,7 @@ cp_parser_single_declaration (cp_parser* parser, decl = error_mark_node; } - if (decl && TREE_CODE (decl) == VAR_DECL) + if (decl && VAR_P (decl)) check_template_variable (decl); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 27e3ff87204..8468a84b285 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5646,7 +5646,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) else if (TREE_CODE (expr) != ADDR_EXPR && TREE_CODE (expr_type) != ARRAY_TYPE) { - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) { error ("%qD is not a valid template argument " "because %qD is a variable, not the address of " @@ -5671,7 +5671,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) decl = ((TREE_CODE (expr) == ADDR_EXPR) ? TREE_OPERAND (expr, 0) : expr); - if (TREE_CODE (decl) != VAR_DECL) + if (!VAR_P (decl)) { error ("%qE is not a valid template argument of type %qT " "because %qE is not a variable", @@ -8837,7 +8837,7 @@ instantiate_class_template_1 (tree type) r = tsubst (t, args, tf_warning_or_error, NULL_TREE); if (TREE_CODE (t) == TEMPLATE_DECL) --processing_template_decl; - if (TREE_CODE (r) == VAR_DECL) + if (VAR_P (r)) { /* In [temp.inst]: @@ -10639,7 +10639,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) break; } - if (TREE_CODE (t) == VAR_DECL && DECL_ANON_UNION_VAR_P (t)) + if (VAR_P (t) && DECL_ANON_UNION_VAR_P (t)) { /* Just use name lookup to find a member alias for an anonymous union, but then add it to the hash table. */ @@ -10657,13 +10657,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) type = DECL_ORIGINAL_TYPE (t); else type = TREE_TYPE (t); - if (TREE_CODE (t) == VAR_DECL + if (VAR_P (t) && VAR_HAD_UNKNOWN_BOUND (t) && type != error_mark_node) type = strip_array_domain (type); type = tsubst (type, args, complain, in_decl); } - if (TREE_CODE (r) == VAR_DECL) + if (VAR_P (r)) { /* Even if the original location is out of scope, the newly substituted one is not. */ @@ -10727,7 +10727,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL)) SET_DECL_RTL (r, NULL); DECL_SIZE (r) = DECL_SIZE_UNIT (r) = 0; - if (TREE_CODE (r) == VAR_DECL) + if (VAR_P (r)) { /* Possibly limit visibility based on template args. */ DECL_VISIBILITY (r) = VISIBILITY_DEFAULT; @@ -12897,9 +12897,9 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, handle local variables, and since we've already done all that needs to be done, that's the right thing to do. */ - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) DECL_TEMPLATE_INSTANTIATED (decl) = 1; - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && ANON_AGGR_TYPE_P (TREE_TYPE (decl))) /* Anonymous aggregates are a special case. */ finish_anon_union (decl); @@ -12920,7 +12920,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, { int const_init = false; maybe_push_decl (decl); - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && DECL_PRETTY_FUNCTION_P (decl)) { /* For __PRETTY_FUNCTION__ we have to adjust the @@ -12951,7 +12951,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, init = t; } - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) const_init = (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (pattern_decl)); cp_finish_decl (decl, init, const_init, NULL_TREE, 0); @@ -18008,7 +18008,7 @@ do_decl_instantiation (tree decl, tree storage) error ("explicit instantiation of non-template %q#D", decl); return; } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) { /* There is an asymmetry here in the way VAR_DECLs and FUNCTION_DECLs are handled by grokdeclarator. In the case of @@ -18024,7 +18024,7 @@ do_decl_instantiation (tree decl, tree storage) return; } result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, false); - if (!result || TREE_CODE (result) != VAR_DECL) + if (!result || !VAR_P (result)) { error ("no matching template for %qD found", decl); return; @@ -18286,7 +18286,7 @@ do_type_instantiation (tree t, tree storage, tsubst_flags_t complain) instantiate_class_member (tmp, extern_p); for (tmp = TYPE_FIELDS (t); tmp; tmp = DECL_CHAIN (tmp)) - if (TREE_CODE (tmp) == VAR_DECL && DECL_TEMPLATE_INSTANTIATION (tmp)) + if (VAR_P (tmp) && DECL_TEMPLATE_INSTANTIATION (tmp)) instantiate_class_member (tmp, extern_p); if (CLASSTYPE_NESTED_UTDS (t)) @@ -18415,7 +18415,7 @@ regenerate_decl_from_template (tree decl, tree tmpl) && !DECL_DECLARED_INLINE_P (decl)) DECL_DECLARED_INLINE_P (decl) = 1; } - else if (TREE_CODE (decl) == VAR_DECL) + else if (VAR_P (decl)) { DECL_INITIAL (decl) = tsubst_expr (DECL_INITIAL (code_pattern), args, @@ -18479,7 +18479,7 @@ template_for_substitution (tree decl) cannot restructure the loop to just keep going until we find a template with a definition, since that might go too far if a specialization was declared, but not defined. */ - gcc_assert (TREE_CODE (decl) != VAR_DECL + gcc_assert (!VAR_P (decl) || DECL_IN_AGGR_P (DECL_TEMPLATE_RESULT (tmpl))); /* Fetch the more general template. */ @@ -18507,7 +18507,7 @@ always_instantiate_p (tree decl) /* And we need to instantiate static data members so that their initializers are available in integral constant expressions. */ - || (TREE_CODE (decl) == VAR_DECL + || (VAR_P (decl) && decl_maybe_constant_var_p (decl))); } @@ -18611,7 +18611,7 @@ instantiate_decl (tree d, int defer_ok, case that an expression refers to the value of the variable -- if the variable has a constant value the referring expression can take advantage of that fact. */ - if (TREE_CODE (d) == VAR_DECL + if (VAR_P (d) || DECL_DECLARED_CONSTEXPR_P (d)) defer_ok = 0; @@ -18730,11 +18730,11 @@ instantiate_decl (tree d, int defer_ok, elsewhere, we don't want to instantiate the entire data member, but we do want to instantiate the initializer so that we can substitute that elsewhere. */ - || (external_p && TREE_CODE (d) == VAR_DECL)) + || (external_p && VAR_P (d))) { /* The definition of the static data member is now required so we must substitute the initializer. */ - if (TREE_CODE (d) == VAR_DECL + if (VAR_P (d) && !DECL_INITIAL (d) && DECL_INITIAL (code_pattern)) { @@ -18784,7 +18784,7 @@ instantiate_decl (tree d, int defer_ok, goto out; /* ??? Historically, we have instantiated inline functions, even when marked as "extern template". */ - if (!(external_p && TREE_CODE (d) == VAR_DECL)) + if (!(external_p && VAR_P (d))) add_pending_template (d); goto out; } @@ -18824,7 +18824,7 @@ instantiate_decl (tree d, int defer_ok, they changed as a result of calling regenerate_decl_from_template. */ input_location = DECL_SOURCE_LOCATION (d); - if (TREE_CODE (d) == VAR_DECL) + if (VAR_P (d)) { tree init; bool const_init = false; @@ -19873,7 +19873,7 @@ type_dependent_expression_p (tree expression) /* A static data member of the current instantiation with incomplete array type is type-dependent, as the definition and specializations can have different bounds. */ - if (TREE_CODE (expression) == VAR_DECL + if (VAR_P (expression) && DECL_CLASS_SCOPE_P (expression) && dependent_type_p (DECL_CONTEXT (expression)) && VAR_HAD_UNKNOWN_BOUND (expression)) @@ -20467,7 +20467,7 @@ build_non_dependent_expr (tree expr) || TREE_CODE (inner_expr) == OFFSET_REF) return expr; /* There is no need to return a proxy for a variable. */ - if (TREE_CODE (expr) == VAR_DECL) + if (VAR_P (expr)) return expr; /* Preserve string constants; conversions from string constants to "char *" are allowed, even though normally a "const char *" diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index 8c524adbf2b..7b6f7b8ce1b 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -302,7 +302,7 @@ repo_emit_p (tree decl) is an artificial restriction; the code in the prelinker and here will work fine if all entities with vague linkage are managed by the repository. */ - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) { tree type = NULL_TREE; if (DECL_VTABLE_OR_VTT_P (decl)) diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index dd22e34197b..b6a9a2edb4a 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -635,7 +635,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) { /* if b is an object, dynamic_cast(&b) == (void *)&b. */ if (TREE_CODE (expr) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL + && VAR_P (TREE_OPERAND (expr, 0)) && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE) return build1 (NOP_EXPR, type, expr); @@ -658,7 +658,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) dynamic_cast(b) (b an object) cannot succeed. */ if (tc == REFERENCE_TYPE) { - if (TREE_CODE (old_expr) == VAR_DECL + if (VAR_P (old_expr) && TREE_CODE (TREE_TYPE (old_expr)) == RECORD_TYPE) { tree expr = throw_bad_cast (); @@ -674,7 +674,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) else if (TREE_CODE (expr) == ADDR_EXPR) { tree op = TREE_OPERAND (expr, 0); - if (TREE_CODE (op) == VAR_DECL + if (VAR_P (op) && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE) { if (complain & tf_warning) diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 0ac7cdc2767..19a4c43ff0d 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -983,7 +983,7 @@ struct lookup_field_info { int shared_member_p (tree t) { - if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == TYPE_DECL \ + if (VAR_P (t) || TREE_CODE (t) == TYPE_DECL \ || TREE_CODE (t) == CONST_DECL) return 1; if (is_overloaded_fn (t)) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2fe2908bf86..8bd76120fc7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2887,7 +2887,7 @@ baselink_for_fns (tree fns) static bool outer_var_p (tree decl) { - return ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL) + return ((VAR_P (decl) || TREE_CODE (decl) == PARM_DECL) && DECL_FUNCTION_SCOPE_P (decl) && (DECL_CONTEXT (decl) != current_function_decl || parsing_nsdmi ())); @@ -3083,7 +3083,7 @@ finish_id_expression (tree id_expression, } else { - error (TREE_CODE (decl) == VAR_DECL + error (VAR_P (decl) ? G_("use of local variable with automatic storage from containing function") : G_("use of parameter from containing function")); error (" %q+#D declared here", decl); @@ -3259,7 +3259,7 @@ finish_id_expression (tree id_expression, /* If we found a variable, then name lookup during the instantiation will always resolve to the same VAR_DECL (or an instantiation thereof). */ - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL) { mark_used (decl); @@ -3303,7 +3303,7 @@ finish_id_expression (tree id_expression, /* Mark variable-like entities as used. Functions are similarly marked either below or after overload resolution. */ - if ((TREE_CODE (decl) == VAR_DECL + if ((VAR_P (decl) || TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == CONST_DECL || TREE_CODE (decl) == RESULT_DECL) @@ -3328,7 +3328,7 @@ finish_id_expression (tree id_expression, } tree wrap; - if (TREE_CODE (decl) == VAR_DECL + if (VAR_P (decl) && !cp_unevaluated_operand && DECL_THREAD_LOCAL_P (decl) && (wrap = get_tls_wrapper_fn (decl))) @@ -4061,7 +4061,7 @@ finish_omp_clauses (tree clauses) goto check_dup_generic; check_dup_generic: t = OMP_CLAUSE_DECL (c); - if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL) + if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { if (processing_template_decl) break; @@ -4084,7 +4084,7 @@ finish_omp_clauses (tree clauses) case OMP_CLAUSE_FIRSTPRIVATE: t = OMP_CLAUSE_DECL (c); - if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL) + if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { if (processing_template_decl) break; @@ -4106,7 +4106,7 @@ finish_omp_clauses (tree clauses) case OMP_CLAUSE_LASTPRIVATE: t = OMP_CLAUSE_DECL (c); - if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL) + if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) { if (processing_template_decl) break; @@ -4258,7 +4258,7 @@ finish_omp_clauses (tree clauses) t = OMP_CLAUSE_DECL (c); if (processing_template_decl - && TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL) + && !VAR_P (t) && TREE_CODE (t) != PARM_DECL) { pc = &OMP_CLAUSE_CHAIN (c); continue; @@ -4298,7 +4298,7 @@ finish_omp_clauses (tree clauses) break; case OMP_CLAUSE_COPYIN: - if (TREE_CODE (t) != VAR_DECL || !DECL_THREAD_LOCAL_P (t)) + if (!VAR_P (t) || !DECL_THREAD_LOCAL_P (t)) { error ("%qE must be % for %", t); remove = true; @@ -4325,7 +4325,7 @@ finish_omp_clauses (tree clauses) { const char *share_name = NULL; - if (TREE_CODE (t) == VAR_DECL && DECL_THREAD_LOCAL_P (t)) + if (VAR_P (t) && DECL_THREAD_LOCAL_P (t)) share_name = "threadprivate"; else switch (cxx_omp_predetermined_sharing (t)) { @@ -4392,7 +4392,7 @@ finish_omp_threadprivate (tree vars) if (error_operand_p (v)) ; - else if (TREE_CODE (v) != VAR_DECL) + else if (!VAR_P (v)) error ("% %qD is not file, namespace " "or block scope variable", v); /* If V had already been marked threadprivate, it doesn't matter @@ -5295,7 +5295,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, /* To get the size of a static data member declared as an array of unknown bound, we need to instantiate it. */ - if (TREE_CODE (expr) == VAR_DECL + if (VAR_P (expr) && VAR_HAD_UNKNOWN_BOUND (expr) && DECL_TEMPLATE_INSTANTIATION (expr)) instantiate_decl (expr, /*defer_ok*/true, /*expl_inst_mem*/false); @@ -5727,7 +5727,7 @@ tree ensure_literal_type_for_constexpr_object (tree decl) { tree type = TREE_TYPE (decl); - if (TREE_CODE (decl) == VAR_DECL && DECL_DECLARED_CONSTEXPR_P (decl) + if (VAR_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl) && !processing_template_decl) { if (CLASS_TYPE_P (type) && !COMPLETE_TYPE_P (complete_type (type))) @@ -9200,7 +9200,7 @@ capture_decltype (tree decl) bool is_capture_proxy (tree decl) { - return (TREE_CODE (decl) == VAR_DECL + return (VAR_P (decl) && DECL_HAS_VALUE_EXPR_P (decl) && !DECL_ANON_UNION_VAR_P (decl) && LAMBDA_FUNCTION_P (DECL_CONTEXT (decl))); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 4159321814a..8faf566c3f3 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -70,7 +70,7 @@ lvalue_kind (const_tree ref) /* unnamed rvalue references are rvalues */ if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref)) && TREE_CODE (ref) != PARM_DECL - && TREE_CODE (ref) != VAR_DECL + && !VAR_P (ref) && TREE_CODE (ref) != COMPONENT_REF /* Functions are always lvalues. */ && TREE_CODE (TREE_TYPE (TREE_TYPE (ref))) != FUNCTION_TYPE) @@ -2219,7 +2219,7 @@ bot_replace (tree* t, int* /*walk_subtrees*/, void* data) { splay_tree target_remap = ((splay_tree) data); - if (TREE_CODE (*t) == VAR_DECL) + if (VAR_P (*t)) { splay_tree_node n = splay_tree_lookup (target_remap, (splay_tree_key) *t); @@ -2584,10 +2584,10 @@ cp_tree_equal (tree t1, tree t2) it means that it's going to be unified with whatever the TARGET_EXPR is really supposed to initialize, so treat it as being equivalent to anything. */ - if (TREE_CODE (o1) == VAR_DECL && DECL_NAME (o1) == NULL_TREE + if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE && !DECL_RTL_SET_P (o1)) /*Nop*/; - else if (TREE_CODE (o2) == VAR_DECL && DECL_NAME (o2) == NULL_TREE + else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE && !DECL_RTL_SET_P (o2)) /*Nop*/; else if (!cp_tree_equal (o1, o2)) @@ -3149,7 +3149,7 @@ handle_init_priority_attribute (tree* node, type = strip_array_types (type); if (decl == NULL_TREE - || TREE_CODE (decl) != VAR_DECL + || !VAR_P (decl) || !TREE_STATIC (decl) || DECL_EXTERNAL (decl) || (TREE_CODE (type) != RECORD_TYPE @@ -3618,7 +3618,7 @@ decl_storage_duration (tree decl) return dk_auto; if (TREE_CODE (decl) == FUNCTION_DECL) return dk_static; - gcc_assert (TREE_CODE (decl) == VAR_DECL); + gcc_assert (VAR_P (decl)); if (!TREE_STATIC (decl) && !DECL_EXTERNAL (decl)) return dk_auto; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 90c7ce49505..34263b716dd 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1581,7 +1581,7 @@ cxx_sizeof_expr (tree e, tsubst_flags_t complain) /* To get the size of a static data member declared as an array of unknown bound, we need to instantiate it. */ - if (TREE_CODE (e) == VAR_DECL + if (VAR_P (e) && VAR_HAD_UNKNOWN_BOUND (e) && DECL_TEMPLATE_INSTANTIATION (e)) instantiate_decl (e, /*defer_ok*/true, /*expl_inst_mem*/false); @@ -1645,7 +1645,7 @@ cxx_alignof_expr (tree e, tsubst_flags_t complain) e = mark_type_use (e); - if (TREE_CODE (e) == VAR_DECL) + if (VAR_P (e)) t = size_int (DECL_ALIGN_UNIT (e)); else if (TREE_CODE (e) == COMPONENT_REF && TREE_CODE (TREE_OPERAND (e, 1)) == FIELD_DECL @@ -1950,7 +1950,7 @@ decay_conversion (tree exp, tsubst_flags_t complain) ptrtype = build_pointer_type (TREE_TYPE (type)); - if (TREE_CODE (exp) == VAR_DECL) + if (VAR_P (exp)) { if (!cxx_mark_addressable (exp)) return error_mark_node; @@ -2280,7 +2280,7 @@ build_class_member_access_expr (tree object, tree member, /* In [expr.ref], there is an explicit list of the valid choices for MEMBER. We check for each of those cases here. */ - if (TREE_CODE (member) == VAR_DECL) + if (VAR_P (member)) { /* A static data member. */ result = member; @@ -3054,7 +3054,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx, tree foo = array; while (TREE_CODE (foo) == COMPONENT_REF) foo = TREE_OPERAND (foo, 0); - if (TREE_CODE (foo) == VAR_DECL && DECL_REGISTER (foo) + if (VAR_P (foo) && DECL_REGISTER (foo) && (complain & tf_warning)) warning_at (loc, OPT_Wextra, "subscripting array declared %"); @@ -5772,7 +5772,7 @@ cxx_mark_addressable (tree exp) if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x) && !DECL_ARTIFICIAL (x)) { - if (TREE_CODE (x) == VAR_DECL && DECL_HARD_REGISTER (x)) + if (VAR_P (x) && DECL_HARD_REGISTER (x)) { error ("address of explicit register variable %qD requested", x); @@ -8050,7 +8050,7 @@ maybe_warn_about_returning_address_of_local (tree retval) warning (OPT_Wreturn_local_addr, "returning reference to temporary"); return; } - if (TREE_CODE (whats_returned) == VAR_DECL + if (VAR_P (whats_returned) && DECL_NAME (whats_returned) && TEMP_NAME_P (DECL_NAME (whats_returned))) { @@ -8288,7 +8288,7 @@ check_return_expr (tree retval, bool *no_warning) named_return_value_okay_p = (retval != NULL_TREE /* Must be a local, automatic variable. */ - && TREE_CODE (retval) == VAR_DECL + && VAR_P (retval) && DECL_CONTEXT (retval) == current_function_decl && ! TREE_STATIC (retval) && ! DECL_ANON_UNION_VAR_P (retval) @@ -8336,7 +8336,7 @@ check_return_expr (tree retval, bool *no_warning) Note that these conditions are similar to, but not as strict as, the conditions for the named return value optimization. */ if ((cxx_dialect != cxx98) - && (TREE_CODE (retval) == VAR_DECL + && (VAR_P (retval) || TREE_CODE (retval) == PARM_DECL) && DECL_CONTEXT (retval) == current_function_decl && !TREE_STATIC (retval) diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index cf42958193a..e97bb3aee6c 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -98,7 +98,7 @@ cxx_readonly_error (tree arg, enum lvalue_use errstring) /* Handle C++-specific things first. */ - if (TREE_CODE (arg) == VAR_DECL + if (VAR_P (arg) && DECL_LANG_SPECIFIC (arg) && DECL_IN_AGGR_P (arg) && !TREE_STATIC (arg)) @@ -113,7 +113,7 @@ cxx_readonly_error (tree arg, enum lvalue_use errstring) arg); else if (INDIRECT_REF_P (arg) && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE - && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL + && (VAR_P (TREE_OPERAND (arg, 0)) || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL)) ERROR_FOR_ASSIGNMENT (G_("assignment of " "read-only reference %qD"), @@ -315,7 +315,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, abstract_class_use use, if (decl) { - if (TREE_CODE (decl) == VAR_DECL) + if (VAR_P (decl)) error ("cannot declare variable %q+D to be of abstract " "type %qT", decl, type); else if (TREE_CODE (decl) == PARM_DECL) @@ -441,7 +441,7 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, if (TREE_CODE (type) == ERROR_MARK) return; - if (value != 0 && (TREE_CODE (value) == VAR_DECL + if (value != 0 && (VAR_P (value) || TREE_CODE (value) == PARM_DECL || TREE_CODE (value) == FIELD_DECL)) { diff --git a/gcc/tree.h b/gcc/tree.h index 1eedf1f5c3e..985512acf28 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -165,6 +165,10 @@ extern const enum tree_code_class tree_code_type[]; #define DECL_P(CODE)\ (TREE_CODE_CLASS (TREE_CODE (CODE)) == tcc_declaration) +/* True if NODE designates a variable declaration. */ +#define VAR_P(NODE) \ + (TREE_CODE (NODE) == VAR_DECL) + /* Nonzero if DECL represents a VAR_DECL or FUNCTION_DECL. */ #define VAR_OR_FUNCTION_DECL_P(DECL)\ -- 2.11.4.GIT