task-errors.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* GCC-StarPU
  2. Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
  3. GCC-StarPU is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. GCC-StarPU is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with GCC-StarPU. If not, see <http://www.gnu.org/licenses/>. */
  13. /* Test error handling for the `task' and `task_implementation' attributes. */
  14. static void my_task (int foo, char *bar) __attribute__ ((task));
  15. static void my_task_cpu (int foo, float *bar) /* (error "type differs") */
  16. __attribute__ ((task_implementation ("cpu", my_task)));
  17. static void my_task_opencl (long foo, char *bar) /* (error "type differs") */
  18. __attribute__ ((task_implementation ("opencl", my_task)));
  19. static void my_task_nowhere (int foo, char *bar) /* (warning "unsupported target") */
  20. __attribute__ ((task_implementation ("does-not-exist", my_task)));
  21. static void my_task_not_quite (int foo, char *bar) /* (error "lacks the 'task' attribute") */
  22. __attribute__ ((task_implementation ("cpu", my_task_nowhere)));
  23. static int foo /* (error "only applies to function") */
  24. __attribute__ ((task_implementation ("cpu", my_task)));
  25. static int bar /* (error "only applies to function") */
  26. __attribute__ ((task, unused));
  27. static int not_a_task __attribute__ ((unused));
  28. static void my_task_almost (int foo, char *bar) /* (error "not a function") */
  29. __attribute__ ((task_implementation ("cpu", not_a_task)));
  30. static void my_task_wrong_task_arg (int foo, char *bar) /* (error "not a function") */
  31. __attribute__ ((task_implementation ("cpu", 123)));
  32. static void my_task_wrong_target_arg (int foo, char *bar) /* (error "string constant expected") */
  33. __attribute__ ((task_implementation (123, my_task)));
  34. static void my_task_with_a_body (int foo, char *bar)
  35. __attribute__ ((task, unused));
  36. extern int my_task_not_void (int foo) /* (error "return type") */
  37. __attribute__ ((task));
  38. static void
  39. my_task_cpu (int foo, float *bar)
  40. {
  41. }
  42. static void
  43. my_task_opencl (long foo, char *bar)
  44. {
  45. }
  46. static void
  47. my_task_nowhere (int foo, char *bar)
  48. {
  49. }
  50. static void
  51. my_task_not_quite (int foo, char *bar)
  52. {
  53. }
  54. static void
  55. my_task_almost (int foo, char *bar)
  56. {
  57. }
  58. static void
  59. my_task_wrong_task_arg (int foo, char *bar)
  60. {
  61. }
  62. static void
  63. my_task_wrong_target_arg (int foo, char *bar)
  64. {
  65. }
  66. static void
  67. my_task_with_a_body (int foo, char *bar) /* (error "must not have a body") */
  68. {
  69. }