Patchwork Fix for PR objc++/23614

login
register
mail settings
Submitter Nicola Pero
Date Oct. 5, 2010, 7:58 p.m.
Message ID <1286308732.39247124@192.168.2.231>
Download mbox | patch
Permalink /patch/66855/
State New
Headers show

Comments

Nicola Pero - Oct. 5, 2010, 7:58 p.m.
This patch fixes PR objc++/23614.

It was not a bug in the ObjC++ compiler; it was a bug in the test.

The compiler barfed on:

class MyWidget {
 public:
  int a;
  MyWidget(void) { a = 17; }
};

MyWidget *widget = nil;

and I think the compiler is correct in barfing, because widget is a pointer
to a C++ class, and you can't assign 'nil' to it.  Note that this assignment
seems irrelevant in the test, which was testing something else.

Thanks
Mike Stump - Oct. 7, 2010, 6:20 p.m.
On Oct 5, 2010, at 12:58 PM, Nicola Pero wrote:
> This patch fixes PR objc++/23614.

> It was not a bug in the ObjC++ compiler; it was a bug in the test.

> -    MyWidget *widget = nil;
> +    MyWidget *widget;

No, please just change to 0.
Nicola Pero - Oct. 7, 2010, 6:22 p.m.
Thanks Mike

you're right - and I had fixed that before pinging - my ping had a NULL there. ;-)

But I can put 0, if you prefer.  Ok to apply with a 0 in there ?

Thanks

-----Original Message-----
From: "Mike Stump" <mikestump@comcast.net>
Sent: Thursday, 7 October, 2010 20:20
To: "Nicola Pero" <nicola.pero@meta-innovation.com>
Cc: "gcc-patches@gnu.org" <gcc-patches@gnu.org>
Subject: Re: Fix for PR objc++/23614

On Oct 5, 2010, at 12:58 PM, Nicola Pero wrote:
> This patch fixes PR objc++/23614.

> It was not a bug in the ObjC++ compiler; it was a bug in the test.

> -    MyWidget *widget = nil;
> +    MyWidget *widget;

No, please just change to 0.
Mike Stump - Oct. 7, 2010, 6:53 p.m.
On Oct 7, 2010, at 11:22 AM, Nicola Pero wrote:
>  Ok to apply with a 0 in there ?

Ok.

Patch

Index: ChangeLog
===================================================================
--- ChangeLog   (revision 164997)
+++ ChangeLog   (working copy)
@@ -1,5 +1,11 @@ 
 2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>
 
+       PR objc++/23614
+       * obj-c++.dg/lookup-2.mm: Do not assign 'nil' to a pointer to a
+       C++ class.  Removed XFAIL.
+
+2010-10-05  Nicola Pero  <nicola.pero@meta-innovation.com>
+
        PR objc++/28050
        * obj-c++.dg/syntax-error-10.mm: New.
 
Index: obj-c++.dg/lookup-2.mm
===================================================================
--- obj-c++.dg/lookup-2.mm      (revision 164996)
+++ obj-c++.dg/lookup-2.mm      (working copy)
@@ -1,5 +1,4 @@ 
 /* { dg-do run } */
-/* { dg-xfail-if "PR23614" { "*-*-*" } { "*" } { "-fnext-runtime" } } */
 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
 #include "../objc-obj-c++-shared/Object1.h"
 #include <stdlib.h>
@@ -38,7 +37,7 @@  MyWidget gWidget;
 @implementation Container
 + (MyWidget *)elementForView:(Foo *)view
 {
-    MyWidget *widget = nil;
+    MyWidget *widget;
     if ([view conformsTo:@protocol(MyProto)]) {
         widget = [(Foo <MyProto> *)view widget];
     }