Commit 9a0cbb60 by Martin Sebor Committed by Martin Sebor

PR middle-end/89934 - ICE on a call with fewer arguments to strncpy declared without prototype

gcc/ChangeLog:

	PR middle-end/89934
	* gimple-ssa-warn-restrict.c (builtin_access::builtin_access): Bail
	out if the number of arguments is less than expected.

gcc/testsuite/ChangeLog:

	PR middle-end/89934
	* gcc.dg/Wrestrict-19.c: New test.
	* gcc.dg/Wrestrict-5.c: Add comment.  Remove unused code.

From-SVN: r270152
parent c2457887
2019-04-04 Martin Sebor <msebor@redhat.com>
PR middle-end/89934
* gimple-ssa-warn-restrict.c (builtin_access::builtin_access): Bail
out if the number of arguments is less than expected.
2019-04-04 Jeff Law <law@redhat.com> 2019-04-04 Jeff Law <law@redhat.com>
PR rtl-optimization/89399 PR rtl-optimization/89399
......
...@@ -730,6 +730,10 @@ builtin_access::builtin_access (gimple *call, builtin_memref &dst, ...@@ -730,6 +730,10 @@ builtin_access::builtin_access (gimple *call, builtin_memref &dst,
offset_int bounds[2] = { maxobjsize, maxobjsize }; offset_int bounds[2] = { maxobjsize, maxobjsize };
if (dstref->strbounded_p) if (dstref->strbounded_p)
{ {
unsigned nargs = gimple_call_num_args (call);
if (nargs <= sizeargno)
return;
tree size = gimple_call_arg (call, sizeargno); tree size = gimple_call_arg (call, sizeargno);
tree range[2]; tree range[2];
if (get_size_range (size, range, true)) if (get_size_range (size, range, true))
......
2019-04-04 Martin Sebor <msebor@redhat.com>
PR middle-end/89934
* gcc.dg/Wrestrict-19.c: New test.
* gcc.dg/Wrestrict-5.c: Add comment. Remove unused code.
2019-04-04 Jeff Law <law@redhat.com> 2019-04-04 Jeff Law <law@redhat.com>
PR rtl-optimization/89399 PR rtl-optimization/89399
......
/* PR middle-end/89934 - ICE on a call with fewer arguments to strncpy
declared without prototype
{ dg-do compile }
{ dg-options "-O2 -Wall" } */
typedef __SIZE_TYPE__ size_t;
char *strncpy ();
char* f0 (char *s)
{
return strncpy ();
}
char* f1 (char *s)
{
return strncpy (s);
}
char* f2 (char *s)
{
return strncpy (s, s + 1); /* ICE here. */
}
void f3 (char *s, size_t n, const char *t)
{
strncpy (s, n, t);
strncpy (n, s, t);
}
/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch]" }
{ dg-prune-output "\\\[-Wint-conversion]" } */
/* Test to verify that valid calls to common restrict-qualified built-in /* PR tree-optimization/83655 - ICE on an invalid call to memcpy declared
with no prototype
Test to verify that valid calls to common restrict-qualified built-in
functions declared with no prototype are checked for overlap, and that functions declared with no prototype are checked for overlap, and that
invalid calls are ignored. invalid calls are ignored.
{ dg-do compile } { dg-do compile }
{ dg-prune-output "conflicting types for built-in" }
{ dg-options "-O2 -Wrestrict" } */ { dg-options "-O2 -Wrestrict" } */
typedef __SIZE_TYPE__ size_t;
#if __cplusplus
extern "C" {
#define NO_PROTO ...
#else
#define NO_PROTO /* empty */
#endif
void* memcpy (); void* memcpy ();
char* strncpy (); char* strncpy ();
......
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