This is a minor issue in the C FE, where it on an invalid code generated bogus
FUNCTION_DECL with ARRAY_TYPE as a type -- and gimplifier can't digest that.

I think the code in finish_decl, whereby we update the type of shadowed global
variables should not overwrite a type of totally unrelated decl.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2016-02-24  Marek Polacek  <pola...@redhat.com>

        PR c/69819
        * c-decl.c (finish_decl): Don't update the copy of the type of a
        different decl type.

        * gcc.dg/pr69819.c: New test.

diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index 8e332f8..298036a 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -4743,7 +4743,7 @@ finish_decl (tree decl, location_t init_loc, tree init,
              struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl));
              while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext))
                b_ext = b_ext->shadowed;
-             if (b_ext)
+             if (b_ext && TREE_CODE (decl) == TREE_CODE (b_ext->decl))
                {
                  if (b_ext->u.type && comptypes (b_ext->u.type, type))
                    b_ext->u.type = composite_type (b_ext->u.type, type);
diff --git gcc/testsuite/gcc.dg/pr69819.c gcc/testsuite/gcc.dg/pr69819.c
index e69de29..a9594dd 100644
--- gcc/testsuite/gcc.dg/pr69819.c
+++ gcc/testsuite/gcc.dg/pr69819.c
@@ -0,0 +1,5 @@
+/* PR c/69819 */
+/* { dg-do compile } */
+
+void foo () { }
+int foo[] = { 0 }; /* { dg-error ".foo. redeclared as different kind of 
symbol" } */

        Marek

Reply via email to