OSDN Git Service

Fix PR c++/43704
[pf3gnuchains/gcc-fork.git] / gcc / cp / cxx-pretty-print.c
index 0b13bc1..04a8314 100644 (file)
@@ -1,6 +1,6 @@
 /* Implementation of subroutines for the GNU C++ pretty-printer.
    Copyright (C) 2003, 2004, 2005, 2007, 2008,
-   2009 Free Software Foundation, Inc.
+   2009, 2010 Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
 
 This file is part of GCC.
@@ -23,10 +23,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
-#include "real.h"
 #include "intl.h"
-#include "cxx-pretty-print.h"
 #include "cp-tree.h"
+#include "cxx-pretty-print.h"
+#include "tree-pretty-print.h"
 #include "toplev.h"
 
 /* Translate if being used for diagnostics, but not for dump files or
@@ -200,6 +200,13 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
     case TYPENAME_TYPE:
     case UNBOUND_CLASS_TEMPLATE:
       pp_cxx_unqualified_id (pp, TYPE_NAME (t));
+      if (CLASS_TYPE_P (t) && CLASSTYPE_USE_TEMPLATE (t))
+       {
+         pp_cxx_begin_template_argument_list (pp);
+         pp_cxx_template_argument_list (pp, INNERMOST_TEMPLATE_ARGS
+                                                 (CLASSTYPE_TI_ARGS (t)));
+         pp_cxx_end_template_argument_list (pp);
+       }
       break;
 
     case BIT_NOT_EXPR:
@@ -332,6 +339,14 @@ pp_cxx_constant (cxx_pretty_printer *pp, tree t)
       }
       break;
 
+    case INTEGER_CST:
+      if (NULLPTR_TYPE_P (TREE_TYPE (t)))
+       {
+         pp_string (pp, "nullptr");
+         break;
+       }
+      /* else fall through.  */
+
     default:
       pp_c_constant (pp_c_base (pp), t);
       break;
@@ -659,7 +674,8 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
       if (TREE_CODE (type) == ARRAY_REF)
        type = build_cplus_array_type
          (TREE_OPERAND (type, 0),
-          build_index_type (fold_build2 (MINUS_EXPR, integer_type_node,
+          build_index_type (fold_build2_loc (input_location,
+                                         MINUS_EXPR, integer_type_node,
                                          TREE_OPERAND (type, 1),
                                          integer_one_node)));
       pp_cxx_type_id (pp, type);
@@ -1085,6 +1101,10 @@ pp_cxx_expression (cxx_pretty_printer *pp, tree t)
       pp_cxx_ws_string (pp, "...");
       break;
 
+    case TEMPLATE_ID_EXPR:
+      pp_cxx_template_id (pp, t);
+      break;
+
     case NONTYPE_ARGUMENT_PACK:
       {
        tree args = ARGUMENT_PACK_ARGS (t);
@@ -1158,16 +1178,6 @@ pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t)
       pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t));
       break;
 
-    case RECORD_TYPE:
-      if (TYPE_PTRMEMFUNC_P (t))
-       {
-         tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t);
-         pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm)));
-         pp_cxx_whitespace (pp);
-         pp_cxx_ptr_operator (pp, t);
-       }
-      break;
-
     case FUNCTION_DECL:
       /* Constructors don't have return types.  And conversion functions
         do not have a type-specifier in their return types.  */
@@ -1263,6 +1273,17 @@ pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
       pp_cxx_right_paren (pp);
       break;
 
+    case RECORD_TYPE:
+      if (TYPE_PTRMEMFUNC_P (t))
+       {
+         tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t);
+         pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm)));
+         pp_cxx_whitespace (pp);
+         pp_cxx_ptr_operator (pp, t);
+         break;
+       }
+      /* else fall through */
+
     default:
       if (!(TREE_CODE (t) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (t)))
        pp_c_specifier_qualifier_list (pp_c_base (pp), t);