This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[3.4] fix 11527


Problem is that some of the data that output_pending_init_elements
uses was getting cleared by the time it was invoked.  Also, the bits
in the middle that were doing the clearing were assuming they'd seen
everything, so they were in fact doing the wrong thing.

Ok for 3.4?


r~


	* c-typeck.c (pop_init_level): Emit pending init elements earlier
	rather than later.
	* gcc.dg/gnu89-init-3.c: New.

Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.272.2.5
diff -c -p -d -r1.272.2.5 c-typeck.c
*** c-typeck.c	20 Mar 2004 20:45:35 -0000	1.272.2.5
--- c-typeck.c	26 Mar 2004 00:30:56 -0000
*************** pop_init_level (int implicit)
*** 4819,4824 ****
--- 4819,4828 ----
  	abort ();
      }
  
+   /* Now output all pending elements.  */
+   constructor_incremental = 1;
+   output_pending_init_elements (1);
+ 
    p = constructor_stack;
  
    /* Error for initializing a flexible array member, or a zero-length
*************** pop_init_level (int implicit)
*** 4872,4881 ****
  	    RESTORE_SPELLING_DEPTH (constructor_depth);
  	  }
      }
- 
-   /* Now output all pending elements.  */
-   constructor_incremental = 1;
-   output_pending_init_elements (1);
  
    /* Pad out the end of the structure.  */
    if (p->replacement_value)
--- 4876,4881 ----
Index: testsuite/gcc.dg/gnu89-init-3.c
===================================================================
RCS file: testsuite/gcc.dg/gnu89-init-3.c
diff -N testsuite/gcc.dg/gnu89-init-3.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/gnu89-init-3.c	26 Mar 2004 00:30:56 -0000
***************
*** 0 ****
--- 1,18 ----
+ /* PR 11527 */
+ /* { dg-do compile } */
+ /* { dg-options "-std=gnu89" } */
+ 
+ typedef struct smrdd_memory_blocks_s
+ {
+   int blocks;
+   int block[];
+ } smrdd_memory_blocks_t;
+ 
+ const smrdd_memory_blocks_t smrdd_memory_blocks =
+ {
+   3,
+   {
+     [5] = 5,
+     [1] = 2,
+   }
+ };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]