Implement printing of rvalue reference types and values
authorArtemiy Volkov <artemiyv@acm.org>
Mon, 20 Mar 2017 20:47:48 +0000 (13:47 -0700)
committerKeith Seitz <keiths@redhat.com>
Mon, 20 Mar 2017 20:47:48 +0000 (13:47 -0700)
This patch provides the ability to print out names of rvalue reference types
and values of those types. This is done in full similarity to regular
references, and as with them, we don't print out "const" suffix because all
rvalue references are const.

gdb/ChangeLog

PR gdb/14441
* c-typeprint.c (c_print_type, c_type_print_varspec_prefix)
(c_type_print_modifier, c_type_print_varspec_suffix)
(c_type_print_base): Support printing rvalue reference types.
* c-valprint.c (c_val_print, c_value_print): Support printing
rvalue reference values.

gdb/ChangeLog
gdb/c-typeprint.c
gdb/c-valprint.c

index 39f1e682a3d79ce79805af70dccc82cb8374e533..7d7494c4015c1669baf408608645a4f15f78e92b 100644 (file)
@@ -1,3 +1,12 @@
+2017-03-20  Artemiy Volkov  <artemiyv@acm.org>
+
+       PR gdb/14441
+       * c-typeprint.c (c_print_type, c_type_print_varspec_prefix)
+       (c_type_print_modifier, c_type_print_varspec_suffix)
+       (c_type_print_base): Support printing rvalue reference types.
+       * c-valprint.c (c_val_print, c_value_print): Support printing
+       rvalue reference values.
+
 2017-03-20  Artemiy Volkov  <artemiyv@acm.org>
 
        PR gdb/14441
index b97216eabeaebbb36f3228d111b9e459f9714273..9e197f5721fcebdfe3bb7c7a9fbda486b517ea76 100644 (file)
@@ -110,7 +110,7 @@ c_print_type (struct type *type,
                      && !TYPE_VECTOR (type))
                  || code == TYPE_CODE_MEMBERPTR
                  || code == TYPE_CODE_METHODPTR
-                 || code == TYPE_CODE_REF)))
+                 || TYPE_IS_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,
@@ -347,9 +347,10 @@ c_type_print_varspec_prefix (struct type *type,
       break;
 
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
                                   stream, show, 1, 0, flags);
-      fprintf_filtered (stream, "&");
+      fprintf_filtered (stream, TYPE_CODE(type) == TYPE_CODE_REF ? "&" : "&&");
       c_type_print_modifier (type, stream, 1, need_post_space);
       break;
 
@@ -416,8 +417,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
   /* We don't print `const' qualifiers for references --- since all
      operators affect the thing referenced, not the reference itself,
      every reference is `const'.  */
-  if (TYPE_CONST (type)
-      && TYPE_CODE (type) != TYPE_CODE_REF)
+  if (TYPE_CONST (type) && !TYPE_IS_REFERENCE (type))
     {
       if (need_pre_space)
        fprintf_filtered (stream, " ");
@@ -728,6 +728,7 @@ c_type_print_varspec_suffix (struct type *type,
 
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
                                   show, 1, 0, flags);
       break;
@@ -896,6 +897,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
     case TYPE_CODE_PTR:
     case TYPE_CODE_MEMBERPTR:
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
     case TYPE_CODE_METHODPTR:
index d29b20ebda9be720e4534550fab1f0239e71c8cd..ab1de5cf9e8fd21fbe1a599c73d5935f62185563 100644 (file)
@@ -541,6 +541,7 @@ c_val_print (struct type *type,
       break;
 
     case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
     case TYPE_CODE_ENUM:
     case TYPE_CODE_FLAGS:
     case TYPE_CODE_FUNC:
@@ -587,8 +588,7 @@ c_value_print (struct value *val, struct ui_file *stream,
   val_type = value_type (val);
   type = check_typedef (val_type);
 
-  if (TYPE_CODE (type) == TYPE_CODE_PTR
-      || TYPE_CODE (type) == TYPE_CODE_REF)
+  if (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_IS_REFERENCE (type))
     {
       /* Hack:  remove (char *) for char strings.  Their
          type is indicated by the quoted string anyway.
This page took 0.029264 seconds and 4 git commands to generate.