Ver código fonte

gcc: Allow use of a PARM_DECL as the argument of pragma `acquire'.

* gcc-plugin/src/starpu.c (handle_pragma_acquire): Check whether the
  chain of ARGS is null, not that of VAR.  This fixes a bug whereby
  non-terminal PARM_DECLs would be wrongfully flagged as junk.
  Reported by Ludovic Stordeur <ludovic.stordeur@inria.fr>.

* gcc-plugin/tests/acquire-errors.c (main): Add test for "junk after
  pragma".

* gcc-plugin/tests/acquire.c (foo): New function.
  (main): Use it; increment the expected DATA_ACQUIRE_CALLS.
Ludovic Courtès 13 anos atrás
pai
commit
7c06d77699

+ 1 - 1
gcc-plugin/src/starpu.c

@@ -892,7 +892,7 @@ handle_pragma_acquire (struct cpp_reader *reader)
       error_at (loc, "%qE is neither a pointer nor an array", var);
       return;
     }
-  else if (TREE_CHAIN (var) != NULL_TREE)
+  else if (TREE_CHAIN (args) != NULL_TREE)
     error_at (loc, "junk after %<starpu acquire%> pragma");
 
   /* If VAR is an array, take its address.  */

+ 3 - 1
gcc-plugin/tests/acquire-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
@@ -36,6 +36,8 @@ main (int argc, char *argv[])
 #pragma starpu acquire y
 #pragma starpu acquire x
 
+#pragma starpu acquire x z			  /* (error "junk after") */
+
   /* XXX: Uncomment below when this is supported.  */
 #if 0
 #pragma starpu acquire z /* error "not registered" */

+ 11 - 1
gcc-plugin/tests/acquire.c

@@ -20,6 +20,14 @@
 
 #include <mocks.h>
 
+static void
+foo (char *x, int foo)
+{
+  expected_acquire_arguments.pointer = x;
+#pragma starpu acquire x
+}
+
+
 int
 main (int argc, char *argv[])
 {
@@ -44,8 +52,10 @@ main (int argc, char *argv[])
   expected_acquire_arguments.pointer = z;
 #pragma starpu acquire z
 
+  foo (z, 345);
+
   assert (data_register_calls == 2);
-  assert (data_acquire_calls == 2);
+  assert (data_acquire_calls == 3);
 
   return EXIT_SUCCESS;
 }