Commit 21b634ae by Marek Polacek Committed by Marek Polacek

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
parent 42242005
2015-05-20 Marek Polacek <polacek@redhat.com>
* c-pragma.c: Use VAR_OR_FUNCTION_DECL_P throughout.
* c-common.c: Likewise.
2015-05-19 David Malcolm <dmalcolm@redhat.com> 2015-05-19 David Malcolm <dmalcolm@redhat.com>
* c-common.h (fe_file_change): Strengthen param from * c-common.h (fe_file_change): Strengthen param from
......
...@@ -7406,7 +7406,7 @@ handle_externally_visible_attribute (tree *pnode, tree name, ...@@ -7406,7 +7406,7 @@ handle_externally_visible_attribute (tree *pnode, tree name,
{ {
tree node = *pnode; 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 if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL
&& !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node)) && !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node))
...@@ -7437,7 +7437,7 @@ handle_no_reorder_attribute (tree *pnode, ...@@ -7437,7 +7437,7 @@ handle_no_reorder_attribute (tree *pnode,
{ {
tree node = *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))) && !(TREE_STATIC (node) || DECL_EXTERNAL (node)))
{ {
warning (OPT_Wattributes, warning (OPT_Wattributes,
...@@ -7893,7 +7893,7 @@ handle_section_attribute (tree *node, tree ARG_UNUSED (name), tree args, ...@@ -7893,7 +7893,7 @@ handle_section_attribute (tree *node, tree ARG_UNUSED (name), tree args,
user_defined_section_attribute = true; 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); error ("section attribute not allowed for %q+D", *node);
goto fail; goto fail;
...@@ -8172,8 +8172,7 @@ handle_weak_attribute (tree *node, tree name, ...@@ -8172,8 +8172,7 @@ handle_weak_attribute (tree *node, tree name,
*no_add_attrs = true; *no_add_attrs = true;
return NULL_TREE; return NULL_TREE;
} }
else if (TREE_CODE (*node) == FUNCTION_DECL else if (VAR_OR_FUNCTION_DECL_P (*node))
|| TREE_CODE (*node) == VAR_DECL)
{ {
struct symtab_node *n = symtab_node::get (*node); struct symtab_node *n = symtab_node::get (*node);
if (n && n->refuse_visibility_changes) if (n && n->refuse_visibility_changes)
...@@ -8309,7 +8308,7 @@ handle_weakref_attribute (tree *node, tree ARG_UNUSED (name), tree args, ...@@ -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. */ such symbols do not even have a DECL_WEAK field. */
if (decl_function_context (*node) if (decl_function_context (*node)
|| current_function_decl || 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); warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true; *no_add_attrs = true;
...@@ -8466,8 +8465,7 @@ handle_visibility_attribute (tree *node, tree name, tree args, ...@@ -8466,8 +8465,7 @@ handle_visibility_attribute (tree *node, tree name, tree args,
bool bool
c_determine_visibility (tree decl) c_determine_visibility (tree decl)
{ {
gcc_assert (TREE_CODE (decl) == VAR_DECL gcc_assert (VAR_OR_FUNCTION_DECL_P (decl));
|| TREE_CODE (decl) == FUNCTION_DECL);
/* If the user explicitly specified the visibility with an /* If the user explicitly specified the visibility with an
attribute, honor that. DECL_VISIBILITY will have been set during attribute, honor that. DECL_VISIBILITY will have been set during
...@@ -9014,8 +9012,7 @@ handle_tm_wrap_attribute (tree *node, tree name, tree args, ...@@ -9014,8 +9012,7 @@ handle_tm_wrap_attribute (tree *node, tree name, tree args,
if (error_operand_p (wrap_decl)) if (error_operand_p (wrap_decl))
; ;
else if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE else if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE
&& TREE_CODE (wrap_decl) != VAR_DECL && !VAR_OR_FUNCTION_DECL_P (wrap_decl))
&& TREE_CODE (wrap_decl) != FUNCTION_DECL)
error ("%qE argument not an identifier", name); error ("%qE argument not an identifier", name);
else else
{ {
...@@ -9089,8 +9086,7 @@ handle_deprecated_attribute (tree *node, tree name, ...@@ -9089,8 +9086,7 @@ handle_deprecated_attribute (tree *node, tree name,
if (TREE_CODE (decl) == TYPE_DECL if (TREE_CODE (decl) == TYPE_DECL
|| TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == VAR_DECL || VAR_OR_FUNCTION_DECL_P (decl)
|| TREE_CODE (decl) == FUNCTION_DECL
|| TREE_CODE (decl) == FIELD_DECL || TREE_CODE (decl) == FIELD_DECL
|| objc_method_decl (TREE_CODE (decl))) || objc_method_decl (TREE_CODE (decl)))
TREE_DEPRECATED (decl) = 1; TREE_DEPRECATED (decl) = 1;
......
...@@ -306,7 +306,7 @@ maybe_apply_pragma_weak (tree decl) ...@@ -306,7 +306,7 @@ maybe_apply_pragma_weak (tree decl)
/* If it's not a function or a variable, it can't be weak. /* 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 FIXME: what kinds of things are visible outside this file but
aren't functions or variables? Should this be an assert instead? */ 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; return;
if (DECL_ASSEMBLER_NAME_SET_P (decl)) if (DECL_ASSEMBLER_NAME_SET_P (decl))
...@@ -486,8 +486,7 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) ...@@ -486,8 +486,7 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy))
} }
if ((TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) if ((TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
&& (TREE_CODE (decl) == FUNCTION_DECL && VAR_OR_FUNCTION_DECL_P (decl))
|| TREE_CODE (decl) == VAR_DECL))
{ {
found = true; found = true;
if (DECL_ASSEMBLER_NAME_SET_P (decl)) if (DECL_ASSEMBLER_NAME_SET_P (decl))
...@@ -547,7 +546,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) ...@@ -547,7 +546,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname)
/* The renaming pragmas are only applied to declarations with /* The renaming pragmas are only applied to declarations with
external linkage. */ 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)) || (!TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl))
|| !has_c_linkage (decl)) || !has_c_linkage (decl))
return asmname; return asmname;
......
2015-05-20 Marek Polacek <polacek@redhat.com>
* c-decl.c: Use VAR_OR_FUNCTION_DECL_P throughout.
* c-typeck.c: Likewise.
2015-05-19 Marek Polacek <polacek@redhat.com> 2015-05-19 Marek Polacek <polacek@redhat.com>
* c-typeck.c (start_init): Use AGGREGATE_TYPE_P. * c-typeck.c (start_init): Use AGGREGATE_TYPE_P.
......
...@@ -2735,8 +2735,7 @@ duplicate_decls (tree newdecl, tree olddecl) ...@@ -2735,8 +2735,7 @@ duplicate_decls (tree newdecl, tree olddecl)
structure is shared in between NEWDECL and OLDECL. */ structure is shared in between NEWDECL and OLDECL. */
if (TREE_CODE (newdecl) == FUNCTION_DECL) if (TREE_CODE (newdecl) == FUNCTION_DECL)
DECL_STRUCT_FUNCTION (newdecl) = NULL; DECL_STRUCT_FUNCTION (newdecl) = NULL;
if (TREE_CODE (newdecl) == FUNCTION_DECL if (VAR_OR_FUNCTION_DECL_P (newdecl))
|| TREE_CODE (newdecl) == VAR_DECL)
{ {
struct symtab_node *snode = symtab_node::get (newdecl); struct symtab_node *snode = symtab_node::get (newdecl);
if (snode) if (snode)
...@@ -2835,7 +2834,7 @@ pushdecl (tree x) ...@@ -2835,7 +2834,7 @@ pushdecl (tree x)
DECL_FILE_SCOPE_P won't work. Local externs don't count DECL_FILE_SCOPE_P won't work. Local externs don't count
unless they have initializers (which generate code). */ unless they have initializers (which generate code). */
if (current_function_decl 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_INITIAL (x) || !DECL_EXTERNAL (x)))
DECL_CONTEXT (x) = current_function_decl; DECL_CONTEXT (x) = current_function_decl;
...@@ -2926,8 +2925,7 @@ pushdecl (tree x) ...@@ -2926,8 +2925,7 @@ pushdecl (tree x)
tree visdecl = 0; tree visdecl = 0;
bool type_saved = false; bool type_saved = false;
if (b && !B_IN_EXTERNAL_SCOPE (b) if (b && !B_IN_EXTERNAL_SCOPE (b)
&& (TREE_CODE (b->decl) == FUNCTION_DECL && VAR_OR_FUNCTION_DECL_P (b->decl)
|| TREE_CODE (b->decl) == VAR_DECL)
&& DECL_FILE_SCOPE_P (b->decl)) && DECL_FILE_SCOPE_P (b->decl))
{ {
visdecl = b->decl; visdecl = b->decl;
...@@ -4614,8 +4612,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, ...@@ -4614,8 +4612,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
decl, csi_modifiable); decl, csi_modifiable);
if (c_dialect_objc () if (c_dialect_objc ()
&& (TREE_CODE (decl) == VAR_DECL && VAR_OR_FUNCTION_DECL_P (decl))
|| TREE_CODE (decl) == FUNCTION_DECL))
objc_check_global_decl (decl); objc_check_global_decl (decl);
/* Add this decl to the current scope. /* Add this decl to the current scope.
...@@ -4677,7 +4674,7 @@ finish_decl (tree decl, location_t init_loc, tree init, ...@@ -4677,7 +4674,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
const char *asmspec = 0; const char *asmspec = 0;
/* If a name was specified, get the string. */ /* 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)) && DECL_FILE_SCOPE_P (decl))
asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree); asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
if (asmspec_tree) if (asmspec_tree)
...@@ -4701,8 +4698,7 @@ finish_decl (tree decl, location_t init_loc, tree init, ...@@ -4701,8 +4698,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
if (init) if (init)
store_init_value (init_loc, decl, init, origtype); store_init_value (init_loc, decl, init, origtype);
if (c_dialect_objc () && (TREE_CODE (decl) == VAR_DECL if (c_dialect_objc () && (VAR_OR_FUNCTION_DECL_P (decl)
|| TREE_CODE (decl) == FUNCTION_DECL
|| TREE_CODE (decl) == FIELD_DECL)) || TREE_CODE (decl) == FIELD_DECL))
objc_check_decl (decl); objc_check_decl (decl);
...@@ -4841,7 +4837,7 @@ finish_decl (tree decl, location_t init_loc, tree init, ...@@ -4841,7 +4837,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
unless the type is an undefined structure or union. unless the type is an undefined structure or union.
If not, it will get done when the type is completed. */ 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. */ /* Determine the ELF visibility. */
if (TREE_PUBLIC (decl)) if (TREE_PUBLIC (decl))
......
...@@ -2672,9 +2672,8 @@ build_external_ref (location_t loc, tree id, int fun, tree *type) ...@@ -2672,9 +2672,8 @@ build_external_ref (location_t loc, tree id, int fun, tree *type)
} }
else if (current_function_decl != 0 else if (current_function_decl != 0
&& !DECL_FILE_SCOPE_P (current_function_decl) && !DECL_FILE_SCOPE_P (current_function_decl)
&& (TREE_CODE (ref) == VAR_DECL && (VAR_OR_FUNCTION_DECL_P (ref)
|| TREE_CODE (ref) == PARM_DECL || TREE_CODE (ref) == PARM_DECL))
|| TREE_CODE (ref) == FUNCTION_DECL))
{ {
tree context = decl_function_context (ref); tree context = decl_function_context (ref);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment