[cfe-commits] r144508 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/SemaObjC/alias-test-2.m test/SemaObjCXX/objc-extern-c.mm
jahanian
fjahanian at apple.com
Tue Nov 15 14:48:29 PST 2011
On Nov 15, 2011, at 1:36 PM, Devang Patel wrote:
> Argyrios,
>
> This causes compatibility-alias.m test failure from gccTestSuite. I think it is because of error message mismatch. In any case, please investigate and if required update the test. Thanks!
Test is fixed in r144718. Diagnostics is much cleaner now.
- fariborz
> -
> Devang
>
>
> On Nov 13, 2011, at 2:08 PM, Argyrios Kyrtzidis wrote:
>
>> Author: akirtzidis
>> Date: Sun Nov 13 16:08:30 2011
>> New Revision: 144508
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=144508&view=rev
>> Log:
>> Don't crash when a duplicate interface/protocol is inside an extern "C" context.
>>
>> Added:
>> cfe/trunk/test/SemaObjCXX/objc-extern-c.mm
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/test/SemaObjC/alias-test-2.m
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=144508&r1=144507&r2=144508&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Nov 13 16:08:30 2011
>> @@ -373,9 +373,15 @@
>> Diag(AtInterfaceLoc, diag::err_duplicate_class_def)<<IDecl->getDeclName();
>> Diag(IDecl->getLocation(), diag::note_previous_definition);
>>
>> - // Return the previous class interface.
>> - // FIXME: don't leak the objects passed in!
>> - return ActOnObjCContainerStartDefinition(IDecl);
>> + // Create a new one; the other may be in a different DeclContex, (e.g.
>> + // this one may be in a LinkageSpecDecl while the other is not) which
>> + // will break invariants.
>> + IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtInterfaceLoc,
>> + ClassName, ClassLoc);
>> + if (AttrList)
>> + ProcessDeclAttributeList(TUScope, IDecl, AttrList);
>> + PushOnScopeChains(IDecl, TUScope);
>> +
>> } else {
>> IDecl->setLocation(ClassLoc);
>> IDecl->setAtStartLoc(AtInterfaceLoc);
>> @@ -575,23 +581,30 @@
>> if (!PDecl->isForwardDecl()) {
>> Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
>> Diag(PDecl->getLocation(), diag::note_previous_definition);
>> - // Just return the protocol we already had.
>> - // FIXME: don't leak the objects passed in!
>> - return ActOnObjCContainerStartDefinition(PDecl);
>> - }
>> - ObjCList<ObjCProtocolDecl> PList;
>> - PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
>> - err = CheckForwardProtocolDeclarationForCircularDependency(
>> - ProtocolName, ProtocolLoc, PDecl->getLocation(), PList);
>> -
>> - // Make sure the cached decl gets a valid start location.
>> - PDecl->setAtStartLoc(AtProtoInterfaceLoc);
>> - PDecl->setLocation(ProtocolLoc);
>> - // Since this ObjCProtocolDecl was created by a forward declaration,
>> - // we now add it to the DeclContext since it wasn't added before
>> - PDecl->setLexicalDeclContext(CurContext);
>> - CurContext->addDecl(PDecl);
>> - PDecl->completedForwardDecl();
>> +
>> + // Create a new one; the other may be in a different DeclContex, (e.g.
>> + // this one may be in a LinkageSpecDecl while the other is not) which
>> + // will break invariants.
>> + // We will not add it to scope chains to ignore it as the warning says.
>> + PDecl = ObjCProtocolDecl::Create(Context, CurContext, ProtocolName,
>> + ProtocolLoc, AtProtoInterfaceLoc,
>> + /*isForwardDecl=*/false);
>> +
>> + } else {
>> + ObjCList<ObjCProtocolDecl> PList;
>> + PList.set((ObjCProtocolDecl *const*)ProtoRefs, NumProtoRefs, Context);
>> + err = CheckForwardProtocolDeclarationForCircularDependency(
>> + ProtocolName, ProtocolLoc, PDecl->getLocation(), PList);
>> +
>> + // Make sure the cached decl gets a valid start location.
>> + PDecl->setAtStartLoc(AtProtoInterfaceLoc);
>> + PDecl->setLocation(ProtocolLoc);
>> + // Since this ObjCProtocolDecl was created by a forward declaration,
>> + // we now add it to the DeclContext since it wasn't added before
>> + PDecl->setLexicalDeclContext(CurContext);
>> + CurContext->addDecl(PDecl);
>> + PDecl->completedForwardDecl();
>> + }
>> } else {
>> PDecl = ObjCProtocolDecl::Create(Context, CurContext, ProtocolName,
>> ProtocolLoc, AtProtoInterfaceLoc,
>>
>> 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=144508&r1=144507&r2=144508&view=diff
>> ==============================================================================
>> --- cfe/trunk/test/SemaObjC/alias-test-2.m (original)
>> +++ cfe/trunk/test/SemaObjC/alias-test-2.m Sun Nov 13 16:08:30 2011
>> @@ -9,9 +9,9 @@
>>
>> @compatibility_alias AliasForSuper Super;
>>
>> - at interface MyAlias : AliasForSuper // expected-error {{duplicate interface definition for class 'MyWpModule'}}
>> + at implementation MyAlias : AliasForSuper // expected-error {{conflicting super class name 'Super'}}
>> @end
>>
>> - at implementation MyAlias : AliasForSuper // expected-error {{conflicting super class name 'Super'}}
>> + at interface MyAlias : AliasForSuper // expected-error {{duplicate interface definition for class 'MyWpModule'}}
>> @end
>>
>>
>> Added: cfe/trunk/test/SemaObjCXX/objc-extern-c.mm
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objc-extern-c.mm?rev=144508&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/SemaObjCXX/objc-extern-c.mm (added)
>> +++ cfe/trunk/test/SemaObjCXX/objc-extern-c.mm Sun Nov 13 16:08:30 2011
>> @@ -0,0 +1,30 @@
>> +// RUN: %clang_cc1 -fsyntax-only -verify %s
>> +
>> + at protocol P // expected-note {{previous}}
>> +-(void)meth1;
>> + at end
>> +
>> + at interface I // expected-note {{previous}}
>> + at end
>> +
>> + at interface I2
>> + at end
>> + at interface I2(C) // expected-note {{previous}}
>> + at end
>> +
>> +extern "C" {
>> + at protocol P // expected-warning {{duplicate protocol definition of 'P' is ignored}}
>> +-(void)meth2;
>> + at end
>> +
>> + at interface I // expected-error {{duplicate}}
>> + at end
>> +
>> + at interface I2(C) // expected-warning {{duplicate}}
>> + at end
>> +}
>> +
>> +void test(id<P> p) {
>> + [p meth1];
>> + [p meth2]; // expected-warning {{not found}}
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
> _______________________________________________
> 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