OSDN Git Service

* config/avr/avr.h: Do not include progmem_section definition when
[pf3gnuchains/gcc-fork.git] / gcc / c-pretty-print.c
index b69f0da..5fdaf2f 100644 (file)
@@ -1,12 +1,12 @@
 /* Subroutines common to both C and C++ pretty-printers.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,15 +15,15 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
 #include "real.h"
+#include "fixed-value.h"
 #include "c-pretty-print.h"
 #include "c-tree.h"
 #include "tree-iterator.h"
@@ -313,6 +313,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
+    case FIXED_POINT_TYPE:
       if (TYPE_NAME (t))
        {
          t = TYPE_NAME (t);
@@ -321,7 +322,10 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
       else
        {
          int prec = TYPE_PRECISION (t);
-         t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
+         if (ALL_FIXED_POINT_MODE_P (TYPE_MODE (t)))
+           t = c_common_type_for_mode (TYPE_MODE (t), TYPE_SATURATING (t));
+         else
+           t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
          if (TYPE_NAME (t))
            {
              pp_c_type_specifier (pp, t);
@@ -343,6 +347,9 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
                case REAL_TYPE:
                  pp_string (pp, "<unnamed-float:");
                  break;
+               case FIXED_POINT_TYPE:
+                 pp_string (pp, "<unnamed-fixed:");
+                 break;
                default:
                  gcc_unreachable ();
                }
@@ -528,8 +535,8 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
          if (host_integerp (maxval, 0))
            pp_wide_integer (pp, tree_low_cst (maxval, 0) + 1);
          else
-           pp_expression (pp, fold (build2 (PLUS_EXPR, type, maxval,
-                                            build_int_cst (type, 1))));
+           pp_expression (pp, fold_build2 (PLUS_EXPR, type, maxval,
+                                           build_int_cst (type, 1)));
        }
       pp_c_right_bracket (pp);
       pp_direct_abstract_declarator (pp, TREE_TYPE (t));
@@ -540,6 +547,7 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
     case BOOLEAN_TYPE:
     case INTEGER_TYPE:
     case REAL_TYPE:
+    case FIXED_POINT_TYPE:
     case ENUMERAL_TYPE:
     case RECORD_TYPE:
     case UNION_TYPE:
@@ -657,6 +665,7 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t)
 
     case INTEGER_TYPE:
     case REAL_TYPE:
+    case FIXED_POINT_TYPE:
     case ENUMERAL_TYPE:
     case UNION_TYPE:
     case RECORD_TYPE:
@@ -679,6 +688,7 @@ pp_c_declarator (c_pretty_printer *pp, tree t)
     {
     case INTEGER_TYPE:
     case REAL_TYPE:
+    case FIXED_POINT_TYPE:
     case ENUMERAL_TYPE:
     case UNION_TYPE:
     case RECORD_TYPE:
@@ -926,6 +936,16 @@ pp_c_floating_constant (c_pretty_printer *pp, tree r)
     pp_string (pp, "df");
 }
 
+/* Print out a FIXED value as a decimal-floating-constant.  */
+
+static void
+pp_c_fixed_constant (c_pretty_printer *pp, tree r)
+{
+  fixed_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_FIXED_CST (r),
+                  sizeof (pp_buffer (pp)->digit_buffer));
+  pp_string (pp, pp_buffer(pp)->digit_buffer);
+}
+
 /* Pretty-print a compound literal expression.  GNU extensions include
    vector constants.  */
 
@@ -954,6 +974,7 @@ pp_c_compound_literal (c_pretty_printer *pp, tree e)
 /* constant:
       integer-constant
       floating-constant
+      fixed-point-constant
       enumeration-constant
       character-constant   */
 
@@ -983,10 +1004,21 @@ pp_c_constant (c_pretty_printer *pp, tree e)
       pp_c_floating_constant (pp, e);
       break;
 
+    case FIXED_CST:
+      pp_c_fixed_constant (pp, e);
+      break;
+
     case STRING_CST:
       pp_c_string_literal (pp, e);
       break;
 
+    case COMPLEX_CST:
+      /* Sometimes, we are confused and we think a complex literal
+         is a constant.  Such thing is a compound literal which
+         grammatically belongs to postifx-expr production.  */
+      pp_c_compound_literal (pp, e);
+      break;
+
     default:
       pp_unsupported_tree (pp, e);
       break;
@@ -1038,6 +1070,7 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e)
 
     case INTEGER_CST:
     case REAL_CST:
+    case FIXED_CST:
     case STRING_CST:
       pp_c_constant (pp, e);
       break;
@@ -1571,11 +1604,12 @@ pp_c_additive_expression (c_pretty_printer *pp, tree e)
   enum tree_code code = TREE_CODE (e);
   switch (code)
     {
+    case POINTER_PLUS_EXPR:
     case PLUS_EXPR:
     case MINUS_EXPR:
       pp_c_additive_expression (pp, TREE_OPERAND (e, 0));
       pp_c_whitespace (pp);
-      if (code == PLUS_EXPR)
+      if (code == PLUS_EXPR || code == POINTER_PLUS_EXPR)
        pp_plus (pp);
       else
        pp_minus (pp);
@@ -1843,6 +1877,10 @@ pp_c_expression (c_pretty_printer *pp, tree e)
       pp_c_floating_constant (pp, e);
       break;
 
+    case FIXED_CST:
+      pp_c_fixed_constant (pp, e);
+      break;
+
     case STRING_CST:
       pp_c_string_literal (pp, e);
       break;
@@ -1949,6 +1987,7 @@ pp_c_expression (c_pretty_printer *pp, tree e)
       pp_conditional_expression (pp, e);
       break;
 
+    case POINTER_PLUS_EXPR:
     case PLUS_EXPR:
     case MINUS_EXPR:
       pp_c_additive_expression (pp, e);