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]

Re: gcc told me to report a bug



Ok - here are two more Objective-C testcases - one showing compilation
crash when a pointer to a structure containing the enumeral bitfield is
declared as argument or return type of a method (pretty worrying this
one), the other one declaring an ivar of that type (again) but testing
setting and reading the ivar, because we want to have tests that not only
we can compile this stuff, but it also runs

Both of them fail with current GCC (most recent GCCs I think).

Then - here you also find a simple patch for the current GCC CVS which
fixes the three testcases.  Ok to apply the patch (to 3.1) and commit the
three testcases ?

Index: objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.112
diff -u -r1.112 objc-act.c
--- objc-act.c  2001/12/04 00:25:20     1.112
+++ objc-act.c  2001/12/05 19:31:23
@@ -6779,9 +6779,14 @@
            charType = 'q';
        }
     }
-
+  else if (code == ENUMERAL_TYPE)
+    {
+      charType = 'i';
+    }
   else
-    abort ();
+    {
+      abort ();
+    }
 
   sprintf (buffer, "b%d%c%d", position, charType, size);
   obstack_grow (&util_obstack, buffer, strlen (buffer));


ChangeLog entry:
================
Wed Dec  5 17:10:38 2001  Nicola Pero  <n.pero@mi.flashnet.it>

	* objc/objc-act.c (encode_complete_bitfield): Fixed encoding 
	enumeral types - encode them using 'i'.

testsuite/objc/execute/enumeration-1.m:
=======================================
/* Contributed by Nicola Pero -  Wed Dec  5 17:12:40 GMT 2001 */
#include <objc/objc.h>
#include <objc/Object.h>

/* Test using a bitfield enumeration ivar.  */

typedef enum
{
  black,
  white
} color;

@interface TestClass: Object
{
  color c:2;
}
- (color)color;
- (void)setColor: (color)a;
@end

@implementation TestClass
- (color)color
{
  return c;
}
- (void)setColor: (color)a
{
  c = a;
}
@end


int main (void)
{
  TestClass *c;
  
  c = [TestClass new];
  
  [c setColor: black];
  [c setColor: white];
  [c setColor: black];
  if ([c color] != black)
    {
      abort ();
    }
  

  return 0;
}

testsuite/objc/execute/enumeration-2.m:
=======================================
/* Contributed by Nicola Pero -  Wed Dec  5 17:15:22 GMT 2001 */
#include <objc/objc.h>
#include <objc/Object.h>

/* Test having methods taking as argument - or returning - 
   a bitfield enumeration ivar.  */

typedef enum { black, white } color;

typedef struct 
{
  color a:2;
  color b:2;
} color_couple;

@interface TestClass: Object
{
  color_couple *c;
}
- (color_couple *)colorCouple;
- (void)setColorCouple: (color_couple *)a;
@end

@implementation TestClass
- (color_couple *)colorCouple
{
  return c;
}
- (void)setColorCouple: (color_couple *)a
{
  c = a;
}
@end


int main (void)
{
  color_couple cc;
  TestClass *c;
  
  c = [TestClass new];
  
  cc.a = black;
  cc.b = white;

  [c setColorCouple: &cc];
  if ([c colorCouple] != &cc)
    {
      abort ();
    }
  

  return 0;
}


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