* 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
+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>
* c-common.h (fe_file_change): Strengthen param from
{
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))
{
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,
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;
*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)
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;
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
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
{
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;
/* 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))
}
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))
/* 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;
+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>
* c-typeck.c (start_init): Use AGGREGATE_TYPE_P.
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)
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;
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;
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.
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)
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);
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))
}
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);