re PR c/34985 (Warning "defined but not used" despite __attribute__((__used__)))

2008-07-29  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR 34985
	* c-decl.c (merge_decls): Merge USED flags.
cp/
	* decl.c (duplicate_decls): Merge USED flags.
testsuite/
	* gcc.dg/pr34985.c: New.
	* g++.dg/warn/pr34985.C: New.

From-SVN: r138235
parent 1fbfb0e2
2008-07-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 34985
* c-decl.c (merge_decls): Merge USED flags.
2008-07-29 Kaz Kojima <kkojima@gcc.gnu.org>
* config/sh/sh.c (sh_gimplify_va_arg_expr): Unshare the addr,
......
......@@ -1862,6 +1862,12 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
extern_changed = DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl);
/* Merge the USED information. */
if (TREE_USED (olddecl))
TREE_USED (newdecl) = 1;
else if (TREE_USED (newdecl))
TREE_USED (olddecl) = 1;
/* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
But preserve OLDDECL's DECL_UID and DECL_CONTEXT. */
{
......
2008-07-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 34985
* decl.c (duplicate_decls): Merge USED flags.
2008-07-27 Jason Merrill <jason@redhat.com>
PR c++/36943
......
......@@ -2056,6 +2056,12 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
ggc_free (DECL_LANG_SPECIFIC (olddecl));
}
/* Merge the USED information. */
if (TREE_USED (olddecl))
TREE_USED (newdecl) = 1;
else if (TREE_USED (newdecl))
TREE_USED (olddecl) = 1;
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
int function_size;
......
2008-07-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR 34985
* gcc.dg/pr34985.c: New.
* g++.dg/warn/pr34985.C: New.
2008-07-29 Daniel Kraft <d@domob.eu>
PR fortran/36403
......
/* PR34985: Warning "defined but not used" despite __attribute__((__used__)) */
/* { dg-do compile } */
/* { dg-options "-Wall -Wextra -O2" } */
static void xxyyzz (void);
static void __attribute__((__used__)) xxyyzz(void)
{
}
/* { dg-final { scan-assembler "xxyyzz" } } */
/* PR34985: Warning "defined but not used" despite __attribute__((__used__)) */
/* { dg-do compile } */
/* { dg-options "-Wall -Wextra -O2" } */
static void xxyyzz (void);
static void __attribute__((__used__)) xxyyzz(void)
{
}
/* { dg-final { scan-assembler "xxyyzz" } } */
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