On 2/12/20 2:23 AM, JunMa wrote:
Hi
In captures_temporary, the current implementation fails to handle
component_ref. This causes ice with case co_await A while
operator co_await is defined in base class of A. Also it is necessary
to capture the object of base class as if it is temporary object.

This patch strips component_ref to its base object and check it as usual.

Bootstrap and test on X86_64, is it OK?

Regards
JunMa

gcc/cp
2020-02-12  Jun Ma <ju...@linux.alibaba.com>

         * coroutines.cc (captures_temporary): Strip component_ref
         to its base object.

gcc/testsuite
2020-02-12  Jun Ma <ju...@linux.alibaba.com>

        * g++.dg/coroutines/torture/co-await-15-capture-comp-ref.C: New test.

+
+      /* In case of component_ref, we need to capture the object of base
+        class as if it is temporary object.  There are two possibilities:
+        (*base).field and base->field.  */
+      while (TREE_CODE (parm) == COMPONENT_REF)
+       {
+         parm = TREE_OPERAND (parm, 0);
+         if (TREE_CODE (parm) == INDIRECT_REF)
+           parm = TREE_OPERAND (parm, 0);
+         while (TREE_CODE (parm) == NOP_EXPR)
+           parm = TREE_OPERAND (parm, 0);

Use STRIP_NOPS.

+       }
+
       if (TREE_CODE (parm) == VAR_DECL && !DECL_ARTIFICIAL (parm))
        /* This isn't a temporary... */
        continue;
- if (TREE_CODE (parm) == PARM_DECL)
+      if (TREE_CODE (parm) == PARM_DECL  || TREE_CODE (parm) == 
NON_LVALUE_EXPR)
        /* .. nor is this... */
        continue;

Either a separate if, or merging both ifs (my preference) would be better.

nathan

--
Nathan Sidwell

Reply via email to