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]

[C patch] Fix non-regression part of PR29092


The PR is about a failure of the C front-end to accept

__attribute__ ((vector_size (8))) int x =
  (__attribute__ ((vector_size (8))) int) {1, 2};

The similar code

 typedef __attribute__ ((vector_size (8))) int vec_int;
 vec_int x =  (vec_int) {1, 2};

never compiled for --std=gnu99. The problem is that initializing objects with static storage duration with compound literals, was allowed by gnu89 and not gnu99. This patch enables the extension at gnu99 too.

Bootstrapped/regtested on i686-pc-linux-gnu. Ok for mainline if it passes?

Paolo
2006-09-26  Paolo Bonzini  <bonzini@gnu.org>

	* c-typeck.c (digest_init): Allow initializing objects with static
	storage duration with compound literals, if gnu99.

2006-09-26  Paolo Bonzini  <bonzini@gnu.org>

	* gcc.dg/simd-6.c: UnXFAIL.

--- c-typeck.c	(revision 116745)
+++ c-typeck.c	(working copy)
@@ -4699,7 +4699,8 @@ digest_init (tree type, tree init, bool 
 	   conversion.  */
 	inside_init = convert (type, inside_init);
 
-      if (require_constant && !flag_isoc99
+      if (require_constant
+	  && (!flag_iso || !flag_isoc99)
 	  && TREE_CODE (inside_init) == COMPOUND_LITERAL_EXPR)
 	{
 	  /* As an extension, allow initializing objects with static storage
--- testsuite/gcc.dg/simd-6.c	2006-09-26 09:23:54.000000000 +0200
+++ testsuite/gcc.dg/simd-6.c	2006-09-26 11:58:33.000000000 +0200
@@ -3,5 +3,5 @@
 
 /* Ensure that we don't need a typedef to initialize a vector type.  */
 #define vector __attribute__ ((vector_size (8)))
-vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" "" { xfail *-*-* } } */
+vector char x = (vector char) {1,2,3,4,5,6,7,8}; /* { dg-bogus "initializer" "" } */
 vector char y = (vector short) {1,2,3,4}; /* { dg-error "initializer" } */

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