Reject typedef redefinitions when the underlying types are not identical,
even if in a system header etc.  rdar://6079937



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54038 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 4d726cf..610bf61 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -248,6 +248,18 @@
     return New;
   }
   
+  // If the typedef types are not identical, reject them in all languages and
+  // with any extensions enabled.
+  if (Old->getUnderlyingType() != New->getUnderlyingType() && 
+      Context.getCanonicalType(Old->getUnderlyingType()) != 
+      Context.getCanonicalType(New->getUnderlyingType())) {
+    Diag(New->getLocation(), diag::err_redefinition_different_typedef,
+         New->getUnderlyingType().getAsString(),
+         Old->getUnderlyingType().getAsString());
+    Diag(Old->getLocation(), diag::err_previous_definition);
+    return Old;
+  }
+  
   // Allow multiple definitions for ObjC built-in typedefs.
   // FIXME: Verify the underlying types are equivalent!
   if (getLangOptions().ObjC1 && isBuiltinObjCType(New))