OSDN Git Service

gcc/
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Feb 2005 00:09:40 +0000 (00:09 +0000)
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Feb 2005 00:09:40 +0000 (00:09 +0000)
        PR c/19333
        * c-decl.c (start_decl): Do not warn about arrays of elements with
        an incomplete type here.
        (grokdeclarator): Do it here by making a pedwarn an error.
        * c-typeck.c (push_init_level): If there were previous errors with
        the constructor type, do not warn about braces for initializers.
        (process_init_element): Likewise for excess initializer elements.

testsuite/
        PR c/19333
        * testsuite/gcc.c-torture/compile/20011130-1.c: Reorder to make
        the test case valid.
        * testsuite/gcc.dg/20030815-1.c: Remove invalid tests.
        * testsuite/gcc.dg/array-7.c: Adjust expected result.
        * testsuite/gcc.dg/pr18596-3.c: Likewise.
        * testsuite/gcc.dg/noncompile/20000901-1.c: Likewise.
        * testsuite/gcc.dg/noncompile/init-2.c: Likewise.
        * testsuite/gcc.dg/noncompile/init-4.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94505 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20011130-1.c
gcc/testsuite/gcc.dg/20030815-1.c
gcc/testsuite/gcc.dg/array-7.c
gcc/testsuite/gcc.dg/noncompile/20000901-1.c
gcc/testsuite/gcc.dg/noncompile/init-2.c
gcc/testsuite/gcc.dg/noncompile/init-4.c
gcc/testsuite/gcc.dg/pr18596-3.c

index e58b0ab..7275dec 100644 (file)
@@ -1,3 +1,13 @@
+2005-01-31  Steven Bosscher  <stevenb@suse.de>
+
+       PR c/19333
+       * c-decl.c (start_decl): Do not warn about arrays of elements with
+       an incomplete type here.
+       (grokdeclarator): Do it here by making a pedwarn an error.
+       * c-typeck.c (push_init_level): If there were previous errors with
+       the constructor type, do not warn about braces for initializers.
+       (process_init_element): Likewise for excess initializer elements.
+
 2005-01-31  Kazu Hirata  <kazu@cs.umass.edu>
 
        * cse.c (delete_trivially_dead_insn): Don't iterate.
index efb17e8..ad76f23 100644 (file)
@@ -3039,11 +3039,6 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
            error ("variable %qD has initializer but incomplete type", decl);
            initialized = 0;
          }
-       else if (!COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
-         {
-           error ("elements of array %qD have incomplete type", decl);
-           initialized = 0;
-         }
        else if (C_DECL_VARIABLE_SIZE (decl))
          {
            /* Although C99 is unclear about whether incomplete arrays
@@ -4148,11 +4143,14 @@ grokdeclarator (const struct c_declarator *declarator,
                itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
              }
 
-           /* If pedantic, complain about arrays of incomplete types.  */
-           if (pedantic && !COMPLETE_TYPE_P (type))
-             pedwarn ("array type has incomplete element type");
-
-           type = build_array_type (type, itype);
+            /* Complain about arrays of incomplete types.  */
+           if (!COMPLETE_TYPE_P (type))
+             {
+               error ("array type has incomplete element type");
+               type = error_mark_node;
+             }
+           else
+             type = build_array_type (type, itype);
 
            if (size_varies)
              C_TYPE_VARIABLE_SIZE (type) = 1;
index fed17f2..54f9714 100644 (file)
@@ -4878,7 +4878,8 @@ push_init_level (int implicit)
     }
   else
     {
-      warning_init ("braces around scalar initializer");
+      if (constructor_type != error_mark_node)
+       warning_init ("braces around scalar initializer");
       constructor_fields = constructor_type;
       constructor_unfilled_fields = constructor_type;
     }
@@ -6240,7 +6241,8 @@ process_init_element (struct c_expr value)
 
       /* Handle the sole element allowed in a braced initializer
         for a scalar variable.  */
-      else if (constructor_fields == 0)
+      else if (constructor_type != error_mark_node
+              && constructor_fields == 0)
        {
          pedwarn_init ("excess elements in scalar initializer");
          break;
index cc1f201..258e232 100644 (file)
@@ -1,3 +1,15 @@
+2005-01-31  Steven Bosscher  <stevenb@suse.de>
+
+       PR c/19333
+       * testsuite/gcc.c-torture/compile/20011130-1.c: Reorder to make
+       the test case valid.
+       * testsuite/gcc.dg/20030815-1.c: Remove invalid tests.
+       * testsuite/gcc.dg/array-7.c: Adjust expected result.
+       * testsuite/gcc.dg/pr18596-3.c: Likewise.
+       * testsuite/gcc.dg/noncompile/20000901-1.c: Likewise.
+       * testsuite/gcc.dg/noncompile/init-2.c: Likewise.
+       * testsuite/gcc.dg/noncompile/init-4.c: Likewise.
+
 2005-01-31  Dale Johannesen  <dalej@apple.com>
 
        * g++.dg/opt/pr19650.C:  New test.
        * gfortran.dg/write_to_null.f90: New test.
 
 2005-01-14  Andrew Pinski  <pinskia@physics.uc.edu>
-            John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+           John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR other/19328
        * gcc.dg/attr-alias-2.c: dg-require-alias takes an
 
 2005-01-06  Mark Mitchell  <mark@codesourcery.com>
 
-        PR c++/19244
+       PR c++/19244
        * g++.dg/parser/ctor2.C: New test.
 
 2004-01-06  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 2004-12-30  Alexander Malmberg  <alexander@malmberg.org>
            Ziemowit Laski  <zlaski@apple.com>
 
-        PR objc/18971
+       PR objc/18971
        * objc.dg/encode-5.m: New test.
 
 2004-12-29  Richard Henderson  <rth@redhat.com>
        * cpp/inc/pragma-once-1a.h: Likewise.
 
 2004-12-15  Bud Davis  <bdavis9659@comcast.net>
-            Steven G. Kargl  <kargls@comcast.net>
+           Steven G. Kargl  <kargls@comcast.net>
 
        PR fortran/17597
        * gfortran.dg/list_read_3.f90: New test.
 
 2004-11-30  Loren James Rittle  <ljrittle@acm.org>
 
-        * g++.old-deja/g++.eh/badalloc1.C (arena_size): Bump up to 262144
+       * g++.old-deja/g++.eh/badalloc1.C (arena_size): Bump up to 262144
        to support new requirements on FreeBSD 5.
 
 2004-11-30  Devang Patel  <dpatel@apple.com>
 
 2004-11-28  Bud Davis  <bdavis9659@comcast.net>
 
-        * gfortran.dg/direct_io_2.f90: New test.
+       * gfortran.dg/direct_io_2.f90: New test.
 
 2004-11-28  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * gcc.dg/vect/vect.exp (sparc*-*-*): Fix a couple of nits.
 
 2004-11-19  Mark Mitchell  <mark@codesourcery.com>
-            Joseph Myers  <joseph@codesourcery.com>
+           Joseph Myers  <joseph@codesourcery.com>
 
        * lib/target-supports.exp (check_visibility_available): Really
        test the compiler.
        * gcc.dg/ppc-mov-1.c: Ditto
 
 2004-11-18  Daniel Jacobowitz  <dan@codesourcery.com>
-            Mark Mitchell  <mark@codesourcery.com>
+           Mark Mitchell  <mark@codesourcery.com>
 
        * testsuite/gcc.dg/pragma-init-fini-2.c: New test.
 
 2004-11-17  Janis Johnson  <janis187@us.ibm.com>
-            Aldy Hernandez  <aldyh@redhat.com>
+           Aldy Hernandez  <aldyh@redhat.com>
 
        * lib/target-supports.exp (check_effective_target_vect_int): New
        (check_effective_target_vect_float): New
        * gcc.dg/vect/pr18400.c: New test.
 
 2004-11-14  Dorit Naishlos  <dorit@il.ibm.com>
-            Andrew Pinski  <pinskia@physics.uc.edu>
+           Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR tree-opt/18425
        * gcc.dg/vect/pr18425.c: New test.
 
 2004-11-10  Fariborz Jahanian <fjahanian@apple.com>
 
-        * gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c:
+       * gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c:
        New test for PR tree-optimization/17892.
 
 2004-11-09  Mark Mitchell  <mark@codesourcery.com>
 2004-10-14  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR middle-end/16567
-        * gcc.c-torture/compile/nested-1.c: New test.
+       * gcc.c-torture/compile/nested-1.c: New test.
 
 2004-10-14  Dorit Naishlos  <dorit@il.ibm.com>
 
index 82ff042..55d4af4 100644 (file)
@@ -1,5 +1,5 @@
-extern struct S x[];
 struct S { int i; };
+extern struct S x[];
 char *bar (const struct S *);
 void foo (void)
 {
index fe1e7b4..7bf21bd 100644 (file)
@@ -4,10 +4,6 @@
 /* { dg-do compile } */
 /* { dg-options "" } */
 
-typedef struct a A[1];
-typedef struct b B[1];
-typedef struct c C[1];
-typedef struct d D[1];
 typedef struct a E;
 typedef struct b F;
 typedef struct c G;
@@ -16,10 +12,6 @@ struct a { int a; };
 struct c { int c; };
 struct d { int d; };
 struct b { int b; };
-int sa = sizeof (A);
-int sb = sizeof (B);
-int sc = sizeof (C);
-int sd = sizeof (D);
 int se = sizeof (E);
 int sf = sizeof (F);
 int sg = sizeof (G);
index b32d4ea..9e70b26 100644 (file)
@@ -11,4 +11,4 @@ f (void)
   struct foo { int a; int b; };
 }
 
-struct foo array[5]; /* { dg-error "storage size" } */
+struct foo array[5]; /* { dg-error "array type has incomplete element type" } */
index 94df14a..ef5c3cb 100644 (file)
@@ -1 +1 @@
-struct foo bar[] = { {"baz"} }; /* { dg-error "have incomplete type|excess elements|near|assumed|storage size" } */
+struct foo bar[] = { {"baz"} }; /* { dg-error "array type has incomplete element type" } */
index 09916be..b069902 100644 (file)
@@ -1 +1 @@
-int d[][] = { {1}, {2}, {3} }; /* { dg-error "incomplete type|storage size|one element" } */
+int d[][] = { {1}, {2}, {3} }; /* { dg-error "incomplete element type" } */
index 2d8bef3..782251f 100644 (file)
@@ -1,2 +1 @@
-struct a { char *b; } c[D] /* { dg-error "undeclared" } */
-  = { { "" } } ;  /* { dg-warning "braces around scalar initializer|near" } */
+struct a { char *b; } c[D]; /* { dg-error "undeclared" } */
index be17e7c..c2a04f8 100644 (file)
@@ -10,5 +10,3 @@ int foo ()
   static int j () = /* { dg-error "invalid storage class" } */
        { 0, 0.0 };
 }
-/* { dg-warning "excess elements" "" { target *-*-* } 11 } */
-/* { dg-warning "near initialization" "" { target *-*-* } 11 } */