Avoid crash on single-field union in Rust
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index c0dd199a79792b342211cf43e6a5f07542d21841..ee9df34ed27ca30a6354ba7b92754db50ad33fa9 100644 (file)
@@ -10076,10 +10076,10 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
       SET_FIELD_BITPOS (TYPE_FIELD (type, 0), 0);
       TYPE_FIELD_NAME (type, 0) = "<<variants>>";
     }
-  else if (TYPE_NFIELDS (type) == 1)
+  /* A union with a single anonymous field is probably an old-style
+     univariant enum.  */
+  else if (TYPE_NFIELDS (type) == 1 && streq (TYPE_FIELD_NAME (type, 0), ""))
     {
-      /* We assume that a union with a single field is a univariant
-        enum.  */
       /* Smash this type to be a structure type.  We have to do this
         because the type has already been recorded.  */
       TYPE_CODE (type) = TYPE_CODE_STRUCT;
This page took 0.040567 seconds and 4 git commands to generate.