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 11614


Hi,
I've installed this obvious fix for 11614, a flexible array snafu.

booted & tested on i686-pc-linux-gnu.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-07-22  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/11614
	* decl.c (grokdeclarator): An array member is only a flexible
	array member if the field itself is the array.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1093
diff -c -3 -p -r1.1093 decl.c
*** cp/decl.c	19 Jul 2003 16:09:46 -0000	1.1093
--- cp/decl.c	22 Jul 2003 15:48:28 -0000
*************** grokdeclarator (tree declarator,
*** 10615,10627 ****
  	    register tree size;
  
  	    size = TREE_OPERAND (declarator, 1);
  
! 	    /* VC++ spells a zero-sized array with [].  */
  	    if (size == NULL_TREE && decl_context == FIELD && !	staticp
! 		&& ! RIDBIT_SETP (RID_TYPEDEF, specbits))
  	      size = integer_zero_node;
- 
- 	    declarator = TREE_OPERAND (declarator, 0);
  
  	    type = create_array_type_for_decl (dname, type, size);
  
--- 10615,10631 ----
  	    register tree size;
  
  	    size = TREE_OPERAND (declarator, 1);
+ 	    declarator = TREE_OPERAND (declarator, 0);
  
! 	    /* C99 spells a flexible array member [].  */
  	    if (size == NULL_TREE && decl_context == FIELD && !	staticp
! 		&& ! RIDBIT_SETP (RID_TYPEDEF, specbits)
! 		&& !(declarator &&
! 		    (TREE_CODE (declarator) == CALL_EXPR
! 		      || TREE_CODE (declarator) == INDIRECT_REF
! 		      || TREE_CODE (declarator) == ADDR_EXPR
! 		      || TREE_CODE (declarator) == ARRAY_REF)))
  	      size = integer_zero_node;
  
  	    type = create_array_type_for_decl (dname, type, size);
  
// { dg-do compile }

// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 22 Jul 2003 <nathan@codesourcery.com>

// PR c++ 11614

typedef int ary_t[];

struct test
{
  ary_t *b;
  int (*a)[]; // this is not a flexible array member
};
 
void test(void)
{
  struct test s;
  int (*a)[] = 0;
  ary_t *b = 0;
  
  a = s.a;
  a = s.b;

  s.a = a;
  s.b = a;

  b = s.a;
  b = s.b;

  s.a = b;
  s.b = b;
}

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