Index: include/clang/Basic/DiagnosticGroups.td
===================================================================
--- include/clang/Basic/DiagnosticGroups.td	(revision 113098)
+++ include/clang/Basic/DiagnosticGroups.td	(working copy)
@@ -226,3 +226,6 @@
 
 // A warning group for warnings about GCC extensions.
 def GNU : DiagGroup<"gnu", [GNUDesignator, VLA]>;
+
+// A warning group for warnings about MSVC extensions.
+def MSVC : DiagGroup<"msvc">;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 113098)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -2847,6 +2847,9 @@
   "member of anonymous struct redeclares %0">;
 def err_anonymous_record_with_type : Error<
   "types cannot be declared in an anonymous %select{struct|union}0">;
+def ext_anonymous_record_with_type : Extension<
+  "types declared in an anonymous %select{struct|union}0 are a MSVC extension">,
+  InGroup<MSVC>;
 def err_anonymous_record_with_function : Error<
   "functions cannot be declared in an anonymous %select{struct|union}0">;
 def err_anonymous_record_with_static : Error<
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp	(revision 113098)
+++ lib/Sema/SemaDecl.cpp	(working copy)
@@ -1898,10 +1898,16 @@
       } else if (RecordDecl *MemRecord = dyn_cast<RecordDecl>(*Mem)) {
         if (!MemRecord->isAnonymousStructOrUnion() &&
             MemRecord->getDeclName()) {
-          // This is a nested type declaration.
-          Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
-            << (int)Record->isUnion();
-          Invalid = true;
+          // Visual C++ allows type definition in anonymous struct or union.
+          if (getLangOptions().Microsoft)
+            Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
+              << (int)Record->isUnion();
+          else {
+            // This is a nested type declaration.
+            Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
+              << (int)Record->isUnion();
+            Invalid = true;
+          }
         }
       } else if (isa<AccessSpecDecl>(*Mem)) {
         // Any access specifier is fine.
@@ -1915,9 +1921,17 @@
           DK = diag::err_anonymous_record_with_function;
         else if (isa<VarDecl>(*Mem))
           DK = diag::err_anonymous_record_with_static;
-        Diag((*Mem)->getLocation(), DK)
+        
+        // Visual C++ allows type definition in anonymous struct or union.
+        if (getLangOptions().Microsoft &&
+            DK == diag::err_anonymous_record_with_type)
+          Diag((*Mem)->getLocation(), diag::ext_anonymous_record_with_type)
             << (int)Record->isUnion();
+        else {
+          Diag((*Mem)->getLocation(), DK)
+              << (int)Record->isUnion();
           Invalid = true;
+        }
       }
     }
   }
Index: test/SemaCXX/MicrosoftExtensions.cpp
===================================================================
--- test/SemaCXX/MicrosoftExtensions.cpp	(revision 113098)
+++ test/SemaCXX/MicrosoftExtensions.cpp	(working copy)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -fexceptions
+// RUN: %clang_cc1 %s -fsyntax-only -Wmsvc -verify -fms-extensions -fexceptions
 
 
 // ::type_info is predeclared with forward class declartion
@@ -30,6 +30,48 @@
   virtual void f3();
 };
 
+
+// MSVC allows type definition in anonymous union and struct
+struct A
+{
+  union 
+  {
+    int a;
+    struct B  // expected-warning {{types declared in an anonymous union are a MSVC extension}}
+    { 
+      int c;
+    } d;
+
+    union C   // expected-warning {{types declared in an anonymous union are a MSVC extension}}
+    {
+      int e;
+      int ee;
+    } f;
+
+    typedef int D;  // expected-warning {{types declared in an anonymous union are a MSVC extension}}
+    struct F;  // expected-warning {{types declared in an anonymous union are a MSVC extension}}
+  };
+
+  struct
+  {
+    int a2;
+
+    struct B2  // expected-warning {{types declared in an anonymous struct are a MSVC extension}}
+    {
+      int c2;
+    } d2;
+    
+	union C2  // expected-warning {{types declared in an anonymous struct are a MSVC extension}}
+    {
+      int e2;
+      int ee2;
+    } f2;
+
+    typedef int D2;  // expected-warning {{types declared in an anonymous struct are a MSVC extension}}
+    struct F2;  // expected-warning {{types declared in an anonymous struct are a MSVC extension}}
+  };
+};
+
 // __stdcall handling
 struct M {
     int __stdcall addP();
