bool isObjCInterfaceType() const; // NSString or NSString<foo>
bool isObjCQualifiedInterfaceType() const; // NSString<foo>
bool isObjCQualifiedIdType() const; // id<foo>
+ bool isObjCQualifiedClassType() const; // Class<foo>
bool isObjCIdType() const; // id
bool isObjCClassType() const; // Class
bool isObjCBuiltinType() const; // 'id' or 'Class'
Protocols.size();
}
/// isObjCQualifiedClassType - true for "Class <p>".
- bool isQualifiedClassType() const {
+ bool isObjCQualifiedClassType() const {
return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) &&
Protocols.size();
}
return OPT->isObjCQualifiedIdType();
return false;
}
+inline bool Type::isObjCQualifiedClassType() const {
+ if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
+ return OPT->isObjCQualifiedClassType();
+ return false;
+}
inline bool Type::isObjCIdType() const {
if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
return OPT->isObjCIdType();
"use of C99-specific array features, accepted as an extension">;
def err_invalid_protocol_qualifiers : Error<
"invalid protocol qualifiers on non-ObjC type">;
-def err_qualified_class_unsupported : Error<
- "protocol qualified 'Class' is unsupported">;
def warn_ivar_use_hidden : Warning<
"local declaration of %0 hides instance variable">;
def error_ivar_use_in_class_method : Error<
QualType ASTContext::getObjCObjectPointerType(QualType InterfaceT,
ObjCProtocolDecl **Protocols,
unsigned NumProtocols) {
- if (InterfaceT.isNull())
- InterfaceT = ObjCBuiltinIdTy;
-
// Sort the protocol list alphabetically to canonicalize it.
if (NumProtocols)
SortAndUniqueProtocols(Protocols, NumProtocols);
if (isObjCIdType() || isObjCQualifiedIdType())
ObjCQIString = "id";
- else if (isObjCClassType())
+ else if (isObjCClassType() || isObjCQualifiedClassType())
ObjCQIString = "Class";
else
ObjCQIString = getInterfaceDecl()->getNameAsString();
}
// Handle messages to id.
- if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) ||
- ReceiverCType->isBlockPointerType() ||
+ if (ReceiverCType->isObjCIdType() || ReceiverCType->isBlockPointerType() ||
Context.isObjCNSObjectType(RExpr->getType())) {
ObjCMethodDecl *Method = LookupInstanceMethodInGlobalPool(
Sel, SourceRange(lbrac,rbrac));
}
// Handle messages to Class.
- if (ReceiverCType == Context.getCanonicalType(Context.getObjCClassType())) {
+ if (ReceiverCType->isObjCClassType() ||
+ ReceiverCType->isObjCQualifiedClassType()) {
ObjCMethodDecl *Method = 0;
if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
if (!Method)
Method = LookupPrivateClassMethod(Sel, ClassDecl);
+
+ // FIXME: if we still haven't found a method, we need to look in
+ // protocols (if we have qualifiers).
}
if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
return true;
case DeclSpec::TST_unspecified:
// "<proto1,proto2>" is an objc qualified ID with a missing id.
if (DeclSpec::ProtocolQualifierListTy PQ = DS.getProtocolQualifiers()) {
- Result = Context.getObjCObjectPointerType(QualType(),
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
(ObjCProtocolDecl**)PQ,
DS.getNumProtocolQualifiers());
break;
DS.getNumProtocolQualifiers());
else if (Result->isObjCIdType())
// id<protocol-list>
- Result = Context.getObjCObjectPointerType(QualType(),
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinIdTy,
(ObjCProtocolDecl**)PQ, DS.getNumProtocolQualifiers());
else if (Result->isObjCClassType()) {
if (DeclLoc.isInvalid())
DeclLoc = DS.getSourceRange().getBegin();
// Class<protocol-list>
- Diag(DeclLoc, diag::err_qualified_class_unsupported)
- << DS.getSourceRange();
+ Result = Context.getObjCObjectPointerType(Context.ObjCBuiltinClassTy,
+ (ObjCProtocolDecl**)PQ, DS.getNumProtocolQualifiers());
} else {
if (DeclLoc.isInvalid())
DeclLoc = DS.getSourceRange().getBegin();
{
int i = [(id <Func>)self class_func0];
i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
- i += [(Class <Func>)self class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}}
- return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-error {{cannot cast 'super' (it isn't an expression)}}
+ i += [(Class <Func>)self class_func0]; //
+ return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}}
}
+ (int) class_func3
{
// GCC doesn't diagnose this.
NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
-// Decided not to support the following GCC extension. Found while researching rdar://6497631
typedef struct objc_class *Class;
-Class <SomeProtocol> UnfortunateGCCExtension; // expected-error {{protocol qualified 'Class' is unsupported}}
+Class <SomeProtocol> UnfortunateGCCExtension;
__attribute ((unavailable))
@protocol FwProto; // expected-note{{marked unavailable}}
-Class <FwProto> cFw = 0; // expected-warning {{'FwProto' is unavailable}} expected-error{{protocol qualified 'Class' is unsupported}}
+Class <FwProto> cFw = 0; // expected-warning {{'FwProto' is unavailable}}
__attribute ((deprecated)) @protocol MyProto1
-Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}} expected-error{{protocol qualified 'Class' is unsupported}}
+Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}}
@protocol FwProto @end // expected-note{{marked unavailable}}
@interface Derived2: Object <Func>
@end
-static void doSomething(Class <Func> unsupportedObjectType) { // expected-error {{protocol qualified 'Class' is unsupported}}
+static void doSomething(Class <Func> unsupportedObjectType) {
[unsupportedObjectType class_func0];
}