Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp	(Version 150684)
+++ lib/Sema/SemaDecl.cpp	(Working copy)
@@ -2424,12 +2424,13 @@
   if (getLangOptions().MicrosoftExt && !getLangOptions().CPlusPlus &&
       CurContext->isRecord() &&
       DS.getStorageClassSpec() == DeclSpec::SCS_unspecified) {
-    // Handle 2 kinds of anonymous struct:
+    // Handle 3 kinds of anonymous struct:
     //   struct STRUCT;
+    //   struct STRUCT{...};
     // and
     //   STRUCT_TYPE;  <- where STRUCT_TYPE is a typedef struct.
     RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag);
-    if ((Record && Record->getDeclName() && !Record->isCompleteDefinition()) ||
+    if ((Record && Record->getDeclName()) ||
         (DS.getTypeSpecType() == DeclSpec::TST_typename &&
          DS.getRepAsType().get()->isStructureType())) {
       Diag(DS.getSourceRange().getBegin(), diag::ext_ms_anonymous_struct)
@@ -2954,7 +2955,7 @@
   SmallVector<NamedDecl*, 2> Chain;
   Chain.push_back(Anon);
 
-  RecordDecl *RecordDef = Record->getDefinition();
+  RecordDecl *RecordDef = Record->isCompleteDefinition() ? Record : Record->getDefinition();
   if (!RecordDef || InjectAnonymousStructOrUnionMembers(*this, S, CurContext,
                                                         RecordDef, AS_none,
                                                         Chain, true))
Index: test/Sema/anonymous-struct-ms.c
===================================================================
--- test/Sema/anonymous-struct-ms.c	(Version 0)
+++ test/Sema/anonymous-struct-ms.c	(Working copy)
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+
+struct sub_u {
+	int b;
+};
+
+typedef struct sub_v {
+	int b;
+} SUB_V_TYPE;
+
+struct s {
+  int a;
+  struct c { // expected-warning{{anonymous structs are a Microsoft extension}}
+    int b;
+  };
+};
+
+struct u {
+  int a;
+  struct sub_u; // expected-warning{{anonymous structs are a Microsoft extension}}
+};
+
+struct v {
+  int a;
+  SUB_V_TYPE; // expected-warning{{anonymous structs are a Microsoft extension}}
+};
+
+void foo(){
+	struct s s1;
+	struct u u1;
+	struct v v1;
+	s1.b=0;
+	u1.b=0;
+	v1.b=0;
+}
