Add support for the weak function attribute
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 19e2ba7..83c8c21 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -518,6 +518,8 @@
return "used";
case GCC_JIT_FN_ATTRIBUTE_VISIBILITY:
return "visibility";
+ case GCC_JIT_FN_ATTRIBUTE_WEAK:
+ return "weak";
}
return NULL;
}
@@ -649,10 +651,15 @@
tree ident = get_identifier (fn_attribute_to_string (attr));
/* See handle_used_attribute in gcc/c-family/c-attribs.cc. */
- if (attr == GCC_JIT_FN_ATTRIBUTE_USED)
+ switch (attr)
{
- TREE_USED (fndecl) = 1;
- DECL_PRESERVE_P (fndecl) = 1;
+ case GCC_JIT_FN_ATTRIBUTE_USED:
+ TREE_USED (fndecl) = 1;
+ DECL_PRESERVE_P (fndecl) = 1;
+ break;
+ case GCC_JIT_FN_ATTRIBUTE_WEAK:
+ DECL_WEAK (fndecl) = 1;
+ break;
}
DECL_ATTRIBUTES (fndecl) =
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index 84188f3..1fd5c87 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -2071,6 +2071,7 @@
GCC_JIT_FN_ATTRIBUTE_TARGET,
GCC_JIT_FN_ATTRIBUTE_USED,
GCC_JIT_FN_ATTRIBUTE_VISIBILITY,
+ GCC_JIT_FN_ATTRIBUTE_WEAK,
};
/* Add an attribute to a function. */