From: Jakub Jelinek Date: Fri, 31 Aug 2012 19:00:59 +0000 (+0200) Subject: re PR c/54428 (ICE in gimplify_expr, at gimplify.c:7591) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d409320ca8b8a9e121e56a636084604b6089ea60;p=gcc.git re PR c/54428 (ICE in gimplify_expr, at gimplify.c:7591) PR c/54428 * c-convert.c (convert): Don't call fold_convert_loc if TYPE_MAIN_VARIANT of a COMPLEX_TYPE is the same, unless e is a COMPLEX_EXPR. Remove TYPE_MAIN_VARIANT check from COMPLEX_TYPE -> COMPLEX_TYPE conversion. * gcc.c-torture/compile/pr54428.c: New test. From-SVN: r190840 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 108c0d316f1..11f9be7b535 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2012-08-31 Jakub Jelinek + + PR c/54428 + * c-convert.c (convert): Don't call fold_convert_loc if + TYPE_MAIN_VARIANT of a COMPLEX_TYPE is the same, unless e + is a COMPLEX_EXPR. Remove TYPE_MAIN_VARIANT check from + COMPLEX_TYPE -> COMPLEX_TYPE conversion. + 2012-08-24 Jakub Jelinek PR c/54355 diff --git a/gcc/c/c-convert.c b/gcc/c/c-convert.c index f4583c549c9..48d73757653 100644 --- a/gcc/c/c-convert.c +++ b/gcc/c/c-convert.c @@ -1,6 +1,6 @@ /* Language-level data type conversion for GNU C. Copyright (C) 1987, 1988, 1991, 1998, 2002, 2003, 2004, 2005, 2007, 2008, - 2009, 2010 Free Software Foundation, Inc. + 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This file is part of GCC. @@ -92,7 +92,9 @@ convert (tree type, tree expr) STRIP_TYPE_NOPS (e); - if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr))) + if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr)) + && (TREE_CODE (TREE_TYPE (expr)) != COMPLEX_TYPE + || TREE_CODE (e) == COMPLEX_EXPR)) return fold_convert_loc (loc, type, expr); if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) return error_mark_node; @@ -135,24 +137,23 @@ convert (tree type, tree expr) but for the C FE c_save_expr needs to be called instead. */ if (TREE_CODE (TREE_TYPE (e)) == COMPLEX_TYPE) { - tree subtype = TREE_TYPE (type); - tree elt_type = TREE_TYPE (TREE_TYPE (e)); - - if (TYPE_MAIN_VARIANT (elt_type) != TYPE_MAIN_VARIANT (subtype) - && TREE_CODE (e) != COMPLEX_EXPR) + if (TREE_CODE (e) != COMPLEX_EXPR) { + tree subtype = TREE_TYPE (type); + tree elt_type = TREE_TYPE (TREE_TYPE (e)); + if (in_late_binary_op) e = save_expr (e); else e = c_save_expr (e); ret - = fold_build2 (COMPLEX_EXPR, type, - convert (subtype, - fold_build1 (REALPART_EXPR, - elt_type, e)), - convert (subtype, - fold_build1 (IMAGPART_EXPR, - elt_type, e))); + = fold_build2_loc (loc, COMPLEX_EXPR, type, + convert (subtype, + fold_build1 (REALPART_EXPR, + elt_type, e)), + convert (subtype, + fold_build1 (IMAGPART_EXPR, + elt_type, e))); goto maybe_fold; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2d3bf4dd61f..685c60dc460 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-08-31 Jakub Jelinek + + PR c/54428 + * gcc.c-torture/compile/pr54428.c: New test. + 2012-08-31 Ollie Wild PR c++/54197 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54428.c b/gcc/testsuite/gcc.c-torture/compile/pr54428.c new file mode 100644 index 00000000000..84a5dbd82bd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr54428.c @@ -0,0 +1,9 @@ +/* PR c/54428 */ + +typedef double _Complex C; + +C +foo (C x, C y, double z, C w) +{ + return y - z * __builtin_cpow (x, 75) * w; +}