fix GIMPLE parser for loops
authorRichard Biener <rguenther@suse.de>
Thu, 7 Jan 2021 15:52:38 +0000 (16:52 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 7 Jan 2021 16:36:25 +0000 (17:36 +0100)
We do not tolerate "growing" a vector to a lower size.

2021-01-07  Richard Biener  <rguenther@suse.de>

gcc/c/
* gimple-parser.c (c_parser_gimple_compound_statement): Only
reallocate loop array if it is too small.

gcc/c/gimple-parser.c

index e64c6e5ebd545f419143355f09bf7f41da11a6e9..58b161b7c76067941d12c57c8a886e61e04af2e3 100644 (file)
@@ -616,8 +616,9 @@ c_parser_gimple_compound_statement (gimple_parser &parser, gimple_seq *seq)
                      class loop *loop = alloc_loop ();
                      loop->num = is_loop_header_of;
                      loop->header = bb;
-                     vec_safe_grow_cleared (loops_for_fn (cfun)->larray,
-                                            is_loop_header_of + 1, true);
+                     if (number_of_loops (cfun) <= (unsigned)is_loop_header_of)
+                       vec_safe_grow_cleared (loops_for_fn (cfun)->larray,
+                                              is_loop_header_of + 1, true);
                      (*loops_for_fn (cfun)->larray)[is_loop_header_of] = loop;
                      flow_loop_tree_node_add (loops_for_fn (cfun)->tree_root,
                                               loop);