c-common.c (decl_attributes): Set TREE_USED on the object pointed to.
authorZack Weinberg <zack@wolery.cumb.org>
Thu, 20 Apr 2000 16:09:27 +0000 (16:09 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Thu, 20 Apr 2000 16:09:27 +0000 (16:09 +0000)
* c-common.c (decl_attributes) [A_ALIAS]: Set TREE_USED on the
object pointed to.

From-SVN: r33284

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/gcc.dg/20000419-2.c [new file with mode: 0644]

index d863072038fc72ec3dcd92d79a1a6ba9856e3b05..970c789d308a553a6562f9730972cbaae2714d3b 100644 (file)
@@ -1,3 +1,8 @@
+2000-04-20  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * c-common.c (decl_attributes) [A_ALIAS]: Set TREE_USED on the
+       object pointed to.
+
 Thu Apr 20 14:19:18 MET DST 2000  Jan Hubicka  <jh@suse.cz>
 
        * loop.c (emit_iv_add_mult):  Simplify it's input and emit
index 386721a66d42e619858b6a08214d9982e85874bc..32b2ede864b5e1a3831a59d204f7785b04e43067 100644 (file)
@@ -981,6 +981,8 @@ decl_attributes (node, attributes, prefix_attributes)
                  break;
                }
              id = get_identifier (TREE_STRING_POINTER (id));
+             /* This counts as a use of the object pointed to.  */
+             TREE_USED (id) = 1;
 
              if (TREE_CODE (decl) == FUNCTION_DECL)
                DECL_INITIAL (decl) = error_mark_node;
diff --git a/gcc/testsuite/gcc.dg/20000419-2.c b/gcc/testsuite/gcc.dg/20000419-2.c
new file mode 100644 (file)
index 0000000..05e4729
--- /dev/null
@@ -0,0 +1,17 @@
+/* A static function with a global alias should not get 'defined but
+   not used' warnings.  Exposed by Linux kernel.  */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+extern void do_something (void);
+extern void do_something_else (void);
+
+static int
+init_foobar(void)  /* { dg-bogus "defined but not used" "not used warning" } */
+{
+  do_something();
+  do_something_else();
+  return 0;
+}
+
+int init_module(void) __attribute__((alias("init_foobar")));