From 1b17b99482291691b4179696e65fb42e1831e3ce Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 4 Jun 2018 18:03:24 +0000 Subject: [PATCH] re PR middle-end/85955 (ICE in fold_convert_loc, at fold-const.c:2408) 2018-06-04 Richard Biener PR tree-optimization/85955 * builtins.c (fold_builtin_sincos): Convert pointers to destination to appropriate type before dereferencing. * gcc.dg/pr85955.c: New testcase. From-SVN: r261165 --- gcc/ChangeLog | 6 ++++++ gcc/builtins.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr85955.c | 15 +++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr85955.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6f3e6543b8f..fda150a0426 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-06-04 Richard Biener + + PR tree-optimization/85955 + * builtins.c (fold_builtin_sincos): Convert pointers to + destination to appropriate type before dereferencing. + 2018-06-04 Segher Boessenkool * config/rs6000/rs6000.md (abs2 for FLOAT128): Handle IFmode. diff --git a/gcc/builtins.c b/gcc/builtins.c index c96ac38e8e9..d4150d877dd 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8266,6 +8266,9 @@ fold_builtin_sincos (location_t loc, call = builtin_save_expr (call); } + tree ptype = build_pointer_type (type); + arg1 = fold_convert (ptype, arg1); + arg2 = fold_convert (ptype, arg2); return build2 (COMPOUND_EXPR, void_type_node, build2 (MODIFY_EXPR, void_type_node, build_fold_indirect_ref_loc (loc, arg1), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e27cf415b70..821e08865fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-06-04 Richard Biener + + PR tree-optimization/85955 + * gcc.dg/pr85955.c: New testcase. + 2018-06-04 Steven G. Kargl PR fortran/85981 diff --git a/gcc/testsuite/gcc.dg/pr85955.c b/gcc/testsuite/gcc.dg/pr85955.c new file mode 100644 index 00000000000..7f67f62dce6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr85955.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -w" } */ + +extern void sincos(double x, double *sinx, double *cosx); +void apply(void (*f)(double, double *, double *), + double x, double *sinx, double *cosx) +{ + f(x, sinx, cosx); + return; +} +void apply_sincos(double x, double **sinx, double **cosx) +{ + apply(sincos, x, sinx, cosx); + return; +} -- 2.30.2