#define T type_as_string
#define V cv_as_string
-#define _ (cp_printer *) 0
+#define o (cp_printer *) 0
cp_printer * cp_printers[256] =
-{
+{
/*0 1 2 3 4 5 6 7 8 9 A B C D E F */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x00 */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x10 */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x20 */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x30 */
- _, A, _, C, D, E, _, _, _, _, _, _, L, _, _, O, /* 0x40 */
- P, Q, _, _, T, _, V, _, _, _, _, _, _, _, _, _, /* 0x50 */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x60 */
- _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x70 */
+ o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x00 */
+ o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x10 */
+ o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x20 */
+ o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x30 */
+ o, A, o, C, D, E, o, o, o, o, o, o, L, o, o, O, /* 0x40 */
+ P, Q, o, o, T, o, V, o, o, o, o, o, o, o, o, o, /* 0x50 */
+ o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x60 */
+ o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, o, /* 0x70 */
};
#undef C
#undef D
#undef Q
#undef T
#undef V
-#undef _
+#undef o
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
IDENTIFIER_LENGTH (ID)))
# define OB_PUTCP(S) (obstack_grow (&scratch_obstack, (S), strlen (S)))
# define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0'))
-# define OB_PUTI(CST) do { sprintf (digit_buffer, "%d", (CST)); \
+# define OB_PUTI(CST) do { sprintf (digit_buffer, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)(CST)); \
OB_PUTCP (digit_buffer); } while (0)
# define OB_UNPUT(N) obstack_blank (&scratch_obstack, - (N));
static void dump_function_name PROTO((tree));
static void dump_expr_list PROTO((tree));
static void dump_global_iord PROTO((tree));
-static void dump_readonly_or_volatile PROTO((tree, enum pad));
+static void dump_qualifiers PROTO((tree, enum pad));
static void dump_char PROTO((int));
static char *aggr_variety PROTO((tree));
static tree ident_fndecl PROTO((tree));
}
static void
-dump_readonly_or_volatile (t, p)
+dump_qualifiers (t, p)
tree t;
enum pad p;
{
- if (TYPE_READONLY (t) || TYPE_VOLATILE (t))
+ if (TYPE_QUALS (t))
{
if (p == before) OB_PUTC (' ');
- if (TYPE_READONLY (t))
- OB_PUTS ("const");
- if (TYPE_READONLY (t) && TYPE_VOLATILE (t))
- OB_PUTC (' ');
- if (TYPE_VOLATILE (t))
- OB_PUTS ("volatile");
+ switch (TYPE_QUALS (t))
+ {
+ case TYPE_QUAL_CONST:
+ OB_PUTS ("const");
+ break;
+
+ case TYPE_QUAL_VOLATILE:
+ OB_PUTS ("volatile");
+ break;
+
+ case TYPE_QUAL_RESTRICT:
+ OB_PUTS ("__restrict");
+ break;
+
+ case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE:
+ OB_PUTS ("const volatile");
+ break;
+
+ case TYPE_QUAL_CONST | TYPE_QUAL_RESTRICT:
+ OB_PUTS ("const __restrict");
+ break;
+
+ case TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT:
+ OB_PUTS ("volatile __restrict");
+ break;
+
+ case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT:
+ OB_PUTS ("const volatile __restrict");
+ break;
+
+ default:
+ my_friendly_abort (0);
+ }
if (p == after) OB_PUTC (' ');
}
}
if (TYPE_LANG_SPECIFIC (t)
&& (IS_SIGNATURE_POINTER (t) || IS_SIGNATURE_REFERENCE (t)))
{
- if (TYPE_READONLY (t) | TYPE_VOLATILE (t))
- dump_readonly_or_volatile (t, after);
+ dump_qualifiers (t, after);
dump_type_real (SIGNATURE_TYPE (t), v, canonical_name);
if (IS_SIGNATURE_POINTER (t))
OB_PUTC ('*');
case TYPE_DECL:
case TEMPLATE_DECL:
+ case NAMESPACE_DECL:
dump_decl (t, v);
break;
case REAL_TYPE:
case VOID_TYPE:
case BOOLEAN_TYPE:
- dump_readonly_or_volatile (t, after);
- OB_PUTID (TYPE_IDENTIFIER (canonical_name ? TYPE_MAIN_VARIANT (t) : t));
+ {
+ tree type;
+ dump_qualifiers (t, after);
+ type = canonical_name ? TYPE_MAIN_VARIANT (t) : t;
+ if (TYPE_NAME (type) && TYPE_IDENTIFIER (type))
+ OB_PUTID (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. */
+ OB_PUTS ("{anonymous}");
+ }
break;
case TEMPLATE_TEMPLATE_PARM:
- if (!CLASSTYPE_TEMPLATE_INFO (t))
+ if (!TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t))
{
/* For parameters inside template signature. */
if (TYPE_IDENTIFIER (t))
else
{
int i;
- tree args = CLASSTYPE_TI_ARGS (t);
+ tree args = TYPE_TI_ARGS (t);
OB_PUTID (TYPE_IDENTIFIER (t));
OB_PUTC ('<');
for (i = 0; i < TREE_VEC_LENGTH (args); i++)
break;
case TEMPLATE_TYPE_PARM:
- dump_readonly_or_volatile (t, after);
+ dump_qualifiers (t, after);
if (TYPE_IDENTIFIER (t))
OB_PUTID (TYPE_IDENTIFIER (t));
else
OB_PUTID (TYPE_IDENTIFIER (t));
break;
+ case TYPEOF_TYPE:
+ OB_PUTS ("__typeof (");
+ dump_expr (TYPE_FIELDS (t), 1);
+ OB_PUTC (')');
+ break;
+
default:
sorry ("`%s' not supported by dump_type",
tree_code_name[(int) TREE_CODE (t)]);
tree name;
char *variety = aggr_variety (t);
- dump_readonly_or_volatile (t, after);
+ dump_qualifiers (t, after);
if (v > 0)
{
name = TYPE_NAME (canonical_name ? TYPE_MAIN_VARIANT (t) : t);
- if (name && DECL_CONTEXT (name) && DECL_CONTEXT (name) != global_namespace)
+ if (name && CP_DECL_CONTEXT (name) != global_namespace)
{
/* FUNCTION_DECL or RECORD_TYPE */
dump_decl (DECL_CONTEXT (name), 0);
switch (TREE_CODE (t))
{
case POINTER_TYPE:
+ case REFERENCE_TYPE:
{
tree sub = TREE_TYPE (t);
dump_type_prefix (sub, v, canonical_name);
/* A tree for a member pointer looks like pointer to offset,
so let the OFFSET_TYPE case handle it. */
- if (TREE_CODE (sub) != OFFSET_TYPE)
+ if (!TYPE_PTRMEM_P (t))
{
switch (TREE_CODE (sub))
{
case POINTER_TYPE:
/* We don't want "char * *" */
- if (! (TYPE_READONLY (sub) || TYPE_VOLATILE (sub)))
+ if (TYPE_QUALS (sub) == TYPE_UNQUALIFIED)
break;
/* But we do want "char *const *" */
default:
OB_PUTC (' ');
}
- OB_PUTC ('*');
- dump_readonly_or_volatile (t, none);
- }
- }
- break;
-
- case REFERENCE_TYPE:
- {
- tree sub = TREE_TYPE (t);
- dump_type_prefix (sub, v, canonical_name);
-
- switch (TREE_CODE (sub))
- {
- case ARRAY_TYPE:
- OB_PUTC2 (' ', '(');
- break;
-
- case POINTER_TYPE:
- /* We don't want "char * &" */
- if (! (TYPE_READONLY (sub) || TYPE_VOLATILE (sub)))
- break;
- /* But we do want "char *const &" */
-
- default:
- OB_PUTC (' ');
+ if (TREE_CODE (t) == POINTER_TYPE)
+ OB_PUTC ('*');
+ else
+ OB_PUTC ('&');
+ dump_qualifiers (t, none);
}
}
- OB_PUTC ('&');
- dump_readonly_or_volatile (t, none);
break;
case OFFSET_TYPE:
OB_PUTC2 (':', ':');
}
OB_PUTC ('*');
- dump_readonly_or_volatile (t, none);
+ dump_qualifiers (t, none);
break;
/* Can only be reached through function pointer -- this would not be
OB_PUTS ("...");
OB_PUTC (')');
if (TREE_CODE (t) == METHOD_TYPE)
- dump_readonly_or_volatile
+ dump_qualifiers
(TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))), before);
dump_type_suffix (TREE_TYPE (t), v, canonical_name);
break;
{
dump_type_prefix (type, v, 0);
OB_PUTC (' ');
- dump_readonly_or_volatile (t, after);
}
- if (DECL_CLASS_SCOPE_P (t))
+ if (CP_DECL_CONTEXT (t) != global_namespace)
{
- dump_type (DECL_CONTEXT (t), 0);
- OB_PUTC2 (':', ':');
+ dump_decl (DECL_CONTEXT (t), 0);
+ OB_PUTC2 (':',':');
}
if (DECL_NAME (t))
dump_decl (DECL_NAME (t), v);
if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
{
OB_PUTS ("vtable for ");
- dump_type (DECL_CONTEXT (t), v);
+ if (TYPE_P (DECL_CONTEXT (t)))
+ dump_type (DECL_CONTEXT (t), v);
+ else
+ /* This case can arise with -fno-vtable-thunks. See
+ expand_upcast_fixups. It's not clear what to print
+ here. */
+ OB_PUTS ("{unknown type}");
break;
}
/* else fall through */
break;
case NAMESPACE_DECL:
- if (DECL_CONTEXT (t) != global_namespace)
+ if (CP_DECL_CONTEXT (t) != global_namespace)
{
dump_decl (DECL_CONTEXT (t), v);
OB_PUTC2 (':',':');
}
- OB_PUTID (DECL_NAME (t));
+ if (DECL_NAME (t) == anonymous_namespace_name)
+ OB_PUTS ("{anonymous}");
+ else
+ OB_PUTID (DECL_NAME (t));
break;
+ case SCOPE_REF:
+ dump_decl (TREE_OPERAND (t, 0), 0);
+ OB_PUTS ("::");
+ dump_decl (TREE_OPERAND (t, 1), 0);
+ break;
+
case ARRAY_REF:
dump_decl (TREE_OPERAND (t, 0), v);
OB_PUTC ('[');
if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
dump_type (TREE_TYPE (t), v);
+ else if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL)
+ dump_decl (DECL_TEMPLATE_RESULT (t), v);
else if (TREE_TYPE (t) == NULL_TREE)
my_friendly_abort (353);
else switch (NEXT_CODE (t))
break;
case LOOKUP_EXPR:
- OB_PUTID (TREE_OPERAND (t, 0));
+ dump_decl (TREE_OPERAND (t, 0), v);
break;
case LABEL_DECL:
parmtypes = TYPE_ARG_TYPES (fntype);
/* Friends have DECL_CLASS_CONTEXT set, but not DECL_CONTEXT. */
- if (DECL_CONTEXT (t))
+ if (DECL_CLASS_SCOPE_P (t))
cname = DECL_CLASS_CONTEXT (t);
/* this is for partially instantiated template methods */
else if (TREE_CODE (fntype) == METHOD_TYPE)
if (DECL_STATIC_FUNCTION_P (t))
OB_PUTS ("static ");
- if (! IDENTIFIER_TYPENAME_P (name)
+ if (! DECL_CONV_FN_P (t)
&& ! DECL_CONSTRUCTOR_P (t)
- && ! DESTRUCTOR_NAME_P (name))
+ && ! DECL_DESTRUCTOR_P (t))
{
dump_type_prefix (TREE_TYPE (fntype), 1, 0);
OB_PUTC (' ');
/* Skip past "in_charge" identifier. */
parmtypes = TREE_CHAIN (parmtypes);
}
+ else if (CP_DECL_CONTEXT (t) != global_namespace)
+ {
+ dump_decl (DECL_CONTEXT (t), 0);
+ OB_PUTC2 (':',':');
+ }
if (DESTRUCTOR_NAME_P (name) && DECL_LANGUAGE (t) == lang_cplusplus)
parmtypes = TREE_CHAIN (parmtypes);
OB_PUTC (')');
- if (v && ! IDENTIFIER_TYPENAME_P (name))
+ if (v && ! DECL_CONV_FN_P (t))
dump_type_suffix (TREE_TYPE (fntype), 1, 0);
if (TREE_CODE (fntype) == METHOD_TYPE)
{
if (IS_SIGNATURE (cname))
/* We look at the type pointed to by the `optr' field of `this.' */
- dump_readonly_or_volatile
+ dump_qualifiers
(TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_VALUE (TYPE_ARG_TYPES (fntype))))), before);
else
- dump_readonly_or_volatile
+ dump_qualifiers
(TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))), before);
}
}
{
tree name = DECL_NAME (t);
- /* There ought to be a better way to find out whether or not something is
- a destructor. */
- if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (t))
- && DECL_LANGUAGE (t) == lang_cplusplus)
+ if (DECL_DESTRUCTOR_P (t))
{
OB_PUTC ('~');
dump_decl (name, 0);
}
- else if (IDENTIFIER_TYPENAME_P (name))
+ else if (DECL_CONV_FN_P (t))
{
/* This cannot use the hack that the operator's return
type is stashed off of its name because it may be
else
dump_decl (name, 0);
- if (DECL_LANG_SPECIFIC (t) && DECL_USE_TEMPLATE (t))
+ if (DECL_LANG_SPECIFIC (t) && DECL_USE_TEMPLATE (t)
+ && DECL_TEMPLATE_INFO (t)
+ && (DECL_TEMPLATE_SPECIALIZATION (t)
+ || TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL
+ || DECL_TEMPLATE_SPECIALIZATION (DECL_TI_TEMPLATE (t))
+ || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t))))
{
tree args = DECL_TEMPLATE_INFO (t) ? DECL_TI_ARGS (t) : NULL_TREE;
+ OB_PUTC ('<');
- if (args != NULL_TREE
- && DECL_CONTEXT (t) != NULL_TREE
- && uses_template_parms (DECL_CONTEXT (t))
- /* This next clause checks that there is only one level of
- template arguments. In that case, they are the
- arguments for the class context. */
- && (TREE_CODE (args) == TREE_LIST
- || (TREE_CODE (args) == TREE_VEC
- && TREE_VEC_ELT (args, 0) != NULL_TREE
- && TREE_CODE (TREE_VEC_ELT (args, 0)) != TREE_VEC)))
- /* We have something like this:
-
- template <class T> struct S { void f(); };
-
- and we are printing S<int>::f(). This is a template
- instantiation, but we don't print anything after the f. */
- ;
- else
+ /* Be careful only to print things when we have them, so as not
+ to crash producing error messages. */
+ if (args)
{
- OB_PUTC ('<');
-
- /* Be careful only to print things when we have them, so as not
- to crash producing error messages. */
- if (args)
+ if (TREE_CODE (args) == TREE_LIST)
{
- if (TREE_CODE (args) == TREE_LIST)
+ tree arg;
+ int need_comma = 0;
+
+ for (arg = args; arg; arg = TREE_CHAIN (arg))
{
- tree arg;
- int need_comma = 0;
-
- for (arg = args; arg; arg = TREE_CHAIN (arg))
- {
- tree a = TREE_VALUE (arg);
-
- if (need_comma)
- OB_PUTS (", ");
-
- if (a)
- {
- if (TREE_CODE_CLASS (TREE_CODE (a)) == 't'
- || TREE_CODE (a) == TEMPLATE_DECL)
- dump_type (a, 0);
- else
- dump_expr (a, 0);
- }
+ tree a = TREE_VALUE (arg);
+
+ if (need_comma)
+ OB_PUTS (", ");
- need_comma = 1;
+ if (a)
+ {
+ if (TREE_CODE_CLASS (TREE_CODE (a)) == 't'
+ || TREE_CODE (a) == TEMPLATE_DECL)
+ dump_type (a, 0);
+ else
+ dump_expr (a, 0);
}
+
+ need_comma = 1;
}
- else if (TREE_CODE (args) == TREE_VEC)
+ }
+ else if (TREE_CODE (args) == TREE_VEC)
+ {
+ int i;
+ int need_comma = 0;
+
+ if (TREE_VEC_LENGTH (args) > 0
+ && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
+ args = TREE_VEC_ELT (args,
+ TREE_VEC_LENGTH (args) - 1);
+
+ for (i = 0; i < TREE_VEC_LENGTH (args); i++)
{
- int i;
- int need_comma = 0;
-
- if (TREE_VEC_LENGTH (args) > 0
- && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC)
- args = TREE_VEC_ELT (args,
- TREE_VEC_LENGTH (args) - 1);
-
- for (i = 0; i < TREE_VEC_LENGTH (args); i++)
- {
- tree a = TREE_VEC_ELT (args, i);
-
- if (need_comma)
- OB_PUTS (", ");
-
- if (a)
- {
- if (TREE_CODE_CLASS (TREE_CODE (a)) == 't'
- || TREE_CODE (a) == TEMPLATE_DECL)
- dump_type (a, 0);
- else
- dump_expr (a, 0);
- }
+ tree a = TREE_VEC_ELT (args, i);
- need_comma = 1;
+ if (need_comma)
+ OB_PUTS (", ");
+
+ if (a)
+ {
+ if (TREE_CODE_CLASS (TREE_CODE (a)) == 't'
+ || TREE_CODE (a) == TEMPLATE_DECL)
+ dump_type (a, 0);
+ else
+ dump_expr (a, 0);
}
+
+ need_comma = 1;
}
}
- OB_PUTC ('>');
}
+ OB_PUTC ('>');
}
}
case CONST_DECL:
case FUNCTION_DECL:
case TEMPLATE_DECL:
+ case NAMESPACE_DECL:
dump_decl (t, -1);
break;
OB_PUTCP (digit_buffer);
break;
+ case PTRMEM_CST:
+ OB_PUTC ('&');
+ dump_type (PTRMEM_CST_CLASS (t), 0);
+ OB_PUTS ("::");
+ OB_PUTID (DECL_NAME (PTRMEM_CST_MEMBER (t)));
+ break;
+
case STRING_CST:
{
char *p = TREE_STRING_POINTER (t);
}
break;
+ case NEW_EXPR:
+ {
+ tree type = TREE_OPERAND (t, 1);
+ if (NEW_EXPR_USE_GLOBAL (t))
+ OB_PUTS ("::");
+ OB_PUTS ("new ");
+ if (TREE_OPERAND (t, 0))
+ {
+ OB_PUTC ('(');
+ dump_expr_list (TREE_OPERAND (t, 0));
+ OB_PUTS (") ");
+ }
+ if (TREE_CODE (type) == ARRAY_REF)
+ type = build_cplus_array_type
+ (TREE_OPERAND (type, 0),
+ build_index_type (size_binop (MINUS_EXPR, TREE_OPERAND (type, 1),
+ integer_one_node)));
+ dump_type (type, 0);
+ if (TREE_OPERAND (t, 2))
+ {
+ OB_PUTC ('(');
+ dump_expr_list (TREE_OPERAND (t, 2));
+ OB_PUTC (')');
+ }
+ }
+ break;
+
case TARGET_EXPR:
/* Note that this only works for G++ target exprs. If somebody
builds a general TARGET_EXPR, there's no way to represent that
case OFFSET_REF:
{
tree ob = TREE_OPERAND (t, 0);
- if (TREE_CODE (ob) == NOP_EXPR
- && TREE_OPERAND (ob, 0) == error_mark_node
- && TREE_CODE (TREE_OPERAND (t, 1)) == FUNCTION_DECL)
- /* A::f */
- dump_expr (TREE_OPERAND (t, 1), 0);
+ if (is_dummy_object (ob))
+ {
+ if (TREE_CODE (TREE_OPERAND (t, 1)) == FUNCTION_DECL)
+ /* A::f */
+ dump_expr (TREE_OPERAND (t, 1), 0);
+ else
+ dump_decl (TREE_OPERAND (t, 1), 0);
+ }
else
{
dump_expr (TREE_OPERAND (t, 0), 0);
OB_PUTID (TREE_OPERAND (t, 0));
break;
+ case ARROW_EXPR:
+ dump_expr (TREE_OPERAND (t, 0), nop);
+ OB_PUTS ("->");
+ break;
+
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
if (TREE_CODE (t) == SIZEOF_EXPR)
cp_file_of (t)
tree t;
{
- if (TREE_CODE (t) == PARM_DECL)
+ if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t))
return DECL_SOURCE_FILE (DECL_CONTEXT (t));
else if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t));
tree t;
{
int line = 0;
- if (TREE_CODE (t) == PARM_DECL)
+ if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t))
line = DECL_SOURCE_LINE (DECL_CONTEXT (t));
- if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t))
+ if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t)
+ && TYPE_MAIN_DECL (TREE_TYPE (t)))
t = TREE_TYPE (t);
if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
case lang_cplusplus:
return "C++";
+ case lang_java:
+ return "Java";
+
default:
my_friendly_abort (355);
return 0;
{
OB_INIT ();
- dump_readonly_or_volatile (p, before);
+ dump_qualifiers (p, before);
OB_FINISH ();