浏览代码

gcc: Use `builtin_decl_explicit' as defined in GCC 4.7.0.

* m4/gcc.m4 (STARPU_GCC_PLUGIN_SUPPORT): Check for
  `builtin_decl_explicit'.
* gcc-plugin/src/starpu-gcc-config.h.in (HAVE_DECL_BUILTIN_DECL_EXPLICIT):
  New macro.

* gcc-plugin/src/starpu.c (builtin_decl_explicit)[!HAVE_DECL_BUILTIN_DECL_EXPLICIT]:
  New function.
  Change all users of `built_in_decls' to use `builtin_decl_explicit'
  instead.
Ludovic Courtès 13 年之前
父节点
当前提交
0cf2504978
共有 3 个文件被更改,包括 23 次插入6 次删除
  1. 2 0
      gcc-plugin/src/starpu-gcc-config.h.in
  2. 18 5
      gcc-plugin/src/starpu.c
  3. 3 1
      m4/gcc.m4

+ 2 - 0
gcc-plugin/src/starpu-gcc-config.h.in

@@ -26,6 +26,8 @@
 
 #undef HAVE_DECL_BUILD_ZERO_CST
 
+#undef HAVE_DECL_BUILTIN_DECL_EXPLICIT
+
 #undef HAVE_C_FAMILY_C_COMMON_H
 #undef HAVE_C_COMMON_H
 

+ 18 - 5
gcc-plugin/src/starpu.c

@@ -177,6 +177,19 @@ build_zero_cst (tree type)
 
 #endif
 
+#if !HAVE_DECL_BUILTIN_DECL_EXPLICIT
+
+/* This function was introduced in GCC 4.7 as a replacement for the
+   `built_in_decls' array.  */
+
+static inline tree
+builtin_decl_explicit (enum built_in_function fncode)
+{
+  return built_in_decls[fncode];
+}
+
+#endif
+
 
 /* Helpers.  */
 
@@ -307,7 +320,7 @@ build_printf (const char *fmt, ...)
 
   va_start (args, fmt);
   vasprintf (&str, fmt, args);
-  call = build_call_expr (built_in_decls[BUILT_IN_PUTS], 1,
+  call = build_call_expr (builtin_decl_explicit (BUILT_IN_PUTS), 1,
 	 		  build_string_literal (strlen (str) + 1, str));
   free (str);
   va_end (args);
@@ -359,7 +372,7 @@ build_error_statements (location_t loc, tree error_var, const char *fmt, ...)
       tree error_code =
 	build1 (NEGATE_EXPR, TREE_TYPE (error_var), error_var);
       print =
-	build_call_expr (built_in_decls[BUILT_IN_PRINTF], 2,
+	build_call_expr (builtin_decl_explicit (BUILT_IN_PRINTF), 2,
 			 build_string_literal (strlen (fmt_long) + 1,
 					       fmt_long),
 			 build_call_expr (strerror_fn, 1, error_code));
@@ -372,7 +385,7 @@ build_error_statements (location_t loc, tree error_var, const char *fmt, ...)
 		xloc.file, xloc.line, str);
 
       print =
-	build_call_expr (built_in_decls[BUILT_IN_PUTS], 1,
+	build_call_expr (builtin_decl_explicit (BUILT_IN_PUTS), 1,
 			 build_string_literal (strlen (fmt_long) + 1,
 					       fmt_long));
     }
@@ -383,8 +396,8 @@ build_error_statements (location_t loc, tree error_var, const char *fmt, ...)
 
   tree stmts = NULL;
   append_to_statement_list (print, &stmts);
-  append_to_statement_list (build_call_expr (built_in_decls[BUILT_IN_ABORT],
-					     0),
+  append_to_statement_list (build_call_expr
+			    (builtin_decl_explicit (BUILT_IN_ABORT), 0),
 			    &stmts);
 
   return stmts;

+ 3 - 1
m4/gcc.m4

@@ -70,9 +70,11 @@ AC_DEFUN([STARPU_GCC_PLUGIN_SUPPORT], [
     dnl   build_call_expr_loc_vec   -- likewise
     dnl   build_array_ref           -- present but undeclared in 4.6.1
     dnl   build_zero_cst            -- not in GCC 4.5.x; appears in 4.6
+    dnl   builtin_decl_explicit     -- new in 4.7, replaces `built_in_decls'
     _STARPU_WITH_GCC_PLUGIN_API([
       AC_CHECK_DECLS([build_call_expr_loc_array, build_call_expr_loc_vec,
-                      build_array_ref, build_zero_cst],
+                      build_array_ref, build_zero_cst,
+		      builtin_decl_explicit],
         [], [], [#include <gcc-plugin.h>
 	         #include <tree.h>])