This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[PATCH 08/11] [PR gdb/14441] gdb: convert lvalue reference type check to general reference type check


In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in
all but these cases we can replace a TYPE_CODE_REF check to TYPE_REFERENCE
check. This patch does exactly that.

./ChangeLog:

2015-12-20  Artemiy Volkov  <artemiyv@acm.org>

        * gdb/aarch64-tdep.c (aarch64_type_align): Change TYPE_CODE_REF
        check to TYPE_REFERENCE check.
        (aarch64_extract_return_value): Likewise.
        (aarch64_store_return_value): Likewise.
        * gdb/amd64-tdep.c (amd64_classify): Likewise.
        * gdb/amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
        Likewise.
        * gdb/arm-tdep.c (arm_type_align): Likewise.
        (arm_extract_return_value): Likewise.
        (arm_store_return_value): Likewise.
        * gdb/ax-gdb.c (gen_fetch): Likewise.
        (gen_cast): Likewise.
        * gdb/c-typeprint.c (c_print_type): Likewise.
        * gdb/c-varobj.c (adjust_value_for_child_access): Likewise.
        (c_value_of_variable): Likewise.
        (cplus_number_of_children): Likewise.
        (cplus_describe_child): Likewise.
        * gdb/compile/compile-c-symbols.c (generate_vla_size): Likewise.
        * gdb/completer.c (expression_completer): Likewise.
        * gdb/cp-support.c (make_symbol_overload_list_adl_namespace):
        Likewise.
        * gdb/darwin-nat-info.c (info_mach_region_command): Likewise.
        * gdb/dwarf2loc.c (entry_data_value_coerce_ref): Likewise.
        (value_of_dwarf_reg_entry): Likewise.
        * gdb/eval.c (ptrmath_type_p): Likewise.
        (evaluate_subexp_standard): Likewise.
        (evaluate_subexp_for_address): Likewise.
        (evaluate_subexp_for_sizeof): Likewise.
        * gdb/findvar.c (extract_typed_address): Likewise.
        (store_typed_address): Likewise.
        * gdb/gdbtypes.c (rank_one_type): Likewise.
        * gdb/hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
        * gdb/infcall.c (value_arg_coerce): Likewise.
        * gdb/language.c (pointer_type): Likewise.
        * gdb/m32c-tdep.c (m32c_reg_arg_type): Likewise.
        (m32c_m16c_address_to_pointer): Likewise.
        (m32c_m16c_pointer_to_address): Likewise.
        * gdb/m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
        * gdb/mn10300-tdep.c (mn10300_type_align): Likewise.
        * gdb/msp430-tdep.c (msp430_push_dummy_call): Likewise.
        * gdb/ppc-sysv-tdep.c (do_ppc_sysv_return_value): Likewise.
        (ppc64_sysv_abi_push_param): Likewise.
        (ppc64_sysv_abi_return_value): Likewise.
        * gdb/printcmd.c (print_formatted): Likewise.
        (x_command): Likewise.
        * gdb/python/py-type.c (typy_get_composite): Likewise.
        (typy_template_argument): Likewise.
        * gdb/python/py-value.c (valpy_referenced_value): Likewise.
        (valpy_get_dynamic_type): Likewise.
        (value_has_field): Likewise.
        (valpy_getitem): Likewise.
        * gdb/python/py-xmethods.c (gdbpy_get_xmethod_result_type):
        Handle TYPE_CODE_VALUE_REF type.
        (gdbpy_invoke_xmethod): Likewise.
        * gdb/s390-linux-tdep.c (s390_function_arg_integer): Change
        TYPE_CODE_REF check to TYPE_REFERENCE check.
        * gdb/sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
        * gdb/sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
        * gdb/spu-tdep.c (spu_scalar_value_p): Likewise.
        * gdb/symtab.c (lookup_symbol_aux): Likewise.
        * gdb/typeprint.c (whatis_exp): Likewise.
        (print_type_scalar): Likewise.
        * gdb/valarith.c (binop_types_user_defined_p): Likewise.
        (unop_user_defined_p): Likewise.
        * gdb/valops.c (value_cast_pointers): Likewise.
        (value_cast): Likewise.
        (value_reinterpret_cast): Likewise.
        (value_dynamic_cast): Likewise.
        (value_addr): Likewise.
        (typecmp): Likewise.
        (value_struct_elt): Likewise.
        (value_struct_elt_bitpos): Likewise.
        (value_find_oload_method_list): Likewise.
        (find_overload_match): Likewise.
        (value_rtti_indirect_type): Likewise.
        * gdb/valprint.c (val_print_scalar_type_p): Likewise.
        (generic_val_print): Likewise.
        * gdb/value.c (value_actual_type): Likewise.
        (value_as_address): Likewise.
        (unpack_long): Likewise.
        (pack_long): Likewise.
        (pack_unsigned_long): Likewise.
        (coerce_ref_if_computed): Likewise.
        (coerce_ref): Likewise. Likewise.
        * gdb/varobj.c (varobj_get_value_type): Likewise.
---
 gdb/aarch64-tdep.c              |  5 +++--
 gdb/amd64-tdep.c                |  2 +-
 gdb/amd64-windows-tdep.c        |  1 +
 gdb/arm-tdep.c                  |  5 +++--
 gdb/ax-gdb.c                    |  2 ++
 gdb/c-typeprint.c               |  2 +-
 gdb/c-varobj.c                  | 10 ++++-----
 gdb/compile/compile-c-symbols.c |  2 +-
 gdb/completer.c                 |  3 +--
 gdb/cp-support.c                |  2 +-
 gdb/darwin-nat-info.c           |  2 +-
 gdb/dwarf2loc.c                 |  4 ++--
 gdb/eval.c                      | 16 +++++++-------
 gdb/findvar.c                   |  6 ++----
 gdb/gdbtypes.c                  |  5 +++--
 gdb/hppa-tdep.c                 |  1 +
 gdb/infcall.c                   |  3 ++-
 gdb/language.c                  |  3 +--
 gdb/m32c-tdep.c                 |  8 +++----
 gdb/m88k-tdep.c                 |  1 +
 gdb/mn10300-tdep.c              |  1 +
 gdb/msp430-tdep.c               |  2 +-
 gdb/ppc-sysv-tdep.c             | 10 ++++-----
 gdb/printcmd.c                  |  4 ++--
 gdb/python/py-type.c            |  5 ++---
 gdb/python/py-value.c           | 13 +++++------
 gdb/python/py-xmethods.c        | 15 +++++++++++++
 gdb/s390-linux-tdep.c           |  2 +-
 gdb/sparc-tdep.c                |  1 +
 gdb/sparc64-tdep.c              |  1 +
 gdb/spu-tdep.c                  |  1 +
 gdb/symtab.c                    |  3 +--
 gdb/typeprint.c                 |  4 ++--
 gdb/valarith.c                  |  6 +++---
 gdb/valops.c                    | 48 ++++++++++++++++++-----------------------
 gdb/valprint.c                  |  5 +++--
 gdb/value.c                     | 12 ++++++-----
 gdb/varobj.c                    |  2 +-
 38 files changed, 117 insertions(+), 101 deletions(-)

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index f4763bb..ae743bc 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -890,6 +890,7 @@ aarch64_type_align (struct type *t)
     case TYPE_CODE_RANGE:
     case TYPE_CODE_BITSTRING:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_CHAR:
     case TYPE_CODE_BOOL:
       return TYPE_LENGTH (t);
@@ -1613,7 +1614,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
 	   || TYPE_CODE (type) == TYPE_CODE_CHAR
 	   || TYPE_CODE (type) == TYPE_CODE_BOOL
 	   || TYPE_CODE (type) == TYPE_CODE_PTR
-	   || TYPE_CODE (type) == TYPE_CODE_REF
+	   || TYPE_REFERENCE (type)
 	   || TYPE_CODE (type) == TYPE_CODE_ENUM)
     {
       /* If the the type is a plain integer, then the access is
@@ -1754,7 +1755,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
 	   || TYPE_CODE (type) == TYPE_CODE_CHAR
 	   || TYPE_CODE (type) == TYPE_CODE_BOOL
 	   || TYPE_CODE (type) == TYPE_CODE_PTR
-	   || TYPE_CODE (type) == TYPE_CODE_REF
+	   || TYPE_REFERENCE (type)
 	   || TYPE_CODE (type) == TYPE_CODE_ENUM)
     {
       if (TYPE_LENGTH (type) <= X_REGISTER_SIZE)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 6096ce9..250e686 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -643,7 +643,7 @@ amd64_classify (struct type *type, enum amd64_reg_class theclass[2])
   if ((code == TYPE_CODE_INT || code == TYPE_CODE_ENUM
        || code == TYPE_CODE_BOOL || code == TYPE_CODE_RANGE
        || code == TYPE_CODE_CHAR
-       || code == TYPE_CODE_PTR || code == TYPE_CODE_REF)
+       || code == TYPE_CODE_PTR || TYPE_REFERENCE (type))
       && (len == 1 || len == 2 || len == 4 || len == 8))
     theclass[0] = AMD64_INTEGER;
 
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index c04b730..32e4075 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -55,6 +55,7 @@ amd64_windows_passed_by_integer_register (struct type *type)
       case TYPE_CODE_CHAR:
       case TYPE_CODE_PTR:
       case TYPE_CODE_REF:
+      case TYPE_CODE_RVALUE_REF:
       case TYPE_CODE_STRUCT:
       case TYPE_CODE_UNION:
 	return (TYPE_LENGTH (type) == 1
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 0e10dfd..a19ed59 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3240,6 +3240,7 @@ arm_type_align (struct type *t)
     case TYPE_CODE_SET:
     case TYPE_CODE_RANGE:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_CHAR:
     case TYPE_CODE_BOOL:
       return TYPE_LENGTH (t);
@@ -7826,7 +7827,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
 	   || TYPE_CODE (type) == TYPE_CODE_CHAR
 	   || TYPE_CODE (type) == TYPE_CODE_BOOL
 	   || TYPE_CODE (type) == TYPE_CODE_PTR
-	   || TYPE_CODE (type) == TYPE_CODE_REF
+          || TYPE_REFERENCE (type)
 	   || TYPE_CODE (type) == TYPE_CODE_ENUM)
     {
       /* If the type is a plain integer, then the access is
@@ -8031,7 +8032,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
 	   || TYPE_CODE (type) == TYPE_CODE_CHAR
 	   || TYPE_CODE (type) == TYPE_CODE_BOOL
 	   || TYPE_CODE (type) == TYPE_CODE_PTR
-	   || TYPE_CODE (type) == TYPE_CODE_REF
+          || TYPE_REFERENCE (type)
 	   || TYPE_CODE (type) == TYPE_CODE_ENUM)
     {
       if (TYPE_LENGTH (type) <= 4)
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 7091a4a..f9e5551 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -492,6 +492,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
     {
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_ENUM:
     case TYPE_CODE_INT:
     case TYPE_CODE_CHAR:
@@ -1002,6 +1003,7 @@ gen_cast (struct agent_expr *ax, struct axs_value *value, struct type *type)
     {
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       /* It's implementation-defined, and I'll bet this is what GCC
          does.  */
       break;
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 1ed8cdc..0037562 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -112,7 +112,7 @@ c_print_type (struct type *type,
 		      && !TYPE_VECTOR (type))
 		  || code == TYPE_CODE_MEMBERPTR
 		  || code == TYPE_CODE_METHODPTR
-                 || TYPE_REFERENCE (type))))
+		  || TYPE_REFERENCE (type))))
 	fputs_filtered (" ", stream);
       need_post_space = (varstring != NULL && strcmp (varstring, "") != 0);
       c_type_print_varspec_prefix (type, stream, show, 0, need_post_space,
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index b39a113..1457655 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -78,7 +78,7 @@ adjust_value_for_child_access (struct value **value,
      to us, is already supposed to be
      reference-stripped.  */
 
-  gdb_assert (TYPE_CODE (*type) != TYPE_CODE_REF);
+  gdb_assert (!TYPE_REFERENCE (*type));
 
   /* Pointers to structures are treated just like
      structures when accessing children.  Don't
@@ -489,7 +489,7 @@ c_value_of_variable (const struct varobj *var,
   struct type *type = get_type (var);
 
   /* Strip top-level references.  */
-  while (TYPE_CODE (type) == TYPE_CODE_REF)
+  while (TYPE_REFERENCE (type))
     type = check_typedef (TYPE_TARGET_TYPE (type));
 
   switch (TYPE_CODE (type))
@@ -586,7 +586,7 @@ cplus_number_of_children (const struct varobj *var)
       if (opts.objectprint)
         {
           value = var->value;
-          lookup_actual_type = (TYPE_CODE (var->type) == TYPE_CODE_REF
+          lookup_actual_type = (TYPE_REFERENCE (var->type)
 				|| TYPE_CODE (var->type) == TYPE_CODE_PTR);
         }
       adjust_value_for_child_access (&value, &type, NULL, lookup_actual_type);
@@ -623,7 +623,7 @@ cplus_number_of_children (const struct varobj *var)
 	  const struct varobj *parent = var->parent;
 
 	  value = parent->value;
-	  lookup_actual_type = (TYPE_CODE (parent->type) == TYPE_CODE_REF
+	  lookup_actual_type = (TYPE_REFERENCE (parent->type)
 				|| TYPE_CODE (parent->type) == TYPE_CODE_PTR);
         }
       adjust_value_for_child_access (&value, &type, NULL, lookup_actual_type);
@@ -728,7 +728,7 @@ cplus_describe_child (const struct varobj *parent, int index,
 
   var = (CPLUS_FAKE_CHILD (parent)) ? parent->parent : parent;
   if (opts.objectprint)
-    lookup_actual_type = (TYPE_CODE (var->type) == TYPE_CODE_REF
+    lookup_actual_type = (TYPE_REFERENCE (var->type)
 			  || TYPE_CODE (var->type) == TYPE_CODE_PTR);
   value = var->value;
   type = varobj_get_value_type (var);
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index f5ca15c..1181a6b 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -593,7 +593,7 @@ generate_vla_size (struct compile_c_instance *compiler,
 {
   type = check_typedef (type);
 
-  if (TYPE_CODE (type) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type))
     type = check_typedef (TYPE_TARGET_TYPE (type));
 
   switch (TYPE_CODE (type))
diff --git a/gdb/completer.c b/gdb/completer.c
index bafcb50..c0dbaaf 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -610,8 +610,7 @@ expression_completer (struct cmd_list_element *ignore,
       for (;;)
 	{
 	  type = check_typedef (type);
-	  if (TYPE_CODE (type) != TYPE_CODE_PTR
-	      && TYPE_CODE (type) != TYPE_CODE_REF)
+	  if (TYPE_CODE (type) != TYPE_CODE_PTR && !TYPE_REFERENCE (type))
 	    break;
 	  type = TYPE_TARGET_TYPE (type);
 	}
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 6f85c4c..458a649 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1279,7 +1279,7 @@ make_symbol_overload_list_adl_namespace (struct type *type,
   int i, prefix_len;
 
   while (TYPE_CODE (type) == TYPE_CODE_PTR
-	 || TYPE_CODE (type) == TYPE_CODE_REF
+	 || TYPE_REFERENCE (type)
          || TYPE_CODE (type) == TYPE_CODE_ARRAY
          || TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
     {
diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c
index 90e61da..d8faa14 100644
--- a/gdb/darwin-nat-info.c
+++ b/gdb/darwin-nat-info.c
@@ -732,7 +732,7 @@ info_mach_region_command (char *exp, int from_tty)
 
   expr = parse_expression (exp);
   val = evaluate_expression (expr);
-  if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (value_type (val)))
     {
       val = value_ind (val);
     }
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index b8e7fa0..fdd6028 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1337,7 +1337,7 @@ entry_data_value_coerce_ref (const struct value *value)
   struct type *checked_type = check_typedef (value_type (value));
   struct value *target_val;
 
-  if (TYPE_CODE (checked_type) != TYPE_CODE_REF)
+  if (!TYPE_REFERENCE (checked_type))
     return NULL;
 
   target_val = (struct value *) value_computed_closure (value);
@@ -1412,7 +1412,7 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
      TYPE_CODE_REF with non-entry data value would give current value - not the
      entry value.  */
 
-  if (TYPE_CODE (checked_type) != TYPE_CODE_REF
+  if (!TYPE_REFERENCE (checked_type)
       || TYPE_TARGET_TYPE (checked_type) == NULL)
     return outer_val;
 
diff --git a/gdb/eval.c b/gdb/eval.c
index 3d408e4..bce06e8 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -640,7 +640,7 @@ static int
 ptrmath_type_p (const struct language_defn *lang, struct type *type)
 {
   type = check_typedef (type);
-  if (TYPE_CODE (type) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type))
     type = TYPE_TARGET_TYPE (type);
 
   switch (TYPE_CODE (type))
@@ -2509,7 +2509,7 @@ evaluate_subexp_standard (struct type *expect_type,
 	{
 	  type = check_typedef (value_type (arg1));
 	  if (TYPE_CODE (type) == TYPE_CODE_PTR
-	      || TYPE_CODE (type) == TYPE_CODE_REF
+	      || TYPE_REFERENCE (type)
 	  /* In C you can dereference an array to get the 1st elt.  */
 	      || TYPE_CODE (type) == TYPE_CODE_ARRAY
 	    )
@@ -2787,9 +2787,9 @@ evaluate_subexp_standard (struct type *expect_type,
 	    {
 	      struct type *type = value_type (result);
 
-	      if (TYPE_CODE (check_typedef (type)) != TYPE_CODE_REF)
+	      if (!TYPE_REFERENCE (type))
 		{
-                 type = lookup_lvalue_reference_type (type);
+		  type = lookup_lvalue_reference_type (type);
 		  result = allocate_value (type);
 		}
 	    }
@@ -2890,7 +2890,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
 
       /* C++: The "address" of a reference should yield the address
        * of the object pointed to.  Let value_addr() deal with it.  */
-      if (TYPE_CODE (SYMBOL_TYPE (var)) == TYPE_CODE_REF)
+      if (TYPE_REFERENCE (SYMBOL_TYPE (var)))
 	goto default_case;
 
       (*pos) += 4;
@@ -2929,7 +2929,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
 	{
 	  struct type *type = check_typedef (value_type (x));
 
-	  if (TYPE_CODE (type) == TYPE_CODE_REF)
+	  if (TYPE_REFERENCE (type))
 	    return value_zero (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
 			       not_lval);
 	  else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x))
@@ -3019,7 +3019,7 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos,
       val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
       type = check_typedef (value_type (val));
       if (TYPE_CODE (type) != TYPE_CODE_PTR
-	  && TYPE_CODE (type) != TYPE_CODE_REF
+	  && !TYPE_REFERENCE (type)
 	  && TYPE_CODE (type) != TYPE_CODE_ARRAY)
 	error (_("Attempt to take contents of a non-pointer value."));
       type = TYPE_TARGET_TYPE (type);
@@ -3091,7 +3091,7 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos,
      the size of the referenced type."  */
   type = check_typedef (type);
   if (exp->language_defn->la_language == language_cplus
-      && TYPE_CODE (type) == TYPE_CODE_REF)
+      && (TYPE_REFERENCE (type)))
     type = check_typedef (TYPE_TARGET_TYPE (type));
   return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
 }
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 855947d..aa6e81d 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -169,8 +169,7 @@ extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
 CORE_ADDR
 extract_typed_address (const gdb_byte *buf, struct type *type)
 {
-  if (TYPE_CODE (type) != TYPE_CODE_PTR
-      && TYPE_CODE (type) != TYPE_CODE_REF)
+  if (TYPE_CODE (type) != TYPE_CODE_PTR && !TYPE_REFERENCE (type))
     internal_error (__FILE__, __LINE__,
 		    _("extract_typed_address: "
 		    "type is not a pointer or reference"));
@@ -242,8 +241,7 @@ store_unsigned_integer (gdb_byte *addr, int len,
 void
 store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr)
 {
-  if (TYPE_CODE (type) != TYPE_CODE_PTR
-      && TYPE_CODE (type) != TYPE_CODE_REF)
+  if (TYPE_CODE (type) != TYPE_CODE_PTR && !TYPE_REFERENCE (type))
     internal_error (__FILE__, __LINE__,
 		    _("store_typed_address: "
 		    "type is not a pointer or reference"));
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 49e5bf2..0cf7d2e 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3475,10 +3475,11 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value)
 
   /* See through references, since we can almost make non-references
      references.  */
-  if (TYPE_CODE (arg) == TYPE_CODE_REF)
+
+  if (TYPE_REFERENCE (arg))
     return (sum_ranks (rank_one_type (parm, TYPE_TARGET_TYPE (arg), NULL),
                        REFERENCE_CONVERSION_BADNESS));
-  if (TYPE_CODE (parm) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (parm))
     return (sum_ranks (rank_one_type (TYPE_TARGET_TYPE (parm), arg, NULL),
                        REFERENCE_CONVERSION_BADNESS));
   if (overload_debug)
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 3206729..bc0c21c 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -902,6 +902,7 @@ hppa64_integral_or_pointer_p (const struct type *type)
       }
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       return (TYPE_LENGTH (type) == 8);
     default:
       break;
diff --git a/gdb/infcall.c b/gdb/infcall.c
index eafd812..0dc897a 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -158,10 +158,11 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       {
 	struct value *new_value;
 
-	if (TYPE_CODE (arg_type) == TYPE_CODE_REF)
+	if (TYPE_REFERENCE (arg_type))
 	  return value_cast_pointers (type, arg, 0);
 
 	/* Cast the value to the reference's target type, and then
diff --git a/gdb/language.c b/gdb/language.c
index 6a10539..25bc644 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -410,8 +410,7 @@ language_info (int quietly)
 int
 pointer_type (struct type *type)
 {
-  return TYPE_CODE (type) == TYPE_CODE_PTR ||
-    TYPE_CODE (type) == TYPE_CODE_REF;
+  return TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_REFERENCE (type);
 }
 
 
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index e31397c..1f5628b 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -2031,7 +2031,7 @@ m32c_reg_arg_type (struct type *type)
   return (code == TYPE_CODE_INT
 	  || code == TYPE_CODE_ENUM
 	  || code == TYPE_CODE_PTR
-	  || code == TYPE_CODE_REF
+	  || TYPE_REFERENCE (type)
 	  || code == TYPE_CODE_BOOL
 	  || code == TYPE_CODE_CHAR);
 }
@@ -2453,8 +2453,7 @@ m32c_m16c_address_to_pointer (struct gdbarch *gdbarch,
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   enum type_code target_code;
-  gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR ||
-	      TYPE_CODE (type) == TYPE_CODE_REF);
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_REFERENCE (type));
 
   target_code = TYPE_CODE (TYPE_TARGET_TYPE (type));
 
@@ -2533,8 +2532,7 @@ m32c_m16c_pointer_to_address (struct gdbarch *gdbarch,
   CORE_ADDR ptr;
   enum type_code target_code;
 
-  gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR ||
-	      TYPE_CODE (type) == TYPE_CODE_REF);
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_REFERENCE (type));
 
   ptr = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
 
diff --git a/gdb/m88k-tdep.c b/gdb/m88k-tdep.c
index 94ea409..445ea2e 100644
--- a/gdb/m88k-tdep.c
+++ b/gdb/m88k-tdep.c
@@ -165,6 +165,7 @@ m88k_integral_or_pointer_p (const struct type *type)
       return 1;
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       {
 	/* Allow only 32-bit pointers.  */
 	return (TYPE_LENGTH (type) == 4);
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 5603333..ddd27e8 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -96,6 +96,7 @@ mn10300_type_align (struct type *type)
     case TYPE_CODE_FLT:
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       return TYPE_LENGTH (type);
 
     case TYPE_CODE_COMPLEX:
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index 5368025..ccaeb39 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -769,7 +769,7 @@ msp430_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
 		  if (code_model == MSP_LARGE_CODE_MODEL
 		      && (TYPE_CODE (arg_type) == TYPE_CODE_PTR
-		          || TYPE_CODE (arg_type) == TYPE_CODE_REF
+		          || TYPE_REFERENCE (arg_type)
 			  || TYPE_CODE (arg_type) == TYPE_CODE_STRUCT
 			  || TYPE_CODE (arg_type) == TYPE_CODE_UNION))
 		    {
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index 1c2644d..035c8c3 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -805,7 +805,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type,
 	    || TYPE_CODE (type) == TYPE_CODE_CHAR
 	    || TYPE_CODE (type) == TYPE_CODE_BOOL
 	    || TYPE_CODE (type) == TYPE_CODE_PTR
-	    || TYPE_CODE (type) == TYPE_CODE_REF
+	    || TYPE_REFERENCE (type)
 	    || TYPE_CODE (type) == TYPE_CODE_ENUM)
 	   && TYPE_LENGTH (type) <= tdep->wordsize)
     {
@@ -1493,7 +1493,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch,
 	    || TYPE_CODE (type) == TYPE_CODE_BOOL
 	    || TYPE_CODE (type) == TYPE_CODE_CHAR
 	    || TYPE_CODE (type) == TYPE_CODE_PTR
-	    || TYPE_CODE (type) == TYPE_CODE_REF)
+	    || TYPE_REFERENCE (type))
 	   && TYPE_LENGTH (type) <= tdep->wordsize)
     {
       ULONGEST word = 0;
@@ -1505,8 +1505,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch,
 
 	  /* Convert any function code addresses into descriptors.  */
 	  if (tdep->elf_abi == POWERPC_ELF_V1
-	      && (TYPE_CODE (type) == TYPE_CODE_PTR
-		  || TYPE_CODE (type) == TYPE_CODE_REF))
+	      && (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_REFERENCE (type)))
 	    {
 	      struct type *target_type
 		= check_typedef (TYPE_TARGET_TYPE (type));
@@ -1999,8 +1998,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
     }
 
   /* All pointers live in r3.  */
-  if (TYPE_CODE (valtype) == TYPE_CODE_PTR
-      || TYPE_CODE (valtype) == TYPE_CODE_REF)
+  if (TYPE_CODE (valtype) == TYPE_CODE_PTR || TYPE_REFERENCE (valtype))
     {
       int regnum = tdep->ppc_gp0_regnum + 3;
 
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c676fc7..3a59ad5 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -306,7 +306,7 @@ print_formatted (struct value *val, int size,
     }
 
   if (options->format == 0 || options->format == 's'
-      || TYPE_CODE (type) == TYPE_CODE_REF
+      || TYPE_REFERENCE (type)
       || TYPE_CODE (type) == TYPE_CODE_ARRAY
       || TYPE_CODE (type) == TYPE_CODE_STRING
       || TYPE_CODE (type) == TYPE_CODE_STRUCT
@@ -1449,7 +1449,7 @@ x_command (char *exp, int from_tty)
 	*exp = 0;
       old_chain = make_cleanup (free_current_contents, &expr);
       val = evaluate_expression (expr);
-      if (TYPE_CODE (value_type (val)) == TYPE_CODE_REF)
+      if (TYPE_REFERENCE (value_type (val)))
 	val = coerce_ref (val);
       /* In rvalue contexts, such as this, functions are coerced into
          pointers to functions.  This makes "x/i main" work.  */
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index ad2f952..2c071cc 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -485,8 +485,7 @@ typy_get_composite (struct type *type)
 	}
       END_CATCH
 
-      if (TYPE_CODE (type) != TYPE_CODE_PTR
-	  && TYPE_CODE (type) != TYPE_CODE_REF)
+      if (TYPE_CODE (type) != TYPE_CODE_PTR && !TYPE_REFERENCE (type))
 	break;
       type = TYPE_TARGET_TYPE (type);
     }
@@ -966,7 +965,7 @@ typy_template_argument (PyObject *self, PyObject *args)
   TRY
     {
       type = check_typedef (type);
-      if (TYPE_CODE (type) == TYPE_CODE_REF)
+      if (TYPE_REFERENCE (type))
 	type = check_typedef (TYPE_TARGET_TYPE (type));
     }
   CATCH (except, RETURN_MASK_ALL)
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index f9231fb..e97a040 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -217,6 +217,7 @@ valpy_referenced_value (PyObject *self, PyObject *args)
           res_val = value_ind (self_val);
           break;
         case TYPE_CODE_REF:
+        case TYPE_CODE_RVALUE_REF:
           res_val = coerce_ref (self_val);
           break;
         default:
@@ -358,8 +359,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure)
       type = value_type (val);
       type = check_typedef (type);
 
-      if (((TYPE_CODE (type) == TYPE_CODE_PTR)
-	   || (TYPE_CODE (type) == TYPE_CODE_REF))
+      if (((TYPE_CODE (type) == TYPE_CODE_PTR) || TYPE_REFERENCE (type))
 	  && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT))
 	{
 	  struct value *target;
@@ -598,9 +598,8 @@ value_has_field (struct value *v, PyObject *field)
     {
       val_type = value_type (v);
       val_type = check_typedef (val_type);
-      if (TYPE_CODE (val_type) == TYPE_CODE_REF
-	  || TYPE_CODE (val_type) == TYPE_CODE_PTR)
-      val_type = check_typedef (TYPE_TARGET_TYPE (val_type));
+      if (TYPE_REFERENCE (val_type) || TYPE_CODE (val_type) == TYPE_CODE_PTR)
+        val_type = check_typedef (TYPE_TARGET_TYPE (val_type));
 
       type_code = TYPE_CODE (val_type);
       if ((type_code == TYPE_CODE_STRUCT || type_code == TYPE_CODE_UNION)
@@ -767,6 +766,8 @@ valpy_getitem (PyObject *self, PyObject *key)
 	    res_val = value_cast (lookup_pointer_type (base_class_type), tmp);
 	  else if (TYPE_CODE (val_type) == TYPE_CODE_REF)
            res_val = value_cast (lookup_lvalue_reference_type (base_class_type), tmp);
+	  else if (TYPE_CODE (val_type) == TYPE_CODE_RVALUE_REF)
+           res_val = value_cast (lookup_rvalue_reference_type (base_class_type), tmp);
 	  else
 	    res_val = value_cast (base_class_type, tmp);
 	}
@@ -1016,7 +1017,7 @@ enum valpy_opcode
 
 /* If TYPE is a reference, return the target; otherwise return TYPE.  */
 #define STRIP_REFERENCE(TYPE) \
-  ((TYPE_CODE (TYPE) == TYPE_CODE_REF) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE))
+  (TYPE_REFERENCE (TYPE) ? (TYPE_TARGET_TYPE (TYPE)) : (TYPE))
 
 /* Helper for valpy_binop.  Returns a value object which is the result
    of applying the operation specified by OPCODE to the given
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index 0cda83d..7eb4118 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -555,6 +555,13 @@ gdbpy_get_xmethod_result_type (const struct extension_language_defn *extlang,
       if (!types_equal (obj_type, this_ref))
 	obj = value_cast (this_ref, obj);
     }
+  else if (TYPE_CODE (obj_type) == TYPE_CODE_RVALUE_REF)
+    {
+      struct type *this_ref = lookup_rvalue_reference_type (this_type);
+
+      if (!types_equal (obj_type, this_ref))
+	obj = value_cast (this_ref, obj);
+    }
   else
     {
       if (!types_equal (obj_type, this_type))
@@ -641,6 +648,14 @@ gdbpy_invoke_xmethod (const struct extension_language_defn *extlang,
       if (!types_equal (obj_type, this_ref))
 	obj = value_cast (this_ref, obj);
     }
+  else if (TYPE_CODE (obj_type) == TYPE_CODE_RVALUE_REF)
+    {
+      struct type *this_ref = lookup_rvalue_reference_type (this_type);
+
+      if (!types_equal (obj_type, this_ref))
+	obj = value_cast (this_ref, obj);
+    }
+
   else
     {
       if (!types_equal (obj_type, this_type))
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 0f8a3a8..85d94de 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -3004,7 +3004,7 @@ s390_function_arg_integer (struct type *type)
       || code == TYPE_CODE_CHAR
       || code == TYPE_CODE_BOOL
       || code == TYPE_CODE_PTR
-      || code == TYPE_CODE_REF)
+      || TYPE_REFERENCE (type))
     return 1;
 
   return ((code == TYPE_CODE_UNION || code == TYPE_CODE_STRUCT)
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index b2bba26..8a415b8 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -225,6 +225,7 @@ sparc_integral_or_pointer_p (const struct type *type)
       return (len == 1 || len == 2 || len == 4 || len == 8);
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       /* Allow either 32-bit or 64-bit pointers.  */
       return (len == 4 || len == 8);
     default:
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index a23740e..200f08d 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -67,6 +67,7 @@ sparc64_integral_or_pointer_p (const struct type *type)
       return 1;
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       {
 	int len = TYPE_LENGTH (type);
 	gdb_assert (len == 8);
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index c94b46e..6ec0771 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1338,6 +1338,7 @@ spu_scalar_value_p (struct type *type)
     case TYPE_CODE_BOOL:
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       return TYPE_LENGTH (type) <= 16;
 
     default:
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c42f5b6..153d603 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2145,8 +2145,7 @@ lookup_symbol_aux (const char *name, const struct block *block,
 	  /* I'm not really sure that type of this can ever
 	     be typedefed; just be safe.  */
 	  t = check_typedef (t);
-	  if (TYPE_CODE (t) == TYPE_CODE_PTR
-	      || TYPE_CODE (t) == TYPE_CODE_REF)
+	  if (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_REFERENCE (t))
 	    t = TYPE_TARGET_TYPE (t);
 
 	  if (TYPE_CODE (t) != TYPE_CODE_STRUCT
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 377223a..5c71550 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -463,8 +463,7 @@ whatis_exp (char *exp, int show)
   get_user_print_options (&opts);
   if (opts.objectprint)
     {
-      if (((TYPE_CODE (type) == TYPE_CODE_PTR)
-	   || (TYPE_CODE (type) == TYPE_CODE_REF))
+      if (((TYPE_CODE (type) == TYPE_CODE_PTR) || TYPE_REFERENCE (type))
 	  && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT))
         real_type = value_rtti_indirect_type (val, &full, &top, &using_enc);
       else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
@@ -581,6 +580,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
     case TYPE_CODE_METHODPTR:
     case TYPE_CODE_METHOD:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_NAMESPACE:
       error (_("internal error: unhandled type in print_type_scalar"));
       break;
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 97145a1..fc6b7f4 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -239,11 +239,11 @@ binop_types_user_defined_p (enum exp_opcode op,
     return 0;
 
   type1 = check_typedef (type1);
-  if (TYPE_CODE (type1) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type1))
     type1 = check_typedef (TYPE_TARGET_TYPE (type1));
 
   type2 = check_typedef (type2);
-  if (TYPE_CODE (type2) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type2))
     type2 = check_typedef (TYPE_TARGET_TYPE (type2));
 
   return (TYPE_CODE (type1) == TYPE_CODE_STRUCT
@@ -277,7 +277,7 @@ unop_user_defined_p (enum exp_opcode op, struct value *arg1)
   if (op == UNOP_ADDR)
     return 0;
   type1 = check_typedef (value_type (arg1));
-  if (TYPE_CODE (type1) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type1))
     type1 = check_typedef (TYPE_TARGET_TYPE (type1));
   return TYPE_CODE (type1) == TYPE_CODE_STRUCT;
 }
diff --git a/gdb/valops.c b/gdb/valops.c
index 3a3e960..adf3636 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -317,7 +317,7 @@ value_cast_pointers (struct type *type, struct value *arg2,
     {
       struct value *v2;
 
-      if (TYPE_CODE (type2) == TYPE_CODE_REF)
+      if (TYPE_REFERENCE (type2))
 	v2 = coerce_ref (arg2);
       else
 	v2 = value_ind (arg2);
@@ -360,24 +360,20 @@ value_cast (struct type *type, struct value *arg2)
   if (value_type (arg2) == type)
     return arg2;
 
-  code1 = TYPE_CODE (check_typedef (type));
-
   /* Check if we are casting struct reference to struct reference.  */
-  if (code1 == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (check_typedef (type)))
     {
       /* We dereference type; then we recurse and finally
          we generate value of the given reference.  Nothing wrong with 
 	 that.  */
       struct type *t1 = check_typedef (type);
       struct type *dereftype = check_typedef (TYPE_TARGET_TYPE (t1));
-      struct value *val =  value_cast (dereftype, arg2);
+      struct value *val = value_cast (dereftype, arg2);
 
       return value_ref (val, TYPE_CODE (t1));
     }
 
-  code2 = TYPE_CODE (check_typedef (value_type (arg2)));
-
-  if (code2 == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (check_typedef (value_type (arg2))))
     /* We deref the value and then do the cast.  */
     return value_cast (type, coerce_ref (arg2)); 
 
@@ -388,7 +384,7 @@ value_cast (struct type *type, struct value *arg2)
 
   /* You can't cast to a reference type.  See value_cast_pointers
      instead.  */
-  gdb_assert (code1 != TYPE_CODE_REF);
+  gdb_assert (!TYPE_REFERENCE (type));
 
   /* A cast to an undetermined-length array_type, such as 
      (TYPE [])OBJECT, is treated like a cast to (TYPE [N])OBJECT,
@@ -591,8 +587,8 @@ value_reinterpret_cast (struct type *type, struct value *arg)
   dest_type = type;
 
   /* If we are casting to a reference type, transform
-     reinterpret_cast<T&>(V) to *reinterpret_cast<T*>(&V).  */
-  if (TYPE_CODE (real_type) == TYPE_CODE_REF)
+     reinterpret_cast<T&[&]>(V) to *reinterpret_cast<T*>(&V).  */
+  if (TYPE_REFERENCE (real_type))
     {
       is_ref = 1;
       arg = value_addr (arg);
@@ -730,10 +726,10 @@ value_dynamic_cast (struct type *type, struct value *arg)
   struct type *class_type, *rtti_type;
   struct value *result, *tem, *original_arg = arg;
   CORE_ADDR addr;
-  int is_ref = TYPE_CODE (resolved_type) == TYPE_CODE_REF;
+  int is_ref = TYPE_REFERENCE (resolved_type);
 
   if (TYPE_CODE (resolved_type) != TYPE_CODE_PTR
-      && TYPE_CODE (resolved_type) != TYPE_CODE_REF)
+      && !TYPE_REFERENCE (resolved_type))
     error (_("Argument to dynamic_cast must be a pointer or reference type"));
   if (TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_VOID
       && TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_STRUCT)
@@ -1461,9 +1457,9 @@ value_addr (struct value *arg1)
   struct value *arg2;
   struct type *type = check_typedef (value_type (arg1));
 
-  if (TYPE_CODE (type) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type))
     {
-      /* Copy the value, but change the type from (T&) to (T*).  We
+      /* Copy the value, but change the type from (T&[&]) to (T*).  We
          keep the same location information, which is efficient, and
          allows &(&X) to get the location containing the reference.  */
       arg2 = value_copy (arg1);
@@ -1711,7 +1707,7 @@ typecmp (int staticp, int varargs, int nargs,
       tt1 = check_typedef (t1[i].type);
       tt2 = check_typedef (value_type (t2[i]));
 
-      if (TYPE_CODE (tt1) == TYPE_CODE_REF
+      if ((TYPE_REFERENCE (tt1))
 	  /* We should be doing hairy argument matching, as below.  */
 	  && (TYPE_CODE (check_typedef (TYPE_TARGET_TYPE (tt1)))
 	      == TYPE_CODE (tt2)))
@@ -1729,14 +1725,12 @@ typecmp (int staticp, int varargs, int nargs,
 	 char *>, and properly access map["hello"], because the
 	 argument to [] will be a reference to a pointer to a char,
 	 and the argument will be a pointer to a char.  */
-      while (TYPE_CODE(tt1) == TYPE_CODE_REF
-	     || TYPE_CODE (tt1) == TYPE_CODE_PTR)
-	{
+      while (TYPE_REFERENCE(tt1) || TYPE_CODE (tt1) == TYPE_CODE_PTR) {
 	  tt1 = check_typedef( TYPE_TARGET_TYPE(tt1) );
 	}
       while (TYPE_CODE(tt2) == TYPE_CODE_ARRAY
 	     || TYPE_CODE(tt2) == TYPE_CODE_PTR
-	     || TYPE_CODE(tt2) == TYPE_CODE_REF)
+	     || TYPE_REFERENCE(tt2))
 	{
 	  tt2 = check_typedef (TYPE_TARGET_TYPE(tt2));
 	}
@@ -2128,7 +2122,7 @@ value_struct_elt (struct value **argp, struct value **args,
 
   /* Follow pointers until we get to a non-pointer.  */
 
-  while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
+  while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_REFERENCE (t))
     {
       *argp = value_ind (*argp);
       /* Don't coerce fn pointer to fn and then back again!  */
@@ -2217,7 +2211,7 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype,
 
   t = check_typedef (value_type (*argp));
 
-  while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
+  while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_REFERENCE (t))
     {
       *argp = value_ind (*argp);
       if (TYPE_CODE (check_typedef (value_type (*argp))) != TYPE_CODE_FUNC)
@@ -2378,7 +2372,7 @@ value_find_oload_method_list (struct value **argp, const char *method,
   t = check_typedef (value_type (*argp));
 
   /* Code snarfed from value_struct_elt.  */
-  while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF)
+  while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_REFERENCE (t))
     {
       *argp = value_ind (*argp);
       /* Don't coerce fn pointer to fn and then back again!  */
@@ -2789,7 +2783,7 @@ find_overload_match (struct value **args, int nargs,
 
       if (TYPE_CODE (temp_type) != TYPE_CODE_PTR
 	  && (TYPE_CODE (objtype) == TYPE_CODE_PTR
-	      || TYPE_CODE (objtype) == TYPE_CODE_REF))
+	      || TYPE_REFERENCE (objtype)))
 	{
 	  temp = value_addr (temp);
 	}
@@ -3586,7 +3580,7 @@ value_rtti_indirect_type (struct value *v, int *full,
 
   type = value_type (v);
   type = check_typedef (type);
-  if (TYPE_CODE (type) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type))
     target = coerce_ref (v);
   else if (TYPE_CODE (type) == TYPE_CODE_PTR)
     {
@@ -3619,8 +3613,8 @@ value_rtti_indirect_type (struct value *v, int *full,
       target_type = value_type (target);
       real_type = make_cv_type (TYPE_CONST (target_type),
 				TYPE_VOLATILE (target_type), real_type, NULL);
-      if (TYPE_CODE (type) == TYPE_CODE_REF)
-        real_type = lookup_lvalue_reference_type (real_type);
+      if (TYPE_REFERENCE (type))
+        real_type = lookup_reference_type (real_type, TYPE_CODE (type));
       else if (TYPE_CODE (type) == TYPE_CODE_PTR)
         real_type = lookup_pointer_type (real_type);
       else
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 753c2a1..7951d0c 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -276,7 +276,7 @@ int
 val_print_scalar_type_p (struct type *type)
 {
   type = check_typedef (type);
-  while (TYPE_CODE (type) == TYPE_CODE_REF)
+  while (TYPE_REFERENCE (type))
     {
       type = TYPE_TARGET_TYPE (type);
       type = check_typedef (type);
@@ -478,7 +478,7 @@ generic_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
 			      original_value, options, 0, stream);
 }
 
-/* generic_val_print helper for TYPE_CODE_REF.  */
+/* generic_val_print helper for TYPE_CODE_{RVALUE_,}REF.  */
 
 static void
 generic_val_print_ref (struct type *type, const gdb_byte *valaddr,
@@ -849,6 +849,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       generic_val_print_ref (type, valaddr, embedded_offset, stream, recurse,
 			     original_value, options);
       break;
diff --git a/gdb/value.c b/gdb/value.c
index 91bf49e..e719ce6 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1129,8 +1129,7 @@ value_actual_type (struct value *value, int resolve_simple_types,
     {
       /* If result's target type is TYPE_CODE_STRUCT, proceed to
 	 fetch its rtti type.  */
-      if ((TYPE_CODE (result) == TYPE_CODE_PTR
-	  || TYPE_CODE (result) == TYPE_CODE_REF)
+      if ((TYPE_CODE (result) == TYPE_CODE_PTR || TYPE_REFERENCE (result))
 	  && TYPE_CODE (check_typedef (TYPE_TARGET_TYPE (result)))
 	     == TYPE_CODE_STRUCT)
         {
@@ -2782,7 +2781,7 @@ value_as_address (struct value *val)
      ABI-specific code is a more reasonable place to handle it.  */
 
   if (TYPE_CODE (value_type (val)) != TYPE_CODE_PTR
-      && TYPE_CODE (value_type (val)) != TYPE_CODE_REF
+      && !TYPE_REFERENCE (value_type (val))
       && gdbarch_integer_to_address_p (gdbarch))
     return gdbarch_integer_to_address (gdbarch, value_type (val),
 				       value_contents (val));
@@ -2839,6 +2838,7 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
 
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       /* Assume a CORE_ADDR can fit in a LONGEST (for now).  Not sure
          whether we want this to be true eventually.  */
       return extract_typed_address (valaddr, type);
@@ -3425,6 +3425,7 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num)
       break;
 
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_PTR:
       store_typed_address (buf, type, (CORE_ADDR) num);
       break;
@@ -3461,6 +3462,7 @@ pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num)
       break;
 
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_PTR:
       store_typed_address (buf, type, (CORE_ADDR) num);
       break;
@@ -3668,7 +3670,7 @@ coerce_ref_if_computed (const struct value *arg)
 {
   const struct lval_funcs *funcs;
 
-  if (TYPE_CODE (check_typedef (value_type (arg))) != TYPE_CODE_REF)
+  if (!TYPE_REFERENCE (check_typedef (value_type (arg))))
     return NULL;
 
   if (value_lval_const (arg) != lval_computed)
@@ -3710,7 +3712,7 @@ coerce_ref (struct value *arg)
   if (retval)
     return retval;
 
-  if (TYPE_CODE (value_type_arg_tmp) != TYPE_CODE_REF)
+  if (!TYPE_REFERENCE (value_type_arg_tmp))
     return arg;
 
   enc_type = check_typedef (value_enclosing_type (arg));
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 0b19d84..5c6dd81 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2229,7 +2229,7 @@ varobj_get_value_type (const struct varobj *var)
 
   type = check_typedef (type);
 
-  if (TYPE_CODE (type) == TYPE_CODE_REF)
+  if (TYPE_REFERENCE (type))
     type = get_target_type (type);
 
   type = check_typedef (type);
-- 
2.6.4


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