[cfe-commits] r52024 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaDeclObjC.cpp test/Sema/objc-typedef-class.m
Steve Naroff
snaroff at apple.com
Thu Jun 5 15:57:10 PDT 2008
Author: snaroff
Date: Thu Jun 5 17:57:10 2008
New Revision: 52024
URL: http://llvm.org/viewvc/llvm-project?rev=52024&view=rev
Log:
Second half of "fix" for <rdar://problem/5986085> clang on xcode: error: redefinition of 'XCElementToggler' as different kind of symbol
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Sema/objc-typedef-class.m
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=52024&r1=52023&r2=52024&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jun 5 17:57:10 2008
@@ -352,6 +352,7 @@
// We won't add this decl to the current scope. We want the namespace
// name to return the original namespace decl during a name lookup.
} else {
+ printf("Weird\n");
// This is an invalid name redefinition.
Diag(Namespc->getLocation(), diag::err_redefinition_different_kind,
Namespc->getName());
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=52024&r1=52023&r2=52024&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jun 5 17:57:10 2008
@@ -712,9 +712,18 @@
// Check for another declaration kind with the same name.
Decl *PrevDecl = LookupDecl(IdentList[i], Decl::IDNS_Ordinary, TUScope);
if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
- Diag(AtClassLoc, diag::err_redefinition_different_kind,
- IdentList[i]->getName());
- Diag(PrevDecl->getLocation(), diag::err_previous_definition);
+ // GCC apparently allows the following idiom:
+ //
+ // typedef NSObject < XCElementTogglerP > XCElementToggler;
+ // @class XCElementToggler;
+ //
+ // FIXME: Make an extension?
+ TypedefDecl *TDD = dyn_cast<TypedefDecl>(PrevDecl);
+ if (!TDD || !isa<ObjCInterfaceType>(TDD->getUnderlyingType())) {
+ Diag(AtClassLoc, diag::err_redefinition_different_kind,
+ IdentList[i]->getName());
+ Diag(PrevDecl->getLocation(), diag::err_previous_definition);
+ }
}
ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
if (!IDecl) { // Not already seen? Make a forward decl.
Modified: cfe/trunk/test/Sema/objc-typedef-class.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-typedef-class.m?rev=52024&r1=52023&r2=52024&view=diff
==============================================================================
--- cfe/trunk/test/Sema/objc-typedef-class.m (original)
+++ cfe/trunk/test/Sema/objc-typedef-class.m Thu Jun 5 17:57:10 2008
@@ -48,14 +48,13 @@
@protocol XCElementTogglerP < XCElementP > -(void) setDisplayed:(BOOL) displayed;
@end
-// FIXME: investigate this redefinition error - gcc apparently accepts it.
-typedef NSObject < XCElementTogglerP > XCElementToggler; // expected-error{{previous definition is here}}
+typedef NSObject < XCElementTogglerP > XCElementToggler;
@interface XCElementRootFace:NSObject {} @end
@interface XCElementFace:XCElementRootFace {} @end
- at class XCElementToggler; // expected-error{{redefinition of 'XCElementToggler' as different kind of symbol}}
+ at class XCElementToggler;
@interface XCRASlice:XCElementFace {} @end
More information about the cfe-commits
mailing list