Microsoft-compatibility change causes regression

mark@codesourcery.com mark@codesourcery.com
Thu May 20 17:41:00 GMT 1999


I don't think this change:

  1999-04-12  Jason Merrill  <jason@yorick.cygnus.com>

	  * decl.c (grokdeclarator): Allow [] syntax for zero-length array.

  Index: decl.c
  ===================================================================
  RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
  retrieving revision 1.338
  retrieving revision 1.339
  diff -u -p -r1.338 -r1.339
  --- decl.c	1999/04/11 11:38:28	1.338
  +++ decl.c	1999/04/13 00:10:42	1.339
  @@ -10090,6 +10090,10 @@ grokdeclarator (declarator, declspecs, d
	      if (type == error_mark_node)
		continue;

  +	    /* VC++ spells a zero-sized array with [].  */
  +	    if (size == NULL_TREE && decl_context == FIELD && ! staticp)
  +	      size = integer_zero_node;
  +

is quite correct.  In particular, it breaks:

  struct S {
    typedef int IA[];

    static IA ia;
  };

  int S::ia[3];

because it makes g++ think that IA is `int ()[0]' which it isn't.  I'm
testing the attached patch, which I will check in on both mainline and
branch, if all goes well.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.359
diff -u -p -r1.359 decl.c
--- decl.c	1999/05/19 10:44:03	1.359
+++ decl.c	1999/05/21 00:41:19
@@ -10322,7 +10322,8 @@ grokdeclarator (declarator, declspecs, d
 	      continue;
 
 	    /* VC++ spells a zero-sized array with [].  */
-	    if (size == NULL_TREE && decl_context == FIELD && ! staticp)
+	    if (size == NULL_TREE && decl_context == FIELD && !	staticp
+		&& ! RIDBIT_SETP (RID_TYPEDEF, specbits))
 	      size = integer_zero_node;
 
 	    if (size)


More information about the Gcc-bugs mailing list