@@ -8626,7 +8626,7 @@ match
gfc_match_structure_decl (void)
{
/* Counter used to give unique internal names to anonymous structures. */
- int gfc_structure_id = 0;
+ static unsigned int gfc_structure_id = 0;
char name[GFC_MAX_SYMBOL_LEN + 1];
gfc_symbol *sym;
match m;
new file mode 100644
@@ -0,0 +1,27 @@
+! { dg-do "compile" }
+! { dg-options "-fdec-structure" }
+!
+! Test a regression where multiple anonymous structures failed to
+! receive unique internal names.
+!
+
+implicit none
+
+structure /s/
+
+ structure record0 ! (2)
+ integer i
+ end structure
+
+ structure record1 ! regression: Type definition was already defined at (2)
+ real r
+ end structure
+
+end structure
+
+record /s/ var
+
+var.record0.i = 0
+var.record1.r = 0.0
+
+end