Commit 5a2a6eb0 by Nicola Pero Committed by Nicola Pero

In gcc/objc/: 2010-11-13 Nicola Pero <nicola.pero@meta-innovation.com>

In gcc/objc/:
2010-11-13  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc-act.c (objc_get_protocol_qualified_type): detect cases
        where we are asked to attach a protocol to something which is not
        an Objective-C object type, and produce an error.

In gcc/testsuite/:
2010-11-13  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc/compile/20060406-1.m: Fixed testcase not to try to qualify
        a pointer to an arbitrary C struct with an Objective-C protocol.
        Test various valid uses of typedef with Objective-C objects and
        protocols instead.
        * objc.dg/invalid-type-1.m: New.
        * obj-c++.dg/invalid-type-1.m: New.

From-SVN: r166709
parent 4286fd7a
2010-11-13 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_get_protocol_qualified_type): detect cases
where we are asked to attach a protocol to something which is not
an Objective-C object type, and produce an error.
2010-11-11 Nicola Pero <nicola.pero@meta-innovation.com> 2010-11-11 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_add_property_declaration): Check that the type * objc-act.c (objc_add_property_declaration): Check that the type
......
...@@ -2530,7 +2530,22 @@ objc_get_protocol_qualified_type (tree interface, tree protocols) ...@@ -2530,7 +2530,22 @@ objc_get_protocol_qualified_type (tree interface, tree protocols)
: xref_tag (RECORD_TYPE, type)); : xref_tag (RECORD_TYPE, type));
} }
else else
return interface; {
/* This case happens when we are given an 'interface' which
is not a valid class name. For example if a typedef was
used, and 'interface' really is the identifier of the
typedef, but when you resolve it you don't get an
Objective-C class, but something else, such as 'int'.
This is an error; protocols make no sense unless you use
them with Objective-C objects. */
error_at (input_location, "only Objective-C object types can be qualified with a protocol");
/* Try to recover. Ignore the invalid class name, and treat
the object as an 'id' to silence further warnings about
the class. */
type = objc_object_type;
is_ptr = true;
}
} }
if (protocols) if (protocols)
......
2010-11-13 Nicola Pero <nicola.pero@meta-innovation.com>
* objc/compile/20060406-1.m: Fixed testcase not to try to qualify
a pointer to an arbitrary C struct with an Objective-C protocol.
Test various valid uses of typedef with Objective-C objects and
protocols instead.
* objc.dg/invalid-type-1.m: New.
* obj-c++.dg/invalid-type-1.m: New.
2010-11-13 Iain Sandoe <iains@gcc.gnu.org> 2010-11-13 Iain Sandoe <iains@gcc.gnu.org>
* gcc.dg/darwin-segaddr.c: New test for multiple argument c/l switch. * gcc.dg/darwin-segaddr.c: New test for multiple argument c/l switch.
...@@ -170,6 +179,7 @@ ...@@ -170,6 +179,7 @@
* gfortran.dg/proc_decl_24.f90: New. * gfortran.dg/proc_decl_24.f90: New.
2010-11-11 Nicola Pero <nicola.pero@meta-innovation.com> 2010-11-11 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/property/at-property-20.m: New. * objc.dg/property/at-property-20.m: New.
* objc.dg/property/synthesize-8.m: New. * objc.dg/property/synthesize-8.m: New.
* obj-c++.dg/property/at-property-20.m: New. * obj-c++.dg/property/at-property-20.m: New.
......
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do compile } */
#include <objc/objc.h>
typedef int Integer;
@class MyClass;
typedef MyClass AClass;
@protocol MyProtocol
- (void) method;
@end
Class <MyProtocol> class_object; /* This is fine. */
id <MyProtocol> object; /* This is fine. */
AClass <MyProtocol> *object1; /* This is fine. */
Integer <MyProtocol> *object2; /* { dg-error ".Integer. is not a template" } */
/* { dg-error ".MyProtocol. was not declared in this scope" "" { target *-*-* } 21 } */
Integer <NonExistingProtocol> *object3; /* { dg-error ".Integer. is not a template" } */
/* { dg-error ".NonExistingProtocol. was not declared in this scope" "" { target *-*-* } 24 } */
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
/* { dg-do compile } */
#include <objc/objc.h>
typedef int Integer;
@class MyClass;
typedef MyClass AClass;
@protocol MyProtocol
- (void) method;
@end
Class <MyProtocol> class_object; /* This is fine. */
id <MyProtocol> object; /* This is fine. */
AClass <MyProtocol> *object1; /* This is fine. */
Integer <MyProtocol> *object2; /* { dg-error "only Objective-C object types can be qualified with a protocol" } */
Integer <NonExistingProtocol> *object3; /* { dg-error "only Objective-C object types can be qualified with a protocol" } */
/* { dg-error "cannot find protocol" "" { target *-*-* } 23 } */
typedef struct /* This test tests typedefs and protocol qualifiers. */
{
void *p;
} *S;
@protocol O @protocol O
- (unsigned)j; - (unsigned)j;
@end @end
@interface T
@end
/* First test. */
typedef T<O> *S;
@interface I @interface I
+ (unsigned char)T:(S<O>[2])p v:(S<O>)h; + (unsigned char)T:(S[2])p
v:(S)h;
@end @end
@implementation I @implementation I
+ (unsigned char)T:(S<O>[2])p v:(S<O>)h + (unsigned char)T:(S[2])p
v:(S)h
{ {
p[0] = (S) 0; p[0] = (S) 0;
p[1] = (S) 0; p[1] = (S) 0;
return 0; return 0;
} }
@end @end
/* Second test. */
typedef T<O> S1;
@interface I1
+ (unsigned char)T1:(S1*[2])p
v1:(S1*)h;
@end
@implementation I1
+ (unsigned char)T1:(S1*[2])p
v1:(S1*)h
{
p[0] = (S1*) 0;
p[1] = (S1*) 0;
return 0;
}
@end
/* Third test. */
typedef T S2;
@interface I2
+ (unsigned char)T1:(S2<O>*[2])p
v1:(S2<O>*)h;
@end
@implementation I2
+ (unsigned char)T1:(S2<O>*[2])p
v1:(S2<O>*)h
{
p[0] = (S2<O>*) 0;
p[1] = (S2<O>*) 0;
return 0;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment