OSDN Git Service

2008-07-29 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
authormanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 29 Jul 2008 10:00:25 +0000 (10:00 +0000)
committermanu <manu@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 29 Jul 2008 10:00:25 +0000 (10:00 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138235 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr34985.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr34985.c [new file with mode: 0644]

index 3766bb6..6533ff3 100644 (file)
@@ -1,3 +1,8 @@
+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,
index bdb6819..7929aa8 100644 (file)
@@ -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.  */
   {
index bbb23ee..b441084 100644 (file)
@@ -1,3 +1,8 @@
+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
index 2d9ccba..248b9b7 100644 (file)
@@ -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;
index e6ec66e..ed53441 100644 (file)
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/testsuite/g++.dg/warn/pr34985.C b/gcc/testsuite/g++.dg/warn/pr34985.C
new file mode 100644 (file)
index 0000000..5643750
--- /dev/null
@@ -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 (file)
index 0000000..5643750
--- /dev/null
@@ -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" } } */