/* 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.
}
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);
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)
{
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;
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)
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
pp_doublequote (pp);
}
+/* Pretty-print an INTEGER literal. */
+
static void
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');
/* 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);
/* 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),
}
}
+/* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
+
void
pp_c_identifier (c_pretty_printer *pp, const char *id)
{
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.
}
}
-/* 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)
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);
}
}
-/* 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)
}
}
-/* 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)
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);
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);
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);
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)
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)
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)
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)
/* statement:
labeled-statement
- coumpound-statement
+ compound-statement
expression-statement
selection-statement
iteration-statement
pp_needs_newline (pp) = true;
break;
- /* coumpound-statement:
+ /* compound-statement:
{ block-item-list(opt) }
block-item-list: