This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH: PR9128, PR9153, PR9171


On Fri, 10 Jan 2003 12:30:04 -0800, Mark Mitchell <mark@codesourcery.com> wrote:

> +   /* Transform `(a, b).x' into `(*(a, &b)).x' and `(a ? b : c).x' into
> +      `(*(a ?  &b : &c)).x'.  Unfortunately, expand_expr cannot handle a
> +      COMPONENT_REF where the first operand is a conditional or comma
> +      expression with class type.  */

I think it's reasonable for the backend to expect that only things of class
'd' or 'r' are lvalues.

> +   if (TREE_CODE (object) == COMPOUND_EXPR)
> +     {
> +       object = build (COMPOUND_EXPR, 
> + 		      build_pointer_type (object_type),
> + 		      TREE_OPERAND (object, 0),
> + 		      build_unary_op (ADDR_EXPR, 
> + 				      TREE_OPERAND (object, 1),
> + 				      /*noconvert=*/1));
> +       object = build_indirect_ref (object, NULL);
> +     }
> +   else if (TREE_CODE (object) == COND_EXPR)
> +     {
> +       object = build (COND_EXPR, 
> + 		      build_pointer_type (object_type),
> + 		      TREE_OPERAND (object, 0),
> + 		      build_unary_op (ADDR_EXPR, 
> + 				      TREE_OPERAND (object, 1),
> + 				      /*noconvert=*/1),
> + 		      build_unary_op (ADDR_EXPR, 
> + 				      TREE_OPERAND (object, 2),
> + 				      /*noconvert=*/1));
> +       object = build_indirect_ref (object, NULL);
>       }

That's what unary_complex_lvalue is for:

!   /* Transform `(a, b).x' into `(*(a, &b)).x', `(a ? b : c).x' into
!      `(*(a ?  &b : &c)).x', and so on.  A COND_EXPR is only an lvalue
!      in the frontend; only _DECLs and _REFs are lvalues in the backend.  */
!   {
!     tree temp = unary_complex_lvalue (ADDR_EXPR, object);
!     if (temp)
        object = build_indirect_ref (object, NULL);
!   }
  
I'll check in this change after testing.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]