[backport from gcc-4.7/trunk ] gcc/ 2011-05-02 Simon Martin PR c/35445 * c-decl.c (finish_decl): Only create a composite if the types are compatible. gcc/testsuite/ 2011-05-02 Simon Martin PR c/35445 * gcc.dg/pr35445.c: New test. --- gcc-4.6.0/gcc/c-decl.c.~1~ 2011-03-20 02:55:25.000000000 +0100 +++ gcc-4.6.0/gcc/c-decl.c 2011-05-16 23:45:29.000000000 +0200 @@ -4246,7 +4246,7 @@ finish_decl (tree decl, location_t init_ b_ext = b_ext->shadowed; if (b_ext) { - if (b_ext->u.type) + if (b_ext->u.type && comptypes (b_ext->u.type, type)) b_ext->u.type = composite_type (b_ext->u.type, type); else b_ext->u.type = type; --- gcc-4.6.0/gcc/testsuite/gcc.dg/pr35445.c.~1~ 1970-01-01 01:00:00.000000000 +0100 +++ gcc-4.6.0/gcc/testsuite/gcc.dg/pr35445.c 2011-05-16 23:45:29.000000000 +0200 @@ -0,0 +1,6 @@ +/* PR c/35445 */ +/* { dg-do "compile" } */ + +extern int i; +extern int i; /* { dg-message "was here" } */ +int i[] = { 0 }; /* { dg-error "conflicting types" } */