We ICEd on this invalid testcase because build_array_ref was getting a decl with an incomplete type as an index, and default_conversion calls require_complete_type on it - and because it's not complete, it returns error_mark_node, and then we trip on an assert requiring it to be an integer type. Fixed by bailing out if default_conversion returns unusable expr.
Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-10-16 Marek Polacek <pola...@redhat.com> PR c/63549 * c-typeck.c (build_array_ref): Bail if the index in an incomplete type. * gcc.dg/pr63549.c: New test. diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index 5c0697a..1e971c1 100644 --- gcc/c/c-typeck.c +++ gcc/c/c-typeck.c @@ -2478,6 +2478,8 @@ build_array_ref (location_t loc, tree array, tree index) /* Apply default promotions *after* noticing character types. */ index = default_conversion (index); + if (index == error_mark_node) + return error_mark_node; gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE); diff --git gcc/testsuite/gcc.dg/pr63549.c gcc/testsuite/gcc.dg/pr63549.c index e69de29..c9b1718 100644 --- gcc/testsuite/gcc.dg/pr63549.c +++ gcc/testsuite/gcc.dg/pr63549.c @@ -0,0 +1,7 @@ +/* PR c/63549 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +enum E e; +int a[10]; +int i = a[e]; /* { dg-error "has an incomplete type" } */ Marek