FreeBSD/contrib/gcc/cp/tree.c
/* If REF is an lvalue, returns the kind of lvalue that REF is.
   Otherwise, returns clk_none.  If TREAT_CLASS_RVALUES_AS_LVALUES is
   nonzero, rvalues of class type are considered lvalues.  */
If REF is an lvalue, returns the kind of lvalue that REF is.
If REF is an lvalue returns the kind of lvalue that REF is .
static cp_lvalue_kind
lvalue_p_1 (tree ref,
	    int treat_class_rvalues_as_lvalues)
{
  cp_lvalue_kind op1_lvalue_kind = clk_none;
  cp_lvalue_kind op2_lvalue_kind = clk_none;
  if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
    return clk_ordinary;
  if (ref == current_class_ptr)
    return clk_none;
  switch (TREE_CODE (ref))
    {
    case PREINCREMENT_EXPR:
    case PREDECREMENT_EXPR:
    case SAVE_EXPR:
    case TRY_CATCH_EXPR:
    case WITH_CLEANUP_EXPR:
    case REALPART_EXPR:
    case IMAGPART_EXPR:
      return lvalue_p_1 (TREE_OPERAND (ref, 0),
			 treat_class_rvalues_as_lvalues);
    case COMPONENT_REF:
      op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0),
				    treat_class_rvalues_as_lvalues);
      if (!op1_lvalue_kind
	  || TREE_CODE (TREE_OPERAND (ref, 1)) != FIELD_DECL)
	;
      else if (DECL_C_BIT_FIELD (TREE_OPERAND (ref, 1)))
	{
	  op1_lvalue_kind &= ~clk_ordinary;
	  op1_lvalue_kind |= clk_bitfield;
	}
      else if (DECL_PACKED (TREE_OPERAND (ref, 1)))
	op1_lvalue_kind |= clk_packed;
      return op1_lvalue_kind;
    case STRING_CST:
      return clk_ordinary;
    case CONST_DECL:
    case VAR_DECL:
      if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
	  && DECL_LANG_SPECIFIC (ref)
	  && DECL_IN_AGGR_P (ref))
	return clk_none;
    case INDIRECT_REF:
    case ARRAY_REF:
    case PARM_DECL:
    case RESULT_DECL:
      if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
	return clk_ordinary;
      break;
    case SCOPE_REF:
      gcc_unreachable ();
    case MAX_EXPR:
    case MIN_EXPR:
      if (TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 0))
	  || TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 1)))
	return clk_none;
      op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0),
				    treat_class_rvalues_as_lvalues);
      op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
				    treat_class_rvalues_as_lvalues);
      break;
    case COND_EXPR:
      op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
				    treat_class_rvalues_as_lvalues);
      op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 2),
				    treat_class_rvalues_as_lvalues);
      break;
    case MODIFY_EXPR:
      return clk_ordinary;
    case COMPOUND_EXPR:
      return lvalue_p_1 (TREE_OPERAND (ref, 1),
			 treat_class_rvalues_as_lvalues);
    case TARGET_EXPR:
      return treat_class_rvalues_as_lvalues ? clk_class : clk_none;
    case VA_ARG_EXPR:
      return (treat_class_rvalues_as_lvalues
	      && CLASS_TYPE_P (TREE_TYPE (ref))
	      ? clk_class : clk_none);
    case CALL_EXPR:
      return clk_none;
    case FUNCTION_DECL:
      return (DECL_NONSTATIC_MEMBER_FUNCTION_P (ref)
	      ? clk_none : clk_ordinary);
    case NON_DEPENDENT_EXPR:
      return clk_ordinary;
    default:
      break;
    }
  if (!op1_lvalue_kind || !op2_lvalue_kind)
    return clk_none;
  op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind;
  if ((op1_lvalue_kind & ~clk_ordinary) != clk_none)
    op1_lvalue_kind &= ~clk_ordinary;
  return op1_lvalue_kind;
}
static cp_lvalue_kind lvalue_p_1 ( tree ref , int treat_class_rvalues_as_lvalues ) { cp_lvalue_kind op1_lvalue_kind = clk_none ; cp_lvalue_kind op2_lvalue_kind = clk_none ; if ( TREE_CODE ( TREE_TYPE ( ref ) ) == REFERENCE_TYPE ) return clk_ordinary ; if ( ref == current_class_ptr ) return clk_none ; switch ( TREE_CODE ( ref ) ) { case PREINCREMENT_EXPR : case PREDECREMENT_EXPR : case SAVE_EXPR : case TRY_CATCH_EXPR : case WITH_CLEANUP_EXPR : case REALPART_EXPR : case IMAGPART_EXPR : return lvalue_p_1 ( TREE_OPERAND ( ref , 0 ) , treat_class_rvalues_as_lvalues ) ; case COMPONENT_REF : op1_lvalue_kind = lvalue_p_1 ( TREE_OPERAND ( ref , 0 ) , treat_class_rvalues_as_lvalues ) ; if ( ! op1_lvalue_kind || TREE_CODE ( TREE_OPERAND ( ref , 1 ) ) != FIELD_DECL ) ; else if ( DECL_C_BIT_FIELD ( TREE_OPERAND ( ref , 1 ) ) ) { op1_lvalue_kind &= ~ clk_ordinary ; op1_lvalue_kind |= clk_bitfield ; } else if ( DECL_PACKED ( TREE_OPERAND ( ref , 1 ) ) ) op1_lvalue_kind |= clk_packed ; return op1_lvalue_kind ; case STRING_CST : return clk_ordinary ; case CONST_DECL : case VAR_DECL : if ( TREE_READONLY ( ref ) && ! TREE_STATIC ( ref ) && DECL_LANG_SPECIFIC ( ref ) && DECL_IN_AGGR_P ( ref ) ) return clk_none ; case INDIRECT_REF : case ARRAY_REF : case PARM_DECL : case RESULT_DECL : if ( TREE_CODE ( TREE_TYPE ( ref ) ) != METHOD_TYPE ) return clk_ordinary ; break ; case SCOPE_REF : gcc_unreachable ( ) ; case MAX_EXPR : case MIN_EXPR : if ( TREE_SIDE_EFFECTS ( TREE_OPERAND ( ref , 0 ) ) || TREE_SIDE_EFFECTS ( TREE_OPERAND ( ref , 1 ) ) ) return clk_none ; op1_lvalue_kind = lvalue_p_1 ( TREE_OPERAND ( ref , 0 ) , treat_class_rvalues_as_lvalues ) ; op2_lvalue_kind = lvalue_p_1 ( TREE_OPERAND ( ref , 1 ) , treat_class_rvalues_as_lvalues ) ; break ; case COND_EXPR : op1_lvalue_kind = lvalue_p_1 ( TREE_OPERAND ( ref , 1 ) , treat_class_rvalues_as_lvalues ) ; op2_lvalue_kind = lvalue_p_1 ( TREE_OPERAND ( ref , 2 ) , treat_class_rvalues_as_lvalues ) ; break ; case MODIFY_EXPR : return clk_ordinary ; case COMPOUND_EXPR : return lvalue_p_1 ( TREE_OPERAND ( ref , 1 ) , treat_class_rvalues_as_lvalues ) ; case TARGET_EXPR : return treat_class_rvalues_as_lvalues ? clk_class : clk_none ; case VA_ARG_EXPR : return ( treat_class_rvalues_as_lvalues && CLASS_TYPE_P ( TREE_TYPE ( ref ) ) ? clk_class : clk_none ) ; case CALL_EXPR : return clk_none ; case FUNCTION_DECL : return ( DECL_NONSTATIC_MEMBER_FUNCTION_P ( ref ) ? clk_none : clk_ordinary ) ; case NON_DEPENDENT_EXPR : return clk_ordinary ; default : break ; } if ( ! op1_lvalue_kind || ! op2_lvalue_kind ) return clk_none ; op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind ; if ( ( op1_lvalue_kind & ~ clk_ordinary ) != clk_none ) op1_lvalue_kind &= ~ clk_ordinary ; return op1_lvalue_kind ; }
If REF is an lvalue, returns the kind of lvalue that REF is.
If REF is an lvalue returns the kind of lvalue that REF is .
/* preincrements and predecrements are valid lvals, provided
	 what they refer to are valid lvals.  */ /* Look at the member designator.  */ /* The "field" can be a FUNCTION_DECL or an OVERLOAD in some
	     situations.  */ /* Clear the ordinary bit.  If this object was a class
	     rvalue we want to preserve that information.  */ /* The lvalue is for a bitfield.  */ /* A currently unresolved scope ref.  */ /* Disallow <? and >? as lvalues if either argument side-effects.  */ /* Any class-valued call would be wrapped in a TARGET_EXPR.  */ /* All functions (except non-static-member functions) are
	 lvalues.  */ /* We must consider NON_DEPENDENT_EXPRs to be lvalues so that
	 things like "&E" where "E" is an expression with a
	 non-dependent type work. It is safe to be lenient because an
	 error will be issued when the template is instantiated if "E"
	 is not an lvalue.  */ /* If one operand is not an lvalue at all, then this expression is
     not an lvalue.  */ /* Otherwise, it's an lvalue, and it has all the odd properties
     contributed by either operand.  */ /* It's not an ordinary lvalue if it involves either a bit-field or
     a class rvalue.  */