summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/redecl-10.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-26 21:30:26 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-26 21:30:26 +0000
commit606a02e37d5fe4db6a2c5681e075a2bfc81c294f (patch)
tree73149f504f957d92e288572227263a1e93f7495d /gcc/testsuite/gcc.dg/redecl-10.c
parent8717605bddf703f04d36ffa38d357008cb3d0739 (diff)
downloadgcc-606a02e37d5fe4db6a2c5681e075a2bfc81c294f.tar.gz
PR c/13801
* c-decl.c (struct c_binding): Add type and inner_comp fields. (bind): Set type and inner_comp fields. (pop_scope): Restore type of decl to the correct type from an outer scope. Give error when popping file scope for incomplete arrays completed incompatibly with default initialization in an inner scope. (diagnose_mismatched_decls): Handle externs with initializers at block scope. (pushdecl): Set type of external declaration at block scope based only on the visible declarations. Save type when changing the type of a declaration. Merge an external declaration at block scope with a visible static declaration at file scope. (implicitly_declare): Give recycled old declaration the new type except for incompatible declarations of built-in functions, saving the old type. testsuite: * gcc.dg/redecl-3.c, gcc.dg/redecl-4.c, gcc.dg/redecl-6.c, gcc.dg/redecl-7.c, gcc.dg/redecl-8.c, gcc.dg/redecl-9.c, gcc.dg/redecl-10.c, gcc.dg/debug/redecl-1.c, gcc.dg/debug/redecl-2.c, gcc.dg/debug/redecl-3.c, gcc.dg/debug/redecl-4.c, gcc.dg/debug/redecl-5.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86636 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/redecl-10.c')
-rw-r--r--gcc/testsuite/gcc.dg/redecl-10.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/redecl-10.c b/gcc/testsuite/gcc.dg/redecl-10.c
new file mode 100644
index 00000000000..88d804e6cfd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/redecl-10.c
@@ -0,0 +1,34 @@
+/* Test for multiple declarations and composite types. Check we don't
+ ICE with nested initializers. */
+
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-g" } */
+
+static int w[];
+void
+f (void)
+{
+ extern int w[] = { 1, 2 }; /* { dg-error "has both" } */
+}
+
+int x[];
+void
+g (void)
+{
+ extern int x[] = { 3, 4, 5 }; /* { dg-error "has both" } */
+}
+
+static int y[];
+void
+h (void)
+{
+ extern int y[] = { 6 }; /* { dg-error "has both" } */
+}
+
+int z[];
+void
+i (void)
+{
+ extern int z[] = { 7 }; /* { dg-error "has both" } */
+}