Explorar o código

gcc: Error out when a task doesn't return `void'.

* gcc-plugin/src/starpu.c (handle_task_attribute): Error out when FN
  doesn't return `void'.

* gcc-plugin/tests/task-errors.c (my_task_not_void): New declaration.
Ludovic Courtès %!s(int64=13) %!d(string=hai) anos
pai
achega
1ddd68b6b8
Modificáronse 2 ficheiros con 9 adicións e 0 borrados
  1. 6 0
      gcc-plugin/src/starpu.c
  2. 3 0
      gcc-plugin/tests/task-errors.c

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

@@ -690,6 +690,12 @@ handle_task_attribute (tree *node, tree name, tree args,
 	      "%<task%> attribute only applies to functions");
   else
     {
+      if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fn))))
+	/* Raise an error but keep going to avoid spitting out too many
+	   errors at the user's face.  */
+	error_at (DECL_SOURCE_LOCATION (fn),
+		  "task return type must be %<void%>");
+
       /* This is a function declaration for something local to this
 	 translation unit, so add the `task' attribute to FN.  */
       *no_add_attrs = false;

+ 3 - 0
gcc-plugin/tests/task-errors.c

@@ -49,6 +49,9 @@ static void my_task_wrong_target_arg (int foo, char *bar) /* (error "string cons
 static void my_task_with_a_body (int foo, char *bar)
   __attribute__ ((task, unused));
 
+extern int my_task_not_void (int foo) /* (error "return type") */
+  __attribute__ ((task));
+
 
 static void
 my_task_cpu (int foo, float *bar)