c-common.c (shadow_warning): Delete.

* c-common.c (shadow_warning): Delete.
	* c-common.h (free_parser_stacks, shadow_warning, sw_kind): Delete.
	* c-decl.c (warn_if_shadowing): Issue shadow warnings directly.
	* c-opts.c (c_common_parse_file): Don't call free_parser_stacks.
	* c-parse.in (free_parser_stacks): Delete.
cp:
	* name-lookup.c (pushdecl): Issue shadow warnings directly.
	* parser.c (free_parser_stacks): Delete.
testsuite:
	* gcc.c-torture/execute/string-opt-15.c: Define memcmp with void *
	arguments.
	* gcc.dg/fwritable-strings-1.c: Expect the deprecation notice.
------
	Bug 13856
	* c-decl.c (diagnose_mismatched_decls): Only give special
	treatment when olddecl is DECL_BUILT_IN, if C_DECL_INVISIBLE
	is also true.
	(merge_decls): Don't clear DECL_BUILT_IN_CLASS and
	DECL_FUNCTION_CODE when defining a built-in function.
	Don't update DECL_ESTIMATED_INSNS.
	* dwarf2out.c (dwarf2out_decl): Don't ignore built-in
	FUNCTION_DECLs.
	* tree.h: Delete DECL_ESTIMATED_INSNS.
	* tree-inline.c (struct inline_data): Delete inlined_insns field.
	(expand_call_inline, optimize_inline_calls): Don't update
	DECL_ESTIMATED_INSNS nor inlined_insns.
	* cgraphunit.c (cgraph_analyze_function): Don't update
	DECL_ESTIMATED_INSNS.
cp:
	* optimize.c (maybe_clone_body): Don't update DECL_ESTIMATED_INSNS.
	* decl.c (duplicate_decls, start_function): Likewise.
testsuite:
	* gcc.dg/visibility-8.c: New testcase.

From-SVN: r77475
This commit is contained in:
Zack Weinberg 2004-02-08 01:59:11 +00:00
parent 19755f9808
commit a6f78652f3
19 changed files with 157 additions and 167 deletions

View File

@ -1,3 +1,29 @@
2004-02-07 Zack Weinberg <zack@codesourcery.com>
Bug 13856
* c-decl.c (diagnose_mismatched_decls): Only give special
treatment when olddecl is DECL_BUILT_IN, if C_DECL_INVISIBLE
is also true.
(merge_decls): Don't clear DECL_BUILT_IN_CLASS and
DECL_FUNCTION_CODE when defining a built-in function.
Don't update DECL_ESTIMATED_INSNS.
* dwarf2out.c (dwarf2out_decl): Don't ignore built-in
FUNCTION_DECLs.
* tree.h: Delete DECL_ESTIMATED_INSNS.
* tree-inline.c (struct inline_data): Delete inlined_insns field.
(expand_call_inline, optimize_inline_calls): Don't update
DECL_ESTIMATED_INSNS nor inlined_insns.
* cgraphunit.c (cgraph_analyze_function): Don't update
DECL_ESTIMATED_INSNS.
2004-02-07 Zack Weinberg <zack@codesourcery.com>
* c-common.c (shadow_warning): Delete.
* c-common.h (free_parser_stacks, shadow_warning, sw_kind): Delete.
* c-decl.c (warn_if_shadowing): Issue shadow warnings directly.
* c-opts.c (c_common_parse_file): Don't call free_parser_stacks.
* c-parse.in (free_parser_stacks): Delete.
2004-02-07 Nathanael Nerode <neroden@gcc.gnu.org>
* Makefile.in, config/t-slibgcc-darwin, config/t-slibgcc-elf-ver,

View File

@ -4266,21 +4266,6 @@ c_init_attributes (void)
#undef DEF_ATTR_TREE_LIST
}
/* Output a -Wshadow warning MSGCODE about NAME, and give the location
of the previous declaration DECL. */
void
shadow_warning (enum sw_kind msgcode, const char *name, tree decl)
{
static const char *const msgs[] = {
/* SW_PARAM */ N_("declaration of \"%s\" shadows a parameter"),
/* SW_LOCAL */ N_("declaration of \"%s\" shadows a previous local"),
/* SW_GLOBAL */ N_("declaration of \"%s\" shadows a global declaration")
};
warning (msgs[msgcode], name);
warning ("%Jshadowed declaration is here", decl);
}
/* Attribute handlers common to C front ends. */
/* Handle a "packed" attribute; arguments as in

View File

@ -330,8 +330,6 @@ extern void (*lang_expand_function_end) (void);
extern int (*lang_missing_noreturn_ok_p) (tree);
extern int yyparse (void);
extern void free_parser_stacks (void);
extern stmt_tree current_stmt_tree (void);
extern tree *current_scope_stmt_stack (void);
extern void begin_stmt_tree (tree *);
@ -347,8 +345,6 @@ extern tree c_begin_if_stmt (void);
extern tree c_begin_while_stmt (void);
extern void c_finish_while_stmt_cond (tree, tree);
enum sw_kind { SW_PARAM = 0, SW_LOCAL, SW_GLOBAL };
extern void shadow_warning (enum sw_kind, const char *, tree);
extern int field_decl_cmp (const void *, const void *);
extern void resort_sorted_fields (void *, void *, gt_pointer_operator,
void *);

View File

@ -939,7 +939,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
unless OLDDECL is a builtin. OLDDECL will be discarded in any case. */
if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
{
if (TREE_CODE (olddecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
if (TREE_CODE (olddecl) != FUNCTION_DECL
|| !DECL_BUILT_IN (olddecl) || !C_DECL_INVISIBLE (olddecl))
{
error ("%J'%D' redeclared as different kind of symbol",
newdecl, newdecl);
@ -956,7 +957,8 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
if (!comptypes (oldtype, newtype, COMPARE_STRICT))
{
if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_BUILT_IN (olddecl))
if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_BUILT_IN (olddecl) && C_DECL_INVISIBLE (olddecl))
{
/* Accept harmless mismatch in function types.
This is for the ffs and fprintf builtins. */
@ -1034,6 +1036,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
can't validate the argument list) the built-in definition is
overridden, but optionally warn this was a bad choice of name. */
if (DECL_BUILT_IN (olddecl)
&& C_DECL_INVISIBLE (olddecl)
&& (!TREE_PUBLIC (newdecl)
|| (DECL_INITIAL (newdecl)
&& !TYPE_ARG_TYPES (TREE_TYPE (newdecl)))))
@ -1428,21 +1431,10 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
if (DECL_BUILT_IN (olddecl))
{
/* Get rid of any built-in function if we have a function
definition. */
if (new_is_definition)
{
TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN;
}
else
{
/* If redeclaring a builtin function, and not a definition,
it stays built in. */
/* If redeclaring a builtin function, it stays built in. */
DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
}
}
/* Also preserve various other info from the definition. */
if (! new_is_definition)
@ -1451,7 +1443,6 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl);
DECL_ESTIMATED_INSNS (newdecl) = DECL_ESTIMATED_INSNS (olddecl);
DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
/* Set DECL_INLINE on the declaration if we've got a body
@ -1553,8 +1544,6 @@ record_external_decl (tree decl)
static void
warn_if_shadowing (tree x, tree old)
{
const char *name;
/* Nothing to shadow? */
if (old == 0
/* Shadow warnings not wanted? */
@ -1571,13 +1560,14 @@ warn_if_shadowing (tree x, tree old)
|| (TREE_CODE (x) == PARM_DECL && current_scope->outer->parm_flag))
return;
name = IDENTIFIER_POINTER (DECL_NAME (x));
if (TREE_CODE (old) == PARM_DECL)
shadow_warning (SW_PARAM, name, old);
warning ("%Jdeclaration of '%D' shadows a parameter", x, x);
else if (DECL_FILE_SCOPE_P (old))
shadow_warning (SW_GLOBAL, name, old);
warning ("%Jdeclaration of '%D' shadows a global declaration", x, x);
else
shadow_warning (SW_LOCAL, name, old);
warning ("%Jdeclaration of '%D' shadows a previous local", x, x);
warning ("%Jshadowed declaration is here", old);
}

View File

@ -1237,7 +1237,6 @@ c_common_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
file_index++;
} while (file_index < num_in_fnames);
free_parser_stacks ();
finish_file ();
}

View File

@ -3763,13 +3763,6 @@ yyprint (FILE *file, int yychar, YYSTYPE yyl)
/* This is not the ideal place to put these, but we have to get them out
of c-lex.c because cp/lex.c has its own versions. */
/* Free malloced parser stacks if necessary. */
void
free_parser_stacks (void)
{
}
/* Parse the file. */
void
c_parse_file (void)

View File

@ -327,10 +327,9 @@ cgraph_analyze_function (struct cgraph_node *node)
cgraph_create_edges (decl, DECL_SAVED_TREE (decl));
node->local.inlinable = tree_inlinable_function_p (decl);
if (!DECL_ESTIMATED_INSNS (decl))
DECL_ESTIMATED_INSNS (decl)
if (!node->local.self_insns)
node->local.self_insns
= (*lang_hooks.tree_inlining.estimate_num_insns) (decl);
node->local.self_insns = DECL_ESTIMATED_INSNS (decl);
if (node->local.inlinable)
node->local.disregard_inline_limits
= (*lang_hooks.tree_inlining.disregard_inline_limits) (decl);

View File

@ -1,3 +1,14 @@
2004-02-07 Zack Weinberg <zack@codesourcery.com>
Bug 13856
* optimize.c (maybe_clone_body): Don't update DECL_ESTIMATED_INSNS.
* decl.c (duplicate_decls, start_function): Likewise.
2004-02-07 Zack Weinberg <zack@codesourcery.com>
* name-lookup.c (pushdecl): Issue shadow warnings directly.
* parser.c (free_parser_stacks): Delete.
2004-02-07 Kazu Hirata <kazu@cs.umass.edu>
* rtti.c: Update copyright.

View File

@ -1853,8 +1853,6 @@ duplicate_decls (tree newdecl, tree olddecl)
regardless of declaration matches. */
SET_DECL_RTL (newdecl, DECL_RTL (olddecl));
}
else
DECL_ESTIMATED_INSNS (newdecl) = DECL_ESTIMATED_INSNS (olddecl);
DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
/* Don't clear out the arguments if we're redefining a function. */
@ -10258,9 +10256,6 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags)
/* Start the statement-tree, start the tree now. */
begin_stmt_tree (&DECL_SAVED_TREE (decl1));
/* Don't double-count statements in templates. */
DECL_ESTIMATED_INSNS (decl1) = 0;
/* Let the user know we're compiling this function. */
announce_function (decl1);

View File

@ -937,15 +937,16 @@ pushdecl (tree x)
/* ARM $8.3 */
if (b->kind == sk_function_parms)
{
error ("declaration of `%#D' shadows a parameter",
name);
error ("declaration of '%#D' shadows a parameter", x);
err = true;
}
}
if (warn_shadow && !err)
shadow_warning (SW_PARAM,
IDENTIFIER_POINTER (name), oldlocal);
{
warning ("declaration of '%#D' shadows a parameter", x);
warning ("%Jshadowed declaration is here", oldlocal);
}
}
/* Maybe warn if shadowing something else. */
@ -958,17 +959,25 @@ pushdecl (tree x)
if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE
&& current_class_ptr
&& !TREE_STATIC (name))
warning ("declaration of `%s' shadows a member of `this'",
IDENTIFIER_POINTER (name));
{
/* Location of previous decl is not useful in this case. */
warning ("declaration of '%D' shadows a member of 'this'",
x);
}
else if (oldlocal != NULL_TREE
&& TREE_CODE (oldlocal) == VAR_DECL)
shadow_warning (SW_LOCAL,
IDENTIFIER_POINTER (name), oldlocal);
{
warning ("declaration of '%D' shadows a previous local", x);
warning ("%Jshadowed declaration is here", oldlocal);
}
else if (oldglobal != NULL_TREE
&& TREE_CODE (oldglobal) == VAR_DECL)
/* XXX shadow warnings in outer-more namespaces */
shadow_warning (SW_GLOBAL,
IDENTIFIER_POINTER (name), oldglobal);
{
warning ("declaration of '%D' shadows a global declaration",
x);
warning ("%Jshadowed declaration is here", oldglobal);
}
}
}

View File

@ -232,10 +232,6 @@ maybe_clone_body (tree fn)
/* Clone the body. */
clone_body (clone, fn, decl_map);
/* There are as many statements in the clone as in the
original. */
DECL_ESTIMATED_INSNS (clone) = DECL_ESTIMATED_INSNS (fn);
/* Clean up. */
splay_tree_delete (decl_map);

View File

@ -15274,14 +15274,6 @@ c_parse_file (void)
the_parser = NULL;
}
/* Clean up after parsing the entire translation unit. */
void
free_parser_stacks (void)
{
/* Nothing to do. */
}
/* This variable must be provided by every front end. */
int yydebug;

View File

@ -12565,12 +12565,6 @@ dwarf2out_decl (tree decl)
return;
case FUNCTION_DECL:
/* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
builtin function. Explicit programmer-supplied declarations of
these same functions should NOT be ignored however. */
if (DECL_EXTERNAL (decl) && DECL_BUILT_IN (decl))
return;
/* What we would really like to do here is to filter out all mere
file-scope declarations of file-scope functions which are never
referenced later within this translation unit (and keep all of ones

View File

@ -1,3 +1,14 @@
2004-02-07 Zack Weinberg <zack@codesourcery.com>
Bug 13856
* gcc.dg/visibility-8.c: New testcase.
2004-02-07 Zack Weinberg <zack@codesourcery.com>
* gcc.c-torture/execute/string-opt-15.c: Define memcmp with void *
arguments.
* gcc.dg/fwritable-strings-1.c: Expect the deprecation notice.
2004-02-07 Roger Sayle <roger@eyesopen.com>
PR middle-end/13696

View File

@ -39,7 +39,7 @@ main ()
should abort. */
__attribute__ ((noinline))
static int
memcmp (const char *p1, const char *p2, size_t len)
memcmp (const void *p1, const void *p2, size_t len)
{
abort ();
}

View File

@ -3,6 +3,7 @@
/* { dg-do run } */
/* { dg-options "-fwritable-strings" } */
/* { dg-error "-fwritable-strings is deprecated" "" { target *-*-* } 0 } */
extern void abort(void);

View File

@ -0,0 +1,16 @@
/* Test hidden visibility on built-in functions (for libc). PR 13856. */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* { dg-require-visibility "" } */
/* { dg-final { scan-assembler "\\.hidden.*__GI_fputs_unlocked" } } */
int fputs_unlocked (const char *restrict, int *restrict)
__asm__ ("__GI_fputs_unlocked")
__attribute__ ((visibility ("hidden")));
int
fputs_unlocked (str, fp)
const char *str;
int *fp;
{
}

View File

@ -95,9 +95,6 @@ typedef struct inline_data
int in_target_cleanup_p;
/* A list of the functions current function has inlined. */
varray_type inlined_fns;
/* The approximate number of instructions we have inlined in the
current call stack. */
int inlined_insns;
/* We use the same mechanism to build clones that we do to perform
inlining. However, there are a few places where we need to
distinguish between those two situations. This flag is true if
@ -1569,11 +1566,6 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
the equivalent inlined version either. */
TREE_USED (*tp) = 1;
/* Our function now has more statements than it did before. */
DECL_ESTIMATED_INSNS (VARRAY_TREE (id->fns, 0)) += DECL_ESTIMATED_INSNS (fn);
/* For accounting, subtract one for the saved call/ret. */
id->inlined_insns += DECL_ESTIMATED_INSNS (fn) - 1;
/* Update callgraph if needed. */
if (id->decl)
{
@ -1590,11 +1582,6 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
}
VARRAY_POP (id->fns);
/* If we've returned to the top level, clear out the record of how
much inlining has been done. */
if (VARRAY_ACTIVE_SIZE (id->fns) == id->first_inlined_fn)
id->inlined_insns = 0;
/* Don't walk into subtrees. We've already handled them above. */
*walk_subtrees = 0;
@ -1634,9 +1621,6 @@ optimize_inline_calls (tree fn)
/* Don't allow recursion into FN. */
VARRAY_TREE_INIT (id.fns, 32, "fns");
VARRAY_PUSH_TREE (id.fns, fn);
if (!DECL_ESTIMATED_INSNS (fn))
DECL_ESTIMATED_INSNS (fn)
= (*lang_hooks.tree_inlining.estimate_num_insns) (fn);
/* Or any functions that aren't finished yet. */
prev_fn = NULL_TREE;
if (current_function_decl)

View File

@ -1627,13 +1627,6 @@ struct tree_type GTY(())
#define DECL_POINTER_ALIAS_SET_KNOWN_P(NODE) \
(DECL_POINTER_ALIAS_SET (NODE) != - 1)
/* In a FUNCTION_DECL for which DECL_BUILT_IN does not hold, this is
the approximate number of statements in this function. There is
no need for this number to be exact; it is only used in various
heuristics regarding optimization. */
#define DECL_ESTIMATED_INSNS(NODE) \
(FUNCTION_DECL_CHECK (NODE)->decl.u1.i)
/* Nonzero for a decl which is at file scope. */
#define DECL_FILE_SCOPE_P(EXP) \
(! DECL_CONTEXT (EXP) \