c-pretty-print.h: Guard against multiple inclusion.

* c-pretty-print.h: Guard against multiple inclusion.
        Robustify macros.
        (pp_c_attributes): Declare.
        * c-pretty-print.c (pp_c_attributes): New function.

From-SVN: r56273
This commit is contained in:
Gabriel Dos Reis 2002-08-14 03:22:18 +00:00 committed by Gabriel Dos Reis
parent cbf2f4797d
commit 6bf346d484
3 changed files with 109 additions and 53 deletions

View File

@ -1,3 +1,10 @@
2002-08-14 Gabriel Dos Reis <gdr@nerim.net>
* c-pretty-print.h: Guard against multiple inclusion.
Robustify macros.
(pp_c_attributes): Declare.
* c-pretty-print.c (pp_c_attributes): New function.
2002-08-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* m68k.c (m68k_output_function_prologue,

View File

@ -259,6 +259,35 @@ pp_c_parameter_declaration (pp, t)
pp_unsupported_tree (pp, t);
}
/* Pretty-print ATTRIBUTES using GNU C extension syntax. */
void
pp_c_attributes (pp, attributes)
c_pretty_printer pp;
tree attributes;
{
if (attributes == NULL_TREE)
return;
pp_c_identifier (pp, "__attribute__");
pp_c_left_paren (pp);
pp_c_left_paren (pp);
for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes))
{
pp_tree_identifier (pp, TREE_PURPOSE (attributes));
if (TREE_VALUE (attributes))
{
pp_c_left_paren (pp);
pp_c_expression_list (pp, TREE_VALUE (attributes));
pp_c_right_paren (pp);
}
if (TREE_CHAIN (attributes))
pp_separate_with (pp, ',');
}
pp_c_right_paren (pp);
pp_c_right_paren (pp);
}
/* Expressions. */

View File

@ -19,6 +19,9 @@ along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#ifndef GCC_C_PRETTY_PRINTER
#define GCC_C_PRETTY_PRINTER
#include "tree.h"
#include "c-common.h"
#include "pretty-print.h"
@ -59,80 +62,95 @@ struct c_pretty_print_info
c_pretty_print_fn assignment_expression;
};
#define pp_c_left_paren(PPI) \
do { \
pp_left_paren (PPI); \
(PPI)->base.padding = pp_none; \
#define pp_c_left_paren(PPI) \
do { \
pp_left_paren (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_right_paren(PPI) \
do { \
pp_right_paren (PPI); \
(PPI)->base.padding = pp_none; \
#define pp_c_right_paren(PPI) \
do { \
pp_right_paren (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_left_bracket(PPI) \
do { \
pp_left_bracket (PPI); \
(PPI)->base.padding = pp_none; \
#define pp_c_left_bracket(PPI) \
do { \
pp_left_bracket (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_right_bracket(PPI) \
do { \
pp_right_bracket (PPI); \
(PPI)->base.padding = pp_none; \
#define pp_c_right_bracket(PPI) \
do { \
pp_right_bracket (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_whitespace(PPI) \
do { \
pp_whitespace (PPI); \
(PPI)->base.padding = pp_none; \
#define pp_c_whitespace(PPI) \
do { \
pp_whitespace (PPI); \
pp_c_base (PPI)->base.padding = pp_none; \
} while (0)
#define pp_c_maybe_whitespace(PPI) \
do { \
if ((PPI)->base.padding != pp_none) \
pp_c_whitespace (PPI); \
#define pp_c_maybe_whitespace(PPI) \
do { \
if (pp_c_base (PPI)->base.padding != pp_none) \
pp_c_whitespace (PPI); \
} while (0)
#define pp_c_identifier(PPI, ID) \
do { \
pp_c_maybe_whitespace (PPI); \
pp_identifier (PPI, ID); \
(PPI)->base.padding = pp_before; \
#define pp_c_identifier(PPI, ID) \
do { \
pp_c_maybe_whitespace (PPI); \
pp_identifier (PPI, ID); \
pp_c_base (PPI)->base.padding = pp_before; \
} while (0)
#define pp_c_tree_identifier(PPI, ID) \
#define pp_c_tree_identifier(PPI, ID) \
pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
#define pp_buffer(PPI) (PPI)->base.buffer
/* Returns the 'output_buffer *' associated with a PRETTY-PRINTER, the latter
being something digestible by pp_c_base. */
#define pp_buffer(PPI) pp_c_base (PPI)->base.buffer
#define pp_declaration(PPI, T) (*(PPI)->declaration) (PPI, T)
#define pp_declaration_specifiers(PPI, D) \
(*(PPI)->declaration_specifiers) (PPI, D)
#define pp_type_specifier(PPI, D) (*(PPI)->type_specifier) (PPI, D)
#define pp_declarator(PPI, D) (*(PPI)->declarator) (PPI, D)
#define pp_direct_declarator(PPI, D) (*(PPI)->direct_declarator) (PPI, D)
#define pp_parameter_declaration(PPI, T) \
(*(PPI)->parameter_declaration) (PPI, T)
#define pp_type_id(PPI, D) (*(PPI)->type_id) (PPI, D)
#define pp_declaration(PPI, T) \
(*pp_c_base (PPI)->declaration) (pp_c_base (PPI), T)
#define pp_declaration_specifiers(PPI, D) \
(*pp_c_base (PPI)->declaration_specifiers) (pp_c_base (PPI), D)
#define pp_type_specifier(PPI, D) \
(*pp_c_base (PPI)->type_specifier) (pp_c_base (PPI), D)
#define pp_declarator(PPI, D) \
(*pp_c_base (PPI)->declarator) (pp_c_base (PPI), D)
#define pp_direct_declarator(PPI, D) \
(*pp_c_base (PPI)->direct_declarator) (pp_c_base (PPI), D)
#define pp_parameter_declaration(PPI, T) \
(*pp_c_base (PPI)->parameter_declaration) (pp_c_base (PPI), T)
#define pp_type_id(PPI, D) \
(*pp_c_base (PPI)->type_id) (pp_c_base (PPI), D)
#define pp_statement(PPI, S) (*(PPI)->statement) (PPI, S)
#define pp_statement(PPI, S) \
(*pp_c_base (PPI)->statement) (pp_c_base (PPI), S)
#define pp_primary_expression(PPI, E) (*(PPI)->primary_expression) (PPI, E)
#define pp_postfix_expression(PPI, E) (*(PPI)->postfix_expression) (PPI, E)
#define pp_unary_expression(PPI, E) (*(PPI)->unary_expression) (PPI, E)
#define pp_initializer(PPI, E) (*(PPI)->initializer) (PPI, E)
#define pp_multiplicative_expression(PPI, E)\
(*(PPI)->multiplicative_expression) (PPI, E)
#define pp_conditional_expression(PPI, E) \
(*(PPI)->conditional_expression) (PPI, E)
#define pp_assignment_expression(PPI, E) \
(*(PPI)->assignment_expression) (PPI, E)
#define pp_primary_expression(PPI, E) \
(*pp_c_base (PPI)->primary_expression) (pp_c_base (PPI), E)
#define pp_postfix_expression(PPI, E) \
(*pp_c_base (PPI)->postfix_expression) (pp_c_base (PPI), E)
#define pp_unary_expression(PPI, E) \
(*pp_c_base (PPI)->unary_expression) (pp_c_base (PPI), E)
#define pp_initializer(PPI, E) \
(*pp_c_base (PPI)->initializer) (pp_c_base (PPI), E)
#define pp_multiplicative_expression(PPI, E) \
(*pp_c_base (PPI)->multiplicative_expression) (pp_c_base (PPI), E)
#define pp_conditional_expression(PPI, E) \
(*pp_c_base (PPI)->conditional_expression) (pp_c_base (PPI), E)
#define pp_assignment_expression(PPI, E) \
(*pp_c_base (PPI)->assignment_expression) (pp_c_base (PPI), E)
/* Returns the c_pretty_printer base object of PRETTY-PRINTER. This
macro must be overriden by any subclass of c_pretty_print_info. */
#define pp_c_base(PP) (PP)
extern void pp_c_pretty_printer_init PARAMS ((c_pretty_printer));
/* Declarations. */
void pp_c_attributes PARAMS ((c_pretty_printer, tree));
void pp_c_cv_qualifier PARAMS ((c_pretty_printer, int));
void pp_c_parameter_declaration_clause PARAMS ((c_pretty_printer, tree));
void pp_c_declaration PARAMS ((c_pretty_printer, tree));
void pp_c_statement PARAMS ((c_pretty_printer, tree));
void pp_c_expression PARAMS ((c_pretty_printer, tree));
/* Statements. */
void pp_c_statement PARAMS ((c_pretty_printer, tree));
/* Expressions. */
@ -143,3 +161,5 @@ void pp_c_cast_expression PARAMS ((c_pretty_printer, tree));
void pp_c_postfix_expression PARAMS ((c_pretty_printer, tree));
void pp_c_initializer PARAMS ((c_pretty_printer, tree));
void pp_c_literal PARAMS ((c_pretty_printer, tree));
#endif /* GCC_C_PRETTY_PRINTER */