diff --git a/src/kernel_internals/typing/cabs2cil.ml b/src/kernel_internals/typing/cabs2cil.ml
index 1b595764bf03ef02f94a6901f87658e97ab5b21d..a8012c9c465ba4586ebad9e4b558678c24d625ee 100644
--- a/src/kernel_internals/typing/cabs2cil.ml
+++ b/src/kernel_internals/typing/cabs2cil.ml
@@ -5230,7 +5230,7 @@ and makeCompType ghost (isstruct: bool)
       if Cil.isFunctionType ftype then
         Kernel.error ~current:true
           "field `%s' declared as a function" n
-      else if Cil.has_flexible_array_member ftype then
+      else if Cil.has_flexible_array_member ftype && isstruct then
         Kernel.error ~current:true
           "field `%s' declared with a type containing a flexible array member."
           n
diff --git a/tests/syntax/flexible_array_member.i b/tests/syntax/flexible_array_member.i
index fbbd55dd676762831d5780ec467bd41a29c8c356..9fda08120828a0b2c8bde3058a345a862bb81ed3 100644
--- a/tests/syntax/flexible_array_member.i
+++ b/tests/syntax/flexible_array_member.i
@@ -1,9 +1,16 @@
 // valid flexible array member declarations
-struct {
+struct s1 {
   int size;
   char data[];
-} s1;
+} ss1;
 
-struct {
+struct s2 {
   char len, data[];
-} s2;
+} ss2;
+
+union u {
+  struct s {
+    char len;
+    char data[];
+  } fam;
+} u1;
diff --git a/tests/syntax/flexible_array_member_invalid1.i b/tests/syntax/flexible_array_member_invalid1.i
index bd4b3f7fc0beb135e67fc780b6b9bae433b41ce2..62ebdab3e24b225226ed31ca6ca17e0cdd50b33f 100644
--- a/tests/syntax/flexible_array_member_invalid1.i
+++ b/tests/syntax/flexible_array_member_invalid1.i
@@ -1,4 +1,4 @@
 // invalid flexible array member (empty struct otherwise)
-struct {
+struct s1 {
   char data[];
-} s1;
+} ss1;
diff --git a/tests/syntax/flexible_array_member_invalid2.i b/tests/syntax/flexible_array_member_invalid2.i
index e5a1463ec5432beb168dfc1b405f6213d1ca08a8..eab5dccd0c3e11ce97ad2511ab92beaeb96bc405 100644
--- a/tests/syntax/flexible_array_member_invalid2.i
+++ b/tests/syntax/flexible_array_member_invalid2.i
@@ -1,6 +1,6 @@
 // invalid flexible array member (two incomplete fields)
-struct {
+struct s {
   int len;
   char data[];
   char more_data[];
-} s;
+} ss;
diff --git a/tests/syntax/flexible_array_member_invalid3.i b/tests/syntax/flexible_array_member_invalid3.i
index 30f2a733c7ee7377ae332c86bba63b0622184dd0..4baf088c14f4a8baeba250ad8f2abe33a2b79766 100644
--- a/tests/syntax/flexible_array_member_invalid3.i
+++ b/tests/syntax/flexible_array_member_invalid3.i
@@ -1,5 +1,5 @@
 // invalid flexible array member (two incomplete fields in same field group)
-struct {
+struct s {
   int len;
   char data[], more_data[];
-} s;
+} ss;
diff --git a/tests/syntax/flexible_array_member_invalid4.i b/tests/syntax/flexible_array_member_invalid4.i
index bd7666227597316d55ba00b5b54ce9fa0b792ddd..e84cce94b9891a77d85135a75691d9f9b7ad1b87 100644
--- a/tests/syntax/flexible_array_member_invalid4.i
+++ b/tests/syntax/flexible_array_member_invalid4.i
@@ -1,6 +1,6 @@
 // invalid flexible array member (incomplete field is not last)
-struct {
+struct s {
   int len;
   char data[];
   char b;
-} s;
+} ss;
diff --git a/tests/syntax/flexible_array_member_invalid5.i b/tests/syntax/flexible_array_member_invalid5.i
index dd3eac2f1c52361a2dbadf2303ba550baf481886..a0339194afe9def80ec7aeba80647ec0e8084981 100644
--- a/tests/syntax/flexible_array_member_invalid5.i
+++ b/tests/syntax/flexible_array_member_invalid5.i
@@ -4,7 +4,7 @@ typedef struct {
   char data[];
 } fam;
 
-struct {
+struct st {
   int len;
   fam f;
-} st;
+} sst;
diff --git a/tests/syntax/oracle/flexible_array_member.res.oracle b/tests/syntax/oracle/flexible_array_member.res.oracle
index a7317194e390ea0960fa4a3cbb72e062ae312798..90af690c44153978d928abf3544bb5802d620eea 100644
--- a/tests/syntax/oracle/flexible_array_member.res.oracle
+++ b/tests/syntax/oracle/flexible_array_member.res.oracle
@@ -1,13 +1,21 @@
 [kernel] Parsing tests/syntax/flexible_array_member.i (no preprocessing)
 /* Generated by Frama-C */
-struct __anonstruct_s1_1 {
+struct s1 {
    int size ;
    char data[] ;
 };
-struct __anonstruct_s2_2 {
+struct s2 {
    char len ;
    char data[] ;
 };
-struct __anonstruct_s1_1 s1;
-struct __anonstruct_s2_2 s2;
+struct s {
+   char len ;
+   char data[] ;
+};
+union u {
+   struct s fam ;
+};
+struct s1 ss1;
+struct s2 ss2;
+union u u1;