Browse Source

gcc: Raise an error when trying to register a `void *' pointer.

* gcc-plugin/src/starpu.c (handle_pragma_register): Raise an error when
  PTR is a `void *'.

* gcc-plugin/tests/register-errors.c (void_pointer): New declaration.
  (main): Add test.
Ludovic Courtès 13 years ago
parent
commit
45ede556e9
2 changed files with 13 additions and 1 deletions
  1. 8 0
      gcc-plugin/src/starpu.c
  2. 5 1
      gcc-plugin/tests/register-errors.c

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

@@ -564,6 +564,14 @@ handle_pragma_register (struct cpp_reader *reader)
       return;
     }
 
+  /* Since we implicitly use sizeof (*PTR), `void *' is not allowed. */
+  if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (ptr))))
+    {
+      error_at (loc, "pointers to %<void%> not allowed "
+		"in %<register%> pragma");
+      return;
+    }
+
   TREE_USED (ptr) = true;
 #ifdef DECL_READ_P
   if (DECL_P (ptr))

+ 5 - 1
gcc-plugin/tests/register-errors.c

@@ -1,5 +1,5 @@
 /* GCC-StarPU
-   Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
+   Copyright (C) 2011, 2012 Institut National de Recherche en Informatique et Automatique
 
    GCC-StarPU is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,6 +18,8 @@
 
 #undef NDEBUG
 
+extern void *void_pointer;
+
 int
 main (int argc, char *argv[])
 {
@@ -50,5 +52,7 @@ main (int argc, char *argv[])
   size_t ps = argc;
 #pragma starpu register p ps  /* No unused variable warning, please! */
 
+#pragma starpu register void_pointer 123 /* (error "not allowed") */
+
   return EXIT_SUCCESS;
 }