From: Manuel López-Ibáñez Date: Tue, 29 Jul 2008 10:00:25 +0000 (+0000) Subject: re PR c/34985 (Warning "defined but not used" despite __attribute__((__used__))) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e27fb29c0dec9ef1cf32fe44ecbf7a6fcc3f09a9;p=gcc.git re PR c/34985 (Warning "defined but not used" despite __attribute__((__used__))) 2008-07-29 Manuel Lopez-Ibanez 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3766bb6f42f..6533ff34a7a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-07-29 Manuel Lopez-Ibanez + + PR 34985 + * c-decl.c (merge_decls): Merge USED flags. + 2008-07-29 Kaz Kojima * config/sh/sh.c (sh_gimplify_va_arg_expr): Unshare the addr, diff --git a/gcc/c-decl.c b/gcc/c-decl.c index bdb68199351..7929aa8e2ba 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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. */ { diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bbb23ee1976..b44108402d4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2008-07-29 Manuel Lopez-Ibanez + + PR 34985 + * decl.c (duplicate_decls): Merge USED flags. + 2008-07-27 Jason Merrill PR c++/36943 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2d9ccba3a5c..248b9b71a05 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e6ec66ef5ba..ed53441e077 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-07-29 Manuel Lopez-Ibanez + + PR 34985 + * gcc.dg/pr34985.c: New. + * g++.dg/warn/pr34985.C: New. + 2008-07-29 Daniel Kraft PR fortran/36403 diff --git a/gcc/testsuite/g++.dg/warn/pr34985.C b/gcc/testsuite/g++.dg/warn/pr34985.C new file mode 100644 index 00000000000..56437509d9f --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr34985.C @@ -0,0 +1,9 @@ +/* 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" } } */ diff --git a/gcc/testsuite/gcc.dg/pr34985.c b/gcc/testsuite/gcc.dg/pr34985.c new file mode 100644 index 00000000000..56437509d9f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr34985.c @@ -0,0 +1,9 @@ +/* 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" } } */