IdentifierInfo **ProtocolNames, unsigned NumProtocols,
AttributeList *AttrList) {
assert(ClassName && "Missing class identifier");
- ObjcInterfaceDecl *IDecl;
-
+
+ ObjcInterfaceDecl* IDecl;
+
+ if (Context.getObjCInterfaceDecl(ClassName))
+ Diag(AtInterfaceLoc, diag::err_duplicate_class_def, ClassName->getName());
+
IDecl = new ObjcInterfaceDecl(AtInterfaceLoc, ClassName);
// Chain & install the interface decl into the identifier.
IDecl->setNext(ClassName->getFETokenInfo<ScopedDecl>());
ClassName->setFETokenInfo(IDecl);
+
+ if (SuperName) {
+ const ObjcInterfaceDecl* SuperClassEntry =
+ Context.getObjCInterfaceDecl(SuperName);
+
+ if (!SuperClassEntry) {
+ Diag(AtInterfaceLoc, diag::err_undef_superclass, SuperName->getName(),
+ ClassName->getName());
+ }
+ }
+
+ Context.setObjCInterfaceDecl(ClassName, IDecl);
+
return IDecl;
}
llvm::FoldingSet<FunctionTypeNoProto> FunctionTypeNoProtos;
llvm::FoldingSet<FunctionTypeProto> FunctionTypeProtos;
llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo;
+ llvm::DenseMap<const IdentifierInfo*, const ObjcInterfaceDecl*> ClassNameInfo;
RecordDecl *CFConstantStringTypeDecl;
public:
+
SourceManager &SourceMgr;
TargetInfo &Target;
IdentifierTable &Idents;
/// position information.
const RecordLayout &getRecordLayout(const RecordDecl *D, SourceLocation L);
+ const ObjcInterfaceDecl* getObjCInterfaceDecl(const IdentifierInfo* ClassName)
+ { return ClassNameInfo[ClassName]; }
+ void setObjCInterfaceDecl(const IdentifierInfo* ClassName,
+ const ObjcInterfaceDecl* InterfaceDecl)
+ { ClassNameInfo[ClassName] = InterfaceDecl; }
+
//===--------------------------------------------------------------------===//
// Type Operators
//===--------------------------------------------------------------------===//
"@optional may be specified in protocols only")
DIAG(err_missing_catch_finally, ERROR,
"@try statment without a @catch and @finally clause")
+DIAG(err_undef_superclass, ERROR,
+ "cannot find interface declaration for '%0', superclass of '%1'")
+DIAG(err_duplicate_class_def, ERROR,
+ "duplicate interface declaration for class '%0'")
+
//===----------------------------------------------------------------------===//
// Semantic Analysis
--- /dev/null
+@class SUPER, Y;
+
+@interface INTF :SUPER // expected-error {{cannot find interface declaration for 'SUPER', superclass of 'INTF'}}
+@end
+
+@interface SUPER @end
+
+@interface INTF1 : SUPER
+@end
+
+@interface INTF2 : INTF1
+@end
+
+@interface INTF3 : Y // expected-error {{cannot find interface declaration for 'Y', superclass of 'INTF3'}}
+@end
+
+@interface INTF1 // expected-error {{duplicate interface declaration for class 'INTF1'}}
+@end