OSDN Git Service

* config/arm/arm.c (arm_promote_prototypes): Use TARGET_AAPCS_BASED.
[pf3gnuchains/gcc-fork.git] / gcc / c-pretty-print.c
index 4a006b2..5673d73 100644 (file)
@@ -1,5 +1,5 @@
 /* Subroutines common to both C and C++ pretty-printers.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
 
 This file is part of GCC.
@@ -140,24 +140,29 @@ pp_c_arrow (c_pretty_printer *pp)
 }
 
 void
-pp_c_semicolon(c_pretty_printer *pp)
+pp_c_semicolon (c_pretty_printer *pp)
 {
   pp_semicolon (pp);
   pp_base (pp)->padding = pp_none;
 }
 
+/* Print out the external representation of CV-QUALIFIER.  */
+
 static void
 pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
 {
   const char *p = pp_last_position_in_text (pp);
-  if (p != NULL && *p == '*')
+  /* The C programming language does not have references, but it is much
+     simpler to handle those here rather than going through the same
+     logic in the C++ pretty-printer.  */
+  if (p != NULL && (*p == '*' || *p == '&'))
     pp_c_whitespace (pp);
   pp_c_identifier (pp, cv);
 }
 
 /* Pretty-print T using the type-cast notation '( type-name )'.  */
 
-static inline void
+static void
 pp_c_type_cast (c_pretty_printer *pp, tree t)
 {
   pp_c_left_paren (pp);
@@ -165,6 +170,9 @@ pp_c_type_cast (c_pretty_printer *pp, tree t)
   pp_c_right_paren (pp);
 }
 
+/* We're about to pretty-print a pointer type as indicated by T.
+   Output a whitespace, if needed, preparing for subsequent output.  */
+
 void
 pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
 {
@@ -283,7 +291,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
       if (TYPE_NAME (t))
         t = TYPE_NAME (t);
       else
-        t = c_common_type_for_mode (TYPE_MODE (t), TREE_UNSIGNED (t));
+        t = c_common_type_for_mode (TYPE_MODE (t), TYPE_UNSIGNED (t));
       pp_c_type_specifier (pp, t);
       break;
 
@@ -417,7 +425,7 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
       pointer
       pointer(opt) direct-abstract-declarator  */
 
-static inline void
+static void
 pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
 {
   if (TREE_CODE (t) == POINTER_TYPE)
@@ -540,7 +548,7 @@ pp_c_declaration_specifiers (c_pretty_printer *pp, tree t)
       direct-declarator [ static type-qualifier-list(opt) assignment-expression(opt)]
       direct-declarator [ type-qualifier-list static assignment-expression ]
       direct-declarator [ type-qualifier-list * ]
-      direct-declaratpr ( parameter-type-list )
+      direct-declarator ( parameter-type-list )
       direct-declarator ( identifier-list(opt) )  */
 
 void
@@ -737,6 +745,8 @@ pp_c_string_literal (c_pretty_printer *pp, tree s)
   pp_doublequote (pp);
 }
 
+/* Pretty-print an INTEGER literal.  */
+
 static void
 pp_c_integer_constant (c_pretty_printer *pp, tree i)
 {
@@ -757,7 +767,7 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i)
                TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i));
       pp_string (pp, pp_buffer (pp)->digit_buffer);
     }
-  if (TREE_UNSIGNED (type))
+  if (TYPE_UNSIGNED (type))
     pp_character (pp, 'u');
   if (type == long_integer_type_node || type == long_unsigned_type_node)
     pp_character (pp, 'l');
@@ -768,15 +778,15 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i)
 
 /* Print out a CHARACTER literal.  */
 
-static inline void
+static void
 pp_c_character_constant (c_pretty_printer *pp, tree c)
 {
   tree type = TREE_TYPE (c);
   if (type == wchar_type_node)
     pp_character (pp, 'L'); 
   pp_quote (pp);
-  if (host_integerp (c, TREE_UNSIGNED (type)))
-    pp_c_char (pp, tree_low_cst (c, TREE_UNSIGNED (type)));
+  if (host_integerp (c, TYPE_UNSIGNED (type)))
+    pp_c_char (pp, tree_low_cst (c, TYPE_UNSIGNED (type)));
   else
     pp_scalar (pp, "\\x%x", (unsigned) TREE_INT_CST_LOW (c));
   pp_quote (pp);
@@ -843,7 +853,7 @@ pp_c_enumeration_constant (c_pretty_printer *pp, tree e)
 
 /* Print out a REAL value as a decimal-floating-constant.  */
 
-static inline void
+static void
 pp_c_floating_constant (c_pretty_printer *pp, tree r)
 {
   real_to_decimal (pp_buffer (pp)->digit_buffer, &TREE_REAL_CST (r),
@@ -922,6 +932,8 @@ pp_c_constant (c_pretty_printer *pp, tree e)
     }
 }
 
+/* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary.  */
+
 void
 pp_c_identifier (c_pretty_printer *pp, const char *id)
 {
@@ -1012,7 +1024,9 @@ void
 pp_c_init_declarator (c_pretty_printer *pp, tree t)
 {
   pp_declarator (pp, t);
-  if (DECL_INITIAL (t))
+  /* We don't want to output function definitions here.  There are handled
+     elsewhere (and the syntactic form is bogus anyway).  */
+  if (TREE_CODE (t) != FUNCTION_DECL && DECL_INITIAL (t))
     {
       tree init = DECL_INITIAL (t);
       /* This C++ bit is handled here because it is easier to do so.
@@ -1106,7 +1120,7 @@ pp_c_initializer_list (c_pretty_printer *pp, tree e)
     }
 }
 
-/* Pretty-print a brace-enclosed initializer-list.   */
+/* Pretty-print a brace-enclosed initializer-list.  */
 
 static void
 pp_c_brace_enclosed_initializer_list (c_pretty_printer *pp, tree l)
@@ -1217,7 +1231,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
       break;
 
     case COMPOUND_LITERAL_EXPR:
-      e = DECL_INITIAL (e);
+      e = DECL_INITIAL (COMPOUND_LITERAL_EXPR_DECL (e));
       /* Fall through.  */
     case CONSTRUCTOR:
       pp_initializer (pp, e);
@@ -1246,7 +1260,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
     }
 }
 
-/* Print out an expression-list; E is expected to be a TREE_LIST  */
+/* Print out an expression-list; E is expected to be a TREE_LIST.  */
 
 void
 pp_c_expression_list (c_pretty_printer *pp, tree e)
@@ -1259,7 +1273,7 @@ pp_c_expression_list (c_pretty_printer *pp, tree e)
     }
 }
 
-/* Print out an expression-list in parens, as in a function call.   */
+/* Print out an expression-list in parens, as in a function call.  */
 
 void
 pp_c_call_argument_list (c_pretty_printer *pp, tree t)
@@ -1402,7 +1416,7 @@ pp_c_multiplicative_expression (c_pretty_printer *pp, tree e)
       additive-expression + multiplicative-expression
       additive-expression - multiplicative-expression   */
 
-static inline void
+static void
 pp_c_additive_expression (c_pretty_printer *pp, tree e)
 {
   enum tree_code code = TREE_CODE (e);
@@ -1431,7 +1445,7 @@ pp_c_additive_expression (c_pretty_printer *pp, tree e)
       shift-expression << additive-expression
       shift-expression >> additive-expression   */
 
-static inline void
+static void
 pp_c_shift_expression (c_pretty_printer *pp, tree e)
 {
   enum tree_code code = TREE_CODE (e);
@@ -1493,7 +1507,7 @@ pp_c_relational_expression (c_pretty_printer *pp, tree e)
       equality-expression == relational-expression
       equality-equality != relational-expression  */
 
-static inline void
+static void
 pp_c_equality_expression (c_pretty_printer *pp, tree e)
 {
   enum tree_code code = TREE_CODE (e);
@@ -1518,7 +1532,7 @@ pp_c_equality_expression (c_pretty_printer *pp, tree e)
       equality-expression
       AND-expression & equality-equality   */
 
-static inline void
+static void
 pp_c_and_expression (c_pretty_printer *pp, tree e)
 {
   if (TREE_CODE (e) == BIT_AND_EXPR)
@@ -1537,7 +1551,7 @@ pp_c_and_expression (c_pretty_printer *pp, tree e)
      AND-expression
      exclusive-OR-expression ^ AND-expression  */
 
-static inline void
+static void
 pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
 {
   if (TREE_CODE (e) == BIT_XOR_EXPR)
@@ -1556,7 +1570,7 @@ pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
      exclusive-OR-expression
      inclusive-OR-expression | exclusive-OR-expression  */
 
-static inline void
+static void
 pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
 {
   if (TREE_CODE (e) == BIT_IOR_EXPR)
@@ -1575,7 +1589,7 @@ pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
       inclusive-OR-expression
       logical-AND-expression && inclusive-OR-expression  */
 
-static inline void
+static void
 pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
 {
   if (TREE_CODE (e) == TRUTH_ANDIF_EXPR)
@@ -1820,7 +1834,7 @@ pp_c_expression (c_pretty_printer *pp, tree e)
 
 /* statement:
       labeled-statement
-      coumpound-statement
+      compound-statement
       expression-statement
       selection-statement
       iteration-statement
@@ -1870,7 +1884,7 @@ pp_c_statement (c_pretty_printer *pp, tree stmt)
       pp_needs_newline (pp) = true;
       break;
 
-      /* coumpound-statement:
+      /* compound-statement:
             {  block-item-list(opt) }
 
          block-item-list: