summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-11-18 19:15:30 +0000
committerSteve Naroff <snaroff@apple.com>2008-11-18 19:15:30 +0000
commit119f60e12a3acc1a82c08337a7f90436ab4b8012 (patch)
tree905778acf153cc8d7c1155718d7eb7f250ec1d56 /clang/lib
parent0d9d8ae487ae3a5cb1b591d86e9f4929b3c95428 (diff)
downloadbcm5719-llvm-119f60e12a3acc1a82c08337a7f90436ab4b8012.tar.gz
bcm5719-llvm-119f60e12a3acc1a82c08337a7f90436ab4b8012.zip
Fix <rdar://problem/6329769> [sema] crash on duplication definition of interface with protocols.
As soon as we detect duplicate interfaces, discontinue further semantic checks (returning the original interface). This is now consistent with how we handle protocols (and less error prone in general). llvm-svn: 59541
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 8eeb2d367d7..49b990906a2 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -75,9 +75,12 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
ObjCInterfaceDecl* IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (IDecl) {
// Class already seen. Is it a forward declaration?
- if (!IDecl->isForwardDecl())
+ if (!IDecl->isForwardDecl()) {
Diag(AtInterfaceLoc, diag::err_duplicate_class_def, IDecl->getName());
- else {
+ // Return the previous class interface.
+ // FIXME: don't leak the objects passed in!
+ return IDecl;
+ } else {
IDecl->setLocation(AtInterfaceLoc);
IDecl->setForwardDecl(false);
}
@@ -119,7 +122,7 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
IDecl->setLocEnd(ClassLoc);
}
- /// Check then save referenced protocols
+ /// Check then save referenced protocols.
if (NumProtoRefs) {
IDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs);
IDecl->setLocEnd(EndProtoLoc);
OpenPOWER on IntegriCloud