Commit 53de5204 by Gabriel Dos Reis Committed by Gabriel Dos Reis

c-pretty-print.h (pp_type_specifier_seq): Fix thinko.

        * c-pretty-print.h (pp_type_specifier_seq): Fix thinko.
        * c-pretty-print.c: Fix formatting.
        (pp_c_integer_constant): Append type annotation to literals.  Tidy.
        (pp_c_type_specifier): Tidy.
        (pp_c_compound_literal): New function.
        (pp_c_initializer): Simplify..
        (pp_c_initializer_list): Likewise.
        (pp_c_brace_enclosed_initializer_list): New function.
        (pp_c_postfix_expression): Simplify.

cp/
        * error.c (dump_type): Simplify.  Use pp_type_specifier_seq for
        "C" types.
        * cxx-pretty-print.c (pp_cxx_type_specifier_seq): Fix thinko.

From-SVN: r71511
parent 1ea8e73b
2003-09-18 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-pretty-print.h (pp_type_specifier_seq): Fix thinko.
* c-pretty-print.c: Fix formatting.
(pp_c_integer_constant): Append type annotation to literals. Tidy.
(pp_c_type_specifier): Tidy.
(pp_c_compound_literal): New function.
(pp_c_initializer): Simplify..
(pp_c_initializer_list): Likewise.
(pp_c_brace_enclosed_initializer_list): New function.
(pp_c_postfix_expression): Simplify.
2003-09-17 Alexandre Oliva <aoliva@redhat.com> 2003-09-17 Alexandre Oliva <aoliva@redhat.com>
* config/mn10300/mn10300.md (andsi3, iorsi3, xorsi3, * config/mn10300/mn10300.md (andsi3, iorsi3, xorsi3,
......
...@@ -64,6 +64,7 @@ static void pp_c_char (c_pretty_printer *, int); ...@@ -64,6 +64,7 @@ static void pp_c_char (c_pretty_printer *, int);
/* postfix-expression */ /* postfix-expression */
static void pp_c_initializer_list (c_pretty_printer *, tree); static void pp_c_initializer_list (c_pretty_printer *, tree);
static void pp_c_brace_enclosed_initializer_list (c_pretty_printer *, tree);
static void pp_c_multiplicative_expression (c_pretty_printer *, tree); static void pp_c_multiplicative_expression (c_pretty_printer *, tree);
static void pp_c_additive_expression (c_pretty_printer *, tree); static void pp_c_additive_expression (c_pretty_printer *, tree);
...@@ -155,6 +156,7 @@ pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv) ...@@ -155,6 +156,7 @@ pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
} }
/* Pretty-print T using the type-cast notation '( type-name )'. */ /* Pretty-print T using the type-cast notation '( type-name )'. */
static inline void static inline void
pp_c_type_cast (c_pretty_printer *pp, tree t) pp_c_type_cast (c_pretty_printer *pp, tree t)
{ {
...@@ -191,6 +193,7 @@ pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t) ...@@ -191,6 +193,7 @@ pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
restrict -- C99 restrict -- C99
__restrict__ -- GNU C __restrict__ -- GNU C
volatile */ volatile */
void void
pp_c_type_qualifier_list (c_pretty_printer *pp, tree t) pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
{ {
...@@ -211,6 +214,7 @@ pp_c_type_qualifier_list (c_pretty_printer *pp, tree t) ...@@ -211,6 +214,7 @@ pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
/* pointer: /* pointer:
* type-qualifier-list(opt) * type-qualifier-list(opt)
* type-qualifier-list(opt) pointer */ * type-qualifier-list(opt) pointer */
static void static void
pp_c_pointer (c_pretty_printer *pp, tree t) pp_c_pointer (c_pretty_printer *pp, tree t)
{ {
...@@ -256,6 +260,7 @@ pp_c_pointer (c_pretty_printer *pp, tree t) ...@@ -256,6 +260,7 @@ pp_c_pointer (c_pretty_printer *pp, tree t)
simple-type-specifier: simple-type-specifier:
__complex__ __complex__
__vector__ */ __vector__ */
void void
pp_c_type_specifier (c_pretty_printer *pp, tree t) pp_c_type_specifier (c_pretty_printer *pp, tree t)
{ {
...@@ -275,7 +280,11 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -275,7 +280,11 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
case CHAR_TYPE: case CHAR_TYPE:
case INTEGER_TYPE: case INTEGER_TYPE:
case REAL_TYPE: case REAL_TYPE:
pp_c_type_specifier (pp, TYPE_NAME (t)); if (TYPE_NAME (t))
t = TYPE_NAME (t);
else
t = c_common_type_for_mode (TYPE_MODE (t), TREE_UNSIGNED (t));
pp_c_type_specifier (pp, t);
break; break;
case TYPE_DECL: case TYPE_DECL:
...@@ -319,6 +328,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -319,6 +328,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
specifier-qualifier-list of such entities or types of such entities, specifier-qualifier-list of such entities or types of such entities,
but also the 'pointer' production part of their declarators. The but also the 'pointer' production part of their declarators. The
remaining part is done by pp_declarator or pp_c_abstract_declarator. */ remaining part is done by pp_declarator or pp_c_abstract_declarator. */
void void
pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
{ {
...@@ -353,9 +363,9 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) ...@@ -353,9 +363,9 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
case COMPLEX_TYPE: case COMPLEX_TYPE:
pp_c_specifier_qualifier_list (pp, TREE_TYPE (t)); pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
if (code == COMPLEX_TYPE) if (code == COMPLEX_TYPE)
pp_c_identifier (pp, flag_isoc99 ? "_Complex" : "__complex__"); pp_c_identifier (pp, flag_isoc99 ? "_Complex" : "__complex__");
else if (code == VECTOR_TYPE) else if (code == VECTOR_TYPE)
pp_c_identifier (pp, "__vector__"); pp_c_identifier (pp, "__vector__");
break; break;
default: default:
...@@ -375,6 +385,7 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) ...@@ -375,6 +385,7 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
parameter-declaration: parameter-declaration:
declaration-specifiers declarator declaration-specifiers declarator
declaration-specifiers abstract-declarator(opt) */ declaration-specifiers abstract-declarator(opt) */
void void
pp_c_parameter_type_list (c_pretty_printer *pp, tree t) pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
{ {
...@@ -405,6 +416,7 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t) ...@@ -405,6 +416,7 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
/* abstract-declarator: /* abstract-declarator:
pointer pointer
pointer(opt) direct-abstract-declarator */ pointer(opt) direct-abstract-declarator */
static inline void static inline void
pp_c_abstract_declarator (c_pretty_printer *pp, tree t) pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
{ {
...@@ -424,6 +436,7 @@ pp_c_abstract_declarator (c_pretty_printer *pp, tree t) ...@@ -424,6 +436,7 @@ pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
direct-abstract-declarator(opt) [ assignment-expression(opt) ] direct-abstract-declarator(opt) [ assignment-expression(opt) ]
direct-abstract-declarator(opt) [ * ] direct-abstract-declarator(opt) [ * ]
direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */ direct-abstract-declarator(opt) ( parameter-type-list(opt) ) */
void void
pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t) pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
{ {
...@@ -467,6 +480,7 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t) ...@@ -467,6 +480,7 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
/* type-name: /* type-name:
specifier-qualifier-list abstract-declarator(opt) */ specifier-qualifier-list abstract-declarator(opt) */
void void
pp_c_type_id (c_pretty_printer *pp, tree t) pp_c_type_id (c_pretty_printer *pp, tree t)
{ {
...@@ -480,6 +494,7 @@ pp_c_type_id (c_pretty_printer *pp, tree t) ...@@ -480,6 +494,7 @@ pp_c_type_id (c_pretty_printer *pp, tree t)
static static
auto auto
register */ register */
void void
pp_c_storage_class_specifier (c_pretty_printer *pp, tree t) pp_c_storage_class_specifier (c_pretty_printer *pp, tree t)
{ {
...@@ -496,6 +511,7 @@ pp_c_storage_class_specifier (c_pretty_printer *pp, tree t) ...@@ -496,6 +511,7 @@ pp_c_storage_class_specifier (c_pretty_printer *pp, tree t)
/* function-specifier: /* function-specifier:
inline */ inline */
void void
pp_c_function_specifier (c_pretty_printer *pp, tree t) pp_c_function_specifier (c_pretty_printer *pp, tree t)
{ {
...@@ -508,6 +524,7 @@ pp_c_function_specifier (c_pretty_printer *pp, tree t) ...@@ -508,6 +524,7 @@ pp_c_function_specifier (c_pretty_printer *pp, tree t)
type-specifier declaration-specifiers(opt) type-specifier declaration-specifiers(opt)
type-qualifier declaration-specifiers(opt) type-qualifier declaration-specifiers(opt)
function-specifier declaration-specifiers(opt) */ function-specifier declaration-specifiers(opt) */
void void
pp_c_declaration_specifiers (c_pretty_printer *pp, tree t) pp_c_declaration_specifiers (c_pretty_printer *pp, tree t)
{ {
...@@ -525,6 +542,7 @@ pp_c_declaration_specifiers (c_pretty_printer *pp, tree t) ...@@ -525,6 +542,7 @@ pp_c_declaration_specifiers (c_pretty_printer *pp, tree t)
direct-declarator [ type-qualifier-list * ] direct-declarator [ type-qualifier-list * ]
direct-declaratpr ( parameter-type-list ) direct-declaratpr ( parameter-type-list )
direct-declarator ( identifier-list(opt) ) */ direct-declarator ( identifier-list(opt) ) */
void void
pp_c_direct_declarator (c_pretty_printer *pp, tree t) pp_c_direct_declarator (c_pretty_printer *pp, tree t)
{ {
...@@ -578,6 +596,7 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t) ...@@ -578,6 +596,7 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t)
/* declarator: /* declarator:
pointer(opt) direct-declarator */ pointer(opt) direct-declarator */
void void
pp_c_declarator (c_pretty_printer *pp, tree t) pp_c_declarator (c_pretty_printer *pp, tree t)
{ {
...@@ -609,6 +628,7 @@ pp_c_declarator (c_pretty_printer *pp, tree t) ...@@ -609,6 +628,7 @@ pp_c_declarator (c_pretty_printer *pp, tree t)
/* declaration: /* declaration:
declaration-specifiers init-declarator-list(opt) ; */ declaration-specifiers init-declarator-list(opt) ; */
void void
pp_c_declaration (c_pretty_printer *pp, tree t) pp_c_declaration (c_pretty_printer *pp, tree t)
{ {
...@@ -617,6 +637,7 @@ pp_c_declaration (c_pretty_printer *pp, tree t) ...@@ -617,6 +637,7 @@ pp_c_declaration (c_pretty_printer *pp, tree t)
} }
/* Pretty-print ATTRIBUTES using GNU C extension syntax. */ /* Pretty-print ATTRIBUTES using GNU C extension syntax. */
void void
pp_c_attributes (c_pretty_printer *pp, tree attributes) pp_c_attributes (c_pretty_printer *pp, tree attributes)
{ {
...@@ -641,6 +662,7 @@ pp_c_attributes (c_pretty_printer *pp, tree attributes) ...@@ -641,6 +662,7 @@ pp_c_attributes (c_pretty_printer *pp, tree attributes)
/* function-definition: /* function-definition:
declaration-specifiers declarator compound-statement */ declaration-specifiers declarator compound-statement */
void void
pp_c_function_definition (c_pretty_printer *pp, tree t) pp_c_function_definition (c_pretty_printer *pp, tree t)
{ {
...@@ -656,6 +678,7 @@ pp_c_function_definition (c_pretty_printer *pp, tree t) ...@@ -656,6 +678,7 @@ pp_c_function_definition (c_pretty_printer *pp, tree t)
/* Expressions. */ /* Expressions. */
/* Print out a c-char. */ /* Print out a c-char. */
static void static void
pp_c_char (c_pretty_printer *pp, int c) pp_c_char (c_pretty_printer *pp, int c)
{ {
...@@ -701,6 +724,7 @@ pp_c_char (c_pretty_printer *pp, int c) ...@@ -701,6 +724,7 @@ pp_c_char (c_pretty_printer *pp, int c)
} }
/* Print out a STRING literal. */ /* Print out a STRING literal. */
void void
pp_c_string_literal (c_pretty_printer *pp, tree s) pp_c_string_literal (c_pretty_printer *pp, tree s)
{ {
...@@ -716,7 +740,9 @@ pp_c_string_literal (c_pretty_printer *pp, tree s) ...@@ -716,7 +740,9 @@ pp_c_string_literal (c_pretty_printer *pp, tree s)
static void static void
pp_c_integer_constant (c_pretty_printer *pp, tree i) pp_c_integer_constant (c_pretty_printer *pp, tree i)
{ {
if (host_integerp (i, 0)) tree type = TREE_TYPE (i);
if (TREE_INT_CST_HIGH (i) == 0)
pp_wide_integer (pp, TREE_INT_CST_LOW (i)); pp_wide_integer (pp, TREE_INT_CST_LOW (i));
else else
{ {
...@@ -731,9 +757,17 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i) ...@@ -731,9 +757,17 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i)
TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i)); TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i));
pp_string (pp, pp_buffer (pp)->digit_buffer); pp_string (pp, pp_buffer (pp)->digit_buffer);
} }
if (TREE_UNSIGNED (type))
pp_character (pp, 'u');
if (type == long_integer_type_node || type == long_unsigned_type_node)
pp_character (pp, 'l');
else if (type == long_long_integer_type_node
|| type == long_long_unsigned_type_node)
pp_string (pp, "ll");
} }
/* Print out a CHARACTER literal. */ /* Print out a CHARACTER literal. */
static inline void static inline void
pp_c_character_constant (c_pretty_printer *pp, tree c) pp_c_character_constant (c_pretty_printer *pp, tree c)
{ {
...@@ -749,6 +783,7 @@ pp_c_character_constant (c_pretty_printer *pp, tree c) ...@@ -749,6 +783,7 @@ pp_c_character_constant (c_pretty_printer *pp, tree c)
} }
/* Print out a BOOLEAN literal. */ /* Print out a BOOLEAN literal. */
static void static void
pp_c_bool_constant (c_pretty_printer *pp, tree b) pp_c_bool_constant (c_pretty_printer *pp, tree b)
{ {
...@@ -780,6 +815,7 @@ pp_c_bool_constant (c_pretty_printer *pp, tree b) ...@@ -780,6 +815,7 @@ pp_c_bool_constant (c_pretty_printer *pp, tree b)
false; that means the value was obtained by a cast, in which case false; that means the value was obtained by a cast, in which case
print out the type-id part of the cast-expression -- the casted value print out the type-id part of the cast-expression -- the casted value
is then printed by pp_c_integer_literal. */ is then printed by pp_c_integer_literal. */
static bool static bool
pp_c_enumeration_constant (c_pretty_printer *pp, tree e) pp_c_enumeration_constant (c_pretty_printer *pp, tree e)
{ {
...@@ -819,15 +855,43 @@ pp_c_floating_constant (c_pretty_printer *pp, tree r) ...@@ -819,15 +855,43 @@ pp_c_floating_constant (c_pretty_printer *pp, tree r)
pp_character (pp, 'l'); pp_character (pp, 'l');
} }
/* Pretty-print a compound literal expression. GNU extensions include
vector constants. */
static void
pp_c_compound_literal (c_pretty_printer *pp, tree e)
{
tree type = TREE_TYPE (e);
pp_c_type_cast (pp, type);
switch (TREE_CODE (type))
{
case RECORD_TYPE:
case UNION_TYPE:
case ARRAY_TYPE:
case VECTOR_TYPE:
case COMPLEX_TYPE:
pp_c_brace_enclosed_initializer_list (pp, e);
break;
default:
pp_unsupported_tree (pp, e);
break;
}
}
/* constant: /* constant:
integer-constant integer-constant
floating-constant floating-constant
enumeration-constant enumeration-constant
chatracter-constant */ chatracter-constant */
void void
pp_c_constant (c_pretty_printer *pp, tree e) pp_c_constant (c_pretty_printer *pp, tree e)
{ {
switch (TREE_CODE (e)) const enum tree_code code = TREE_CODE (e);
switch (code)
{ {
case INTEGER_CST: case INTEGER_CST:
{ {
...@@ -872,6 +936,7 @@ pp_c_identifier (c_pretty_printer *pp, const char *id) ...@@ -872,6 +936,7 @@ pp_c_identifier (c_pretty_printer *pp, const char *id)
constant constant
string-literal string-literal
( expression ) */ ( expression ) */
void void
pp_c_primary_expression (c_pretty_printer *pp, tree e) pp_c_primary_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -931,11 +996,7 @@ pp_c_initializer (c_pretty_printer *pp, tree e) ...@@ -931,11 +996,7 @@ pp_c_initializer (c_pretty_printer *pp, tree e)
{ {
enum tree_code code = TREE_CODE (TREE_TYPE (e)); enum tree_code code = TREE_CODE (TREE_TYPE (e));
if (code == RECORD_TYPE || code == UNION_TYPE || code == ARRAY_TYPE) if (code == RECORD_TYPE || code == UNION_TYPE || code == ARRAY_TYPE)
{ pp_c_brace_enclosed_initializer_list (pp, e);
pp_c_left_brace (pp);
pp_c_initializer_list (pp, e);
pp_c_right_brace (pp);
}
else else
pp_unsupported_tree (pp, TREE_OPERAND (e, 1)); pp_unsupported_tree (pp, TREE_OPERAND (e, 1));
} }
...@@ -946,6 +1007,7 @@ pp_c_initializer (c_pretty_printer *pp, tree e) ...@@ -946,6 +1007,7 @@ pp_c_initializer (c_pretty_printer *pp, tree e)
/* init-declarator: /* init-declarator:
declarator: declarator:
declarator = initializer */ declarator = initializer */
void void
pp_c_init_declarator (c_pretty_printer *pp, tree t) pp_c_init_declarator (c_pretty_printer *pp, tree t)
{ {
...@@ -987,46 +1049,80 @@ pp_c_init_declarator (c_pretty_printer *pp, tree t) ...@@ -987,46 +1049,80 @@ pp_c_init_declarator (c_pretty_printer *pp, tree t)
designator: designator:
[ constant-expression ] [ constant-expression ]
identifier */ identifier */
static void static void
pp_c_initializer_list (c_pretty_printer *pp, tree e) pp_c_initializer_list (c_pretty_printer *pp, tree e)
{ {
tree type = TREE_TYPE (e); tree type = TREE_TYPE (e);
const enum tree_code code = TREE_CODE (type); const enum tree_code code = TREE_CODE (type);
if (code == RECORD_TYPE || code == UNION_TYPE || code == ARRAY_TYPE) switch (code)
{ {
tree init = TREE_OPERAND (e, 0); case RECORD_TYPE:
for (; init != NULL_TREE; init = TREE_CHAIN (init)) case UNION_TYPE:
{ case ARRAY_TYPE:
if (code == RECORD_TYPE || code == UNION_TYPE) {
{ tree init = TREE_OPERAND (e, 0);
pp_c_dot (pp); for (; init != NULL_TREE; init = TREE_CHAIN (init))
pp_c_primary_expression (pp, TREE_PURPOSE (init)); {
} if (code == RECORD_TYPE || code == UNION_TYPE)
else {
{ pp_c_dot (pp);
pp_c_left_bracket (pp); pp_c_primary_expression (pp, TREE_PURPOSE (init));
if (TREE_PURPOSE (init)) }
pp_c_constant (pp, TREE_PURPOSE (init)); else
pp_c_right_bracket (pp); {
} pp_c_left_bracket (pp);
pp_c_whitespace (pp); if (TREE_PURPOSE (init))
pp_equal (pp); pp_c_constant (pp, TREE_PURPOSE (init));
pp_c_whitespace (pp); pp_c_right_bracket (pp);
pp_initializer (pp, TREE_VALUE (init)); }
if (TREE_CHAIN (init)) pp_c_whitespace (pp);
pp_separate_with (pp, ','); pp_equal (pp);
} pp_c_whitespace (pp);
pp_initializer (pp, TREE_VALUE (init));
if (TREE_CHAIN (init))
pp_separate_with (pp, ',');
}
}
break;
case VECTOR_TYPE:
pp_c_expression_list (pp, TREE_VECTOR_CST_ELTS (e));
break;
case COMPLEX_TYPE:
{
const bool cst = TREE_CODE (e) == COMPLEX_CST;
pp_expression (pp, cst ? TREE_REALPART (e) : TREE_OPERAND (e, 0));
pp_separate_with (pp, ',');
pp_expression (pp, cst ? TREE_IMAGPART (e) : TREE_OPERAND (e, 1));
}
break;
default:
pp_unsupported_tree (pp, type);
break;
} }
else
pp_unsupported_tree (pp, type);
} }
/* Pretty-print a brace-enclosed initializer-list. */
static void
pp_c_brace_enclosed_initializer_list (c_pretty_printer *pp, tree l)
{
pp_c_left_brace (pp);
pp_c_initializer_list (pp, l);
pp_c_right_brace (pp);
}
/* This is a convenient function, used to bridge gap between C and C++ /* This is a convenient function, used to bridge gap between C and C++
grammars. grammars.
id-expression: id-expression:
identifier */ identifier */
void void
pp_c_id_expression (c_pretty_printer *pp, tree t) pp_c_id_expression (c_pretty_printer *pp, tree t)
{ {
...@@ -1060,6 +1156,7 @@ pp_c_id_expression (c_pretty_printer *pp, tree t) ...@@ -1060,6 +1156,7 @@ pp_c_id_expression (c_pretty_printer *pp, tree t)
postfix-expression -- postfix-expression --
( type-name ) { initializer-list } ( type-name ) { initializer-list }
( type-name ) { initializer-list , } */ ( type-name ) { initializer-list , } */
void void
pp_c_postfix_expression (c_pretty_printer *pp, tree e) pp_c_postfix_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1118,25 +1215,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e) ...@@ -1118,25 +1215,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
case COMPLEX_CST: case COMPLEX_CST:
case VECTOR_CST: case VECTOR_CST:
case COMPLEX_EXPR: case COMPLEX_EXPR:
pp_c_type_cast (pp, TREE_TYPE (e)); pp_c_compound_literal (pp, e);
pp_c_left_brace (pp);
if (code == COMPLEX_CST)
{
pp_expression (pp, TREE_REALPART (e));
pp_separate_with (pp, ',');
pp_expression (pp, TREE_IMAGPART (e));
}
else if (code == VECTOR_CST)
pp_c_expression_list (pp, TREE_VECTOR_CST_ELTS (e));
else if (code == COMPLEX_EXPR)
{
pp_expression (pp, TREE_OPERAND (e, 0));
pp_separate_with (pp, ',');
pp_expression (pp, TREE_OPERAND (e, 1));
}
pp_c_right_brace (pp);
break; break;
case COMPOUND_LITERAL_EXPR: case COMPOUND_LITERAL_EXPR:
...@@ -1170,6 +1249,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e) ...@@ -1170,6 +1249,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 void
pp_c_expression_list (c_pretty_printer *pp, tree e) pp_c_expression_list (c_pretty_printer *pp, tree e)
{ {
...@@ -1182,6 +1262,7 @@ pp_c_expression_list (c_pretty_printer *pp, tree e) ...@@ -1182,6 +1262,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 void
pp_c_call_argument_list (c_pretty_printer *pp, tree t) pp_c_call_argument_list (c_pretty_printer *pp, tree t)
{ {
...@@ -1208,6 +1289,7 @@ pp_c_call_argument_list (c_pretty_printer *pp, tree t) ...@@ -1208,6 +1289,7 @@ pp_c_call_argument_list (c_pretty_printer *pp, tree t)
__alignof__ ( type-id ) __alignof__ ( type-id )
__real__ unary-expression __real__ unary-expression
__imag__ unary-expression */ __imag__ unary-expression */
void void
pp_c_unary_expression (c_pretty_printer *pp, tree e) pp_c_unary_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1266,6 +1348,7 @@ pp_c_unary_expression (c_pretty_printer *pp, tree e) ...@@ -1266,6 +1348,7 @@ pp_c_unary_expression (c_pretty_printer *pp, tree e)
/* cast-expression: /* cast-expression:
unary-expression unary-expression
( type-name ) cast-expression */ ( type-name ) cast-expression */
void void
pp_c_cast_expression (c_pretty_printer *pp, tree e) pp_c_cast_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1288,6 +1371,7 @@ pp_c_cast_expression (c_pretty_printer *pp, tree e) ...@@ -1288,6 +1371,7 @@ pp_c_cast_expression (c_pretty_printer *pp, tree e)
multiplicative-expression * cast-expression multiplicative-expression * cast-expression
multiplicative-expression / cast-expression multiplicative-expression / cast-expression
multiplicative-expression % cast-expression */ multiplicative-expression % cast-expression */
static void static void
pp_c_multiplicative_expression (c_pretty_printer *pp, tree e) pp_c_multiplicative_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1319,6 +1403,7 @@ pp_c_multiplicative_expression (c_pretty_printer *pp, tree e) ...@@ -1319,6 +1403,7 @@ pp_c_multiplicative_expression (c_pretty_printer *pp, tree e)
multiplicative-expression multiplicative-expression
additive-expression + multiplicative-expression additive-expression + multiplicative-expression
additive-expression - multiplicative-expression */ additive-expression - multiplicative-expression */
static inline void static inline void
pp_c_additive_expression (c_pretty_printer *pp, tree e) pp_c_additive_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1347,6 +1432,7 @@ pp_c_additive_expression (c_pretty_printer *pp, tree e) ...@@ -1347,6 +1432,7 @@ pp_c_additive_expression (c_pretty_printer *pp, tree e)
additive-expression additive-expression
shift-expression << additive-expression shift-expression << additive-expression
shift-expression >> additive-expression */ shift-expression >> additive-expression */
static inline void static inline void
pp_c_shift_expression (c_pretty_printer *pp, tree e) pp_c_shift_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1373,6 +1459,7 @@ pp_c_shift_expression (c_pretty_printer *pp, tree e) ...@@ -1373,6 +1459,7 @@ pp_c_shift_expression (c_pretty_printer *pp, tree e)
relational-expression > shift-expression relational-expression > shift-expression
relational-expression <= shift-expression relational-expression <= shift-expression
relational-expression >= shift-expression */ relational-expression >= shift-expression */
static void static void
pp_c_relational_expression (c_pretty_printer *pp, tree e) pp_c_relational_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1407,6 +1494,7 @@ pp_c_relational_expression (c_pretty_printer *pp, tree e) ...@@ -1407,6 +1494,7 @@ pp_c_relational_expression (c_pretty_printer *pp, tree e)
relational-expression relational-expression
equality-expression == relational-expression equality-expression == relational-expression
equality-equality != relational-expression */ equality-equality != relational-expression */
static inline void static inline void
pp_c_equality_expression (c_pretty_printer *pp, tree e) pp_c_equality_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1431,6 +1519,7 @@ pp_c_equality_expression (c_pretty_printer *pp, tree e) ...@@ -1431,6 +1519,7 @@ pp_c_equality_expression (c_pretty_printer *pp, tree e)
/* AND-expression: /* AND-expression:
equality-expression equality-expression
AND-expression & equality-equality */ AND-expression & equality-equality */
static inline void static inline void
pp_c_and_expression (c_pretty_printer *pp, tree e) pp_c_and_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1449,6 +1538,7 @@ pp_c_and_expression (c_pretty_printer *pp, tree e) ...@@ -1449,6 +1538,7 @@ pp_c_and_expression (c_pretty_printer *pp, tree e)
/* exclusive-OR-expression: /* exclusive-OR-expression:
AND-expression AND-expression
exclusive-OR-expression ^ AND-expression */ exclusive-OR-expression ^ AND-expression */
static inline void static inline void
pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e) pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1467,6 +1557,7 @@ pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e) ...@@ -1467,6 +1557,7 @@ pp_c_exclusive_or_expression (c_pretty_printer *pp, tree e)
/* inclusive-OR-expression: /* inclusive-OR-expression:
exclusive-OR-expression exclusive-OR-expression
inclusive-OR-expression | exclusive-OR-expression */ inclusive-OR-expression | exclusive-OR-expression */
static inline void static inline void
pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e) pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1485,6 +1576,7 @@ pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e) ...@@ -1485,6 +1576,7 @@ pp_c_inclusive_or_expression (c_pretty_printer *pp, tree e)
/* logical-AND-expression: /* logical-AND-expression:
inclusive-OR-expression inclusive-OR-expression
logical-AND-expression && inclusive-OR-expression */ logical-AND-expression && inclusive-OR-expression */
static inline void static inline void
pp_c_logical_and_expression (c_pretty_printer *pp, tree e) pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1503,6 +1595,7 @@ pp_c_logical_and_expression (c_pretty_printer *pp, tree e) ...@@ -1503,6 +1595,7 @@ pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
/* logical-OR-expression: /* logical-OR-expression:
logical-AND-expression logical-AND-expression
logical-OR-expression || logical-AND-expression */ logical-OR-expression || logical-AND-expression */
void void
pp_c_logical_or_expression (c_pretty_printer *pp, tree e) pp_c_logical_or_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1521,6 +1614,7 @@ pp_c_logical_or_expression (c_pretty_printer *pp, tree e) ...@@ -1521,6 +1614,7 @@ pp_c_logical_or_expression (c_pretty_printer *pp, tree e)
/* conditional-expression: /* conditional-expression:
logical-OR-expression logical-OR-expression
logical-OR-expression ? expression : conditional-expression */ logical-OR-expression ? expression : conditional-expression */
static void static void
pp_c_conditional_expression (c_pretty_printer *pp, tree e) pp_c_conditional_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1547,6 +1641,7 @@ pp_c_conditional_expression (c_pretty_printer *pp, tree e) ...@@ -1547,6 +1641,7 @@ pp_c_conditional_expression (c_pretty_printer *pp, tree e)
assignment-expression: one of assignment-expression: one of
= *= /= %= += -= >>= <<= &= ^= |= */ = *= /= %= += -= >>= <<= &= ^= |= */
static void static void
pp_c_assignment_expression (c_pretty_printer *pp, tree e) pp_c_assignment_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1571,6 +1666,7 @@ pp_c_assignment_expression (c_pretty_printer *pp, tree e) ...@@ -1571,6 +1666,7 @@ pp_c_assignment_expression (c_pretty_printer *pp, tree e)
functions. This makes some redundancy, but it worths it. That also functions. This makes some redundancy, but it worths it. That also
prevents a possible infinite recursion between pp_c_primary_expression () prevents a possible infinite recursion between pp_c_primary_expression ()
and pp_c_expression (). */ and pp_c_expression (). */
void void
pp_c_expression (c_pretty_printer *pp, tree e) pp_c_expression (c_pretty_printer *pp, tree e)
{ {
...@@ -1608,12 +1704,12 @@ pp_c_expression (c_pretty_printer *pp, tree e) ...@@ -1608,12 +1704,12 @@ pp_c_expression (c_pretty_printer *pp, tree e)
case CALL_EXPR: case CALL_EXPR:
case COMPONENT_REF: case COMPONENT_REF:
case COMPLEX_CST: case COMPLEX_CST:
case COMPLEX_EXPR:
case VECTOR_CST: case VECTOR_CST:
case ABS_EXPR: case ABS_EXPR:
case FFS_EXPR: case FFS_EXPR:
case CONSTRUCTOR: case CONSTRUCTOR:
case COMPOUND_LITERAL_EXPR: case COMPOUND_LITERAL_EXPR:
case COMPLEX_EXPR:
case VA_ARG_EXPR: case VA_ARG_EXPR:
pp_postfix_expression (pp, e); pp_postfix_expression (pp, e);
break; break;
...@@ -1732,6 +1828,7 @@ pp_c_expression (c_pretty_printer *pp, tree e) ...@@ -1732,6 +1828,7 @@ pp_c_expression (c_pretty_printer *pp, tree e)
selection-statement selection-statement
iteration-statement iteration-statement
jump-statement */ jump-statement */
void void
pp_c_statement (c_pretty_printer *pp, tree stmt) pp_c_statement (c_pretty_printer *pp, tree stmt)
{ {
...@@ -2030,6 +2127,7 @@ pp_c_statement (c_pretty_printer *pp, tree stmt) ...@@ -2030,6 +2127,7 @@ pp_c_statement (c_pretty_printer *pp, tree stmt)
/* Initialize the PRETTY-PRINTER for handling C codes. */ /* Initialize the PRETTY-PRINTER for handling C codes. */
void void
pp_c_pretty_printer_init (c_pretty_printer *pp) pp_c_pretty_printer_init (c_pretty_printer *pp)
{ {
......
...@@ -106,7 +106,7 @@ struct c_pretty_print_info ...@@ -106,7 +106,7 @@ struct c_pretty_print_info
#define pp_abstract_declarator(PP, D) \ #define pp_abstract_declarator(PP, D) \
pp_c_base (PP)->abstract_declarator (pp_c_base (PP), D) pp_c_base (PP)->abstract_declarator (pp_c_base (PP), D)
#define pp_type_specifier_seq(PPI, D) \ #define pp_type_specifier_seq(PPI, D) \
pp_c_base (PPI)->type_specifie_seqr (pp_c_base (PPI), D) pp_c_base (PPI)->type_specifier_seq (pp_c_base (PPI), D)
#define pp_declarator(PPI, D) \ #define pp_declarator(PPI, D) \
pp_c_base (PPI)->declarator (pp_c_base (PPI), D) pp_c_base (PPI)->declarator (pp_c_base (PPI), D)
#define pp_direct_declarator(PPI, D) \ #define pp_direct_declarator(PPI, D) \
......
2003-09-18 Gabriel Dos Reis <gdr@integrable-solutions.net>
* error.c (dump_type): Simplify. Use pp_type_specifier_seq for
"C" types.
* cxx-pretty-print.c (pp_cxx_type_specifier_seq): Fix thinko.
2003-09-17 Richard Henderson <rth@redhat.com> 2003-09-17 Richard Henderson <rth@redhat.com>
* semantics.c (expand_body): Don't save/restore input_location. * semantics.c (expand_body): Don't save/restore input_location.
......
...@@ -993,14 +993,13 @@ pp_cxx_simple_type_specifier (cxx_pretty_printer *pp, tree t) ...@@ -993,14 +993,13 @@ pp_cxx_simple_type_specifier (cxx_pretty_printer *pp, tree t)
static void static void
pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t) pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t)
{ {
pp_c_type_qualifier_list (pp_c_base (pp), t);
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
case TEMPLATE_DECL: case TEMPLATE_DECL:
case TEMPLATE_TYPE_PARM: case TEMPLATE_TYPE_PARM:
case TYPE_DECL: case TYPE_DECL:
case BOUND_TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM:
pp_c_type_qualifier_list (pp_c_base (pp), t);
pp_cxx_simple_type_specifier (pp, t); pp_cxx_simple_type_specifier (pp, t);
break; break;
......
...@@ -338,45 +338,14 @@ dump_type (tree t, int flags) ...@@ -338,45 +338,14 @@ dump_type (tree t, int flags)
dump_decl (t, flags & ~TFF_DECL_SPECIFIERS); dump_decl (t, flags & ~TFF_DECL_SPECIFIERS);
break; break;
case COMPLEX_TYPE:
pp_string (cxx_pp, "__complex__ ");
dump_type (TREE_TYPE (t), flags);
break;
case VECTOR_TYPE:
pp_string (cxx_pp, "__vector__ ");
{
/* The subtype of a VECTOR_TYPE is something like intQI_type_node,
which has no name and is not very useful for diagnostics. So
look up the equivalent C type and print its name. */
tree elt = TREE_TYPE (t);
elt = c_common_type_for_mode (TYPE_MODE (elt), TREE_UNSIGNED (elt));
dump_type (elt, flags);
}
break;
case INTEGER_TYPE: case INTEGER_TYPE:
if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && TREE_UNSIGNED (t))
pp_string (cxx_pp, "unsigned ");
else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && !TREE_UNSIGNED (t))
pp_string (cxx_pp, "signed ");
/* fall through. */
case REAL_TYPE: case REAL_TYPE:
case VOID_TYPE: case VOID_TYPE:
case BOOLEAN_TYPE: case BOOLEAN_TYPE:
{ case COMPLEX_TYPE:
tree type; case VECTOR_TYPE:
dump_qualifiers (t, after); pp_base (cxx_pp)->padding = pp_none;
type = flags & TFF_CHASE_TYPEDEF ? TYPE_MAIN_VARIANT (t) : t; pp_type_specifier_seq (cxx_pp, t);
if (TYPE_NAME (type) && TYPE_IDENTIFIER (type))
pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (type));
else
/* Types like intQI_type_node and friends have no names.
These don't come up in user error messages, but it's nice
to be able to print them from the debugger. */
pp_identifier (cxx_pp, "<anonymous>");
}
break; break;
case TEMPLATE_TEMPLATE_PARM: case TEMPLATE_TEMPLATE_PARM:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment