/* Implementation of subroutines for the GNU C++ pretty-printer.
- Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2007, 2008,
+ 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC.
#include "system.h"
#include "coretypes.h"
#include "tm.h"
-#include "real.h"
-#include "cxx-pretty-print.h"
+#include "intl.h"
#include "cp-tree.h"
-#include "toplev.h"
+#include "cxx-pretty-print.h"
+#include "tree-pretty-print.h"
+
+/* Translate if being used for diagnostics, but not for dump files or
+ __PRETTY_FUNCTION. */
+#define M_(msgid) (pp_translate_identifiers (pp) ? _(msgid) : (msgid))
static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree);
static void pp_cxx_nested_name_specifier (cxx_pretty_printer *, tree);
static void pp_cxx_statement (cxx_pretty_printer *, tree);
static void pp_cxx_template_parameter (cxx_pretty_printer *, tree);
static void pp_cxx_cast_expression (cxx_pretty_printer *, tree);
+static void pp_cxx_typeid_expression (cxx_pretty_printer *, tree);
\f
static inline void
static inline void
pp_cxx_conversion_function_id (cxx_pretty_printer *pp, tree t)
{
- pp_cxx_identifier (pp, "operator");
+ pp_cxx_ws_string (pp, "operator");
pp_cxx_type_specifier_seq (pp, TREE_TYPE (t));
}
switch (code)
{
case RESULT_DECL:
- pp_cxx_identifier (pp, "<return-value>");
+ pp_cxx_ws_string (pp, M_("<return-value>"));
break;
case OVERLOAD:
case IDENTIFIER_NODE:
if (t == NULL)
- pp_cxx_identifier (pp, "<unnamed>");
+ pp_cxx_ws_string (pp, M_("<unnamed>"));
else if (IDENTIFIER_TYPENAME_P (t))
pp_cxx_conversion_function_id (pp, t);
else
case TYPENAME_TYPE:
case UNBOUND_CLASS_TEMPLATE:
pp_cxx_unqualified_id (pp, TYPE_NAME (t));
+ if (CLASS_TYPE_P (t) && CLASSTYPE_USE_TEMPLATE (t))
+ {
+ pp_cxx_begin_template_argument_list (pp);
+ pp_cxx_template_argument_list (pp, INNERMOST_TEMPLATE_ARGS
+ (CLASSTYPE_TI_ARGS (t)));
+ pp_cxx_end_template_argument_list (pp);
+ }
+ break;
+
+ case BIT_NOT_EXPR:
+ pp_cxx_complement (pp);
+ pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 0));
break;
case TEMPLATE_TYPE_PARM:
{
if (TREE_CODE (t) == TEMPLATE_ID_EXPR
&& TYPE_P (scope) && dependent_type_p (scope))
- pp_cxx_identifier (pp, "template");
+ pp_cxx_ws_string (pp, "template");
}
/* nested-name-specifier:
static void
pp_cxx_nested_name_specifier (cxx_pretty_printer *pp, tree t)
{
- if (t != NULL && t != pp->enclosing_scope)
+ if (!SCOPE_FILE_SCOPE_P (t) && t != pp->enclosing_scope)
{
tree scope = TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t);
pp_cxx_nested_name_specifier (pp, scope);
}
break;
+ case INTEGER_CST:
+ if (NULLPTR_TYPE_P (TREE_TYPE (t)))
+ {
+ pp_string (pp, "nullptr");
+ break;
+ }
+ /* else fall through. */
+
default:
pp_c_constant (pp_c_base (pp), t);
break;
GNU Extensions:
__builtin_va_arg ( assignment-expression , type-id )
+ __builtin_offsetof ( type-id, offsetof-expression )
__has_nothrow_assign ( type-id )
__has_nothrow_constructor ( type-id )
__is_convertible_to ( type-id , type-id )
__is_empty ( type-id )
__is_enum ( type-id )
+ __is_literal_type ( type-id )
__is_pod ( type-id )
__is_polymorphic ( type-id )
+ __is_std_layout ( type-id )
+ __is_trivial ( type-id )
__is_union ( type-id ) */
static void
pp_cxx_va_arg_expression (pp, t);
break;
+ case OFFSETOF_EXPR:
+ pp_cxx_offsetof_expression (pp, t);
+ break;
+
default:
pp_c_primary_expression (pp_c_base (pp), t);
break;
reinterpret_cast < type-id > ( expression )
const_cast < type-id > ( expression )
typeid ( expression )
- typeif ( type-id ) */
+ typeid ( type-id ) */
static void
pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t)
case REINTERPRET_CAST_EXPR:
case CONST_CAST_EXPR:
if (code == DYNAMIC_CAST_EXPR)
- pp_cxx_identifier (pp, "dynamic_cast");
+ pp_cxx_ws_string (pp, "dynamic_cast");
else if (code == STATIC_CAST_EXPR)
- pp_cxx_identifier (pp, "static_cast");
+ pp_cxx_ws_string (pp, "static_cast");
else if (code == REINTERPRET_CAST_EXPR)
- pp_cxx_identifier (pp, "reinterpret_cast");
+ pp_cxx_ws_string (pp, "reinterpret_cast");
else
- pp_cxx_identifier (pp, "const_cast");
+ pp_cxx_ws_string (pp, "const_cast");
pp_cxx_begin_template_argument_list (pp);
pp_cxx_type_id (pp, TREE_TYPE (t));
pp_cxx_end_template_argument_list (pp);
pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
{
enum tree_code code = TREE_CODE (t);
+ tree type = TREE_OPERAND (t, 1);
+ tree init = TREE_OPERAND (t, 2);
switch (code)
{
case NEW_EXPR:
case VEC_NEW_EXPR:
if (NEW_EXPR_USE_GLOBAL (t))
pp_cxx_colon_colon (pp);
- pp_cxx_identifier (pp, "new");
+ pp_cxx_ws_string (pp, "new");
if (TREE_OPERAND (t, 0))
{
pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0));
pp_space (pp);
}
- /* FIXME: array-types are built with one more element. */
- pp_cxx_type_id (pp, TREE_OPERAND (t, 1));
- if (TREE_OPERAND (t, 2))
+ if (TREE_CODE (type) == ARRAY_REF)
+ type = build_cplus_array_type
+ (TREE_OPERAND (type, 0),
+ build_index_type (fold_build2_loc (input_location,
+ MINUS_EXPR, integer_type_node,
+ TREE_OPERAND (type, 1),
+ integer_one_node)));
+ pp_cxx_type_id (pp, type);
+ if (init)
{
pp_left_paren (pp);
- t = TREE_OPERAND (t, 2);
- if (TREE_CODE (t) == TREE_LIST)
- pp_c_expression_list (pp_c_base (pp), t);
- else if (t == void_zero_node)
+ if (TREE_CODE (init) == TREE_LIST)
+ pp_c_expression_list (pp_c_base (pp), init);
+ else if (init == void_zero_node)
; /* OK, empty initializer list. */
else
- pp_cxx_expression (pp, t);
+ pp_cxx_expression (pp, init);
pp_right_paren (pp);
}
break;
case VEC_DELETE_EXPR:
if (DELETE_EXPR_USE_GLOBAL (t))
pp_cxx_colon_colon (pp);
- pp_cxx_identifier (pp, "delete");
- if (code == VEC_DELETE_EXPR)
+ pp_cxx_ws_string (pp, "delete");
+ pp_space (pp);
+ if (code == VEC_DELETE_EXPR
+ || DELETE_EXPR_USE_VEC (t))
{
pp_left_bracket (pp);
pp_right_bracket (pp);
+ pp_space (pp);
}
pp_c_cast_expression (pp_c_base (pp), TREE_OPERAND (t, 0));
break;
case SIZEOF_EXPR:
if (PACK_EXPANSION_P (TREE_OPERAND (t, 0)))
{
- pp_cxx_identifier (pp, "sizeof");
- pp_cxx_identifier (pp, "...");
+ pp_cxx_ws_string (pp, "sizeof");
+ pp_cxx_ws_string (pp, "...");
pp_cxx_whitespace (pp);
pp_cxx_left_paren (pp);
if (TYPE_P (TREE_OPERAND (t, 0)))
/* Fall through */
case ALIGNOF_EXPR:
- pp_cxx_identifier (pp, code == SIZEOF_EXPR ? "sizeof" : "__alignof__");
+ pp_cxx_ws_string (pp, code == SIZEOF_EXPR ? "sizeof" : "__alignof__");
pp_cxx_whitespace (pp);
if (TYPE_P (TREE_OPERAND (t, 0)))
{
pp_unary_expression (pp, TREE_OPERAND (t, 0));
break;
+ case AT_ENCODE_EXPR:
+ pp_cxx_ws_string (pp, "@encode");
+ pp_cxx_whitespace (pp);
+ pp_cxx_left_paren (pp);
+ pp_cxx_type_id (pp, TREE_OPERAND (t, 0));
+ pp_cxx_right_paren (pp);
+ break;
+
+ case NOEXCEPT_EXPR:
+ pp_cxx_ws_string (pp, "noexcept");
+ pp_cxx_whitespace (pp);
+ pp_cxx_left_paren (pp);
+ pp_cxx_expression (pp, TREE_OPERAND (t, 0));
+ pp_cxx_right_paren (pp);
+ break;
+
case UNARY_PLUS_EXPR:
pp_plus (pp);
pp_cxx_cast_expression (pp, TREE_OPERAND (t, 0));
{
switch (TREE_CODE (t))
{
- /* Handle unfortunate OFFESET_REF overloading here. */
+ /* Handle unfortunate OFFSET_REF overloading here. */
case OFFSET_REF:
if (TYPE_P (TREE_OPERAND (t, 0)))
{
case MEMBER_REF:
case DOTSTAR_EXPR:
pp_cxx_pm_expression (pp, TREE_OPERAND (t, 0));
- pp_cxx_dot (pp);
+ if (TREE_CODE (t) == MEMBER_REF)
+ pp_cxx_arrow (pp);
+ else
+ pp_cxx_dot (pp);
pp_star(pp);
pp_cxx_cast_expression (pp, TREE_OPERAND (t, 1));
break;
break;
}
- pp_cxx_identifier (pp, op);
+ pp_cxx_ws_string (pp, op);
}
break;
case THROW_EXPR:
- pp_cxx_identifier (pp, "throw");
+ pp_cxx_ws_string (pp, "throw");
if (TREE_OPERAND (e, 0))
pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 0));
break;
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
+ case NOEXCEPT_EXPR:
pp_cxx_unary_expression (pp, t);
break;
case NON_DEPENDENT_EXPR:
case MUST_NOT_THROW_EXPR:
- pp_cxx_expression (pp, t);
+ pp_cxx_expression (pp, TREE_OPERAND (t, 0));
break;
case EXPR_PACK_EXPANSION:
pp_cxx_expression (pp, PACK_EXPANSION_PATTERN (t));
- pp_cxx_identifier (pp, "...");
+ pp_cxx_ws_string (pp, "...");
+ break;
+
+ case TEMPLATE_ID_EXPR:
+ pp_cxx_template_id (pp, t);
break;
case NONTYPE_ARGUMENT_PACK:
{
case FUNCTION_DECL:
if (DECL_VIRTUAL_P (t))
- pp_cxx_identifier (pp, "virtual");
+ pp_cxx_ws_string (pp, "virtual");
else if (DECL_CONSTRUCTOR_P (t) && DECL_NONCONVERTING_P (t))
- pp_cxx_identifier (pp, "explicit");
+ pp_cxx_ws_string (pp, "explicit");
else
pp_c_function_specifier (pp_c_base (pp), t);
break;
case TYPE_DECL:
- pp_cxx_identifier (pp, "typedef");
+ pp_cxx_ws_string (pp, "typedef");
pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t));
break;
- case RECORD_TYPE:
- if (TYPE_PTRMEMFUNC_P (t))
- {
- tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t);
- pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm)));
- pp_cxx_whitespace (pp);
- pp_cxx_ptr_operator (pp, t);
- }
- break;
-
case FUNCTION_DECL:
/* Constructors don't have return types. And conversion functions
do not have a type-specifier in their return types. */
break;
case TYPENAME_TYPE:
- pp_cxx_identifier (pp, "typename");
+ pp_cxx_ws_string (pp, "typename");
pp_cxx_nested_name_specifier (pp, TYPE_CONTEXT (t));
pp_cxx_unqualified_id (pp, TYPE_NAME (t));
break;
break;
case DECLTYPE_TYPE:
- pp_cxx_identifier (pp, "decltype");
+ pp_cxx_ws_string (pp, "decltype");
pp_cxx_left_paren (pp);
pp_cxx_expression (pp, DECLTYPE_TYPE_EXPR (t));
pp_cxx_right_paren (pp);
break;
+ case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_P (t))
+ {
+ tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t);
+ pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm)));
+ pp_cxx_whitespace (pp);
+ pp_cxx_ptr_operator (pp, t);
+ break;
+ }
+ /* else fall through */
+
default:
if (!(TREE_CODE (t) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (t)))
pp_c_specifier_qualifier_list (pp_c_base (pp), t);
if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE
|| TYPE_PTR_TO_MEMBER_P (TREE_TYPE (t)))
pp_cxx_ptr_operator (pp, TREE_TYPE (t));
+ pp_c_attributes_display (pp_c_base (pp),
+ TYPE_ATTRIBUTES (TREE_TYPE (t)));
if (TREE_CODE (t) == POINTER_TYPE)
{
pp_star (pp);
static inline tree
pp_cxx_implicit_parameter_type (tree mf)
{
- return TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (mf))));
+ return class_of_this_parm (TREE_TYPE (mf));
}
/*
tree ex_spec = TYPE_RAISES_EXCEPTIONS (t);
bool need_comma = false;
- if (!TYPE_NOTHROW_P (t) && ex_spec == NULL)
+ if (ex_spec == NULL)
return;
- pp_cxx_identifier (pp, "throw");
+ if (TREE_PURPOSE (ex_spec))
+ {
+ pp_cxx_ws_string (pp, "noexcept");
+ pp_cxx_whitespace (pp);
+ pp_cxx_left_paren (pp);
+ if (DEFERRED_NOEXCEPT_SPEC_P (ex_spec))
+ pp_cxx_ws_string (pp, "<uninstantiated>");
+ else
+ pp_cxx_expression (pp, TREE_PURPOSE (ex_spec));
+ pp_cxx_right_paren (pp);
+ return;
+ }
+ pp_cxx_ws_string (pp, "throw");
pp_cxx_left_paren (pp);
for (; ex_spec && TREE_VALUE (ex_spec); ex_spec = TREE_CHAIN (ex_spec))
{
|| template_parameter_pack_p (t))
/* A function parameter pack or non-type template
parameter pack. */
- pp_cxx_identifier (pp, "...");
+ pp_cxx_ws_string (pp, "...");
pp_cxx_id_expression (pp, DECL_NAME (t));
}
pp_cxx_primary_expression (pp, purpose);
pp_cxx_call_argument_list (pp, TREE_VALUE (t));
if (is_pack)
- pp_cxx_identifier (pp, "...");
+ pp_cxx_ws_string (pp, "...");
if (TREE_CHAIN (t))
pp_cxx_separate_with (pp, ',');
}
if (TREE_CODE (t) == METHOD_TYPE)
{
pp_base (pp)->padding = pp_before;
- pp_cxx_cv_qualifier_seq
- (pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))));
+ pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (t));
}
pp_cxx_exception_specification (pp, t);
break;
case TEMPLATE_PARM_INDEX:
case TEMPLATE_DECL:
case TYPEOF_TYPE:
+ case UNDERLYING_TYPE:
case DECLTYPE_TYPE:
case TEMPLATE_ID_EXPR:
pp_cxx_type_specifier_seq (pp, t);
case TYPE_PACK_EXPANSION:
pp_cxx_type_id (pp, PACK_EXPANSION_PATTERN (t));
- pp_cxx_identifier (pp, "...");
+ pp_cxx_ws_string (pp, "...");
break;
default:
break;
case USING_STMT:
- pp_cxx_identifier (pp, "using");
- pp_cxx_identifier (pp, "namespace");
+ pp_cxx_ws_string (pp, "using");
+ pp_cxx_ws_string (pp, "namespace");
if (DECL_CONTEXT (t))
pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t));
pp_cxx_qualified_id (pp, USING_STMT_NAMESPACE (t));
break;
case USING_DECL:
- pp_cxx_identifier (pp, "using");
+ pp_cxx_ws_string (pp, "using");
pp_cxx_nested_name_specifier (pp, USING_DECL_SCOPE (t));
pp_cxx_unqualified_id (pp, DECL_NAME (t));
break;
try compound-statement handler-seq */
case TRY_BLOCK:
pp_maybe_newline_and_indent (pp, 0);
- pp_cxx_identifier (pp, "try");
+ pp_cxx_ws_string (pp, "try");
pp_newline_and_indent (pp, 3);
pp_cxx_statement (pp, TRY_STMTS (t));
pp_newline_and_indent (pp, -3);
type-specifier-seq abstract-declarator
... */
case HANDLER:
- pp_cxx_identifier (pp, "catch");
+ pp_cxx_ws_string (pp, "catch");
pp_cxx_left_paren (pp);
pp_cxx_exception_declaration (pp, HANDLER_PARMS (t));
pp_cxx_right_paren (pp);
if ( expression ) statement
if ( expression ) statement else statement */
case IF_STMT:
- pp_cxx_identifier (pp, "if");
+ pp_cxx_ws_string (pp, "if");
pp_cxx_whitespace (pp);
pp_cxx_left_paren (pp);
pp_cxx_expression (pp, IF_COND (t));
if (ELSE_CLAUSE (t))
{
tree else_clause = ELSE_CLAUSE (t);
- pp_cxx_identifier (pp, "else");
+ pp_cxx_ws_string (pp, "else");
if (TREE_CODE (else_clause) == IF_STMT)
pp_cxx_whitespace (pp);
else
break;
case SWITCH_STMT:
- pp_cxx_identifier (pp, "switch");
+ pp_cxx_ws_string (pp, "switch");
pp_space (pp);
pp_cxx_left_paren (pp);
pp_cxx_expression (pp, SWITCH_STMT_COND (t));
for ( expression(opt) ; expression(opt) ; expression(opt) ) statement
for ( declaration expression(opt) ; expression(opt) ) statement */
case WHILE_STMT:
- pp_cxx_identifier (pp, "while");
+ pp_cxx_ws_string (pp, "while");
pp_space (pp);
pp_cxx_left_paren (pp);
pp_cxx_expression (pp, WHILE_COND (t));
break;
case DO_STMT:
- pp_cxx_identifier (pp, "do");
+ pp_cxx_ws_string (pp, "do");
pp_newline_and_indent (pp, 3);
pp_cxx_statement (pp, DO_BODY (t));
pp_newline_and_indent (pp, -3);
- pp_cxx_identifier (pp, "while");
+ pp_cxx_ws_string (pp, "while");
pp_space (pp);
pp_cxx_left_paren (pp);
pp_cxx_expression (pp, DO_COND (t));
break;
case FOR_STMT:
- pp_cxx_identifier (pp, "for");
+ pp_cxx_ws_string (pp, "for");
pp_space (pp);
pp_cxx_left_paren (pp);
if (FOR_INIT_STMT (t))
pp_needs_newline (pp) = true;
break;
+ case RANGE_FOR_STMT:
+ pp_cxx_ws_string (pp, "for");
+ pp_space (pp);
+ pp_cxx_left_paren (pp);
+ pp_cxx_statement (pp, RANGE_FOR_DECL (t));
+ pp_space (pp);
+ pp_needs_newline (pp) = false;
+ pp_colon (pp);
+ pp_space (pp);
+ pp_cxx_statement (pp, RANGE_FOR_EXPR (t));
+ pp_cxx_right_paren (pp);
+ pp_newline_and_indent (pp, 3);
+ pp_cxx_statement (pp, FOR_BODY (t));
+ pp_indentation (pp) -= 3;
+ pp_needs_newline (pp) = true;
+ break;
+
/* jump-statement:
goto identifier;
continue ;
return expression(opt) ; */
case BREAK_STMT:
case CONTINUE_STMT:
- pp_identifier (pp, TREE_CODE (t) == BREAK_STMT ? "break" : "continue");
+ pp_string (pp, TREE_CODE (t) == BREAK_STMT ? "break" : "continue");
pp_cxx_semicolon (pp);
pp_needs_newline (pp) = true;
break;
break;
case CLEANUP_STMT:
- pp_cxx_identifier (pp, "try");
+ pp_cxx_ws_string (pp, "try");
pp_newline_and_indent (pp, 2);
pp_cxx_statement (pp, CLEANUP_BODY (t));
pp_newline_and_indent (pp, -2);
- pp_cxx_identifier (pp, CLEANUP_EH_ONLY (t) ? "catch" : "finally");
+ pp_cxx_ws_string (pp, CLEANUP_EH_ONLY (t) ? "catch" : "finally");
pp_newline_and_indent (pp, 2);
pp_cxx_statement (pp, CLEANUP_EXPR (t));
pp_newline_and_indent (pp, -2);
static void
pp_cxx_original_namespace_definition (cxx_pretty_printer *pp, tree t)
{
- pp_cxx_identifier (pp, "namespace");
+ pp_cxx_ws_string (pp, "namespace");
if (DECL_CONTEXT (t))
pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t));
if (DECL_NAME (t))
static void
pp_cxx_namespace_alias_definition (cxx_pretty_printer *pp, tree t)
{
- pp_cxx_identifier (pp, "namespace");
+ pp_cxx_ws_string (pp, "namespace");
if (DECL_CONTEXT (t))
pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t));
pp_cxx_unqualified_id (pp, t);
switch (TREE_CODE (parameter))
{
case TYPE_DECL:
- pp_cxx_identifier (pp, "class");
+ pp_cxx_ws_string (pp, "class");
if (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (t)))
- pp_cxx_identifier (pp, "...");
+ pp_cxx_ws_string (pp, "...");
if (DECL_NAME (parameter))
pp_cxx_tree_identifier (pp, DECL_NAME (parameter));
- /* FIXME: Chech if we should print also default argument. */
+ /* FIXME: Check if we should print also default argument. */
break;
case PARM_DECL:
parm = TEMPLATE_TYPE_PARM_INDEX (parm);
pp_cxx_begin_template_argument_list (pp);
- pp_cxx_identifier (pp, "template-parameter-");
+ pp_cxx_ws_string (pp, M_("template-parameter-"));
pp_wide_integer (pp, TEMPLATE_PARM_LEVEL (parm));
pp_minus (pp);
pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1);
{
tree tmpl = most_general_template (t);
tree level;
- int i = 0;
pp_maybe_newline_and_indent (pp, 0);
for (level = DECL_TEMPLATE_PARMS (tmpl); level; level = TREE_CHAIN (level))
{
- pp_cxx_identifier (pp, "template");
+ pp_cxx_ws_string (pp, "template");
pp_cxx_begin_template_argument_list (pp);
pp_cxx_template_parameter_list (pp, TREE_VALUE (level));
pp_cxx_end_template_argument_list (pp);
pp_newline_and_indent (pp, 3);
- i += 3;
}
if (TREE_CODE (t) == FUNCTION_DECL && DECL_SAVED_TREE (t))
pp_cxx_function_definition (pp, t);
{
if (TREE_CODE (t) == STATIC_ASSERT)
{
- pp_cxx_identifier (pp, "static_assert");
+ pp_cxx_ws_string (pp, "static_assert");
pp_cxx_left_paren (pp);
pp_cxx_expression (pp, STATIC_ASSERT_CONDITION (t));
pp_cxx_separate_with (pp, ',');
}
}
-void
+static void
pp_cxx_typeid_expression (cxx_pretty_printer *pp, tree t)
{
t = TREE_OPERAND (t, 0);
- pp_cxx_identifier (pp, "typeid");
+ pp_cxx_ws_string (pp, "typeid");
pp_cxx_left_paren (pp);
if (TYPE_P (t))
pp_cxx_type_id (pp, t);
void
pp_cxx_va_arg_expression (cxx_pretty_printer *pp, tree t)
{
- pp_cxx_identifier (pp, "__builtin_va_arg");
+ pp_cxx_ws_string (pp, "va_arg");
pp_cxx_left_paren (pp);
pp_cxx_assignment_expression (pp, TREE_OPERAND (t, 0));
pp_cxx_separate_with (pp, ',');
pp_cxx_right_paren (pp);
}
+static bool
+pp_cxx_offsetof_expression_1 (cxx_pretty_printer *pp, tree t)
+{
+ switch (TREE_CODE (t))
+ {
+ case ARROW_EXPR:
+ if (TREE_CODE (TREE_OPERAND (t, 0)) == STATIC_CAST_EXPR
+ && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (t, 0))))
+ {
+ pp_cxx_type_id (pp, TREE_TYPE (TREE_TYPE (TREE_OPERAND (t, 0))));
+ pp_cxx_separate_with (pp, ',');
+ return true;
+ }
+ return false;
+ case COMPONENT_REF:
+ if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0)))
+ return false;
+ if (TREE_CODE (TREE_OPERAND (t, 0)) != ARROW_EXPR)
+ pp_cxx_dot (pp);
+ pp_cxx_expression (pp, TREE_OPERAND (t, 1));
+ return true;
+ case ARRAY_REF:
+ if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0)))
+ return false;
+ pp_left_bracket (pp);
+ pp_cxx_expression (pp, TREE_OPERAND (t, 1));
+ pp_right_bracket (pp);
+ return true;
+ default:
+ return false;
+ }
+}
+
+void
+pp_cxx_offsetof_expression (cxx_pretty_printer *pp, tree t)
+{
+ pp_cxx_ws_string (pp, "offsetof");
+ pp_cxx_left_paren (pp);
+ if (!pp_cxx_offsetof_expression_1 (pp, TREE_OPERAND (t, 0)))
+ pp_cxx_expression (pp, TREE_OPERAND (t, 0));
+ pp_cxx_right_paren (pp);
+}
+
void
pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t)
{
switch (kind)
{
case CPTK_HAS_NOTHROW_ASSIGN:
- pp_cxx_identifier (pp, "__has_nothrow_assign");
+ pp_cxx_ws_string (pp, "__has_nothrow_assign");
break;
case CPTK_HAS_TRIVIAL_ASSIGN:
- pp_cxx_identifier (pp, "__has_trivial_assign");
+ pp_cxx_ws_string (pp, "__has_trivial_assign");
break;
case CPTK_HAS_NOTHROW_CONSTRUCTOR:
- pp_cxx_identifier (pp, "__has_nothrow_constructor");
+ pp_cxx_ws_string (pp, "__has_nothrow_constructor");
break;
case CPTK_HAS_TRIVIAL_CONSTRUCTOR:
- pp_cxx_identifier (pp, "__has_trivial_constructor");
+ pp_cxx_ws_string (pp, "__has_trivial_constructor");
break;
case CPTK_HAS_NOTHROW_COPY:
- pp_cxx_identifier (pp, "__has_nothrow_copy");
+ pp_cxx_ws_string (pp, "__has_nothrow_copy");
break;
case CPTK_HAS_TRIVIAL_COPY:
- pp_cxx_identifier (pp, "__has_trivial_copy");
+ pp_cxx_ws_string (pp, "__has_trivial_copy");
break;
case CPTK_HAS_TRIVIAL_DESTRUCTOR:
- pp_cxx_identifier (pp, "__has_trivial_destructor");
+ pp_cxx_ws_string (pp, "__has_trivial_destructor");
break;
case CPTK_HAS_VIRTUAL_DESTRUCTOR:
- pp_cxx_identifier (pp, "__has_virtual_destructor");
+ pp_cxx_ws_string (pp, "__has_virtual_destructor");
break;
case CPTK_IS_ABSTRACT:
- pp_cxx_identifier (pp, "__is_abstract");
+ pp_cxx_ws_string (pp, "__is_abstract");
break;
case CPTK_IS_BASE_OF:
- pp_cxx_identifier (pp, "__is_base_of");
+ pp_cxx_ws_string (pp, "__is_base_of");
break;
case CPTK_IS_CLASS:
- pp_cxx_identifier (pp, "__is_class");
+ pp_cxx_ws_string (pp, "__is_class");
break;
case CPTK_IS_CONVERTIBLE_TO:
- pp_cxx_identifier (pp, "__is_convertible_to");
+ pp_cxx_ws_string (pp, "__is_convertible_to");
break;
case CPTK_IS_EMPTY:
- pp_cxx_identifier (pp, "__is_empty");
+ pp_cxx_ws_string (pp, "__is_empty");
break;
case CPTK_IS_ENUM:
- pp_cxx_identifier (pp, "__is_enum");
+ pp_cxx_ws_string (pp, "__is_enum");
break;
case CPTK_IS_POD:
- pp_cxx_identifier (pp, "__is_pod");
+ pp_cxx_ws_string (pp, "__is_pod");
break;
case CPTK_IS_POLYMORPHIC:
- pp_cxx_identifier (pp, "__is_polymorphic");
+ pp_cxx_ws_string (pp, "__is_polymorphic");
+ break;
+ case CPTK_IS_STD_LAYOUT:
+ pp_cxx_ws_string (pp, "__is_std_layout");
+ break;
+ case CPTK_IS_TRIVIAL:
+ pp_cxx_ws_string (pp, "__is_trivial");
break;
case CPTK_IS_UNION:
- pp_cxx_identifier (pp, "__is_union");
+ pp_cxx_ws_string (pp, "__is_union");
+ break;
+ case CPTK_IS_LITERAL_TYPE:
+ pp_cxx_ws_string (pp, "__is_literal_type");
break;
default: