--- gcc/cp/error.c 2018/04/24 18:20:22 1.1.1.1 +++ gcc/cp/error.c 2018/04/24 18:27:16 1.1.1.2 @@ -1,6 +1,6 @@ /* Call-backs for C++ error reporting. This code is non-reentrant. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. This file is part of GNU CC. @@ -16,7 +16,8 @@ GNU General Public License for more deta You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ #include "config.h" #include "tree.h" @@ -34,6 +35,7 @@ typedef char* cp_printer (); #define O op_as_string #define P parm_as_string #define T type_as_string +#define V cv_as_string #define _ (cp_printer *) 0 cp_printer * cp_printers[256] = @@ -44,7 +46,7 @@ cp_printer * cp_printers[256] = _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x20 */ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x30 */ _, A, _, C, D, E, _, _, _, _, _, _, L, _, _, O, /* 0x40 */ - P, _, _, _, T, _, _, _, _, _, _, _, _, _, _, _, /* 0x50 */ + P, _, _, _, T, _, V, _, _, _, _, _, _, _, _, _, /* 0x50 */ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x60 */ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x70 */ }; @@ -55,6 +57,7 @@ cp_printer * cp_printers[256] = #undef O #undef P #undef T +#undef V #undef _ #define obstack_chunk_alloc xmalloc @@ -268,18 +271,18 @@ dump_aggr_type (t, v) name = TYPE_NAME (t); - if (DECL_CONTEXT (name)) + if (name && DECL_CONTEXT (name)) { /* FUNCTION_DECL or RECORD_TYPE */ dump_decl (DECL_CONTEXT (name), 0); OB_PUTC2 (':', ':'); } - /* kludge around wierd behavior on g++.brendan/line1.C */ - if (TREE_CODE (name) != IDENTIFIER_NODE) + /* kludge around weird behavior on g++.brendan/line1.C */ + 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) @@ -511,6 +514,9 @@ ident_fndecl (t) { 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 @@ -585,7 +591,7 @@ dump_decl (t, v) break; case VAR_DECL: - if (VTABLE_NAME_P (DECL_NAME (t))) + if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t))) { OB_PUTS ("vtable for "); dump_type (DECL_CONTEXT (t), v); @@ -599,6 +605,7 @@ dump_decl (t, v) { dump_type_prefix (TREE_TYPE (t), v); OB_PUTC (' '); + dump_readonly_or_volatile (t, after); } /* DECL_CLASS_CONTEXT isn't being set in some cases. Hmm... */ if (DECL_CONTEXT (t) @@ -615,6 +622,10 @@ dump_decl (t, v) dump_type_suffix (TREE_TYPE (t), v); break; + case NAMESPACE_DECL: + OB_PUTID (DECL_NAME (t)); + break; + case ARRAY_REF: dump_decl (TREE_OPERAND (t, 0), v); OB_PUTC ('['); @@ -637,26 +648,30 @@ dump_decl (t, v) /* 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: @@ -779,7 +794,7 @@ dump_function_decl (t, v) 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); @@ -818,7 +833,8 @@ 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); @@ -932,9 +948,16 @@ dump_expr (t, nop) char *p = enum_name_string (t, type); OB_PUTCP (p); } - else if (type == char_type_node - || type == signed_char_type_node - || type == unsigned_char_type_node) + else if (type == boolean_type_node) + { + if (t == boolean_false_node) + OB_PUTS ("false"); + else if (t == boolean_true_node) + OB_PUTS ("true"); + else + my_friendly_abort (366); + } + else if (type == char_type_node) { OB_PUTC ('\''); dump_char (TREE_INT_CST_LOW (t)); @@ -1017,8 +1040,7 @@ dump_expr (t, nop) } else { - sorry ("operand of SAVE_EXPR not understood"); - goto error; + dump_expr (TREE_OPERAND (t, 0), 0); } break; @@ -1135,6 +1157,13 @@ dump_expr (t, nop) } break; + case ARRAY_REF: + dump_expr (TREE_OPERAND (t, 0), 0); + OB_PUTC ('['); + dump_expr (TREE_OPERAND (t, 1), 0); + OB_PUTC (']'); + break; + case CONVERT_EXPR: dump_unary_op ("+", t, nop); break; @@ -1437,3 +1466,17 @@ args_as_string (p, v) 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); +}