[cfe-commits] r59541 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/alias-test-2.m test/SemaObjC/check-dup-objc-decls-1.m

Chris Lattner clattner at apple.com
Wed Nov 19 20:58:57 PST 2008


On Nov 18, 2008, at 11:15 AM, Steve Naroff wrote:

> Author: snaroff
> Date: Tue Nov 18 13:15:30 2008
> New Revision: 59541
>
> URL: http://llvm.org/viewvc/llvm-project?rev=59541&view=rev
> Log:
> 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).

Thanks Steve,

> +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Nov 18 13:15:30 2008
> @@ -75,9 +75,12 @@
>   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 {

I think you can remove the "else" now.

-Chris

>
>       IDecl->setLocation(AtInterfaceLoc);
>       IDecl->setForwardDecl(false);
>     }
> @@ -119,7 +122,7 @@
>     IDecl->setLocEnd(ClassLoc);
>   }
>
> -  /// Check then save referenced protocols
> +  /// Check then save referenced protocols.
>   if (NumProtoRefs) {
>     IDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs,  
> NumProtoRefs);
>     IDecl->setLocEnd(EndProtoLoc);
>
> Modified: cfe/trunk/test/SemaObjC/alias-test-2.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/alias-test-2.m?rev=59541&r1=59540&r2=59541&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/test/SemaObjC/alias-test-2.m (original)
> +++ cfe/trunk/test/SemaObjC/alias-test-2.m Tue Nov 18 13:15:30 2008
> @@ -1,6 +1,7 @@
> // RUN: clang -fsyntax-only -verify %s
>
> - at interface Super @end
> +// Note: GCC doesn't produce any of the following errors.
> + at interface Super @end // expected-error {{previous definition is  
> here}}
>
> @interface MyWpModule @end
>
> @@ -11,6 +12,6 @@
> @interface MyAlias : AliasForSuper // expected-error {{duplicate  
> interface declaration for class 'MyWpModule'}}
> @end
>
> - at implementation MyAlias : AliasForSuper
> + at implementation MyAlias : AliasForSuper // expected-error  
> {{conflicting super class name 'Super'}}
> @end
>
>
> Modified: cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m?rev=59541&r1=59540&r2=59541&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m (original)
> +++ cfe/trunk/test/SemaObjC/check-dup-objc-decls-1.m Tue Nov 18  
> 13:15:30 2008
> @@ -26,3 +26,14 @@
> {
> 	int Bar, Foo, FooBar;
> }
> +
> + at protocol P -im1; @end
> + at protocol Q -im2; @end
> + at interface A<P> @end
> + at interface A<Q> @end  // expected-error {{duplicate interface  
> declaration for class 'A'}}
> +
> + at protocol PP<P> @end
> + at protocol PP<Q> @end  // expected-error {{duplicate protocol  
> declaration of 'PP'}}
> +
> + at interface A(Cat)<P> @end
> + at interface A(Cat)<Q> @end // expected-warning {{duplicate interface  
> declaration for category 'A(Cat)'}}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list