Increase index number for creating temp vars' name.
authorBin Cheng <bin.cheng@linux.alibaba.com>
Wed, 5 Feb 2020 10:45:08 +0000 (18:45 +0800)
committerBin Cheng <bin.cheng@linux.alibaba.com>
Wed, 5 Feb 2020 10:48:02 +0000 (18:48 +0800)
gcc/cp
    * coroutines.cc (maybe_promote_captured_temps): Increase the index
    number for temporary variables' name.

gcc/cp/ChangeLog
gcc/cp/coroutines.cc

index a54c8db23a6155bfc6e225bbc0c11f770ed0545f..7c24ab8b33bc381cec9dea3d3e6a8e39bba908d1 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-05  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       * coroutines.cc (maybe_promote_captured_temps): Increase the index
+       number for temporary variables' name.
+
 2020-02-05  Jun Ma <JunMa@linux.alibaba.com>
 
        * coroutines.cc (build_co_await): Call convert_from_reference
index e24ea7b29ad67bf02876ab46214363bb8da5a302..0a8a531d6d78575754041f65fa75c82f3a3f1bb2 100644 (file)
@@ -2676,12 +2676,12 @@ maybe_promote_captured_temps (tree *stmt, void *d)
       /* Collected the scope vars we need move the temps to regular. */
       tree aw_bind_body = push_stmt_list ();
       tree varlist = NULL_TREE;
-      unsigned vnum = 0;
+      int vnum = -1;
       while (!awpts->to_replace->is_empty ())
        {
          size_t bufsize = sizeof ("__aw_.tmp.") + 20;
          char *buf = (char *) alloca (bufsize);
-         snprintf (buf, bufsize, "__aw_%d.tmp.%d", awpts->count, vnum);
+         snprintf (buf, bufsize, "__aw_%d.tmp.%d", awpts->count, ++vnum);
          tree to_replace = awpts->to_replace->pop ();
          tree orig_temp;
          if (TREE_CODE (to_replace) == CO_AWAIT_EXPR)