+2012-12-07  Tom Tromey  <tromey@redhat.com>
+
+       * typeprint.c (_initialize_typeprint): Set completer
+       for "whatis" and "ptype".
+
 2012-12-07  Joel Brobecker  <brobecker@adacore.com>
 
        * copyright.py (NOT_FSF_LIST): Remove duplicate entry
 
     "p &values.0.->z_field" \
     "completion of field in anonymous union"
 
+gdb_test "complete ptype &values\[0\]->z" \
+    "ptype &values.0.->z_field" \
+    "ptype completion of field in anonymous union"
+
+gdb_test "complete whatis &values\[0\]->z" \
+    "whatis &values.0.->z_field" \
+    "whatis completion of field in anonymous union"
+
 # The following tests used to simply try to complete `${objdir}/file',
 # and so on.  The problem is that ${objdir} can be very long; the
 # completed filename may be more than eighty characters wide.  When
 
 #include <ctype.h>
 #include "cli/cli-utils.h"
 #include "python/python.h"
+#include "completer.h"
 
 extern void _initialize_typeprint (void);
 
 void
 _initialize_typeprint (void)
 {
-  add_com ("ptype", class_vars, ptype_command, _("\
+  struct cmd_list_element *c;
+
+  c = add_com ("ptype", class_vars, ptype_command, _("\
 Print definition of type TYPE.\n\
 Usage: ptype[/FLAGS] TYPE-NAME | EXPRESSION\n\
 Argument may be a type name defined by typedef, or \"struct STRUCT-TAG\"\n\
   /M    print methods defined in a class\n\
   /t    do not print typedefs defined in a class\n\
   /T    print typedefs defined in a class"));
+  set_cmd_completer (c, expression_completer);
 
-  add_com ("whatis", class_vars, whatis_command,
-          _("Print data type of expression EXP.\n\
+  c = add_com ("whatis", class_vars, whatis_command,
+              _("Print data type of expression EXP.\n\
 Only one level of typedefs is unrolled.  See also \"ptype\"."));
+  set_cmd_completer (c, expression_completer);
 
   add_prefix_cmd ("type", no_class, show_print_type,
                  _("Generic command for showing type-printing settings."),