/* Call-backs for C++ error reporting.
This code is non-reentrant.
- Copyright (C) 1993 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
This file is part of GNU CC.
#define L language_as_string
#define O op_as_string
#define P parm_as_string
+#define Q assop_as_string
#define T type_as_string
+#define V cv_as_string
#define _ (cp_printer *) 0
cp_printer * cp_printers[256] =
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x20 */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x30 */
_, A, _, C, D, E, _, _, _, _, _, _, L, _, _, O, /* 0x40 */
- P, _, _, _, T, _, _, _, _, _, _, _, _, _, _, _, /* 0x50 */
+ P, Q, _, _, T, _, V, _, _, _, _, _, _, _, _, _, /* 0x50 */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x60 */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x70 */
};
#undef L
#undef O
#undef P
+#undef Q
#undef T
+#undef V
#undef _
#define obstack_chunk_alloc xmalloc
break;
case TEMPLATE_TYPE_PARM:
- OB_PUTID (TYPE_IDENTIFIER (t));
- break;
-
- case UNINSTANTIATED_P_TYPE:
- OB_PUTID (DECL_NAME (UPT_TEMPLATE (t)));
- OB_PUTS ("<...>");
+ if (TYPE_IDENTIFIER (t))
+ OB_PUTID (TYPE_IDENTIFIER (t));
+ else
+ OB_PUTS ("{anonymous template type parm}");
break;
/* This is not always necessary for pointers and such, but doing this
dump_type_suffix (t, v);
break;
+ case TYPENAME_TYPE:
+ OB_PUTS ("typename ");
+ dump_type (TYPE_CONTEXT (t), 0);
+ OB_PUTS ("::");
+ OB_PUTID (TYPE_IDENTIFIER (t));
+ break;
+
default:
sorry ("`%s' not supported by dump_type",
tree_code_name[(int) TREE_CODE (t)]);
name = TYPE_NAME (t);
- if (DECL_CONTEXT (name))
+ if (name && DECL_CONTEXT (name))
{
/* FUNCTION_DECL or RECORD_TYPE */
dump_decl (DECL_CONTEXT (name), 0);
}
/* kludge around weird behavior on g++.brendan/line1.C */
- if (TREE_CODE (name) != IDENTIFIER_NODE)
+ if (name && TREE_CODE (name) != IDENTIFIER_NODE)
name = DECL_NAME (name);
- if (ANON_AGGRNAME_P (name))
+ if (name == 0 || ANON_AGGRNAME_P (name))
{
OB_PUTS ("{anonymous");
if (!v)
case TREE_LIST:
case TYPE_DECL:
case TREE_VEC:
- case UNINSTANTIATED_P_TYPE:
case UNION_TYPE:
case UNKNOWN_TYPE:
case VOID_TYPE:
+ case TYPENAME_TYPE:
dump_type (t, v);
break;
case TREE_LIST:
case TYPE_DECL:
case TREE_VEC:
- case UNINSTANTIATED_P_TYPE:
case UNION_TYPE:
case UNKNOWN_TYPE:
case VOID_TYPE:
+ case TYPENAME_TYPE:
break;
default:
{
tree n = lookup_name (t, 0);
+ if (n == NULL_TREE)
+ return NULL_TREE;
+
if (TREE_CODE (n) == FUNCTION_DECL)
return n;
else if (TREE_CODE (n) == TREE_LIST
#endif
#define GLOBAL_IORD_P(NODE) \
- !strncmp(IDENTIFIER_POINTER(NODE),GLOBAL_THING,sizeof(GLOBAL_THING)-1)
+ ! strncmp (IDENTIFIER_POINTER(NODE), GLOBAL_THING, sizeof (GLOBAL_THING) - 1)
void
dump_global_iord (t)
case TYPE_DECL:
{
/* Don't say 'typedef class A' */
- tree type = TREE_TYPE (t);
- if (((IS_AGGR_TYPE (type) && ! TYPE_PTRMEMFUNC_P (type))
- || TREE_CODE (type) == ENUMERAL_TYPE)
- && type == TYPE_MAIN_VARIANT (type))
+ if (DECL_ARTIFICIAL (t))
{
- dump_type (type, v);
+ dump_type (TREE_TYPE (t), v);
break;
}
}
/* These special cases are duplicated here so that other functions
can feed identifiers to cp_error and get them demangled properly. */
case IDENTIFIER_NODE:
- if (DESTRUCTOR_NAME_P (t))
- {
- OB_PUTC ('~');
- dump_decl (DECL_NAME (ident_fndecl (t)), 0);
- }
- else if (IDENTIFIER_TYPENAME_P (t))
- {
- OB_PUTS ("operator ");
- /* Not exactly IDENTIFIER_TYPE_VALUE. */
- dump_type (TREE_TYPE (t), 0);
- break;
- }
- else if (IDENTIFIER_OPNAME_P (t))
- {
- char *name_string = operator_name_string (t);
- OB_PUTS ("operator ");
- OB_PUTCP (name_string);
- }
- else
- OB_PUTID (t);
+ { tree f;
+ if (DESTRUCTOR_NAME_P (t)
+ && (f = ident_fndecl (t))
+ && DECL_LANGUAGE (f) == lang_cplusplus)
+ {
+ OB_PUTC ('~');
+ dump_decl (DECL_NAME (f), 0);
+ }
+ else if (IDENTIFIER_TYPENAME_P (t))
+ {
+ OB_PUTS ("operator ");
+ /* Not exactly IDENTIFIER_TYPE_VALUE. */
+ dump_type (TREE_TYPE (t), 0);
+ break;
+ }
+ else if (IDENTIFIER_OPNAME_P (t))
+ {
+ char *name_string = operator_name_string (t);
+ OB_PUTS ("operator ");
+ OB_PUTCP (name_string);
+ }
+ else
+ OB_PUTID (t);
+ }
break;
case FUNCTION_DECL:
OB_UNPUT (2);
OB_PUTC2 ('>', ' ');
- if (DECL_TEMPLATE_IS_CLASS (t))
- {
- OB_PUTS ("class ");
- OB_PUTID (DECL_NAME (t));
- }
+ if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
+ dump_type (TREE_TYPE (t), v);
else switch (NEXT_CODE (t))
{
case METHOD_TYPE:
break;
case CONST_DECL:
- if (NEXT_CODE (t) == ENUMERAL_TYPE)
+ if (NEXT_CODE (t) == ENUMERAL_TYPE
+ || TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_CONST_PARM)
goto general;
else
dump_expr (DECL_INITIAL (t), 0);
break;
+ case USING_DECL:
+ OB_PUTS ("using ");
+ dump_type (DECL_INITIAL (t), 0);
+ OB_PUTS ("::");
+ OB_PUTID (DECL_NAME (t));
+ break;
+
default:
sorry ("`%s' not supported by dump_decl",
tree_code_name[(int) TREE_CODE (t)]);
parmtypes = TREE_CHAIN (parmtypes);
}
- if (DESTRUCTOR_NAME_P (name))
+ if (DESTRUCTOR_NAME_P (name) && DECL_LANGUAGE (t) == lang_cplusplus)
parmtypes = TREE_CHAIN (parmtypes);
dump_function_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)))
+ if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (t))
+ && DECL_LANGUAGE (t) == lang_cplusplus)
{
OB_PUTC ('~');
dump_decl (name, 0);
case FIELD_DECL:
case CONST_DECL:
case FUNCTION_DECL:
+ case TEMPLATE_DECL:
dump_decl (t, -1);
break;
}
else if (type == boolean_type_node)
{
- if (t == boolean_false_node)
+ if (t == boolean_false_node
+ || (TREE_INT_CST_LOW (t) == 0
+ && TREE_INT_CST_HIGH (t) == 0))
OB_PUTS ("false");
else if (t == boolean_true_node)
OB_PUTS ("true");
- else
- my_friendly_abort (366);
}
else if (type == char_type_node)
{
args = TREE_CHAIN (args);
}
dump_expr (fn, 0);
- OB_PUTC('(');
+ OB_PUTC ('(');
dump_expr_list (args);
OB_PUTC (')');
}
break;
- case WITH_CLEANUP_EXPR:
- /* Note that this only works for G++ cleanups. If somebody
- builds a general cleanup, there's no way to represent it. */
- dump_expr (TREE_OPERAND (t, 0), 0);
- 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
break;
}
+ case TEMPLATE_CONST_PARM:
+ {
+ tree r = TREE_VEC_ELT (TREE_VALUE (current_template_parms),
+ TEMPLATE_CONST_IDX (t));
+ dump_decl (TREE_VALUE (r), -1);
+ break;
+ }
+
+ case IDENTIFIER_NODE:
+ OB_PUTID (t);
+ break;
+
+ case SCOPE_REF:
+ dump_type (TREE_OPERAND (t, 0), 0);
+ OB_PUTS ("::");
+ dump_expr (TREE_OPERAND (t, 1), 0);
+ break;
+
+ case CAST_EXPR:
+ if (TREE_CHAIN (TREE_OPERAND (t, 0)))
+ {
+ dump_type (TREE_TYPE (t), 0);
+ OB_PUTC ('(');
+ dump_expr_list (TREE_OPERAND (t, 0), 0);
+ OB_PUTC (')');
+ }
+ else
+ {
+ OB_PUTC ('(');
+ dump_type (TREE_TYPE (t), 0);
+ OB_PUTC (')');
+ OB_PUTC ('(');
+ dump_expr_list (TREE_OPERAND (t, 0));
+ OB_PUTC (')');
+ }
+ break;
+
+ case LOOKUP_EXPR:
+ OB_PUTID (TREE_OPERAND (t, 0));
+ break;
+
+ case SIZEOF_EXPR:
+ OB_PUTS ("sizeof (");
+ if (TREE_CODE_CLASS (TREE_CODE (TREE_OPERAND (t, 0))) == 't')
+ dump_type (TREE_OPERAND (t, 0), 0);
+ else
+ dump_unary_op ("*", t, 0);
+ OB_PUTC (')');
+ break;
+
case TREE_LIST:
if (TREE_VALUE (t) && TREE_CODE (TREE_VALUE (t)) == FUNCTION_DECL)
{
}
char *
-fndecl_as_string (cname, fndecl, print_ret_type_p)
- tree cname, fndecl;
+fndecl_as_string (fndecl, print_ret_type_p)
+ tree fndecl;
int print_ret_type_p;
{
return decl_as_string (fndecl, print_ret_type_p);
t = TREE_TYPE (t);
if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
- {
- if (IS_AGGR_TYPE (t))
- line = CLASSTYPE_SOURCE_LINE (t);
- else
- line = DECL_SOURCE_LINE (TYPE_NAME (t));
- }
+ line = DECL_SOURCE_LINE (TYPE_NAME (t));
else
line = DECL_SOURCE_LINE (t);
return buf;
}
+char *
+assop_as_string (p, v)
+ enum tree_code p;
+ int v;
+{
+ static char buf[] = "operator ";
+
+ if (p == 0)
+ return "{unknown}";
+
+ strcpy (buf + 9, assignop_tab [p]);
+ return buf;
+}
+
char *
args_as_string (p, v)
tree p;
return type_as_string (p, v);
}
+
+char *
+cv_as_string (p, v)
+ tree p;
+ int v;
+{
+ OB_INIT ();
+
+ dump_readonly_or_volatile (p, before);
+
+ OB_FINISH ();
+
+ return (char *)obstack_base (&scratch_obstack);
+}