From f7750236cb3d9623c00d1dea6301eb691aad5197 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Fri, 10 Jul 2009 16:01:34 +0000 Subject: [PATCH] backport: re PR middle-end/40291 (ICE on unprototyped memcmp with long long last argument) 2009-07-10 Richard Guenther Backport from mainline 2009-05-29 Jakub Jelinek PR middle-end/40291 * builtins.c (expand_builtin_memcmp): Convert len to sizetype before expansion. * gcc.c-torture/compile/pr40291.c: New test. From-SVN: r149487 --- gcc/ChangeLog | 9 +++++++++ gcc/builtins.c | 2 +- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/gcc.c-torture/compile/pr40291.c | 7 +++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr40291.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 921b6c88566c..282148ea546f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2009-07-10 Richard Guenther + + Backport from mainline + 2009-05-29 Jakub Jelinek + + PR middle-end/40291 + * builtins.c (expand_builtin_memcmp): Convert len to sizetype + before expansion. + 2009-07-10 Richard Guenther Backport from mainline diff --git a/gcc/builtins.c b/gcc/builtins.c index d61651e77283..82bc24f84ba3 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -4119,7 +4119,7 @@ expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode) arg1_rtx = get_memory_rtx (arg1, len); arg2_rtx = get_memory_rtx (arg2, len); - arg3_rtx = expand_normal (len); + arg3_rtx = expand_normal (fold_convert (sizetype, len)); /* Set MEM_SIZE as appropriate. */ if (GET_CODE (arg3_rtx) == CONST_INT) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index de50754b7d68..b3cc101ee35b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2009-07-10 Richard Guenther + + Backport from mainline + 2009-05-29 Jakub Jelinek + + PR middle-end/40291 + * gcc.c-torture/compile/pr40291.c: New test. + 2009-07-10 Richard Guenther Backport from mainline diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40291.c b/gcc/testsuite/gcc.c-torture/compile/pr40291.c new file mode 100644 index 000000000000..d50bbee66080 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr40291.c @@ -0,0 +1,7 @@ +/* PR middle-end/40291 */ + +int +foo (void *x, char *y, unsigned long long z) +{ + return memcmp (x, y, z); +} -- 2.47.2