Commit 13c5654f by Martin Sebor

builtins.c (check_sizes, [...]): Fix typos introduced during merge conflict resolution.

gcc/ChangeLog:
	* builtins.c (check_sizes, check_strncat_sizes): Fix typos
	introduced during merge	conflict resolution.
	(expand_builtin_strncat): Same.

gcc/testsuite/ChangeLog:
	* gcc.dg/pr78138.c: Adjust text of expected diagnostics.
	* gcc.dg/pr79214.c: Same.
	* gcc.dg/pr79222.c: Same.
	* gcc.dg/pr79223.c: Same.
	* gcc.dg/tree-ssa/builtins-folding-gimple-ub.c: Expect warnings.

From-SVN: r247652
parent 2d66253d
...@@ -3147,12 +3147,12 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize) ...@@ -3147,12 +3147,12 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize)
if (range[0] == range[1]) if (range[0] == range[1])
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: specified size %E " "%K%qD specified size %E "
"exceeds maximum object size %E", "exceeds maximum object size %E",
exp, get_callee_fndecl (exp), range[0], maxobjsize); exp, get_callee_fndecl (exp), range[0], maxobjsize);
else else
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: specified size between %E and %E " "%K%qD specified size between %E and %E "
"exceeds maximum object size %E", "exceeds maximum object size %E",
exp, get_callee_fndecl (exp), exp, get_callee_fndecl (exp),
range[0], range[1], maxobjsize); range[0], range[1], maxobjsize);
...@@ -3178,14 +3178,14 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize) ...@@ -3178,14 +3178,14 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize)
and a source of unknown length. The call will write and a source of unknown length. The call will write
at least one byte past the end of the destination. */ at least one byte past the end of the destination. */
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: writing %E or more bytes into a region " "%K%qD writing %E or more bytes into a region "
"of size %E overflows the destination", "of size %E overflows the destination",
exp, get_callee_fndecl (exp), range[0], objsize); exp, get_callee_fndecl (exp), range[0], objsize);
} }
else if (tree_int_cst_equal (range[0], range[1])) else if (tree_int_cst_equal (range[0], range[1]))
warning_at (loc, opt, warning_at (loc, opt,
(integer_onep (range[0]) (integer_onep (range[0])
? G_("%K%qD: writing %E byte into a region " ? G_("%K%qD writing %E byte into a region "
"of size %E overflows the destination") "of size %E overflows the destination")
: G_("%K%qD writing %E bytes into a region " : G_("%K%qD writing %E bytes into a region "
"of size %E overflows the destination")), "of size %E overflows the destination")),
...@@ -3194,13 +3194,13 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize) ...@@ -3194,13 +3194,13 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize)
{ {
/* Avoid printing the upper bound if it's invalid. */ /* Avoid printing the upper bound if it's invalid. */
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: writing %E or more bytes into a region " "%K%qD writing %E or more bytes into a region "
"of size %E overflows the destination", "of size %E overflows the destination",
exp, get_callee_fndecl (exp), range[0], objsize); exp, get_callee_fndecl (exp), range[0], objsize);
} }
else else
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: writing between %E and %E bytes into " "%K%qD writing between %E and %E bytes into "
"a region of size %E overflows the destination", "a region of size %E overflows the destination",
exp, get_callee_fndecl (exp), range[0], range[1], exp, get_callee_fndecl (exp), range[0], range[1],
objsize); objsize);
...@@ -3229,13 +3229,13 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize) ...@@ -3229,13 +3229,13 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize)
is greater than the object size if both are big. */ is greater than the object size if both are big. */
if (range[0] == range[1]) if (range[0] == range[1])
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: specified bound %E " "%K%qD specified bound %E "
"exceeds maximum object size %E", "exceeds maximum object size %E",
exp, get_callee_fndecl (exp), exp, get_callee_fndecl (exp),
range[0], maxobjsize); range[0], maxobjsize);
else else
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: specified bound between %E and %E " "%K%qD specified bound between %E and %E "
"exceeds maximum object size %E", "exceeds maximum object size %E",
exp, get_callee_fndecl (exp), exp, get_callee_fndecl (exp),
range[0], range[1], maxobjsize); range[0], range[1], maxobjsize);
...@@ -3247,13 +3247,13 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize) ...@@ -3247,13 +3247,13 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize)
{ {
if (tree_int_cst_equal (range[0], range[1])) if (tree_int_cst_equal (range[0], range[1]))
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: specified bound %E " "%K%qD specified bound %E "
"exceeds destination size %E", "exceeds destination size %E",
exp, get_callee_fndecl (exp), exp, get_callee_fndecl (exp),
range[0], objsize); range[0], objsize);
else else
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: specified bound between %E and %E " "%K%qD specified bound between %E and %E "
"exceeds destination size %E", "exceeds destination size %E",
exp, get_callee_fndecl (exp), exp, get_callee_fndecl (exp),
range[0], range[1], objsize); range[0], range[1], objsize);
...@@ -3272,20 +3272,20 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize) ...@@ -3272,20 +3272,20 @@ check_sizes (int opt, tree exp, tree size, tree maxlen, tree src, tree objsize)
if (tree_int_cst_equal (range[0], range[1])) if (tree_int_cst_equal (range[0], range[1]))
warning_at (loc, opt, warning_at (loc, opt,
(tree_int_cst_equal (range[0], integer_one_node) (tree_int_cst_equal (range[0], integer_one_node)
? G_("%K%qD: reading %E byte from a region of size %E") ? G_("%K%qD reading %E byte from a region of size %E")
: G_("%K%qD reading %E bytes from a region of size %E")), : G_("%K%qD reading %E bytes from a region of size %E")),
exp, get_callee_fndecl (exp), range[0], slen); exp, get_callee_fndecl (exp), range[0], slen);
else if (tree_int_cst_sign_bit (range[1])) else if (tree_int_cst_sign_bit (range[1]))
{ {
/* Avoid printing the upper bound if it's invalid. */ /* Avoid printing the upper bound if it's invalid. */
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: reading %E or more bytes from a region " "%K%qD reading %E or more bytes from a region "
"of size %E", "of size %E",
exp, get_callee_fndecl (exp), range[0], slen); exp, get_callee_fndecl (exp), range[0], slen);
} }
else else
warning_at (loc, opt, warning_at (loc, opt,
"%K%qD: reading between %E and %E bytes from a region " "%K%qD reading between %E and %E bytes from a region "
"of size %E", "of size %E",
exp, get_callee_fndecl (exp), range[0], range[1], slen); exp, get_callee_fndecl (exp), range[0], range[1], slen);
return false; return false;
...@@ -3876,7 +3876,7 @@ check_strncat_sizes (tree exp, tree objsize) ...@@ -3876,7 +3876,7 @@ check_strncat_sizes (tree exp, tree objsize)
loc = expansion_point_location_if_in_system_header (loc); loc = expansion_point_location_if_in_system_header (loc);
warning_at (loc, OPT_Wstringop_overflow_, warning_at (loc, OPT_Wstringop_overflow_,
"%K%qD: specified bound %E equals destination size", "%K%qD specified bound %E equals destination size",
exp, get_callee_fndecl (exp), maxlen); exp, get_callee_fndecl (exp), maxlen);
return false; return false;
...@@ -3942,7 +3942,7 @@ expand_builtin_strncat (tree exp, rtx) ...@@ -3942,7 +3942,7 @@ expand_builtin_strncat (tree exp, rtx)
loc = expansion_point_location_if_in_system_header (loc); loc = expansion_point_location_if_in_system_header (loc);
warning_at (loc, OPT_Wstringop_overflow_, warning_at (loc, OPT_Wstringop_overflow_,
"%K%qD: specified bound %E equals destination size", "%K%qD specified bound %E equals destination size",
exp, get_callee_fndecl (exp), maxlen); exp, get_callee_fndecl (exp), maxlen);
return NULL_RTX; return NULL_RTX;
......
...@@ -12,7 +12,7 @@ extern char* strcpy (char*, const char*); ...@@ -12,7 +12,7 @@ extern char* strcpy (char*, const char*);
void f (int i, int j) void f (int i, int j)
{ {
strcpy (d, j ? "12345" : "123456"); /* { dg-warning ".strcpy.: writing between 6 and 7 bytes into a region of size 5 " } */ strcpy (d, j ? "12345" : "123456"); /* { dg-warning ".strcpy. writing between 6 and 7 bytes into a region of size 5 " } */
} }
void g (void *p) void g (void *p)
......
...@@ -22,67 +22,67 @@ size_t range (void) ...@@ -22,67 +22,67 @@ size_t range (void)
void test_bzero (void) void test_bzero (void)
{ {
bzero (d, range ()); /* { dg-warning ".__builtin_bzero. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ bzero (d, range ()); /* { dg-warning ".__builtin_bzero. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
void test_memcpy (void) void test_memcpy (void)
{ {
memcpy (d, s, range ()); /* { dg-warning ".__builtin_memcpy. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ memcpy (d, s, range ()); /* { dg-warning ".__builtin_memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
void test_memmove (void) void test_memmove (void)
{ {
memmove (d, d + 1, range ()); /* { dg-warning ".__builtin_memmove. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ memmove (d, d + 1, range ()); /* { dg-warning ".__builtin_memmove. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
void test_mempcpy (void) void test_mempcpy (void)
{ {
mempcpy (d, s, range ()); /* { dg-warning ".__builtin_mempcpy. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ mempcpy (d, s, range ()); /* { dg-warning ".__builtin_mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
void test_memset (int n) void test_memset (int n)
{ {
memset (d, n, range ()); /* { dg-warning ".__builtin_memset. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ memset (d, n, range ()); /* { dg-warning ".__builtin_memset. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
void test_strcat (int i) void test_strcat (int i)
{ {
const char *s = i < 0 ? "123" : "4567"; const char *s = i < 0 ? "123" : "4567";
strcat (d, s); /* { dg-warning ".__builtin_strcat. writing 4 bytes into a region of size 3 overflows the destination" } */ strcat (d, s); /* { dg-warning ".__builtin_strcat. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
} }
char* test_stpcpy (int i) char* test_stpcpy (int i)
{ {
const char *s = i < 0 ? "123" : "4567"; const char *s = i < 0 ? "123" : "4567";
return stpcpy (d, s); /* { dg-warning ".__builtin_stpcpy. writing 4 bytes into a region of size 3 overflows the destination" } */ return stpcpy (d, s); /* { dg-warning ".__builtin_stpcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
} }
char* test_stpncpy (int i) char* test_stpncpy (int i)
{ {
const char *s = i < 0 ? "123" : "4567"; const char *s = i < 0 ? "123" : "4567";
return stpncpy (d, s, range ()); /* { dg-warning ".__builtin_stpncpy. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ return stpncpy (d, s, range ()); /* { dg-warning ".__builtin_stpncpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
char* test_strcpy (int i) char* test_strcpy (int i)
{ {
const char *s = i < 0 ? "123" : "4567"; const char *s = i < 0 ? "123" : "4567";
return strcpy (d, s); /* { dg-warning ".__builtin_strcpy. writing 4 bytes into a region of size 3 overflows the destination" } */ return strcpy (d, s); /* { dg-warning ".__builtin_strcpy. writing between 4 and 5 bytes into a region of size 3 overflows the destination" } */
} }
char* test_strncpy (int i) char* test_strncpy (int i)
{ {
const char *s = i < 0 ? "123" : "4567"; const char *s = i < 0 ? "123" : "4567";
return strncpy (d, s, range ()); /* { dg-warning ".__builtin_strncpy. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ return strncpy (d, s, range ()); /* { dg-warning ".__builtin_strncpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
char* test_strncat (int i) char* test_strncat (int i)
{ {
const char *s = i < 0 ? "123" : "4567"; const char *s = i < 0 ? "123" : "4567";
return strncat (d, s, range ()); /* { dg-warning ".__builtin_strncat.: specified bound between 4 and \[0-9\]+" } */ return strncat (d, s, range ()); /* { dg-warning ".__builtin_strncat. specified bound between 4 and \[0-9\]+" } */
} }
...@@ -9,5 +9,5 @@ char d[3]; ...@@ -9,5 +9,5 @@ char d[3];
char* f (int i) char* f (int i)
{ {
const char *s = i < 0 ? "01234567" : "9876543210"; const char *s = i < 0 ? "01234567" : "9876543210";
return stpcpy (d, s); /* { dg-warning ".stpcpy. writing 9 bytes into a region of size 3 overflows the destination" } */ return stpcpy (d, s); /* { dg-warning ".stpcpy. writing between 9 and 11 bytes into a region of size 3 overflows the destination" } */
} }
...@@ -23,15 +23,15 @@ size_t range (void) ...@@ -23,15 +23,15 @@ size_t range (void)
void test_memcpy (void) void test_memcpy (void)
{ {
memcpy (d, s, range ()); /* { dg-warning ".memcpy. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ memcpy (d, s, range ()); /* { dg-warning ".memcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
void test_mempcpy (void) void test_mempcpy (void)
{ {
mempcpy (d, s, range ()); /* { dg-warning ".mempcpy. writing between 4 and \[0-9\]+ bytes into a region of size 3 overflows the destination" } */ mempcpy (d, s, range ()); /* { dg-warning ".mempcpy. writing 4 or more bytes into a region of size 3 overflows the destination" } */
} }
void test_memmove (void) void test_memmove (void)
{ {
memmove (d + 1, d, range ()); /* { dg-warning ".memmove. writing between 4 and \[0-9\]+ bytes into a region of size 2 overflows the destination" } */ memmove (d + 1, d, range ()); /* { dg-warning ".memmove. writing 4 or more bytes into a region of size 2 overflows the destination" } */
} }
...@@ -13,9 +13,16 @@ main (void) ...@@ -13,9 +13,16 @@ main (void)
/* MEMCHR. */ /* MEMCHR. */
if (__builtin_memchr ("", 'x', 1000)) /* Not folded away. */ if (__builtin_memchr ("", 'x', 1000)) /* Not folded away. */
__builtin_abort (); {
/* { dg-warning "reading 1000 bytes from a region of size 1" "" { target *-*-* } .-2 } */
__builtin_abort ();
}
if (__builtin_memchr (foo1, 'x', 1000)) /* Not folded away. */ if (__builtin_memchr (foo1, 'x', 1000)) /* Not folded away. */
__builtin_abort (); {
/* { dg-warning "reading 1000 bytes from a region of size 1" "" { target *-*-* } .-2 } */
__builtin_abort ();
}
/* STRNCMP. */ /* STRNCMP. */
if (strncmp ("a", "b", -1)) /* { dg-warning "implicit declaration of function" } */ if (strncmp ("a", "b", -1)) /* { dg-warning "implicit declaration of function" } */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment