Second half of "fix" for <rdar://problem/5986085> clang on xcode: error: redefinition of 'XCElementToggler' as different kind of symbol


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52024 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 84a8e82..240e6c7 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -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.