瀏覽代碼

gcc: Get rid of "used but never defined" warnings for file-scope tasks.

* gcc-plugin/src/starpu.c (handle_task_attribute): Add a dummy body to
  FN when it has file scope.
Ludovic Courtès 14 年之前
父節點
當前提交
2a579a30db
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      gcc-plugin/src/starpu.c

+ 8 - 0
gcc-plugin/src/starpu.c

@@ -437,6 +437,14 @@ handle_task_attribute (tree *node, tree name, tree args,
 	       NULL_TREE,
 	       NULL_TREE);
 
+  if (!TREE_PUBLIC (fn))
+    {
+      /* Set a dummy body to avoid "used but never defined" warnings when FN
+	 has file scope.  */
+      DECL_SAVED_TREE (fn) = build_printf ("hello from the task!");
+      DECL_INITIAL (fn) = build_block (NULL_TREE, NULL_TREE, fn, NULL_TREE);
+    }
+
   /* Push a declaration for the corresponding `starpu_codelet' object and add
      it as an attribute of FN.  */
   tree cl = build_codelet_declaration (fn);