We ICEd on the following test while warning for -Wtraditional-conversion because at that point VAL had been turned into error_mark_node because we require a complete type when converting arguments. Fixed by checking for error_mark_node first so that we don't try to access it later with TYPE_PRECISION and similar.
Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-02-22 Marek Polacek <pola...@redhat.com> PR c/79662 * c-typeck.c (convert_arguments): Handle error_mark_node. * gcc.dg/enum-incomplete-4.c: New test. diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index ed8ffe4..8c2c561 100644 --- gcc/c/c-typeck.c +++ gcc/c/c-typeck.c @@ -3437,15 +3437,18 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist, /* Detect integer changing in width or signedness. These warnings are only activated with -Wtraditional-conversion, not with -Wtraditional. */ - else if (warn_traditional_conversion && INTEGRAL_TYPE_P (type) + else if (warn_traditional_conversion + && INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (valtype)) { tree would_have_been = default_conversion (val); tree type1 = TREE_TYPE (would_have_been); - if (TREE_CODE (type) == ENUMERAL_TYPE - && (TYPE_MAIN_VARIANT (type) - == TYPE_MAIN_VARIANT (valtype))) + if (val == error_mark_node) + /* VAL could have been of incomplete type. */; + else if (TREE_CODE (type) == ENUMERAL_TYPE + && (TYPE_MAIN_VARIANT (type) + == TYPE_MAIN_VARIANT (valtype))) /* No warning if function asks for enum and the actual arg is that enum type. */ ; diff --git gcc/testsuite/gcc.dg/enum-incomplete-4.c gcc/testsuite/gcc.dg/enum-incomplete-4.c index e69de29..03fb9f4 100644 --- gcc/testsuite/gcc.dg/enum-incomplete-4.c +++ gcc/testsuite/gcc.dg/enum-incomplete-4.c @@ -0,0 +1,11 @@ +/* PR c/79662 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +extern enum e ve; + +int +f0 (int i) +{ + f0 (ve); /* { dg-error "incomplete" } */ +} Marek