summaryrefslogtreecommitdiff
path: root/fixincludes/inclhack.def
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-03-24 23:20:15 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-03-24 23:20:15 +0000
commit5aee6890a77c463cb318485a6bc95d8891793f03 (patch)
tree606a7efe5f95105e61a8c817193b4c9725cfbe39 /fixincludes/inclhack.def
parent6a99666adef759d3d32f4f56ed4e9f63f0848fbd (diff)
downloadgcc-5aee6890a77c463cb318485a6bc95d8891793f03.tar.gz
fixincludes:
* inclhack.def (glibc_strncpy): New fix. * fixincl.x: Regenerate. * tests/base/bits/string2.h: Update. gcc/testsuite: * gcc.dg/strncpy-fix-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157717 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'fixincludes/inclhack.def')
-rw-r--r--fixincludes/inclhack.def22
1 files changed, 22 insertions, 0 deletions
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index e34e3902fda..27ed40934be 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1598,6 +1598,28 @@ fix = {
};
+/* Some versions of glibc have a version of bits/string2.h that
+ produces "value computed is not used" warnings from strncpy; fix
+ this definition by using __builtin_strncpy instead as in newer
+ versions. */
+fix = {
+ hackname = glibc_strncpy;
+ files = bits/string2.h;
+ bypass = "__builtin_strncpy";
+ c_fix = format;
+ c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
+ c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
+ test_text = <<-EOT
+ # define strncpy(dest, src, n) \
+ (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
+ ? (strlen (src) + 1 >= ((size_t) (n)) \\
+ ? (char *) memcpy (dest, src, n) \\
+ : strncpy (dest, src, n)) \\
+ : strncpy (dest, src, n)))
+ EOT;
+
+};
+
/* glibc's tgmath.h relies on an expression that is not an integer
constant expression being treated as it was by GCC 4.4 and
earlier. */