[obv] use prototype_p in a number of places
Nathan Froyd
froydnj@codesourcery.com
Tue Dec 21 21:14:00 GMT 2010
We have this perfectly decent function for testing if a function has a
prototype, why not use it?
Testing in progress on x86_64-unknown-linux-gnu. Will build crosses for
appropriate targets and commit under the obvious rule if successful.
-Nathan
gcc/
* c-aux-info.c (gen_formal_list_for_type): Use prototype_p.
* c-decl.c (diagnose_mismatched_decls, merge_decls): Likewise.
(c_builtin_function, c_builtin_function_ext_scope): Likewise.
(start_decl, start_function): Likewise.
* c-tree.h (C_DECL_ISNT_PROTOTYPED): Likewise.
* config/ia64/ia64.h (INIT_CUMULATIVE_ARGS): Likewise.
* config/rs6000/rs6000.c (init_cumulative_args): Likewise.
* config/sh/sh.c (sh_init_cumulative_args): Likewise.
* config/sparc/sparc.c (init_cumulative_args): Likewise.
* dwarf2out.c (add_prototyped_attribute): Likewise.
(gen_subprogram_die): Likewise.
* ipa-type-escape.c (check_function_parameter_and_return_types):
Likewise.
(check_call): Likewise.
* tree-ssa.c (useless_type_conversion_p): Likewise.
gcc/ada/
* gcc-interface/utils.c (handle_nonnull_attribute): Use prototype_p.
(handle_sentinel_attribute): Likewise.
gcc/c-family/
* c-common.c (handle_nonnull_attribute, handle_sentinel_attribute):
Use prototype_p.
gcc/cp/
* decl.c (decls_match, duplicate_decls): Use prototype_p.
* pt.c (push_template_decl_real): Likewise.
gcc/lto/
* lto-lang.c (handle_nonnull_attribute, handle_sentinel_attribute):
Use prototype_p.
gcc/objc/
* objc-act.c (next_sjlj_build_enter_and_setjmp): Use prototype_p.
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index d044957..b92e916 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -5065,7 +5065,7 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
will have the correct types when we actually check them later. */
if (!args)
{
- if (!TYPE_ARG_TYPES (type))
+ if (!prototype_p (type))
{
error ("nonnull attribute without arguments on a non-prototype");
*no_add_attrs = true;
@@ -5130,7 +5130,7 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
{
tree params = TYPE_ARG_TYPES (*node);
- if (!params)
+ if (!prototype_p (*node))
{
warning (OPT_Wattributes,
"%qs attribute requires prototypes with named arguments",
diff --git a/gcc/c-aux-info.c b/gcc/c-aux-info.c
index 346901f..694f9c1 100644
--- a/gcc/c-aux-info.c
+++ b/gcc/c-aux-info.c
@@ -163,7 +163,7 @@ gen_formal_list_for_type (tree fntype, formals_style style)
if (!*formal_list)
{
- if (TYPE_ARG_TYPES (fntype))
+ if (prototype_p (fntype))
/* assert (TREE_VALUE (TYPE_ARG_TYPES (fntype)) == void_type_node); */
formal_list = "void";
else
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index f9672a0..0b4763f 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -1833,7 +1833,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
&& !C_DECL_DECLARED_BUILTIN (olddecl)
&& (!TREE_PUBLIC (newdecl)
|| (DECL_INITIAL (newdecl)
- && !TYPE_ARG_TYPES (TREE_TYPE (newdecl)))))
+ && !prototype_p (TREE_TYPE (newdecl)))))
{
warning (OPT_Wshadow, "declaration of %q+D shadows "
"a built-in function", newdecl);
@@ -1870,7 +1870,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
/* If we have a prototype after an old-style function definition,
the argument types must be checked specially. */
else if (DECL_INITIAL (olddecl)
- && !TYPE_ARG_TYPES (oldtype) && TYPE_ARG_TYPES (newtype)
+ && !prototype_p (oldtype) && prototype_p (newtype)
&& TYPE_ACTUAL_ARG_TYPES (oldtype)
&& !validate_proto_after_old_defn (newdecl, newtype, oldtype))
{
@@ -2139,9 +2139,9 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
bool new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
&& DECL_INITIAL (newdecl) != 0);
bool new_is_prototype = (TREE_CODE (newdecl) == FUNCTION_DECL
- && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != 0);
+ && prototype_p (TREE_TYPE (newdecl)));
bool old_is_prototype = (TREE_CODE (olddecl) == FUNCTION_DECL
- && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) != 0);
+ && prototype_p (TREE_TYPE (olddecl)));
bool extern_changed = false;
/* For real parm decl following a forward decl, rechain the old decl
@@ -3539,7 +3539,7 @@ c_builtin_function (tree decl)
tree id = DECL_NAME (decl);
const char *name = IDENTIFIER_POINTER (id);
- C_DECL_BUILTIN_PROTOTYPE (decl) = (TYPE_ARG_TYPES (type) != 0);
+ C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
/* Should never be called on a symbol with a preexisting meaning. */
gcc_assert (!I_SYMBOL_BINDING (id));
@@ -3565,7 +3565,7 @@ c_builtin_function_ext_scope (tree decl)
tree id = DECL_NAME (decl);
const char *name = IDENTIFIER_POINTER (id);
- C_DECL_BUILTIN_PROTOTYPE (decl) = (TYPE_ARG_TYPES (type) != 0);
+ C_DECL_BUILTIN_PROTOTYPE (decl) = prototype_p (type);
/* Should never be called on a symbol with a preexisting meaning. */
gcc_assert (!I_SYMBOL_BINDING (id));
@@ -4001,7 +4001,7 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
prototypes file (if requested). */
if (TREE_CODE (decl) == FUNCTION_DECL)
- gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0);
+ gen_aux_info_record (decl, 0, 0, prototype_p (TREE_TYPE (decl)));
/* ANSI specifies that a tentative definition which is not merged with
a non-tentative definition behaves exactly like a definition with an
@@ -7625,7 +7625,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
current_function_prototype_locus = UNKNOWN_LOCATION;
current_function_prototype_built_in = false;
current_function_prototype_arg_types = NULL_TREE;
- if (TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
+ if (!prototype_p (TREE_TYPE (decl1)))
{
if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE
&& comptypes (TREE_TYPE (TREE_TYPE (decl1)),
@@ -7674,7 +7674,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
/* Optionally warn of old-fashioned def with no previous prototype. */
if (warn_strict_prototypes
&& old_decl != error_mark_node
- && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
+ && !prototype_p (TREE_TYPE (decl1))
&& C_DECL_ISNT_PROTOTYPE (old_decl))
warning_at (loc, OPT_Wstrict_prototypes,
"function declaration isn%'t a prototype");
@@ -7692,7 +7692,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
&& old_decl != 0
&& old_decl != error_mark_node
&& TREE_USED (old_decl)
- && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0)
+ && !prototype_p (TREE_TYPE (old_decl)))
warning_at (loc, OPT_Wmissing_prototypes,
"%qD was used with no prototype before its definition", decl1);
/* Optionally warn of any global def with no previous declaration. */
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 7b39d55..8eb849a 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7348,7 +7348,7 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
will have the correct types when we actually check them later. */
if (!args)
{
- if (!TYPE_ARG_TYPES (type))
+ if (!prototype_p (type))
{
error ("nonnull attribute without arguments on a non-prototype");
*no_add_attrs = true;
@@ -7631,7 +7631,7 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
{
tree params = TYPE_ARG_TYPES (*node);
- if (!params)
+ if (!prototype_p (*node))
{
warning (OPT_Wattributes,
"%qE attribute requires prototypes with named arguments", name);
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index 7bf3bc0..8e88362 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -98,7 +98,7 @@ along with GCC; see the file COPYING3. If not see
(but this is presently difficult because some of them need FILE*). */
#define C_DECL_ISNT_PROTOTYPE(EXP) \
(EXP == 0 \
- || (TYPE_ARG_TYPES (TREE_TYPE (EXP)) == 0 \
+ || (!prototype_p (TREE_TYPE (EXP)) \
&& !DECL_BUILT_IN (EXP)))
/* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
index 0b512f2..ad6c150 100644
--- a/gcc/config/ia64/ia64.h
+++ b/gcc/config/ia64/ia64.h
@@ -1047,7 +1047,7 @@ do { \
(CUM).words = 0; \
(CUM).int_regs = 0; \
(CUM).fp_regs = 0; \
- (CUM).prototype = ((FNTYPE) && TYPE_ARG_TYPES (FNTYPE)) || (LIBNAME); \
+ (CUM).prototype = ((FNTYPE) && prototype_p (FNTYPE)) || (LIBNAME); \
(CUM).atypes[0] = (CUM).atypes[1] = (CUM).atypes[2] = I64; \
(CUM).atypes[3] = (CUM).atypes[4] = (CUM).atypes[5] = I64; \
(CUM).atypes[6] = (CUM).atypes[7] = I64; \
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index bc27f73..f26e37e 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -7874,7 +7874,7 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype,
cum->words = 0;
cum->fregno = FP_ARG_MIN_REG;
cum->vregno = ALTIVEC_ARG_MIN_REG;
- cum->prototype = (fntype && TYPE_ARG_TYPES (fntype));
+ cum->prototype = (fntype && prototype_p (fntype));
cum->call_cookie = ((DEFAULT_ABI == ABI_V4 && libcall)
? CALL_LIBCALL : CALL_NORMAL);
cum->sysv_gregno = GP_ARG_MIN_REG;
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 2fdf03a..7abf868 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -12112,7 +12112,7 @@ sh_init_cumulative_args (CUMULATIVE_ARGS * pcum,
{
pcum->force_mem = ((TARGET_HITACHI || pcum->renesas_abi)
&& aggregate_value_p (TREE_TYPE (fntype), fndecl));
- pcum->prototype_p = TYPE_ARG_TYPES (fntype) ? TRUE : FALSE;
+ pcum->prototype_p = prototype_p (fntype);
pcum->arg_count [(int) SH_ARG_INT]
= TARGET_SH5 && aggregate_value_p (TREE_TYPE (fntype), fndecl);
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index a066b2a..7df0dfb 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -5017,7 +5017,7 @@ init_cumulative_args (struct sparc_args *cum, tree fntype,
tree fndecl ATTRIBUTE_UNUSED)
{
cum->words = 0;
- cum->prototype_p = fntype && TYPE_ARG_TYPES (fntype);
+ cum->prototype_p = fntype && prototype_p (fntype);
cum->libcall_p = fntype == 0;
}
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f9331bc..f74b0c2 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -983,7 +983,7 @@ decls_match (tree newdecl, tree olddecl)
if (same_type_p (TREE_TYPE (f1), TREE_TYPE (f2)))
{
- if (p2 == NULL_TREE && DECL_EXTERN_C_P (olddecl)
+ if (!prototype_p (f2) && DECL_EXTERN_C_P (olddecl)
&& (DECL_BUILT_IN (olddecl)
#ifndef NO_IMPLICIT_EXTERN_C
|| (DECL_IN_SYSTEM_HEADER (newdecl) && !DECL_CLASS_SCOPE_P (newdecl))
@@ -996,7 +996,7 @@ decls_match (tree newdecl, tree olddecl)
TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
}
#ifndef NO_IMPLICIT_EXTERN_C
- else if (p1 == NULL_TREE
+ else if (!prototype_p (f1)
&& (DECL_EXTERN_C_P (olddecl)
&& DECL_IN_SYSTEM_HEADER (olddecl)
&& !DECL_CLASS_SCOPE_P (olddecl))
@@ -1536,8 +1536,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
}
else if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_INITIAL (olddecl) != NULL_TREE
- && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == NULL_TREE
- && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != NULL_TREE)
+ && !prototype_p (TREE_TYPE (olddecl))
+ && prototype_p (TREE_TYPE (newdecl)))
{
/* Prototype decl follows defn w/o prototype. */
warning_at (input_location, 0, "prototype for %q+#D", newdecl);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c76d381..ae6aed0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4737,7 +4737,7 @@ push_template_decl_real (tree decl, bool is_friend)
return error_mark_node;
}
if (NEW_DELETE_OPNAME_P (DECL_NAME (decl))
- && (!TYPE_ARG_TYPES (TREE_TYPE (decl))
+ && (!prototype_p (TREE_TYPE (decl))
|| TYPE_ARG_TYPES (TREE_TYPE (decl)) == void_list_node
|| !TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl)))
|| (TREE_CHAIN (TYPE_ARG_TYPES ((TREE_TYPE (decl))))
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1fa3300..73373c0 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -17651,7 +17651,7 @@ static inline void
add_prototyped_attribute (dw_die_ref die, tree func_type)
{
if (get_AT_unsigned (comp_unit_die (), DW_AT_language) == DW_LANG_C89
- && TYPE_ARG_TYPES (func_type) != NULL)
+ && prototype_p (func_type))
add_AT_flag (die, DW_AT_prototyped, 1);
}
@@ -18900,7 +18900,6 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
tree origin = decl_ultimate_origin (decl);
dw_die_ref subr_die;
- tree fn_arg_types;
tree outer_scope;
dw_die_ref old_die = lookup_decl_die (decl);
int declaration = (current_function_decl != decl
@@ -19238,8 +19237,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
void_type_node 2) an unprototyped function declaration (not a
definition). This just means that we have no info about the
parameters at all. */
- fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
- if (fn_arg_types != NULL)
+ if (prototype_p (TREE_TYPE (decl)))
{
/* This is the prototyped case, check for.... */
if (stdarg_p (TREE_TYPE (decl)))
diff --git a/gcc/ipa-type-escape.c b/gcc/ipa-type-escape.c
index 6b464df..1ecf68e 100644
--- a/gcc/ipa-type-escape.c
+++ b/gcc/ipa-type-escape.c
@@ -1025,7 +1025,7 @@ check_function_parameter_and_return_types (tree fn, bool escapes)
{
tree arg;
- if (TYPE_ARG_TYPES (TREE_TYPE (fn)))
+ if (prototype_p (TREE_TYPE (fn)))
{
for (arg = TYPE_ARG_TYPES (TREE_TYPE (fn));
arg && TREE_VALUE (arg) != void_type_node;
@@ -1333,7 +1333,7 @@ check_call (gimple call)
/* Check that there are no implicit casts in the passing of
parameters. */
- if (TYPE_ARG_TYPES (TREE_TYPE (callee_t)))
+ if (prototype_p (TREE_TYPE (callee_t)))
{
for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t)), i = 0;
arg_type && TREE_VALUE (arg_type) != void_type_node
diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c
index de51eb0..ed4bde9 100644
--- a/gcc/lto/lto-lang.c
+++ b/gcc/lto/lto-lang.c
@@ -313,7 +313,7 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
will have the correct types when we actually check them later. */
if (!args)
{
- gcc_assert (TYPE_ARG_TYPES (type));
+ gcc_assert (prototype_p (type));
return NULL_TREE;
}
@@ -370,8 +370,11 @@ handle_sentinel_attribute (tree *node, tree ARG_UNUSED (name), tree args,
int ARG_UNUSED (flags),
bool * ARG_UNUSED (no_add_attrs))
{
- tree params = TYPE_ARG_TYPES (*node);
- gcc_assert (params);
+ tree params;
+
+ gcc_assert (prototype_p (*node));
+
+ params = TYPE_ARG_TYPES (*node);
while (TREE_CHAIN (params))
params = TREE_CHAIN (params);
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 2076111..2ac51bb 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -5126,7 +5126,7 @@ next_sjlj_build_enter_and_setjmp (void)
t = build_fold_addr_expr_loc (input_location, t);
#ifdef OBJCPLUS
/* Convert _setjmp argument to type that is expected. */
- if (TYPE_ARG_TYPES (TREE_TYPE (objc_setjmp_decl)))
+ if (prototype_p (TREE_TYPE (objc_setjmp_decl)))
t = convert (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (objc_setjmp_decl))), t);
else
t = convert (ptr_type_node, t);
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 78497ce..7bd01f8 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1241,7 +1241,7 @@ useless_type_conversion_p (tree outer_type, tree inner_type)
|| TREE_CODE (TREE_TYPE (outer_type)) == METHOD_TYPE)
&& (TREE_CODE (TREE_TYPE (outer_type))
== TREE_CODE (TREE_TYPE (inner_type)))
- && !TYPE_ARG_TYPES (TREE_TYPE (outer_type))
+ && !prototype_p (TREE_TYPE (outer_type))
&& useless_type_conversion_p (TREE_TYPE (TREE_TYPE (outer_type)),
TREE_TYPE (TREE_TYPE (inner_type)))))
return true;
@@ -1407,7 +1407,7 @@ useless_type_conversion_p (tree outer_type, tree inner_type)
return false;
/* A conversion to an unprototyped argument list is ok. */
- if (!TYPE_ARG_TYPES (outer_type))
+ if (!prototype_p (outer_type))
return true;
/* If the unqualified argument types are compatible the conversion
More information about the Gcc-patches
mailing list