Переглянути джерело

gcc: Use `_Static_assert' when available.

* gcc-plugin/src/starpu.c (verify): New macro.
  (build_codelet_wrapper_definition): Use it.
Ludovic Courtès 13 роки тому
батько
коміт
7bdfff3fa3
1 змінених файлів з 9 додано та 1 видалено
  1. 9 1
      gcc-plugin/src/starpu.c

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

@@ -113,6 +113,13 @@ static bool heap_allocated_p (const_tree var_decl);
       gcc_assert ((var) != NULL_TREE && TREE_CODE (var) == FUNCTION_DECL); \
     }
 
+/* Compile-time assertions.  */
+
+#if STARPU_GNUC_PREREQ (4, 6)
+# define verify(cond, msg) _Static_assert ((cond), msg)
+#else
+# define verify(cond, msg) assert (cond);
+#endif
 
 
 /* Useful code backported from GCC 4.6.  */
@@ -1462,7 +1469,8 @@ build_codelet_wrapper_definition (tree task_impl)
 	       offset 0 of `struct starpu_vector_interface'.  The latter allows us
 	       to use a simple pointer dereference instead of expanding
 	       `STARPU_VECTOR_GET_PTR'.  */
-	    assert (offsetof (struct starpu_vector_interface, ptr) == 0);
+	    verify (offsetof (struct starpu_vector_interface, ptr) == 0,
+		    "unexpected vector interface layout");
 
 	    /* Compute `type *PTR = *(type **) VDESC;'.  */
 	    tree ptr = build1 (INDIRECT_REF,