From 21b634ae9bc1c800784c7b009706477a9f49c1fb Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 20 May 2015 10:10:07 +0000 Subject: [PATCH] c-pragma.c: Use VAR_OR_FUNCTION_DECL_P throughout. * c-pragma.c: Use VAR_OR_FUNCTION_DECL_P throughout. * c-common.c: Likewise. * c-decl.c: Use VAR_OR_FUNCTION_DECL_P throughout. * c-typeck.c: Likewise. From-SVN: r223437 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-common.c | 20 ++++++++------------ gcc/c-family/c-pragma.c | 7 +++---- gcc/c/ChangeLog | 5 +++++ gcc/c/c-decl.c | 22 +++++++++------------- gcc/c/c-typeck.c | 5 ++--- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 695bfee4645..fba79aabdae 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2015-05-20 Marek Polacek + + * c-pragma.c: Use VAR_OR_FUNCTION_DECL_P throughout. + * c-common.c: Likewise. + 2015-05-19 David Malcolm * c-common.h (fe_file_change): Strengthen param from diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 3998b23b00b..a2b37931911 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -7406,7 +7406,7 @@ handle_externally_visible_attribute (tree *pnode, tree name, { tree node = *pnode; - if (TREE_CODE (node) == FUNCTION_DECL || TREE_CODE (node) == VAR_DECL) + if (VAR_OR_FUNCTION_DECL_P (node)) { if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL && !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node)) @@ -7437,7 +7437,7 @@ handle_no_reorder_attribute (tree *pnode, { tree node = *pnode; - if ((TREE_CODE (node) != FUNCTION_DECL && TREE_CODE (node) != VAR_DECL) + if (!VAR_OR_FUNCTION_DECL_P (node) && !(TREE_STATIC (node) || DECL_EXTERNAL (node))) { warning (OPT_Wattributes, @@ -7893,7 +7893,7 @@ handle_section_attribute (tree *node, tree ARG_UNUSED (name), tree args, user_defined_section_attribute = true; - if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) + if (!VAR_OR_FUNCTION_DECL_P (decl)) { error ("section attribute not allowed for %q+D", *node); goto fail; @@ -8172,8 +8172,7 @@ handle_weak_attribute (tree *node, tree name, *no_add_attrs = true; return NULL_TREE; } - else if (TREE_CODE (*node) == FUNCTION_DECL - || TREE_CODE (*node) == VAR_DECL) + else if (VAR_OR_FUNCTION_DECL_P (*node)) { struct symtab_node *n = symtab_node::get (*node); if (n && n->refuse_visibility_changes) @@ -8309,7 +8308,7 @@ handle_weakref_attribute (tree *node, tree ARG_UNUSED (name), tree args, such symbols do not even have a DECL_WEAK field. */ if (decl_function_context (*node) || current_function_decl - || (TREE_CODE (*node) != VAR_DECL && TREE_CODE (*node) != FUNCTION_DECL)) + || !VAR_OR_FUNCTION_DECL_P (*node)) { warning (OPT_Wattributes, "%qE attribute ignored", name); *no_add_attrs = true; @@ -8466,8 +8465,7 @@ handle_visibility_attribute (tree *node, tree name, tree args, bool c_determine_visibility (tree decl) { - gcc_assert (TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == FUNCTION_DECL); + gcc_assert (VAR_OR_FUNCTION_DECL_P (decl)); /* If the user explicitly specified the visibility with an attribute, honor that. DECL_VISIBILITY will have been set during @@ -9014,8 +9012,7 @@ handle_tm_wrap_attribute (tree *node, tree name, tree args, if (error_operand_p (wrap_decl)) ; else if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE - && TREE_CODE (wrap_decl) != VAR_DECL - && TREE_CODE (wrap_decl) != FUNCTION_DECL) + && !VAR_OR_FUNCTION_DECL_P (wrap_decl)) error ("%qE argument not an identifier", name); else { @@ -9089,8 +9086,7 @@ handle_deprecated_attribute (tree *node, tree name, if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == PARM_DECL - || TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == FUNCTION_DECL + || VAR_OR_FUNCTION_DECL_P (decl) || TREE_CODE (decl) == FIELD_DECL || objc_method_decl (TREE_CODE (decl))) TREE_DEPRECATED (decl) = 1; diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 6894f0e7c3d..b82ca9f4f04 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -306,7 +306,7 @@ maybe_apply_pragma_weak (tree decl) /* If it's not a function or a variable, it can't be weak. FIXME: what kinds of things are visible outside this file but aren't functions or variables? Should this be an assert instead? */ - if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) + if (!VAR_OR_FUNCTION_DECL_P (decl)) return; if (DECL_ASSEMBLER_NAME_SET_P (decl)) @@ -486,8 +486,7 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) } if ((TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) - && (TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == VAR_DECL)) + && VAR_OR_FUNCTION_DECL_P (decl)) { found = true; if (DECL_ASSEMBLER_NAME_SET_P (decl)) @@ -547,7 +546,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) /* The renaming pragmas are only applied to declarations with external linkage. */ - if ((TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) + if (!VAR_OR_FUNCTION_DECL_P (decl) || (!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl)) || !has_c_linkage (decl)) return asmname; diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 4521cd13218..170f0675544 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2015-05-20 Marek Polacek + + * c-decl.c: Use VAR_OR_FUNCTION_DECL_P throughout. + * c-typeck.c: Likewise. + 2015-05-19 Marek Polacek * c-typeck.c (start_init): Use AGGREGATE_TYPE_P. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 4f6761d2392..a2edefc5f34 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -2735,8 +2735,7 @@ duplicate_decls (tree newdecl, tree olddecl) structure is shared in between NEWDECL and OLDECL. */ if (TREE_CODE (newdecl) == FUNCTION_DECL) DECL_STRUCT_FUNCTION (newdecl) = NULL; - if (TREE_CODE (newdecl) == FUNCTION_DECL - || TREE_CODE (newdecl) == VAR_DECL) + if (VAR_OR_FUNCTION_DECL_P (newdecl)) { struct symtab_node *snode = symtab_node::get (newdecl); if (snode) @@ -2835,7 +2834,7 @@ pushdecl (tree x) DECL_FILE_SCOPE_P won't work. Local externs don't count unless they have initializers (which generate code). */ if (current_function_decl - && ((TREE_CODE (x) != FUNCTION_DECL && TREE_CODE (x) != VAR_DECL) + && (!VAR_OR_FUNCTION_DECL_P (x) || DECL_INITIAL (x) || !DECL_EXTERNAL (x))) DECL_CONTEXT (x) = current_function_decl; @@ -2926,8 +2925,7 @@ pushdecl (tree x) tree visdecl = 0; bool type_saved = false; if (b && !B_IN_EXTERNAL_SCOPE (b) - && (TREE_CODE (b->decl) == FUNCTION_DECL - || TREE_CODE (b->decl) == VAR_DECL) + && VAR_OR_FUNCTION_DECL_P (b->decl) && DECL_FILE_SCOPE_P (b->decl)) { visdecl = b->decl; @@ -4613,9 +4611,8 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, record_inline_static (input_location, current_function_decl, decl, csi_modifiable); - if (c_dialect_objc () - && (TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == FUNCTION_DECL)) + if (c_dialect_objc () + && VAR_OR_FUNCTION_DECL_P (decl)) objc_check_global_decl (decl); /* Add this decl to the current scope. @@ -4670,14 +4667,14 @@ diagnose_uninitialized_cst_member (tree decl, tree type) void finish_decl (tree decl, location_t init_loc, tree init, - tree origtype, tree asmspec_tree) + tree origtype, tree asmspec_tree) { tree type; bool was_incomplete = (DECL_SIZE (decl) == 0); const char *asmspec = 0; /* If a name was specified, get the string. */ - if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL) + if (VAR_OR_FUNCTION_DECL_P (decl) && DECL_FILE_SCOPE_P (decl)) asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree); if (asmspec_tree) @@ -4701,8 +4698,7 @@ finish_decl (tree decl, location_t init_loc, tree init, if (init) store_init_value (init_loc, decl, init, origtype); - if (c_dialect_objc () && (TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == FUNCTION_DECL + if (c_dialect_objc () && (VAR_OR_FUNCTION_DECL_P (decl) || TREE_CODE (decl) == FIELD_DECL)) objc_check_decl (decl); @@ -4841,7 +4837,7 @@ finish_decl (tree decl, location_t init_loc, tree init, unless the type is an undefined structure or union. If not, it will get done when the type is completed. */ - if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL) + if (VAR_OR_FUNCTION_DECL_P (decl)) { /* Determine the ELF visibility. */ if (TREE_PUBLIC (decl)) diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index cf5322f5f21..ba8797bb8d4 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -2672,9 +2672,8 @@ build_external_ref (location_t loc, tree id, int fun, tree *type) } else if (current_function_decl != 0 && !DECL_FILE_SCOPE_P (current_function_decl) - && (TREE_CODE (ref) == VAR_DECL - || TREE_CODE (ref) == PARM_DECL - || TREE_CODE (ref) == FUNCTION_DECL)) + && (VAR_OR_FUNCTION_DECL_P (ref) + || TREE_CODE (ref) == PARM_DECL)) { tree context = decl_function_context (ref); -- 2.30.2