This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
declaration/definition mismatches (1/2)
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 27 Jun 2003 17:27:36 -0700
- Subject: declaration/definition mismatches (1/2)
I've got a patch under development (to follow shortly) which among
other things causes GCC to issue a warning when a forward declaration
has the 'static' qualifier and the definition doesn't, or vice versa.
This exposed a number of such mismatches in GCC itself. This is patch
1 of 2 to correct these mismatches.
bootstrapped i686-linux, applied.
zw
* c-format.c (check_format_string, get_constant)
* cfgrtl.c (rtl_split_edge):
Mark the definition static, matching the forward declaration.
cp:
* decl.c (build_typename_type)
* mangle.c (write_template_template_arg)
* parser.c (cp_parser_scope_through_which_access_occurs)
* pt.c (push_access_scope_real, push_access_scope, pop_access_scope)
* repo.c (get_base_filename)
* semantics.c (maybe_convert_cond):
Mark the definition static, matching the forward declaration.
java:
* class.c (build_method_symbols_entry)
* expr.c (get_offset_table_index)
* jcf-parse.c (jcf_parse):
Mark the definition static, matching the forward declaration.
===================================================================
Index: c-format.c
--- c-format.c 23 Jun 2003 15:27:34 -0000 1.41
+++ c-format.c 28 Jun 2003 00:06:16 -0000
@@ -116,7 +116,7 @@ handle_format_arg_attribute (tree *node,
/* Verify that the format_num argument is actually a string, in case
the format attribute is in error. */
-bool
+static bool
check_format_string (tree argument, unsigned HOST_WIDE_INT format_num,
int flags, bool *no_add_attrs)
{
@@ -146,7 +146,7 @@ check_format_string (tree argument, unsi
/* Strip any conversions from the expression, verify it is a constant,
and store its value. If validated_p is true, abort on errors.
Returns true on success, false otherwise. */
-bool
+static bool
get_constant(tree expr, unsigned HOST_WIDE_INT *value, int validated_p)
{
while (TREE_CODE (expr) == NOP_EXPR
===================================================================
Index: cfgrtl.c
--- cfgrtl.c 26 Jun 2003 06:13:27 -0000 1.84
+++ cfgrtl.c 28 Jun 2003 00:06:16 -0000
@@ -1200,7 +1200,7 @@ back_edge_of_syntactic_loop_p (basic_blo
The case of a block ending in an unconditional jump to a
block with multiple predecessors is not handled optimally. */
-basic_block
+static basic_block
rtl_split_edge (edge edge_in)
{
basic_block bb;
===================================================================
Index: cp/decl.c
--- cp/decl.c 27 Jun 2003 21:21:04 -0000 1.1073
+++ cp/decl.c 28 Jun 2003 00:06:17 -0000
@@ -5415,7 +5415,7 @@ typename_compare (const void * k1, const
static GTY ((param_is (union tree_node))) htab_t typename_htab;
-tree
+static tree
build_typename_type (tree context, tree name, tree fullname)
{
tree t;
===================================================================
Index: cp/mangle.c
--- cp/mangle.c 24 Jun 2003 15:40:03 -0000 1.77
+++ cp/mangle.c 28 Jun 2003 00:06:17 -0000
@@ -2138,7 +2138,7 @@ write_template_arg (tree node)
::= <name>
::= <substitution> */
-void
+static void
write_template_template_arg (const tree decl)
{
MANGLE_TRACE_TREE ("template-template-arg", decl);
===================================================================
Index: cp/parser.c
--- cp/parser.c 24 Jun 2003 15:40:03 -0000 1.66
+++ cp/parser.c 28 Jun 2003 00:06:17 -0000
@@ -1786,7 +1786,7 @@ cp_parser_is_keyword (cp_token* token, e
or `x', respectively. If the DECL was named as `A::B' then
NESTED_NAME_SPECIFIER is `A'. */
-tree
+static tree
cp_parser_scope_through_which_access_occurs (tree decl,
tree object_type,
tree nested_name_specifier)
===================================================================
Index: cp/pt.c
--- cp/pt.c 27 Jun 2003 22:46:45 -0000 1.707
+++ cp/pt.c 28 Jun 2003 00:06:17 -0000
@@ -180,7 +180,7 @@ static tree tsubst_copy_and_build (tree,
template argument for TEMPLATE_DECL. If CONTEXT is not NULL_TREE,
this is used instead of the context of T. */
-void
+static void
push_access_scope_real (tree t, tree args, tree context)
{
if (TREE_CODE (t) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (t))
@@ -227,7 +227,7 @@ push_access_scope_real (tree t, tree arg
/* Like push_access_scope_real, but always uses DECL_CONTEXT. */
-void
+static void
push_access_scope (tree t)
{
push_access_scope_real (t, NULL_TREE, NULL_TREE);
@@ -236,7 +236,7 @@ push_access_scope (tree t)
/* Restore the scope set up by push_access_scope. T is the node we
are processing. */
-void
+static void
pop_access_scope (tree t)
{
if (TREE_CODE (t) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (t))
===================================================================
Index: cp/repo.c
--- cp/repo.c 10 Jan 2003 02:22:19 -0000 1.47
+++ cp/repo.c 28 Jun 2003 00:06:17 -0000
@@ -234,7 +234,7 @@ extract_string (char **pp)
return obstack_finish (&temporary_obstack);
}
-const char *
+static const char *
get_base_filename (const char *filename)
{
char *p = getenv ("COLLECT_GCC_OPTIONS");
===================================================================
Index: cp/semantics.c
--- cp/semantics.c 24 Jun 2003 15:40:05 -0000 1.314
+++ cp/semantics.c 28 Jun 2003 00:06:17 -0000
@@ -393,7 +393,7 @@ finish_goto_stmt (tree destination)
/* COND is the condition-expression for an if, while, etc.,
statement. Convert it to a boolean value, if appropriate. */
-tree
+static tree
maybe_convert_cond (tree cond)
{
/* Empty conditions remain empty. */
===================================================================
Index: java/class.c
--- java/class.c 20 Jun 2003 09:08:22 -0000 1.159
+++ java/class.c 28 Jun 2003 00:06:18 -0000
@@ -2042,7 +2042,7 @@ emit_register_classes (void)
/* Make a method_symbol_type (_Jv_MethodSymbol) node for METHOD. */
-tree
+static tree
build_method_symbols_entry (tree method)
{
tree clname, name, signature, method_symbol;
===================================================================
Index: java/expr.c
--- java/expr.c 1 May 2003 16:13:36 -0000 1.165
+++ java/expr.c 28 Jun 2003 00:06:18 -0000
@@ -1821,7 +1821,7 @@ invoke_build_dtable (int is_invoke_inter
METHOD. If this method has not been seen before, it will be added to the
otable_methods. If it has, the existing otable slot will be reused. */
-int
+static int
get_offset_table_index (tree method)
{
int i = 1;
===================================================================
Index: java/jcf-parse.c
--- java/jcf-parse.c 13 May 2003 18:06:49 -0000 1.141
+++ java/jcf-parse.c 28 Jun 2003 00:06:18 -0000
@@ -607,7 +607,7 @@ load_class (tree class_or_name, int verb
/* Parse the .class file JCF. */
-void
+static void
jcf_parse (JCF* jcf)
{
int i, code;