We ICEd on this testcase in do_warn_double_promotion because an invalid conversion had produced an error result type and accessing that via TYPE_MAIN_VARIANT crashes. Fixed in an obvious way.
Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-02-15 Marek Polacek <pola...@redhat.com> PR c/79515 * c-warn.c (do_warn_double_promotion): Don't warn if an invalid conversion has occured. * gcc.dg/dfp/pr79515.c: New. diff --git gcc/c-family/c-warn.c gcc/c-family/c-warn.c index 3c9077c..09c5760 100644 --- gcc/c-family/c-warn.c +++ gcc/c-family/c-warn.c @@ -1864,6 +1864,9 @@ do_warn_double_promotion (tree result_type, tree type1, tree type2, warn about it. */ if (c_inhibit_evaluation_warnings) return; + /* If an invalid conversion has occured, don't warn. */ + if (result_type == error_mark_node) + return; if (TYPE_MAIN_VARIANT (result_type) != double_type_node && TYPE_MAIN_VARIANT (result_type) != complex_double_type_node) return; diff --git gcc/testsuite/gcc.dg/dfp/pr79515.c gcc/testsuite/gcc.dg/dfp/pr79515.c index e69de29..6f6f09c 100644 --- gcc/testsuite/gcc.dg/dfp/pr79515.c +++ gcc/testsuite/gcc.dg/dfp/pr79515.c @@ -0,0 +1,13 @@ +/* PR c/79515 */ +/* { dg-do compile } */ +/* { dg-options "-Wdouble-promotion" } */ + +extern _Decimal64 x; +extern int i; + +void +foo (void) +{ + if (x <= 2.0) /* { dg-error "mix operands" } */ + i++; +} Marek