GNU allows structs with flexible array members to be placed inside
arrays and other structs/unions as an extension. Downgrade our error
to a warning. Fixes PR3540.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64239 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 25fd5c3..e898782 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -399,12 +399,9 @@
         D.setInvalidType(true);
       } else if (const RecordType *EltTy = T->getAsRecordType()) {
         // If the element type is a struct or union that contains a variadic
-        // array, reject it: C99 6.7.2.1p2.
-        if (EltTy->getDecl()->hasFlexibleArrayMember()) {
-          Diag(DeclType.Loc, diag::err_flexible_array_in_array) << T;
-          T = Context.IntTy;
-          D.setInvalidType(true);
-        }
+        // array, accept it as a GNU extension: C99 6.7.2.1p2.
+        if (EltTy->getDecl()->hasFlexibleArrayMember())
+          Diag(DeclType.Loc, diag::ext_flexible_array_in_array) << T;
       } else if (T->isObjCInterfaceType()) {
         Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces) << T;
       }