diff options
author | cvs2svn <cvs2svn@FreeBSD.org> | 2001-03-19 20:56:12 +0000 |
---|---|---|
committer | cvs2svn <cvs2svn@FreeBSD.org> | 2001-03-19 20:56:12 +0000 |
commit | dc54a98d057114b4701ceeceeeb16f446ade4cf4 (patch) | |
tree | 797d608e70dda10b0da9a4097457ac5fd8f1bc60 /contrib/gcc/cp | |
parent | 06b8915d1faf919850dd08fb24caab3f447e37b6 (diff) |
Notes
Diffstat (limited to 'contrib/gcc/cp')
-rw-r--r-- | contrib/gcc/cp/class.h | 117 | ||||
-rw-r--r-- | contrib/gcc/cp/edsel.c | 928 | ||||
-rw-r--r-- | contrib/gcc/cp/g++.c | 582 | ||||
-rw-r--r-- | contrib/gcc/cp/gc.c | 1550 | ||||
-rw-r--r-- | contrib/gcc/cp/gpcompare.texi | 236 | ||||
-rw-r--r-- | contrib/gcc/cp/reno.texi | 752 | ||||
-rw-r--r-- | contrib/gcc/cp/templates.texi | 235 | ||||
-rw-r--r-- | contrib/gcc/cp/tree.def | 116 |
8 files changed, 0 insertions, 4516 deletions
diff --git a/contrib/gcc/cp/class.h b/contrib/gcc/cp/class.h deleted file mode 100644 index f2c21735cc4cd..0000000000000 --- a/contrib/gcc/cp/class.h +++ /dev/null @@ -1,117 +0,0 @@ -/* Variables and structures for overloading rules. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* The following structure is used when comparing various alternatives - for overloading. The unsigned quantity `strikes.i' is used - for fast comparison of two possibilities. This number is an - aggregate of four constituents: - - EVIL: if this is non-zero, then the candidate should not be considered - ELLIPSIS: if this is non-zero, then some actual argument has been matched - against an ellipsis - USER: if this is non-zero, then a user-defined type conversion is needed - B_OR_D: if this is non-zero, then use a base pointer instead of the - type of the pointer we started with. - EASY: if this is non-zero, then we have a builtin conversion - (such as int to long, int to float, etc) to do. - - If two candidates require user-defined type conversions, and the - type conversions are not identical, then an ambiguity error - is reported. - - If two candidates agree on user-defined type conversions, - and one uses pointers of strictly higher type (derived where - another uses base), then that alternative is silently chosen. - - Note that this technique really only works for 255 arguments. Perhaps - this is not enough. */ - -/* These macros and harshness_code are used by the NEW METHOD. */ -#define EVIL_CODE (1<<7) -#define CONST_CODE (1<<6) -#define ELLIPSIS_CODE (1<<5) -#define USER_CODE (1<<4) -#define STD_CODE (1<<3) -#define PROMO_CODE (1<<2) -#define QUAL_CODE (1<<1) -#define TRIVIAL_CODE (1<<0) - -struct harshness_code -{ - /* What kind of conversion is involved. */ - unsigned short code; - - /* The inheritance distance. */ - short distance; - - /* For a PROMO_CODE, Any special penalties involved in integral conversions. - This exists because $4.1 of the ARM states that something like - `short unsigned int' should promote to `int', not `unsigned int'. - If, for example, it tries to match two fns, f(int) and f(unsigned), - f(int) should be a better match than f(unsigned) by this rule. Without - this extra metric, they both only appear as "integral promotions", which - will lead to an ambiguity. - For a TRIVIAL_CODE, This is also used by build_overload_call_real and - convert_harshness to keep track of other information we need. */ - unsigned short int_penalty; -}; - -struct candidate -{ - struct harshness_code h; /* Used for single-argument conversions. */ - - int h_len; /* The length of the harshness vector. */ - - tree function; /* A FUNCTION_DECL */ - tree basetypes; /* The path to function. */ - tree arg; /* first parm to function. */ - - /* Indexed by argument number, encodes evil, user, d_to_b, and easy - strikes for that argument. At end of array, we store the index+1 - of where we started using default parameters, or 0 if there are - none. */ - struct harshness_code *harshness; - - union - { - tree field; /* If no evil strikes, the FUNCTION_DECL of - the function (if a member function). */ - int bad_arg; /* the index of the first bad argument: - 0 if no bad arguments - > 0 is first bad argument - -1 if extra actual arguments - -2 if too few actual arguments. - -3 if const/non const method mismatch. - -4 if type unification failed. - -5 if contravariance violation. */ - } u; -}; -int rank_for_overload (); - -/* Variables shared between class.c and call.c. */ - -extern int n_vtables; -extern int n_vtable_entries; -extern int n_vtable_searches; -extern int n_vtable_elems; -extern int n_convert_harshness; -extern int n_compute_conversion_costs; -extern int n_build_method_call; -extern int n_inner_fields_searched; diff --git a/contrib/gcc/cp/edsel.c b/contrib/gcc/cp/edsel.c deleted file mode 100644 index 35099d523f76a..0000000000000 --- a/contrib/gcc/cp/edsel.c +++ /dev/null @@ -1,928 +0,0 @@ -/* Interface to LUCID Cadillac system for GNU compiler. - Copyright (C) 1988, 1992, 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "config.h" - -#include "tree.h" -#include "flags.h" -#include <stdio.h> -#include "cp-tree.h" -#include "obstack.h" - -#ifdef CADILLAC -#include <compilerreq.h> -#include <compilerconn.h> -#include <sys/time.h> -#include <sys/types.h> -#include <errno.h> -#include <sys/file.h> - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -void init_cadillac (); - -extern char *input_filename; -extern int lineno; - -/* Put random information we might want to get back from - Cadillac here. */ -typedef struct -{ - /* The connection to the Cadillac kernel. */ - Connection *conn; - - /* Input and output file descriptors for Cadillac. */ - short fd_input, fd_output; - - /* #include nesting of current file. */ - short depth; - - /* State variables for the connection. */ - char messages; - char conversion; - char emission; - char process_until; - - /* #if level of current file. */ - int iflevel; - - /* Line number that starts current source file. */ - int lineno; - - /* Name of current file. */ - char *filename; - - /* Where to stop processing (if process_until is set). */ - char *end_filename; - int end_position; - -} cadillac_struct; -static cadillac_struct cadillacObj; - -/* Nonzero if in the process of exiting. */ -static int exiting; - -void cadillac_note_source (); -static void CWriteLanguageDecl (); -static void CWriteLanguageType (); -static void CWriteTopLevel (); -static void cadillac_note_filepos (); -static void cadillac_process_request (), cadillac_process_requests (); -static void cadillac_switch_source (); -static void exit_cadillac (); - -/* Blocking test. */ -static int -readable_p (fd) - int fd; -{ - fd_set f; - - FD_ZERO (&f); - FD_SET (fd, &f); - - return select (32, &f, NULL, NULL, 0) == 1; -} - -static CObjectType *tree_to_cadillac_map; -struct obstack cadillac_obstack; - - -#include "stack.h" - -struct context_level -{ - struct stack_level base; - - tree context; -}; - -/* Stack for maintaining contexts (in case functions or types are nested). - When defining a struct type, the `context' field is the RECORD_TYPE. - When defining a function, the `context' field is the FUNCTION_DECL. */ - -static struct context_level *context_stack; - -static struct context_level * -push_context_level (stack, obstack) - struct stack_level *stack; - struct obstack *obstack; -{ - struct context_level tem; - - tem.base.prev = stack; - return (struct context_level *)push_stack_level (obstack, &tem, sizeof (tem)); -} - -/* Discard a level of search allocation. */ - -static struct context_level * -pop_context_level (stack) - struct context_level *stack; -{ - stack = (struct context_level *)pop_stack_level (stack); - return stack; -} - -void -init_cadillac () -{ - extern FILE *finput; - extern int errno; - CCompilerMessage* req; - cadillac_struct *cp = &cadillacObj; - int i; - - if (! flag_cadillac) - return; - - tree_to_cadillac_map = (CObjectType*) xmalloc (sizeof (CObjectType) * LAST_CPLUS_TREE_CODE); - for (i = 0; i < LAST_CPLUS_TREE_CODE; i++) - tree_to_cadillac_map[i] = MiscOType; - tree_to_cadillac_map[RECORD_TYPE] = StructOType; - tree_to_cadillac_map[UNION_TYPE] = UnionOType; - tree_to_cadillac_map[ENUMERAL_TYPE] = EnumTypeOType; - tree_to_cadillac_map[TYPE_DECL] = TypedefOType; - tree_to_cadillac_map[VAR_DECL] = VariableOType; - tree_to_cadillac_map[CONST_DECL] = EnumConstantOType; - tree_to_cadillac_map[FUNCTION_DECL] = FunctionOType; - tree_to_cadillac_map[FIELD_DECL] = FieldOType; - -#ifdef sun - on_exit (&exit_cadillac, 0); -#endif - - gcc_obstack_init (&cadillac_obstack); - - /* Yow! This is the way Cadillac was designed to deal with - Oregon C++ compiler! */ - cp->fd_input = flag_cadillac; - cp->fd_output = flag_cadillac; - - /* Start in "turned-on" state. */ - cp->messages = 1; - cp->conversion = 1; - cp->emission = 1; - - /* Establish a connection with Cadillac here. */ - cp->conn = NewConnection (cp, cp->fd_input, cp->fd_output); - - CWriteHeader (cp->conn, WaitingMType, 0); - CWriteRequestBuffer (cp->conn); - - if (!readable_p (cp->fd_input)) - ; - - req = CReadCompilerMessage (cp->conn); - - if (!req) - switch (errno) - { - case EWOULDBLOCK: - sleep (5); - return; - - case 0: - fatal ("init_cadillac: EOF on connection to kernel, exiting\n"); - break; - - default: - perror ("Editor to kernel connection"); - exit (0); - } -} - -static void -cadillac_process_requests (conn) - Connection *conn; -{ - CCompilerMessage *req; - while (req = (CCompilerMessage*) CPeekNextRequest (conn)) - { - req = CReadCompilerMessage (conn); - cadillac_process_request (&cadillacObj, req); - } -} - -static void -cadillac_process_request (cp, req) - cadillac_struct *cp; - CCompilerMessage *req; -{ - if (! req) - return; - - switch (req->reqType) - { - case ProcessUntilMType: - if (cp->process_until) - my_friendly_abort (23); - cp->process_until = 1; - /* This is not really right. */ - cp->end_position = ((CCompilerCommand*)req)->processuntil.position; -#if 0 - cp->end_filename = req->processuntil.filename; -#endif - break; - - case CommandMType: - switch (req->header.data) - { - case MessagesOnCType: - cp->messages = 1; - break; - case MessagesOffCType: - cp->messages = 0; - break; - case ConversionOnCType: - cp->conversion = 1; - break; - case ConversionOffCType: - cp->conversion = 0; - break; - case EmissionOnCType: - cp->emission = 1; - break; - case EmissionOffCType: - cp->emission = 0; - break; - - case FinishAnalysisCType: - return; - - case PuntAnalysisCType: - case ContinueAnalysisCType: - case GotoFileposCType: - case OpenSucceededCType: - case OpenFailedCType: - fprintf (stderr, "request type %d not implemented\n", req->reqType); - return; - - case DieCType: - if (! exiting) - my_friendly_abort (24); - return; - - } - break; - - default: - fatal ("unknown request type %d", req->reqType); - } -} - -void -cadillac_start () -{ - Connection *conn = cadillacObj.conn; - CCompilerMessage *req; - - /* Let Cadillac know that we start in C++ language scope. */ - CWriteHeader (conn, ForeignLinkageMType, LinkCPlus); - CWriteLength (conn); - CWriteRequestBuffer (conn); - - cadillac_process_requests (conn); -} - -static void -cadillac_printf (msg, name) -{ - if (cadillacObj.messages) - printf ("[%s,%4d] %s `%s'\n", input_filename, lineno, msg, name); -} - -void -cadillac_start_decl (decl) - tree decl; -{ - Connection *conn = cadillacObj.conn; - CObjectType object_type = tree_to_cadillac_map [TREE_CODE (decl)]; - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - /* Currently, cadillac only implements top-level forms. */ - return; - case RECORD_TYPE: - case UNION_TYPE: - cadillac_printf ("start class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl))); - break; - default: - my_friendly_abort (25); - } - else - { - cadillac_printf ("start top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); - CWriteTopLevel (conn, StartMType); - } - - CWriteLanguageDecl (conn, decl, tree_to_cadillac_map[TREE_CODE (decl)]); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_decl (decl) - tree decl; -{ - Connection *conn = cadillacObj.conn; - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - cadillac_printf ("end class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl))); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - break; - default: - my_friendly_abort (26); - } - else - { - cadillac_printf ("end top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - } - - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_start_function (fndecl) - tree fndecl; -{ - Connection *conn = cadillacObj.conn; - - if (context_stack) - /* nested functions not yet handled. */ - my_friendly_abort (27); - - cadillac_printf ("start top-level function", lang_printable_name (fndecl)); - context_stack = push_context_level (context_stack, &cadillac_obstack); - context_stack->context = fndecl; - - CWriteTopLevel (conn, StartMType); - my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 202); - CWriteLanguageDecl (conn, fndecl, - (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE - ? MemberFnOType : FunctionOType)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_function (fndecl) - tree fndecl; -{ - Connection *conn = cadillacObj.conn; - - cadillac_printf ("end top-level function", lang_printable_name (fndecl)); - context_stack = pop_context_level (context_stack); - - if (context_stack) - /* nested functions not yet implemented. */ - my_friendly_abort (28); - - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_anon_union (decl) - tree decl; -{ - Connection *conn = cadillacObj.conn; - - if (! global_bindings_p ()) - return; - cadillac_printf ("finish top-level anon union", ""); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_start_enum (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - break; - default: - my_friendly_abort (29); - } - else - { - cadillac_printf ("start top-level enum", IDENTIFIER_POINTER (name)); - CWriteTopLevel (conn, StartMType); - } - - CWriteLanguageType (conn, type, tree_to_cadillac_map[ENUMERAL_TYPE]); -} - -void -cadillac_finish_enum (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - break; - default: - my_friendly_abort (30); - } - else - { - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - cadillac_printf ("finish top-level enum", IDENTIFIER_POINTER (name)); - CWriteTopLevel (conn, StopMType); - } - - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_start_struct (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - return; - default: - my_friendly_abort (31); - } - else - { - cadillac_printf ("start struct", IDENTIFIER_POINTER (name)); - CWriteTopLevel (conn, StartMType); - } - - context_stack = push_context_level (context_stack, &cadillac_obstack); - context_stack->context = type; - - CWriteLanguageType (conn, type, - TYPE_LANG_SPECIFIC (type) && CLASSTYPE_DECLARED_CLASS (type) ? ClassOType : tree_to_cadillac_map[TREE_CODE (type)]); -} - -void -cadillac_finish_struct (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - context_stack = pop_context_level (context_stack); - if (context_stack) - return; - - cadillac_printf ("finish struct", IDENTIFIER_POINTER (name)); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_exception (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - - fatal ("cadillac_finish_exception"); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_push_class (type) - tree type; -{ -} - -void -cadillac_pop_class () -{ -} - -void -cadillac_push_lang (name) - tree name; -{ - Connection *conn = cadillacObj.conn; - CLinkLanguageType m; - - if (name == lang_name_cplusplus) - m = LinkCPlus; - else if (name == lang_name_c) - m = LinkC; - else - my_friendly_abort (32); - CWriteHeader (conn, ForeignLinkageMType, m); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_pop_lang () -{ - Connection *conn = cadillacObj.conn; - - CWriteHeader (conn, ForeignLinkageMType, LinkPop); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_stmt () -{ -} - -void -cadillac_note_source () -{ - cadillacObj.lineno = lineno; - cadillacObj.filename = input_filename; -} - -static void -CWriteTopLevel (conn, m) - Connection *conn; - CMessageSubType m; -{ - static context_id = 0; - CWriteHeader (conn, TopLevelFormMType, m); - cadillac_note_filepos (); - - /* Eventually, this will point somewhere into the digest file. */ - context_id += 1; - CWriteSomething (conn, &context_id, sizeof (BITS32)); - - CWriteSomething (conn, &cadillacObj.iflevel, sizeof (BITS32)); - CWriteLength (conn); -} - -static void -cadillac_note_filepos () -{ - extern FILE *finput; - int pos = ftell (finput); - CWriteSomething (cadillacObj.conn, &pos, sizeof (BITS32)); -} - -void -cadillac_switch_source (startflag) - int startflag; -{ - Connection *conn = cadillacObj.conn; - /* Send out the name of the source file being compiled. */ - - CWriteHeader (conn, SourceFileMType, startflag ? StartMType : StopMType); - CWriteSomething (conn, &cadillacObj.depth, sizeof (BITS16)); - CWriteVstring0 (conn, input_filename); - CWriteLength (conn); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_push_source () -{ - cadillacObj.depth += 1; - cadillac_switch_source (1); -} - -void -cadillac_pop_source () -{ - cadillacObj.depth -= 1; - cadillac_switch_source (0); -} - -struct cadillac_mdep -{ - short object_type; - char linkage; - char access; - short length; -}; - -static void -CWriteLanguageElem (conn, p, name) - Connection *conn; - struct cadillac_mdep *p; - char *name; -{ - CWriteSomething (conn, &p->object_type, sizeof (BITS16)); - CWriteSomething (conn, &p->linkage, sizeof (BITS8)); - CWriteSomething (conn, &p->access, sizeof (BITS8)); - CWriteSomething (conn, &p->length, sizeof (BITS16)); - CWriteVstring0 (conn, name); - -#if 0 - /* Don't write date_type. */ - CWriteVstring0 (conn, ""); -#endif - CWriteLength (conn); -} - -static void -CWriteLanguageDecl (conn, decl, object_type) - Connection *conn; - tree decl; - CObjectType object_type; -{ - struct cadillac_mdep foo; - tree name; - - CWriteHeader (conn, LanguageElementMType, StartDefineMType); - foo.object_type = object_type; - if (decl_type_context (decl)) - { - foo.linkage = ParentLinkage; - if (TREE_PRIVATE (decl)) - foo.access = PrivateAccess; - else if (TREE_PROTECTED (decl)) - foo.access = ProtectedAccess; - else - foo.access = PublicAccess; - } - else - { - if (TREE_PUBLIC (decl)) - foo.linkage = GlobalLinkage; - else - foo.linkage = FileLinkage; - foo.access = PublicAccess; - } - name = DECL_NAME (decl); - foo.length = IDENTIFIER_LENGTH (name); - - CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -static void -CWriteLanguageType (conn, type, object_type) - Connection *conn; - tree type; - CObjectType object_type; -{ - struct cadillac_mdep foo; - tree name = TYPE_NAME (type); - - CWriteHeader (conn, LanguageElementMType, StartDefineMType); - foo.object_type = object_type; - if (current_class_type) - { - foo.linkage = ParentLinkage; - if (TREE_PRIVATE (type)) - foo.access = PrivateAccess; - else if (TREE_PROTECTED (type)) - foo.access = ProtectedAccess; - else - foo.access = PublicAccess; - } - else - { - foo.linkage = NoLinkage; - foo.access = PublicAccess; - } - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - foo.length = IDENTIFIER_LENGTH (name); - - CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -static void -CWriteUseObject (conn, type, object_type, use) - Connection *conn; - tree type; - CObjectType object_type; - CMessageSubType use; -{ - struct cadillac_mdep foo; - tree name = NULL_TREE; - - CWriteHeader (conn, LanguageElementMType, use); - foo.object_type = object_type; - if (current_class_type) - { - foo.linkage = ParentLinkage; - if (TREE_PRIVATE (type)) - foo.access = PrivateAccess; - else if (TREE_PROTECTED (type)) - foo.access = ProtectedAccess; - else - foo.access = PublicAccess; - } - else - { - foo.linkage = NoLinkage; - foo.access = PublicAccess; - } - switch (TREE_CODE (type)) - { - case VAR_DECL: - case FIELD_DECL: - case TYPE_DECL: - case CONST_DECL: - case FUNCTION_DECL: - name = DECL_NAME (type); - break; - - default: - my_friendly_abort (33); - } - - foo.length = IDENTIFIER_LENGTH (name); - - CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -/* Here's how we exit under cadillac. */ - -static void -exit_cadillac () -{ - extern int errorcount; - - Connection *conn = cadillacObj.conn; - - if (flag_cadillac) - { - CCompilerMessage *req; - - CWriteHeader (conn, FinishedMType, - errorcount ? 0 : CsObjectWritten | CsComplete); - /* Bye, bye! */ - CWriteRequestBuffer (conn); - - /* Block on read. */ - while (! readable_p (cadillacObj.fd_input)) - { - if (exiting) - my_friendly_abort (34); - exiting = 1; - } - exiting = 1; - - req = CReadCompilerMessage (conn); - cadillac_process_request (&cadillacObj, req); - } -} - -#else -/* Stubs. */ -void init_cadillac () {} -void cadillac_start () {} -void cadillac_start_decl (decl) - tree decl; -{} -void -cadillac_finish_decl (decl) - tree decl; -{} -void -cadillac_start_function (fndecl) - tree fndecl; -{} -void -cadillac_finish_function (fndecl) - tree fndecl; -{} -void -cadillac_finish_anon_union (decl) - tree decl; -{} -void -cadillac_start_enum (type) - tree type; -{} -void -cadillac_finish_enum (type) - tree type; -{} -void -cadillac_start_struct (type) - tree type; -{} -void -cadillac_finish_struct (type) - tree type; -{} -void -cadillac_finish_exception (type) - tree type; -{} -void -cadillac_push_class (type) - tree type; -{} -void -cadillac_pop_class () -{} -void -cadillac_push_lang (name) - tree name; -{} -void -cadillac_pop_lang () -{} -void -cadillac_note_source () -{} -void -cadillac_finish_stmt () -{} -void -cadillac_switch_source () -{} -void -cadillac_push_source () -{} -void -cadillac_pop_source () -{} -#endif diff --git a/contrib/gcc/cp/g++.c b/contrib/gcc/cp/g++.c deleted file mode 100644 index f694898fa966a..0000000000000 --- a/contrib/gcc/cp/g++.c +++ /dev/null @@ -1,582 +0,0 @@ -/* G++ preliminary semantic processing for the compiler driver. - Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. - Contributed by Brendan Kehoe (brendan@cygnus.com). - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* This program is a wrapper to the main `gcc' driver. For GNU C++, - we need to do two special things: a) append `-lg++' in situations - where it's appropriate, to link in libg++, and b) add `-xc++'..`-xnone' - around file arguments named `foo.c' or `foo.i'. So, we do all of - this semantic processing then just exec gcc with the new argument - list. - - We used to do all of this in a small shell script, but many users - found the performance of this as a shell script to be unacceptable. - In situations where your PATH has a lot of NFS-mounted directories, - using a script that runs sed and other things would be a nasty - performance hit. With this program, we never search the PATH at all. */ - -#include "config.h" -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif -#include <stdio.h> -#include <sys/types.h> -#if !defined(_WIN32) -#include <sys/file.h> /* May get R_OK, etc. on some systems. */ -#else -#include <process.h> -#endif -#include <errno.h> - -/* Defined to the name of the compiler; if using a cross compiler, the - Makefile should compile this file with the proper name - (e.g., "i386-aout-gcc"). */ -#ifndef GCC_NAME -#define GCC_NAME "gcc" -#endif - -/* This bit is set if we saw a `-xfoo' language specification. */ -#define LANGSPEC (1<<1) -/* This bit is set if they did `-lm' or `-lmath'. */ -#define MATHLIB (1<<2) - -#ifndef MATH_LIBRARY -#define MATH_LIBRARY "-lm" -#endif - -/* On MSDOS, write temp files in current dir - because there's no place else we can expect to use. */ -#ifdef __MSDOS__ -#ifndef P_tmpdir -#define P_tmpdir "." -#endif -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#endif -#endif - -#ifndef VPROTO -#ifdef __STDC__ -#define PVPROTO(ARGS) ARGS -#define VPROTO(ARGS) ARGS -#define VA_START(va_list,var) va_start(va_list,var) -#else -#define PVPROTO(ARGS) () -#define VPROTO(ARGS) (va_alist) va_dcl -#define VA_START(va_list,var) va_start(va_list) -#endif -#endif - -#ifndef errno -extern int errno; -#endif - -extern int sys_nerr; -#ifndef HAVE_STRERROR -#if defined(bsd4_4) -extern const char *const sys_errlist[]; -#else -extern char *sys_errlist[]; -#endif -#else -extern char *strerror(); -#endif - -/* Name with which this program was invoked. */ -static char *programname; - -char * -my_strerror(e) - int e; -{ - -#ifdef HAVE_STRERROR - return strerror(e); - -#else - - static char buffer[30]; - if (!e) - return ""; - - if (e > 0 && e < sys_nerr) - return sys_errlist[e]; - - sprintf (buffer, "Unknown error %d", e); - return buffer; -#endif -} - -#ifdef HAVE_VPRINTF -/* Output an error message and exit */ - -static void -fatal VPROTO((char *format, ...)) -{ -#ifndef __STDC__ - char *format; -#endif - va_list ap; - - VA_START (ap, format); - -#ifndef __STDC__ - format = va_arg (ap, char*); -#endif - - fprintf (stderr, "%s: ", programname); - vfprintf (stderr, format, ap); - va_end (ap); - fprintf (stderr, "\n"); -#if 0 - /* XXX Not needed for g++ driver. */ - delete_temp_files (); -#endif - exit (1); -} - -static void -error VPROTO((char *format, ...)) -{ -#ifndef __STDC__ - char *format; -#endif - va_list ap; - - VA_START (ap, format); - -#ifndef __STDC__ - format = va_arg (ap, char*); -#endif - - fprintf (stderr, "%s: ", programname); - vfprintf (stderr, format, ap); - va_end (ap); - - fprintf (stderr, "\n"); -} - -#else /* not HAVE_VPRINTF */ - -static void -error (msg, arg1, arg2) - char *msg, *arg1, *arg2; -{ - fprintf (stderr, "%s: ", programname); - fprintf (stderr, msg, arg1, arg2); - fprintf (stderr, "\n"); -} - -static void -fatal (msg, arg1, arg2) - char *msg, *arg1, *arg2; -{ - error (msg, arg1, arg2); -#if 0 - /* XXX Not needed for g++ driver. */ - delete_temp_files (); -#endif - exit (1); -} - -#endif /* not HAVE_VPRINTF */ - -/* More 'friendly' abort that prints the line and file. - config.h can #define abort fancy_abort if you like that sort of thing. */ - -void -fancy_abort () -{ - fatal ("Internal g++ abort."); -} - -char * -xmalloc (size) - unsigned size; -{ - register char *value = (char *) malloc (size); - if (value == 0) - fatal ("virtual memory exhausted"); - return value; -} - -/* Return a newly-allocated string whose contents concatenate those - of s1, s2, s3. */ -static char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); - char *result = xmalloc (len1 + len2 + len3 + 1); - - strcpy (result, s1); - strcpy (result + len1, s2); - strcpy (result + len1 + len2, s3); - *(result + len1 + len2 + len3) = 0; - - return result; -} - -static void -pfatal_with_name (name) - char *name; -{ - fatal (concat ("%s: ", my_strerror (errno), ""), name); -} - -#ifdef __MSDOS__ -/* This is the common prefix we use to make temp file names. */ -char *temp_filename; - -/* Length of the prefix. */ -int temp_filename_length; - -/* Compute a string to use as the base of all temporary file names. */ -static char * -choose_temp_base_try (try, base) -char *try; -char *base; -{ - char *rv; - if (base) - rv = base; - else if (try == (char *)0) - rv = 0; - else if (access (try, R_OK | W_OK) != 0) - rv = 0; - else - rv = try; - return rv; -} - -static void -choose_temp_base () -{ - char *base = 0; - int len; - - base = choose_temp_base_try (getenv ("TMPDIR"), base); - base = choose_temp_base_try (getenv ("TMP"), base); - base = choose_temp_base_try (getenv ("TEMP"), base); - -#ifdef P_tmpdir - base = choose_temp_base_try (P_tmpdir, base); -#endif - - base = choose_temp_base_try ("/usr/tmp", base); - base = choose_temp_base_try ("/tmp", base); - - /* If all else fails, use the current directory! */ - if (base == (char *)0) - base = "./"; - - len = strlen (base); - temp_filename = xmalloc (len + sizeof("/ccXXXXXX")); - strcpy (temp_filename, base); - if (len > 0 && temp_filename[len-1] != '/') - temp_filename[len++] = '/'; - strcpy (temp_filename + len, "ccXXXXXX"); - - mktemp (temp_filename); - temp_filename_length = strlen (temp_filename); - if (temp_filename_length == 0) - abort (); -} - -static void -perror_exec (name) - char *name; -{ - char *s; - - if (errno < sys_nerr) - s = concat ("installation problem, cannot exec %s: ", - my_strerror( errno ), ""); - else - s = "installation problem, cannot exec %s"; - error (s, name); -} - -/* This is almost exactly what's in gcc.c:pexecute for MSDOS. */ -void -run_dos (program, argv) - char *program; - char *argv[]; -{ - char *scmd, *rf; - FILE *argfile; - int i; - - choose_temp_base (); /* not in gcc.c */ - - scmd = (char *) malloc (strlen (program) + strlen (temp_filename) + 10); - rf = scmd + strlen (program) + 6; - sprintf (scmd, "%s.exe @%s.gp", program, temp_filename); - - argfile = fopen (rf, "w"); - if (argfile == 0) - pfatal_with_name (rf); - - for (i=1; argv[i]; i++) - { - char *cp; - for (cp = argv[i]; *cp; cp++) - { - if (*cp == '"' || *cp == '\'' || *cp == '\\' || isspace (*cp)) - fputc ('\\', argfile); - fputc (*cp, argfile); - } - fputc ('\n', argfile); - } - fclose (argfile); - - i = system (scmd); - - remove (rf); - - if (i == -1) - perror_exec (program); -} -#endif /* __MSDOS__ */ - -int -main (argc, argv) - int argc; - char **argv; -{ - register int i, j = 0; - register char *p; - int verbose = 0; - - /* This will be 0 if we encounter a situation where we should not - link in libstdc++, or 2 if we should link in libg++ as well. */ - int library = 1; - - /* Used to track options that take arguments, so we don't go wrapping - those with -xc++/-xnone. */ - char *quote = NULL; - - /* The new argument list will be contained in this. */ - char **arglist; - - /* The name of the compiler we will want to run---by default, it - will be the definition of `GCC_NAME', e.g., `gcc'. */ - char *gcc = GCC_NAME; - - /* Non-zero if we saw a `-xfoo' language specification on the - command line. Used to avoid adding our own -xc++ if the user - already gave a language for the file. */ - int saw_speclang = 0; - - /* Non-zero if we saw `-lm' or `-lmath' on the command line. */ - char *saw_math = 0; - - /* The number of arguments being added to what's in argv, other than - libraries. We use this to track the number of times we've inserted - -xc++/-xnone. */ - int added = 0; - - /* An array used to flag each argument that needs a bit set for - LANGSPEC or MATHLIB. */ - int *args; - - p = argv[0] + strlen (argv[0]); - - /* If we're called as g++ (or i386-aout-g++), link in libg++ as well. */ - - if (strcmp (p - 3, "g++") == 0) - { - library = 2; - } - - while (p != argv[0] && p[-1] != '/') - --p; - programname = p; - - if (argc == 1) - fatal ("No input files specified.\n"); - -#ifndef __MSDOS__ - /* We do a little magic to find out where the main gcc executable - is. If they ran us as /usr/local/bin/g++, then we will look - for /usr/local/bin/gcc; similarly, if they just ran us as `g++', - we'll just look for `gcc'. */ - if (p != argv[0]) - { - *--p = '\0'; - gcc = (char *) malloc ((strlen (argv[0]) + 1 + strlen (GCC_NAME) + 1) - * sizeof (char)); - sprintf (gcc, "%s/%s", argv[0], GCC_NAME); - } -#endif - - args = (int *) malloc (argc * sizeof (int)); - bzero ((char *) args, argc * sizeof (int)); - - for (i = 1; i < argc; i++) - { - /* If the previous option took an argument, we swallow it here. */ - if (quote) - { - quote = NULL; - continue; - } - - if (argv[i][0] == '\0' || argv[i][1] == '\0') - continue; - - if (argv[i][0] == '-') - { - if (library != 0 && strcmp (argv[i], "-nostdlib") == 0) - { - library = 0; - } - else if (strcmp (argv[i], "-lm") == 0 - || strcmp (argv[i], "-lmath") == 0) - args[i] |= MATHLIB; - else if (strcmp (argv[i], "-v") == 0) - { - verbose = 1; - if (argc == 2) - { - /* If they only gave us `-v', don't try to link - in libg++. */ - library = 0; - } - } - else if (strncmp (argv[i], "-x", 2) == 0) - saw_speclang = 1; - else if (((argv[i][2] == '\0' - && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL) - || strcmp (argv[i], "-Tdata") == 0)) - quote = argv[i]; - else if (library != 0 && ((argv[i][2] == '\0' - && (char *) strchr ("cSEM", argv[i][1]) != NULL) - || strcmp (argv[i], "-MM") == 0)) - { - /* Don't specify libraries if we won't link, since that would - cause a warning. */ - library = 0; - } - else - /* Pass other options through. */ - continue; - } - else - { - int len; - - if (saw_speclang) - { - saw_speclang = 0; - continue; - } - - /* If the filename ends in .c or .i, put options around it. - But not if a specified -x option is currently active. */ - len = strlen (argv[i]); - if (len > 2 - && (argv[i][len - 1] == 'c' || argv[i][len - 1] == 'i') - && argv[i][len - 2] == '.') - { - args[i] |= LANGSPEC; - added += 2; - } - } - } - - if (quote) - fatal ("argument to `%s' missing\n", quote); - - if (added || library) - { - arglist = (char **) malloc ((argc + added + 4) * sizeof (char *)); - - for (i = 1, j = 1; i < argc; i++, j++) - { - arglist[j] = argv[i]; - - /* Make sure -lg++ is before the math library, since libg++ - itself uses those math routines. */ - if (!saw_math && (args[i] & MATHLIB) && library) - { - --j; - saw_math = argv[i]; - } - - /* Wrap foo.c and foo.i files in a language specification to - force the gcc compiler driver to run cc1plus on them. */ - if (args[i] & LANGSPEC) - { - int len = strlen (argv[i]); - if (argv[i][len - 1] == 'i') - arglist[j++] = "-xc++-cpp-output"; - else - arglist[j++] = "-xc++"; - arglist[j++] = argv[i]; - arglist[j] = "-xnone"; - } - } - - /* Add `-lg++' if we haven't already done so. */ - if (library == 2) - arglist[j++] = "-lg++"; - if (library) - arglist[j++] = "-lstdc++"; - if (saw_math) - arglist[j++] = saw_math; - else if (library) - arglist[j++] = MATH_LIBRARY; - - arglist[j] = NULL; - } - else - /* No need to copy 'em all. */ - arglist = argv; - - arglist[0] = gcc; - - if (verbose) - { - if (j == 0) - j = argc; - - for (i = 0; i < j; i++) - fprintf (stderr, " %s", arglist[i]); - fprintf (stderr, "\n"); - } -#if !defined(OS2) && !defined (_WIN32) -#ifdef __MSDOS__ - run_dos (gcc, arglist); -#else /* !__MSDOS__ */ - if (execvp (gcc, arglist) < 0) - pfatal_with_name (gcc); -#endif /* __MSDOS__ */ -#else /* OS2 or _WIN32 */ - if (spawnvp (1, gcc, arglist) < 0) - pfatal_with_name (gcc); -#endif - - return 0; -} diff --git a/contrib/gcc/cp/gc.c b/contrib/gcc/cp/gc.c deleted file mode 100644 index cff1635f53a49..0000000000000 --- a/contrib/gcc/cp/gc.c +++ /dev/null @@ -1,1550 +0,0 @@ -/* Garbage collection primitives for GNU C++. - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@cygnus.com) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include "config.h" -#include "tree.h" -#include "cp-tree.h" -#include "flags.h" -#include "output.h" - -#undef NULL -#define NULL 0 - -extern tree define_function (); -extern tree build_t_desc_overload (); -extern struct obstack *permanent_obstack; - -/* This is the function decl for the (pseudo-builtin) __gc_protect - function. Args are (class *value, int index); Returns value. */ -tree gc_protect_fndecl; - -/* This is the function decl for the (pseudo-builtin) __gc_unprotect - function. Args are (int index); void return. */ -tree gc_unprotect_fndecl; - -/* This is the function decl for the (pseudo-builtin) __gc_push - function. Args are (int length); void return. */ -tree gc_push_fndecl; - -/* This is the function decl for the (pseudo-builtin) __gc_pop - function. Args are void; void return. */ -tree gc_pop_fndecl; - -/* Special integers that are used to represent bits in gc-safe objects. */ -tree gc_nonobject; -tree gc_visible; -tree gc_white; -tree gc_offwhite; -tree gc_grey; -tree gc_black; - -/* in c-common.c */ -extern tree combine_strings PROTO((tree)); - -/* Predicate that returns non-zero if TYPE needs some kind of - entry for the GC. Returns zero otherwise. */ -int -type_needs_gc_entry (type) - tree type; -{ - tree ttype = type; - - if (! flag_gc || type == error_mark_node) - return 0; - - /* Aggregate types need gc entries if any of their members - need gc entries. */ - if (IS_AGGR_TYPE (type)) - { - tree binfos; - tree fields = TYPE_FIELDS (type); - int i; - - /* We don't care about certain pointers. Pointers - to virtual baseclasses are always up front. We also - cull out virtual function table pointers because it's - easy, and it simplifies the logic.*/ - while (fields - && (DECL_NAME (fields) == NULL_TREE - || VFIELD_NAME_P (DECL_NAME (fields)) - || VBASE_NAME_P (DECL_NAME (fields)) - || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fields)), "__bits"))) - fields = TREE_CHAIN (fields); - - while (fields) - { - if (type_needs_gc_entry (TREE_TYPE (fields))) - return 1; - fields = TREE_CHAIN (fields); - } - - binfos = TYPE_BINFO_BASETYPES (type); - if (binfos) - for (i = TREE_VEC_LENGTH (binfos)-1; i >= 0; i--) - if (type_needs_gc_entry (BINFO_TYPE (TREE_VEC_ELT (binfos, i)))) - return 1; - - return 0; - } - - while (TREE_CODE (ttype) == ARRAY_TYPE - && TREE_CODE (TREE_TYPE (ttype)) == ARRAY_TYPE) - ttype = TREE_TYPE (ttype); - if ((TREE_CODE (ttype) == POINTER_TYPE - || TREE_CODE (ttype) == ARRAY_TYPE - || TREE_CODE (ttype) == REFERENCE_TYPE) - && IS_AGGR_TYPE (TREE_TYPE (ttype)) - && CLASSTYPE_RTTI (TREE_TYPE (ttype))) - return 1; - - return 0; -} - -/* Predicate that returns non-zero iff FROM is safe from the GC. - - If TO is nonzero, it means we know that FROM is being stored - in TO, which make make it safe. */ -int -value_safe_from_gc (to, from) - tree to, from; -{ - /* First, return non-zero for easy cases: parameters, - static variables. */ - if (TREE_CODE (from) == PARM_DECL - || (TREE_CODE (from) == VAR_DECL - && TREE_STATIC (from))) - return 1; - - /* If something has its address taken, it cannot be - in the heap, so it doesn't need to be protected. */ - if (TREE_CODE (from) == ADDR_EXPR || TREE_REFERENCE_EXPR (from)) - return 1; - - /* If we are storing into a static variable, then what - we store will be safe from the gc. */ - if (to && TREE_CODE (to) == VAR_DECL - && TREE_STATIC (to)) - return 1; - - /* Now recurse on structure of FROM. */ - switch (TREE_CODE (from)) - { - case COMPONENT_REF: - /* These guys are special, and safe. */ - if (TREE_CODE (TREE_OPERAND (from, 1)) == FIELD_DECL - && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (from, 1))) - || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (from, 1))))) - return 1; - /* fall through... */ - case NOP_EXPR: - case CONVERT_EXPR: - case NON_LVALUE_EXPR: - case WITH_CLEANUP_EXPR: - case SAVE_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - if (value_safe_from_gc (to, TREE_OPERAND (from, 0))) - return 1; - break; - - case VAR_DECL: - case PARM_DECL: - /* We can safely pass these things as parameters to functions. */ - if (to == 0) - return 1; - - case ARRAY_REF: - case INDIRECT_REF: - case RESULT_DECL: - case OFFSET_REF: - case CALL_EXPR: - case METHOD_CALL_EXPR: - break; - - case COMPOUND_EXPR: - case TARGET_EXPR: - if (value_safe_from_gc (to, TREE_OPERAND (from, 1))) - return 1; - break; - - case COND_EXPR: - if (value_safe_from_gc (to, TREE_OPERAND (from, 1)) - && value_safe_from_gc (to, TREE_OPERAND (from, 2))) - return 1; - break; - - case PLUS_EXPR: - case MINUS_EXPR: - if ((type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 0))) - || value_safe_from_gc (to, TREE_OPERAND (from, 0))) - && (type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 1))) == 0 - || value_safe_from_gc (to, TREE_OPERAND (from, 1)))) - return 1; - break; - - case RTL_EXPR: - /* Every time we build an RTL_EXPR in the front-end, we must - ensure that everything in it is safe from the garbage collector. - ??? This has only been done for `build_new'. */ - return 1; - - default: - my_friendly_abort (41); - } - - if (to == 0) - return 0; - - /* FROM wasn't safe. But other properties of TO might make it safe. */ - switch (TREE_CODE (to)) - { - case VAR_DECL: - case PARM_DECL: - /* We already culled out static VAR_DECLs above. */ - return 0; - - case COMPONENT_REF: - /* These guys are special, and safe. */ - if (TREE_CODE (TREE_OPERAND (to, 1)) == FIELD_DECL - && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (to, 1))) - || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (to, 1))))) - return 1; - /* fall through... */ - - case NOP_EXPR: - case NON_LVALUE_EXPR: - case WITH_CLEANUP_EXPR: - case SAVE_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - return value_safe_from_gc (TREE_OPERAND (to, 0), from); - - case COMPOUND_EXPR: - case TARGET_EXPR: - return value_safe_from_gc (TREE_OPERAND (to, 1), from); - - case COND_EXPR: - return (value_safe_from_gc (TREE_OPERAND (to, 1), from) - && value_safe_from_gc (TREE_OPERAND (to, 2), from)); - - case INDIRECT_REF: - case ARRAY_REF: - /* This used to be 0, but our current restricted model - allows this to be 1. We'll never get arrays this way. */ - return 1; - - default: - my_friendly_abort (42); - } - - /* Catch-all case is that TO/FROM is not safe. */ - return 0; -} - -/* Function to build a static GC entry for DECL. TYPE is DECL's type. - - For objects of type `class *', this is just an entry in the - static vector __PTR_LIST__. - - For objects of type `class[]', this requires building an entry - in the static vector __ARR_LIST__. - - For aggregates, this records all fields of type `class *' - and `class[]' in the respective lists above. */ -void -build_static_gc_entry (decl, type) - tree decl; - tree type; -{ - /* Now, figure out what sort of entry to build. */ - if (TREE_CODE (type) == POINTER_TYPE - || TREE_CODE (type) == REFERENCE_TYPE) - assemble_gc_entry (IDENTIFIER_POINTER (DECL_NAME (decl))); - else if (TREE_CODE (type) == RECORD_TYPE) - { - tree ref = get_temp_name (build_reference_type (type), 1); - DECL_INITIAL (ref) = build1 (ADDR_EXPR, TREE_TYPE (ref), decl); - TREE_CONSTANT (DECL_INITIAL (ref)) = 1; - cp_finish_decl (ref, DECL_INITIAL (ref), NULL_TREE, 0, 0); - } - else - { - /* Not yet implemented. - - Cons up a static variable that holds address and length info - and add that to ___ARR_LIST__. */ - my_friendly_abort (43); - } -} - -/* Protect FROM from the GC, assuming FROM is going to be - stored into TO. We handle three cases for TO here: - - case 1: TO is a stack variable. - case 2: TO is zero (which means it is a parameter). - case 3: TO is a return value. */ - -tree -protect_value_from_gc (to, from) - tree to, from; -{ - if (to == 0) - { - tree cleanup; - - to = get_temp_regvar (TREE_TYPE (from), from); - - /* Convert from integer to list form since we'll use it twice. */ - DECL_GC_OFFSET (to) = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to)); - cleanup = build_function_call (gc_unprotect_fndecl, - DECL_GC_OFFSET (to)); - - if (! cp_expand_decl_cleanup (to, cleanup)) - { - compiler_error ("cannot unprotect parameter in this scope"); - return error_mark_node; - } - } - - /* Should never need to protect a value that's headed for static storage. */ - if (TREE_STATIC (to)) - my_friendly_abort (44); - - switch (TREE_CODE (to)) - { - case COMPONENT_REF: - case INDIRECT_REF: - return protect_value_from_gc (TREE_OPERAND (to, 0), from); - - case VAR_DECL: - case PARM_DECL: - { - tree rval; - if (DECL_GC_OFFSET (to) == NULL_TREE) - { - /* Because of a cast or a conversion, we might stick - a value into a variable that would not normally - have a GC entry. */ - DECL_GC_OFFSET (to) = size_int (++current_function_obstack_index); - } - - if (TREE_CODE (DECL_GC_OFFSET (to)) != TREE_LIST) - { - DECL_GC_OFFSET (to) - = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to)); - } - - current_function_obstack_usage = 1; - rval = build_function_call (gc_protect_fndecl, - tree_cons (NULL_TREE, from, - DECL_GC_OFFSET (to))); - TREE_TYPE (rval) = TREE_TYPE (from); - return rval; - } - } - - /* If we fall through the switch, assume we lost. */ - my_friendly_abort (45); - /* NOTREACHED */ - return NULL_TREE; -} - -/* Given the expression EXP of type `class *', return the head - of the object pointed to by EXP. */ -tree -build_headof (exp) - tree exp; -{ - tree type = TREE_TYPE (exp); - tree vptr, offset; - - if (TREE_CODE (type) != POINTER_TYPE) - { - error ("`headof' applied to non-pointer type"); - return error_mark_node; - } - type = TREE_TYPE (type); - - if (!TYPE_VIRTUAL_P (type) || CLASSTYPE_VFIELD (type) == NULL_TREE) - return exp; - - vptr = fold (size_binop (PLUS_EXPR, - size_binop (FLOOR_DIV_EXPR, - DECL_FIELD_BITPOS (CLASSTYPE_VFIELD (type)), - size_int (BITS_PER_UNIT)), - exp)); - vptr = build1 (INDIRECT_REF, build_pointer_type (vtable_entry_type), vptr); - - if (flag_vtable_thunks) - offset = build_array_ref (vptr, integer_zero_node); - else - offset = build_component_ref (build_array_ref (vptr, integer_zero_node), - delta_identifier, - NULL_TREE, 0); - - type = build_type_variant (ptr_type_node, TREE_READONLY (exp), - TREE_THIS_VOLATILE (exp)); - return build (PLUS_EXPR, type, exp, - convert (ptrdiff_type_node, offset)); -} - -/* Return the type_info node associated with the expression EXP. If EXP is - a reference to a polymorphic class, return the dynamic type; otherwise - return the static type of the expression. */ -tree -build_typeid (exp) - tree exp; -{ - tree type; - - if (!flag_rtti) - cp_error ("cannot take typeid of object when -frtti is not specified"); - - if (exp == error_mark_node) - return error_mark_node; - - type = TREE_TYPE (exp); - - /* Strip top-level cv-qualifiers. */ - type = TYPE_MAIN_VARIANT (type); - - /* if b is an instance of B, typeid(b) == typeid(B). Do this before - reference trickiness. */ - if (TREE_CODE (exp) == VAR_DECL && TREE_CODE (type) == RECORD_TYPE) - return get_typeid (type); - - /* peel back references, so they match. */ - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - - /* Peel off cv qualifiers. */ - type = TYPE_MAIN_VARIANT (type); - - /* Apply trivial conversion T -> T& for dereferenced ptrs. */ - if (TREE_CODE (type) == RECORD_TYPE) - type = build_reference_type (type); - - /* If exp is a reference to polymorphic type, get the real type_info. */ - if (TREE_CODE (type) == REFERENCE_TYPE && TYPE_VIRTUAL_P (TREE_TYPE (type))) - { - /* build reference to type_info from vtable. */ - tree t; - - if (flag_vtable_thunks) - t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_one_node); - else - t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_zero_node); - - TREE_TYPE (t) = build_pointer_type (__class_desc_type_node); - t = build_indirect_ref (t, NULL); - return t; - } - - /* otherwise return the type_info for the static type of the expr. */ - return get_typeid (type); -} - -/* Return the type_info object for TYPE, creating it if necessary. */ -tree -get_typeid (type) - tree type; -{ - tree t, td; - - if (type == error_mark_node) - return error_mark_node; - - /* Is it useful (and/or correct) to have different typeids for `T &' - and `T'? */ - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - - td = build_t_desc (type, 1); - if (td == error_mark_node) - return error_mark_node; - - t = TREE_OPERAND (td, 0); - return t; -} - -/* Get a bad_cast node for the program to throw... - - See libstdc++::exception{,.cc} for __bad_cast_object */ -tree -get_bad_cast_node () -{ - static tree t; - if (t == NULL_TREE - && (t = lookup_name (get_identifier ("__bad_cast_object"), 0)) - == NULL_TREE) - { - error ("you must #include <typeinfo>"); - return error_mark_node; - } - return t; -} - -/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working - paper. */ -tree -build_dynamic_cast (type, expr) - tree type, expr; -{ - enum tree_code tc = TREE_CODE (type); - tree exprtype = TREE_TYPE (expr); - enum tree_code ec = TREE_CODE (exprtype); - tree retval; - - if (type == error_mark_node || expr == error_mark_node) - return error_mark_node; - - switch (tc) - { - case POINTER_TYPE: - if (ec == REFERENCE_TYPE) - { - expr = convert_from_reference (expr); - exprtype = TREE_TYPE (expr); - ec = TREE_CODE (exprtype); - } - if (ec != POINTER_TYPE) - goto fail; - if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE) - goto fail; - if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0) - goto fail; - if (TREE_READONLY (TREE_TYPE (exprtype)) && - ! TYPE_READONLY (TREE_TYPE (type))) - goto fail; - if (TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node) - break; - /* else fall through */ - case REFERENCE_TYPE: - if (TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE - && TYPE_SIZE (TREE_TYPE (type)) != NULL_TREE) - break; - /* else fall through */ - default: - goto fail; - } - - /* Apply trivial conversion T -> T& for dereferenced ptrs. */ - if (ec == RECORD_TYPE) - { - exprtype = build_type_variant (exprtype, TREE_READONLY (expr), - TREE_THIS_VOLATILE (expr)); - exprtype = build_reference_type (exprtype); - expr = convert_to_reference (exprtype, expr, CONV_IMPLICIT, - LOOKUP_NORMAL, NULL_TREE); - ec = REFERENCE_TYPE; - } - - if (tc == REFERENCE_TYPE) - { - if (ec != REFERENCE_TYPE) - goto fail; - if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE) - goto fail; - if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0) - goto fail; - } - - /* If *type is an unambiguous accessible base class of *exprtype, - convert statically. */ - { - int distance; - tree path; - - distance = get_base_distance (TREE_TYPE (type), TREE_TYPE (exprtype), 1, - &path); - if (distance >= 0) - return build_vbase_path (PLUS_EXPR, type, expr, path, 0); - } - - /* Otherwise *exprtype must be a polymorphic class (have a vtbl). */ - if (TYPE_VIRTUAL_P (TREE_TYPE (exprtype))) - { - /* if TYPE is `void *', return pointer to complete object. */ - if (tc == POINTER_TYPE - && TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node) - { - /* if b is an object, dynamic_cast<void *>(&b) == (void *)&b. */ - if (TREE_CODE (expr) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL - && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE) - return build1 (NOP_EXPR, type, expr); - - return build_headof (expr); - } - else - { - tree retval; - tree result, td1, td2, elems, tmp1, expr1; - - /* If we got here, we can't convert statically. Therefore, - dynamic_cast<D&>(b) (b an object) cannot succeed. */ - if (ec == REFERENCE_TYPE) - { - if (TREE_CODE (expr) == VAR_DECL - && TREE_CODE (TREE_TYPE (expr)) == RECORD_TYPE) - { - cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed", - expr, type); - return build_throw (get_bad_cast_node ()); - } - } - /* Ditto for dynamic_cast<D*>(&b). */ - else if (TREE_CODE (expr) == ADDR_EXPR) - { - tree op = TREE_OPERAND (expr, 0); - if (TREE_CODE (op) == VAR_DECL - && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE) - { - cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed", - expr, type); - retval = build_int_2 (0, 0); - TREE_TYPE (retval) = type; - return retval; - } - } - - expr1 = expr; - if (tc == REFERENCE_TYPE) - expr1 = build_unary_op (ADDR_EXPR, expr1, 0); - - /* Build run-time conversion. */ - expr1 = build_headof (expr1); - - if (ec == POINTER_TYPE) - td1 = build_typeid (build_indirect_ref (expr, NULL_PTR)); - else - td1 = build_typeid (expr); - - if (tc == POINTER_TYPE) - td2 = get_typeid (TREE_TYPE (type)); - else - td2 = get_typeid (type); - - elems = tree_cons (NULL_TREE, td2, - tree_cons (NULL_TREE, build_int_2 (1, 0), - tree_cons (NULL_TREE, expr1, NULL_TREE))); - result = build_method_call (td1, - get_identifier ("__rtti_match"), elems, NULL_TREE, LOOKUP_NORMAL); - - if (tc == REFERENCE_TYPE) - { - expr1 = build_throw (get_bad_cast_node ()); - expr1 = build_compound_expr (tree_cons (NULL_TREE, expr1, - build_tree_list (NULL_TREE, convert (type, integer_zero_node)))); - TREE_TYPE (expr1) = type; - return build (COND_EXPR, type, result, result, expr1); - } - - /* Now back to the type we want from a void*. */ - result = convert (type, result); - return result; - } - } - - fail: - cp_error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T'", - expr, exprtype, type); - return error_mark_node; -} - -/* Build and initialize various sorts of descriptors. Every descriptor - node has a name associated with it (the name created by mangling). - For this reason, we use the identifier as our access to the __*_desc - nodes, instead of sticking them directly in the types. Otherwise we - would burden all built-in types (and pointer types) with slots that - we don't necessarily want to use. - - For each descriptor we build, we build a variable that contains - the descriptor's information. When we need this info at runtime, - all we need is access to these variables. - - Note: these constructors always return the address of the descriptor - info, since that is simplest for their mutual interaction. */ - -static tree -build_generic_desc (tdecl, type, elems) - tree tdecl; - tree type; - tree elems; -{ - tree init = elems; - int toplev = global_bindings_p (); - - TREE_CONSTANT (init) = 1; - TREE_STATIC (init) = 1; - TREE_READONLY (init) = 1; - - TREE_TYPE (tdecl) = type; - DECL_INITIAL (tdecl) = init; - TREE_STATIC (tdecl) = 1; - DECL_SIZE (tdecl) = NULL_TREE; - layout_decl (tdecl, 0); - if (! toplev) - push_to_top_level (); - cp_finish_decl (tdecl, init, NULL_TREE, 0, 0); - if (! toplev) - pop_from_top_level (); - - if (! TREE_USED (tdecl)) - { - assemble_external (tdecl); - TREE_USED (tdecl) = 1; - } - - return IDENTIFIER_AS_DESC (DECL_NAME (tdecl)); -} - -/* Build an initializer for a __bltn_desc node. */ -static tree -build_bltn_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree elems, t; - - if (type == boolean_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_BOOL"), - 0, 0); - else if (type == char_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_CHAR"), - 0, 0); - else if (type == short_integer_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SHORT"), - 0, 0); - else if (type == integer_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_INT"), - 0, 0); - else if (type == long_integer_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_LONG"), - 0, 0); - else if (type == long_long_integer_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_LONGLONG"), 0, 0); - else if (type == float_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_FLOAT"), - 0, 0); - else if (type == double_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_DOUBLE"), 0, 0); - else if (type == long_double_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_LDOUBLE"), 0, 0); - else if (type == unsigned_char_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UCHAR"), - 0, 0); - else if (type == short_unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_USHORT"), - 0, 0); - else if (type == unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UINT"), - 0, 0); - else if (type == long_unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_ULONG"), - 0, 0); - else if (type == long_long_unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_ULONGLONG"), 0, 0); - else if (type == signed_char_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SCHAR"), - 0, 0); - else if (type == wchar_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_WCHAR"), - 0, 0); - else if (type == void_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_VOID"), - 0, 0); - else - { - cp_compiler_error ("type `%T' not handled as a built-in type"); - } - - elems = tree_cons (NULL_TREE, t, NULL_TREE); - return build_generic_desc (tdecl, __bltn_desc_type_node, elems); -} - -/* Build an initializer for a __user_desc node. */ -static tree -build_user_desc (tdecl) - tree tdecl; -{ - tree elems, name_string, t; - tree tname = DECL_NAME (tdecl); - - name_string = combine_strings (build_string - (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - elems = name_string; - return build_generic_desc (tdecl, __user_desc_type_node, elems); -} - -/* Build an initializer for a __class_type_info node. */ -static tree -build_class_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree tname = DECL_NAME (tdecl); - tree name_string; - - int i = CLASSTYPE_N_BASECLASSES (type); - int n_base = i; - int base_cnt = 0; - tree binfos = TYPE_BINFO_BASETYPES (type); - tree vb = CLASSTYPE_VBASECLASSES (type); - tree base, elems, access, offset, isvir; - tree base_list, off_list, acc_list, isvir_list; - tree t; - static tree acc_pub = NULL_TREE; - static tree acc_pro = NULL_TREE; - static tree acc_pri = NULL_TREE; - - if (acc_pub == NULL_TREE) - { - acc_pub = lookup_field (__class_desc_type_node, - get_identifier("_RTTI_ACCESS_PUBLIC"), 0, 0); - acc_pro = lookup_field (__class_desc_type_node, - get_identifier("_RTTI_ACCESS_PROTECTED"), 0, 0); - acc_pri = lookup_field (__class_desc_type_node, - get_identifier("_RTTI_ACCESS_PRIVATE"), 0, 0); - } - - base_list = build_tree_list (NULL_TREE, integer_zero_node); - off_list = build_tree_list (NULL_TREE, integer_zero_node); - acc_list = build_tree_list (NULL_TREE, integer_zero_node); - isvir_list = build_tree_list (NULL_TREE, integer_zero_node); - while (--i >= 0) - { - tree binfo = TREE_VEC_ELT (binfos, i); - - base = build_t_desc (BINFO_TYPE (binfo), 1); - if (TREE_VIA_VIRTUAL (binfo)) - { - tree t = BINFO_TYPE (binfo); - char *name; - tree field; - int off; - - name = (char *) alloca (TYPE_NAME_LENGTH (t)+sizeof (VBASE_NAME)+1); - sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (t)); - field = lookup_field (type, get_identifier (name), 0, 0); - offset = size_binop (FLOOR_DIV_EXPR, - DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT)); - } - else - offset = BINFO_OFFSET (binfo); - - if (TREE_VIA_PUBLIC (binfo)) - access = acc_pub; - else if (TREE_VIA_PROTECTED (binfo)) - access = acc_pro; - else - access = acc_pri; - if (TREE_VIA_VIRTUAL (binfo)) - isvir = build_int_2 (1, 0); - else - isvir = build_int_2 (0, 0); - - base_list = tree_cons (NULL_TREE, base, base_list); - isvir_list = tree_cons (NULL_TREE, isvir, isvir_list); - acc_list = tree_cons (NULL_TREE, access, acc_list); - off_list = tree_cons (NULL_TREE, offset, off_list); - base_cnt++; - } -#if 0 - i = n_base; - while (vb) - { - tree b; - access = acc_pub; - while (--i >= 0) - { - b = TREE_VEC_ELT (binfos, i); - if (BINFO_TYPE (vb) == BINFO_TYPE (b) && TREE_VIA_VIRTUAL (b)) - { - if (TREE_VIA_PUBLIC (b)) - access = acc_pub; - else if (TREE_VIA_PROTECTED (b)) - access = acc_pro; - else - access = acc_pri; - break; - } - } - base = build_t_desc (BINFO_TYPE (vb), 1); - offset = BINFO_OFFSET (vb); - isvir = build_int_2 (1, 0); - - base_list = tree_cons (NULL_TREE, base, base_list); - isvir_list = tree_cons (NULL_TREE, isvir, isvir_list); - acc_list = tree_cons (NULL_TREE, access, acc_list); - off_list = tree_cons (NULL_TREE, offset, off_list); - - base_cnt++; - vb = TREE_CHAIN (vb); - } -#endif - base_list = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), - base_list, 0); - off_list = finish_table (NULL_TREE, integer_type_node, - off_list, 0); - isvir_list = finish_table (NULL_TREE, integer_type_node, - isvir_list, 0); - acc_list = finish_table (NULL_TREE, __access_mode_type_node, - acc_list, 0); - - - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - - elems = tree_cons (NULL_TREE, name_string, - tree_cons (NULL_TREE, default_conversion (base_list), - tree_cons (NULL_TREE, default_conversion (off_list), - tree_cons (NULL_TREE, default_conversion (isvir_list), - tree_cons (NULL_TREE, default_conversion (acc_list), - tree_cons (NULL_TREE, build_int_2 (base_cnt, 0), NULL_TREE)))))); - - return build_generic_desc (tdecl, __class_desc_type_node, elems); -} - -/* Build an initializer for a __pointer_type_info node. */ -static tree -build_ptr_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree t, elems; - - t = TREE_TYPE (type); - t = build_t_desc (t, 1); - t = build_indirect_ref (t, NULL); - elems = tree_cons (NULL_TREE, t, NULL_TREE); - return build_generic_desc (tdecl, __ptr_desc_type_node, elems); -} - -/* Build an initializer for a __attr_type_info node. */ -static tree -build_attr_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree elems, t, attrval; - - if (TYPE_READONLY (type)) - { - if (TYPE_VOLATILE (type)) - attrval = lookup_field (__attr_desc_type_node, - get_identifier("_RTTI_ATTR_CONSTVOL"), 0, 0); - else - attrval = lookup_field (__attr_desc_type_node, - get_identifier("_RTTI_ATTR_CONST"), 0, 0); - } - else - { - if (TYPE_VOLATILE (type)) - attrval = lookup_field (__attr_desc_type_node, - get_identifier("_RTTI_ATTR_VOLATILE"), 0, 0); - } - t = build_t_desc (TYPE_MAIN_VARIANT (type), 1); - t = build_indirect_ref (t , NULL); - elems = tree_cons (NULL_TREE, attrval, tree_cons (NULL_TREE, t, NULL_TREE)); - return build_generic_desc (tdecl, __attr_desc_type_node, elems); -} - -/* Build an initializer for a __func_type_info node. */ -static tree -build_func_desc (tdecl) - tree tdecl; -{ - tree elems, name_string; - tree tname = DECL_NAME (tdecl); - - name_string = combine_strings (build_string - (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - elems = name_string; - return build_generic_desc (tdecl, __func_desc_type_node, elems); -} - -/* Build an initializer for a __ptmf_type_info node. */ -static tree -build_ptmf_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree elems, name_string; - tree tname = DECL_NAME (tdecl); - - name_string = combine_strings (build_string - (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - elems = name_string; - return build_generic_desc (tdecl, __ptmf_desc_type_node, elems); -} - -/* Build an initializer for a __ptmd_type_info node. */ -static tree -build_ptmd_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree tc, t, elems; - tc = build_t_desc (TYPE_OFFSET_BASETYPE (type), 1); - tc = build_indirect_ref (tc , NULL); - t = build_t_desc (TREE_TYPE (type), 1); - t = build_indirect_ref (t , NULL); - elems = tree_cons (NULL_TREE, tc, - tree_cons (NULL_TREE, t, NULL_TREE)); - return build_generic_desc (tdecl, __ptmd_desc_type_node, elems); -} - -struct uninst_st { - tree type; - struct uninst_st *next; -}; -typedef struct uninst_st uninst_node; -static uninst_node * uninst_desc = (uninst_node *)NULL; - -static void -add_uninstantiated_desc (type) - tree type; -{ - uninst_node *t; - - t = (uninst_node *) xmalloc (sizeof (struct uninst_st)); - t->type = type; - t->next = uninst_desc; - uninst_desc = t; -} - -/* We may choose to link the emitting of certain high use TDs for certain - objects, we do that here. Return the type to link against if such a - link exists, otherwise just return TYPE. */ - -tree -get_def_to_follow (type) - tree type; -{ -#if 0 - /* For now we don't lay out T&, T* TDs with the main TD for the object. */ - /* Let T* and T& be written only when T is written (if T is an aggr). - We do this for const, but not for volatile, since volatile - is rare and const is not. */ - if (!TYPE_VOLATILE (taggr) - && (TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && IS_AGGR_TYPE (TREE_TYPE (taggr))) - taggr = TREE_TYPE (taggr); -#endif - return type; -} - -/* build a general type_info node. */ -tree -build_t_desc (type, definition) - tree type; - int definition; -{ - tree tdecl; - tree tname, name_string; - tree elems; - tree t, tt, taggr; - - if (__ptmd_desc_type_node == NULL_TREE) - { - init_type_desc(); - if (__ptmd_desc_type_node) - { - for ( ; uninst_desc; uninst_desc = uninst_desc->next ) - build_t_desc (uninst_desc->type, 1); - } - } - if (__t_desc_type_node == NULL_TREE) - { - static int warned = 0; - if (! warned) - { - cp_error ("failed to build type descriptor node of '%T', maybe typeinfo.h not included", type); - } - warned = 1; - return error_mark_node; - } - if (__ptmd_desc_type_node == NULL_TREE) - { - add_uninstantiated_desc (type); - definition = 0; - } - - push_obstacks (&permanent_obstack, &permanent_obstack); - tname = build_t_desc_overload (type); - - if (!IDENTIFIER_AS_DESC (tname)) - { - tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node); - DECL_EXTERNAL (tdecl) = 1; - TREE_PUBLIC (tdecl) = 1; - tdecl = pushdecl_top_level (tdecl); - SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0)); - if (!definition) - cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0); - } - else - tdecl = TREE_OPERAND (IDENTIFIER_AS_DESC (tname), 0); - - /* If it's not a definition, don't do anything more. */ - if (!definition) - return IDENTIFIER_AS_DESC (tname); - - /* If it has already been written, don't to anything more. */ - /* Should this be on tdecl? */ - if (TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname))) - return IDENTIFIER_AS_DESC (tname); - - /* If we previously defined it, return the defined result. */ - if (DECL_INITIAL (tdecl)) - return IDENTIFIER_AS_DESC (tname); - - taggr = get_def_to_follow (type); - - /* If we know that we don't need to write out this type's - vtable, then don't write out it's type_info. Somebody - else will take care of that. */ - if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr)) - { - /* Let's play follow the vtable. */ - TREE_PUBLIC (tdecl) = CLASSTYPE_INTERFACE_KNOWN (taggr); - DECL_EXTERNAL (tdecl) = CLASSTYPE_INTERFACE_ONLY (taggr); - } - else - { - DECL_EXTERNAL (tdecl) = 0; - TREE_PUBLIC (tdecl) = (definition > 1); - } - - if (DECL_EXTERNAL (tdecl)) - return IDENTIFIER_AS_DESC (tname); - - /* Show that we are defining the t_desc for this type. */ - DECL_INITIAL (tdecl) = error_mark_node; - t = DECL_CONTEXT (tdecl); - if ( t && TREE_CODE_CLASS (TREE_CODE (t)) == 't') - pushclass (t, 2); - - if (TYPE_VOLATILE (type) || TYPE_READONLY (type)) - t = build_attr_desc (tdecl, type); - else if (TREE_CODE (type) == ARRAY_TYPE) - t = build_ptr_desc (tdecl, type); - else if (TREE_CODE (type) == POINTER_TYPE) - { - if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE) - { - type = TREE_TYPE (type); - t = build_ptmd_desc (tdecl, type); - } - else - { - t = build_ptr_desc (tdecl, type); - } - } - else if (TYPE_BUILT_IN (type)) - t = build_bltn_desc (tdecl, type); - else if (IS_AGGR_TYPE (type)) - { - if (TYPE_PTRMEMFUNC_P (type)) - { - t = build_ptmf_desc (tdecl, type); - } - else - { - t = build_class_desc (tdecl, type); - } - } - else if (TREE_CODE (type) == FUNCTION_TYPE) - t = build_func_desc (tdecl); - else - t = build_user_desc (tdecl); - - pop_obstacks (); - return t; -} - -#if 0 -/* This is the old dossier type descriptor generation code, it's much - more extended than rtti. It's reserved for later use. */ -/* Build an initializer for a __t_desc node. So that we can take advantage - of recursion, we accept NULL for TYPE. - DEFINITION is greater than zero iff we must define the type descriptor - (as opposed to merely referencing it). 1 means treat according to - #pragma interface/#pragma implementation rules. 2 means define as - global and public, no matter what. */ -tree -build_t_desc (type, definition) - tree type; - int definition; -{ - tree tdecl; - tree tname, name_string; - tree elems, fields; - tree parents, vbases, offsets, ivars, methods, target_type; - int method_count = 0, field_count = 0; - - if (type == NULL_TREE) - return NULL_TREE; - - tname = build_t_desc_overload (type); - if (IDENTIFIER_AS_DESC (tname) - && (!definition || TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname)))) - return IDENTIFIER_AS_DESC (tname); - - tdecl = lookup_name (tname, 0); - if (tdecl == NULL_TREE) - { - tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node); - DECL_EXTERNAL (tdecl) = 1; - TREE_PUBLIC (tdecl) = 1; - tdecl = pushdecl_top_level (tdecl); - } - /* If we previously defined it, return the defined result. */ - else if (definition && DECL_INITIAL (tdecl)) - return IDENTIFIER_AS_DESC (tname); - - if (definition) - { - tree taggr = type; - /* Let T* and T& be written only when T is written (if T is an aggr). - We do this for const, but not for volatile, since volatile - is rare and const is not. */ - if (!TYPE_VOLATILE (taggr) - && (TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && IS_AGGR_TYPE (TREE_TYPE (taggr))) - taggr = TREE_TYPE (taggr); - - /* If we know that we don't need to write out this type's - vtable, then don't write out it's dossier. Somebody - else will take care of that. */ - if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr)) - { - if (CLASSTYPE_VTABLE_NEEDS_WRITING (taggr)) - { - TREE_PUBLIC (tdecl) = ! CLASSTYPE_INTERFACE_ONLY (taggr) - && CLASSTYPE_INTERFACE_KNOWN (taggr); - DECL_EXTERNAL (tdecl) = 0; - } - else - { - if (write_virtuals != 0) - TREE_PUBLIC (tdecl) = 1; - } - } - else - { - DECL_EXTERNAL (tdecl) = 0; - TREE_PUBLIC (tdecl) = (definition > 1); - } - } - SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0)); - - if (!definition || DECL_EXTERNAL (tdecl)) - { - /* That's it! */ - cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0); - return IDENTIFIER_AS_DESC (tname); - } - - /* Show that we are defining the t_desc for this type. */ - DECL_INITIAL (tdecl) = error_mark_node; - - parents = build_tree_list (NULL_TREE, integer_zero_node); - vbases = build_tree_list (NULL_TREE, integer_zero_node); - offsets = build_tree_list (NULL_TREE, integer_zero_node); - methods = NULL_TREE; - ivars = NULL_TREE; - - if (TYPE_LANG_SPECIFIC (type)) - { - int i = CLASSTYPE_N_BASECLASSES (type); - tree method_vec = CLASSTYPE_METHOD_VEC (type); - tree *meth, *end; - tree binfos = TYPE_BINFO_BASETYPES (type); - tree vb = CLASSTYPE_VBASECLASSES (type); - - while (--i >= 0) - parents = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (TREE_VEC_ELT (binfos, i)), 0), parents); - - while (vb) - { - vbases = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (vb), 0), vbases); - offsets = tree_cons (NULL_TREE, BINFO_OFFSET (vb), offsets); - vb = TREE_CHAIN (vb); - } - - if (method_vec) - for (meth = TREE_VEC_END (method_vec), - end = &TREE_VEC_ELT (method_vec, 0); meth-- != end; ) - if (*meth) - { - methods = tree_cons (NULL_TREE, build_m_desc (*meth), methods); - method_count++; - } - } - - if (IS_AGGR_TYPE (type)) - { - for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields)) - if (TREE_CODE (fields) == FIELD_DECL - || TREE_CODE (fields) == VAR_DECL) - { - ivars = tree_cons (NULL_TREE, build_i_desc (fields), ivars); - field_count++; - } - ivars = nreverse (ivars); - } - - parents = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), parents, 0); - vbases = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), vbases, 0); - offsets = finish_table (NULL_TREE, integer_type_node, offsets, 0); - if (methods == NULL_TREE) - methods = null_pointer_node; - else - methods = build_unary_op (ADDR_EXPR, - finish_table (NULL_TREE, __m_desc_type_node, methods, 0), - 0); - if (ivars == NULL_TREE) - ivars = null_pointer_node; - else - ivars = build_unary_op (ADDR_EXPR, - finish_table (NULL_TREE, __i_desc_type_node, ivars, 0), - 0); - if (TREE_TYPE (type)) - target_type = build_t_desc (TREE_TYPE (type), definition); - else - target_type = integer_zero_node; - - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - - elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0), - tree_cons (NULL_TREE, - TYPE_SIZE(type)? size_in_bytes(type) : integer_zero_node, - /* really should use bitfield initialization here. */ - tree_cons (NULL_TREE, integer_zero_node, - tree_cons (NULL_TREE, target_type, - tree_cons (NULL_TREE, build_int_2 (field_count, 2), - tree_cons (NULL_TREE, build_int_2 (method_count, 2), - tree_cons (NULL_TREE, ivars, - tree_cons (NULL_TREE, methods, - tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, parents, 0), - tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, vbases, 0), - build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, offsets, 0)))))))))))); - return build_generic_desc (tdecl, elems); -} - -/* Build an initializer for a __i_desc node. */ -tree -build_i_desc (decl) - tree decl; -{ - tree elems, name_string; - tree taggr; - - name_string = DECL_NAME (decl); - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string))); - - /* Now decide whether this ivar should cause it's type to get - def'd or ref'd in this file. If the type we are looking at - has a proxy definition, we look at the proxy (i.e., a - `foo *' is equivalent to a `foo'). */ - taggr = TREE_TYPE (decl); - - if ((TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && TYPE_VOLATILE (taggr) == 0) - taggr = TREE_TYPE (taggr); - - elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0), - tree_cons (NULL_TREE, DECL_FIELD_BITPOS (decl), - build_tree_list (NULL_TREE, build_t_desc (TREE_TYPE (decl), - ! IS_AGGR_TYPE (taggr))))); - taggr = build (CONSTRUCTOR, __i_desc_type_node, NULL_TREE, elems); - TREE_CONSTANT (taggr) = 1; - TREE_STATIC (taggr) = 1; - TREE_READONLY (taggr) = 1; - return taggr; -} - -/* Build an initializer for a __m_desc node. */ -tree -build_m_desc (decl) - tree decl; -{ - tree taggr, elems, name_string; - tree parm_count, req_count, vindex, vcontext; - tree parms; - int p_count, r_count; - tree parm_types = NULL_TREE; - - for (parms = TYPE_ARG_TYPES (TREE_TYPE (decl)), p_count = 0, r_count = 0; - parms != NULL_TREE; parms = TREE_CHAIN (parms), p_count++) - { - taggr = TREE_VALUE (parms); - if ((TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && TYPE_VOLATILE (taggr) == 0) - taggr = TREE_TYPE (taggr); - - parm_types = tree_cons (NULL_TREE, build_t_desc (TREE_VALUE (parms), - ! IS_AGGR_TYPE (taggr)), - parm_types); - if (TREE_PURPOSE (parms) == NULL_TREE) - r_count++; - } - - parm_types = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), - nreverse (parm_types), 0); - parm_count = build_int_2 (p_count, 0); - req_count = build_int_2 (r_count, 0); - - if (DECL_VINDEX (decl)) - vindex = DECL_VINDEX (decl); - else - vindex = integer_zero_node; - if (DECL_CONTEXT (decl) - && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (decl))) == 't') - vcontext = build_t_desc (DECL_CONTEXT (decl), 0); - else - vcontext = integer_zero_node; - name_string = DECL_NAME (decl); - if (name_string == NULL) - name_string = DECL_ASSEMBLER_NAME (decl); - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string))); - - /* Now decide whether the return type of this mvar - should cause it's type to get def'd or ref'd in this file. - If the type we are looking at has a proxy definition, - we look at the proxy (i.e., a `foo *' is equivalent to a `foo'). */ - taggr = TREE_TYPE (TREE_TYPE (decl)); - - if ((TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && TYPE_VOLATILE (taggr) == 0) - taggr = TREE_TYPE (taggr); - - elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0), - tree_cons (NULL_TREE, vindex, - tree_cons (NULL_TREE, vcontext, - tree_cons (NULL_TREE, build_t_desc (TREE_TYPE (TREE_TYPE (decl)), - ! IS_AGGR_TYPE (taggr)), - tree_cons (NULL_TREE, build_c_cast (build_pointer_type (default_function_type), build_unary_op (ADDR_EXPR, decl, 0), 0), - tree_cons (NULL_TREE, parm_count, - tree_cons (NULL_TREE, req_count, - build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, parm_types, 0))))))))); - - taggr = build (CONSTRUCTOR, __m_desc_type_node, NULL_TREE, elems); - TREE_CONSTANT (taggr) = 1; - TREE_STATIC (taggr) = 1; - TREE_READONLY (taggr) = 1; - return taggr; -} -#endif /* dossier */ - - -/* Conditionally emit code to set up an unwind-protect for the - garbage collector. If this function doesn't do anything that involves - the garbage collector, then do nothing. Otherwise, call __gc_push - at the beginning and __gc_pop at the end. - - NOTE! The __gc_pop function must operate transparently, since - it comes where the logical return label lies. This means that - at runtime *it* must preserve any return value registers. */ - -void -expand_gc_prologue_and_epilogue () -{ - extern tree maybe_gc_cleanup; - struct rtx_def *last_parm_insn, *mark; - extern struct rtx_def *get_last_insn (); - extern struct rtx_def *get_first_nonparm_insn (); - extern struct rtx_def *previous_insn (); - tree action; - - /* If we didn't need the obstack, don't cons any space. */ - if (current_function_obstack_index == 0 - || current_function_obstack_usage == 0) - return; - - mark = get_last_insn (); - last_parm_insn = get_first_nonparm_insn (); - if (last_parm_insn == 0) last_parm_insn = mark; - else last_parm_insn = previous_insn (last_parm_insn); - - action = build_function_call (gc_push_fndecl, - build_tree_list (NULL_TREE, size_int (++current_function_obstack_index))); - expand_expr_stmt (action); - - reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn); - - /* This will be expanded as a cleanup. */ - TREE_VALUE (maybe_gc_cleanup) - = build_function_call (gc_pop_fndecl, NULL_TREE); -} - -/* Some day we'll use this function as a call-back and clean - up all the unnecessary gc dribble that we otherwise create. */ -void -lang_expand_end_bindings (first, last) - struct rtx_def *first, *last; -{ -} - -void -init_gc_processing () -{ - tree parmtypes = hash_tree_chain (class_star_type_node, - hash_tree_chain (integer_type_node, NULL_TREE)); - gc_protect_fndecl = define_function ("__gc_protect", - build_function_type (class_star_type_node, parmtypes), - NOT_BUILT_IN, 0, 0); - - parmtypes = hash_tree_chain (integer_type_node, NULL_TREE); - gc_unprotect_fndecl = define_function ("__gc_unprotect", - build_function_type (void_type_node, parmtypes), - NOT_BUILT_IN, 0, 0); - - gc_push_fndecl = define_function ("__gc_push", - TREE_TYPE (gc_unprotect_fndecl), - NOT_BUILT_IN, 0, 0); - - gc_pop_fndecl = define_function ("__gc_pop", - build_function_type (void_type_node, - void_list_node), - NOT_BUILT_IN, 0, 0); - gc_nonobject = build_int_2 (0x80000000, 0); - gc_visible = build_int_2 (0x40000000, 0); - gc_white = integer_zero_node; - gc_offwhite = build_int_2 (0x10000000, 0); - gc_grey = build_int_2 (0x20000000, 0); - gc_black = build_int_2 (0x30000000, 0); -} diff --git a/contrib/gcc/cp/gpcompare.texi b/contrib/gcc/cp/gpcompare.texi deleted file mode 100644 index 7b0d573105b60..0000000000000 --- a/contrib/gcc/cp/gpcompare.texi +++ /dev/null @@ -1,236 +0,0 @@ -@node ANSI -@chapter @sc{gnu} C++ Conformance to @sc{ansi} C++ - -These changes in the @sc{gnu} C++ compiler were made to comply more -closely with the @sc{ansi} base document, @cite{The Annotated C++ -Reference Manual} (the @sc{arm}). Further reducing the divergences from -@sc{ansi} C++ is a continued goal of the @sc{gnu} C++ Renovation -Project. - -@b{Section 3.4}, @i{Start and Termination}. It is now invalid to take -the address of the function @samp{main()}. - -@b{Section 4.8}, @i{Pointers to Members}. The compiler produces -an error for trying to convert between a pointer to a member and the type -@samp{void *}. - -@b{Section 5.2.5}, @i{Increment and Decrement}. It is an error to use -the increment and decrement operators on an enumerated type. - -@b{Section 5.3.2}, @i{Sizeof}. Doing @code{sizeof} on a function is now -an error. - -@b{Section 5.3.4}, @i{Delete}. The syntax of a @i{cast-expression} is -now more strictly controlled. - -@b{Section 7.1.1}, @i{Storage Class Specifiers}. Using the -@code{static} and @code{extern} specifiers can now only be applied to -names of objects, functions, and anonymous unions. - -@b{Section 7.1.1}, @i{Storage Class Specifiers}. The compiler no longer complains -about taking the address of a variable which has been declared to have @code{register} -storage. - -@b{Section 7.1.2}, @i{Function Specifiers}. The compiler produces an -error when the @code{inline} or @code{virtual} specifiers are -used on anything other than a function. - -@b{Section 8.3}, @i{Function Definitions}. It is now an error to shadow -a parameter name with a local variable; in the past, the compiler only -gave a warning in such a situation. - -@b{Section 8.4.1}, @i{Aggregates}. The rules concerning declaration of -an aggregate are now all checked in the @sc{gnu} C++ compiler; they -include having no private or protected members and no base classes. - -@b{Section 8.4.3}, @i{References}. Declaring an array of references is -now forbidden. Initializing a reference with an initializer list is -also considered an error. - -@b{Section 9.5}, @i{Unions}. Global anonymous unions must be declared -@code{static}. - -@b{Section 11.4}, @i{Friends}. Declaring a member to be a friend of a -type that has not yet been defined is an error. - -@b{Section 12.1}, @i{Constructors}. The compiler generates a -default copy constructor for a class if no constructor has been declared. - -@ignore -@b{Section 12.4}, @i{Destructors}. In accordance with the @sc{ansi} C++ -draft standard working paper, a pure virtual destructor must now be -defined. -@end ignore - -@b{Section 12.6.2}, @i{Special Member Functions}. When using a -@i{mem-initializer} list, the compiler will now initialize class members -in declaration order, not in the order in which you specify them. -Also, the compiler enforces the rule that non-static @code{const} -and reference members must be initialized with a @i{mem-initializer} -list when their class does not have a constructor. - -@b{Section 12.8}, @i{Copying Class Objects}. The compiler generates -default copy constructors correctly, and supplies default assignment -operators compatible with user-defined ones. - -@b{Section 13.4}, @i{Overloaded Operators}. An overloaded operator may -no longer have default arguments. - -@b{Section 13.4.4}, @i{Function Call}. An overloaded @samp{operator ()} -must be a non-static member function. - -@b{Section 13.4.5}, @i{Subscripting}. An overloaded @samp{operator []} -must be a non-static member function. - -@b{Section 13.4.6}, @i{Class Member Access}. An overloaded @samp{operator ->} -must be a non-static member function. - -@b{Section 13.4.7}, @i{Increment and Decrement}. The compiler will now -make sure a postfix @samp{@w{operator ++}} or @samp{@w{operator --}} has an -@code{int} as its second argument. - - -@node Encoding -@chapter Name Encoding in @sc{gnu} C++ - -@c FIXME!! rewrite name encoding section -@c ...to give complete rules rather than diffs from ARM. -@c To avoid plagiarism, invent some different way of structuring the -@c description of the rules than what ARM uses. - -@cindex mangling -@cindex name encoding -@cindex encoding information in names -In order to support its strong typing rules and the ability to provide -function overloading, the C++ programming language @dfn{encodes} -information about functions and objects, so that conflicts across object -files can be detected during linking. @footnote{This encoding is also -sometimes called, whimsically enough, @dfn{mangling}; the corresponding -decoding is sometimes called @dfn{demangling}.} These rules tend to be -unique to each individual implementation of C++. - -The scheme detailed in the commentary for 7.2.1 of @cite{The Annotated -Reference Manual} offers a description of a possible implementation -which happens to closely resemble the @code{cfront} compiler. The -design used in @sc{gnu} C++ differs from this model in a number of ways: - -@itemize @bullet -@item -In addition to the basic types @code{void}, @code{char}, @code{short}, -@code{int}, @code{long}, @code{float}, @code{double}, and @code{long -double}, @sc{gnu} C++ supports two additional types: @code{wchar_t}, the wide -character type, and @code{long long} (if the host supports it). The -encodings for these are @samp{w} and @samp{x} respectively. - -@item -According to the @sc{arm}, qualified names (e.g., @samp{foo::bar::baz}) are -encoded with a leading @samp{Q}. Followed by the number of -qualifications (in this case, three) and the respective names, this -might be encoded as @samp{Q33foo3bar3baz}. @sc{gnu} C++ adds a leading -underscore to the list, producing @samp{_Q33foo3bar3baz}. - -@item -The operator @samp{*=} is encoded as @samp{__aml}, not @samp{__amu}, to -match the normal @samp{*} operator, which is encoded as @samp{__ml}. - -@c XXX left out ->(), __wr -@item -In addition to the normal operators, @sc{gnu} C++ also offers the minimum and -maximum operators @samp{>?} and @samp{<?}, encoded as @samp{__mx} and -@samp{__mn}, and the conditional operator @samp{?:}, encoded as @samp{__cn}. - -@cindex destructors, encoding of -@cindex constructors, encoding of -@item -Constructors are encoded as simply @samp{__@var{name}}, where @var{name} -is the encoded name (e.g., @code{3foo} for the @code{foo} class -constructor). Destructors are encoded as two leading underscores -separated by either a period or a dollar sign, depending on the -capabilities of the local host, followed by the encoded name. For -example, the destructor @samp{foo::~foo} is encoded as @samp{_$_3foo}. - -@item -Virtual tables are encoded with a prefix of @samp{_vt}, rather than -@samp{__vtbl}. The names of their classes are separated by dollar signs -(or periods), and not encoded as normal: the virtual table for -@code{foo} is @samp{__vt$foo}, and the table for @code{foo::bar} is -named @samp{__vt$foo$bar}. - -@item -Static members are encoded as a leading underscore, followed by the -encoded name of the class in which they appear, a separating dollar sign -or period, and finally the unencoded name of the variable. For example, -if the class @code{foo} contains a static member @samp{bar}, its -encoding would be @samp{_3foo$bar}. - -@item -@sc{gnu} C++ is not as aggressive as other compilers when it comes to always -generating @samp{Fv} for functions with no arguments. In particular, -the compiler does not add the sequence to conversion operators. The -function @samp{foo::bar()} is encoded as @samp{bar__3foo}, not -@samp{bar__3fooFv}. - -@item -The argument list for methods is not prefixed by a leading @samp{F}; it -is considered implied. - -@item -@sc{gnu} C++ approaches the task of saving space in encodings -differently from that noted in the @sc{arm}. It does use the -@samp{T@var{n}} and @samp{N@var{x}@var{y}} codes to signify copying the -@var{n}th argument's type, and making the next @var{x} arguments be the -type of the @var{y}th argument, respectively. However, the values for -@var{n} and @var{y} begin at zero with @sc{gnu} C++, whereas the -@sc{arm} describes them as starting at one. For the function @samp{foo -(bartype, bartype)}, @sc{gnu} C++ uses @samp{foo__7bartypeT0}, while -compilers following the @sc{arm} example generate @samp{foo__7bartypeT1}. - -@c Note it loses on `foo (int, int, int, int, int)'. -@item -@sc{gnu} C++ does not bother using the space-saving methods for types whose -encoding is a single character (like an integer, encoded as @samp{i}). -This is useful in the most common cases (two @code{int}s would result in -using three letters, instead of just @samp{ii}). -@end itemize - -@c @node Cfront -@c @chapter @code{cfront} Compared to @sc{gnu} C++ -@c -@c -@c FIXME!! Fill in. Consider points in the following: -@c -@c @display -@c Date: Thu, 2 Jan 92 21:35:20 EST -@c From: raeburn@@cygnus.com -@c Message-Id: <9201030235.AA10999@@cambridge.cygnus.com> -@c To: mrs@@charlie.secs.csun.edu -@c Cc: g++@@cygnus.com -@c Subject: Re: ARM and GNU C++ incompatabilities -@c -@c Along with that, we should probably describe how g++ differs from -@c cfront, in ways that the users will notice. (E.g., cfront supposedly -@c allows "free (new char[10])"; does g++? How do the template -@c implementations differ? "New" placement syntax?) -@c @end display -@c -@c XXX For next revision. -@c -@c GNU C++: -@c * supports expanding inline functions in many situations, -@c including those which have static objects, use `for' statements, -@c and other situations. Part of this versatility is due to is -@c ability to not always generate temporaries for assignments. -@c * deliberately allows divide by 0 and mod 0, since [according -@c to Wilson] there are actually situations where you'd like to allow -@c such things. Note on most systems it will cause some sort of trap -@c or bus error. Cfront considers it an error. -@c * does [appear to] support nested classes within templates. -@c * conversion functions among baseclasses are all usable by -@c a class that's derived from all of those bases. -@c * sizeof works even when the class is defined within its ()'s -@c * conditional expressions work with member fns and pointers to -@c members. -@c * can handle non-trivial declarations of variables within switch -@c statements. -@c -@c Cfront: diff --git a/contrib/gcc/cp/reno.texi b/contrib/gcc/cp/reno.texi deleted file mode 100644 index 59c3448a0399b..0000000000000 --- a/contrib/gcc/cp/reno.texi +++ /dev/null @@ -1,752 +0,0 @@ -\input texinfo @c -*- Texinfo -*- -@setfilename reno-1.info - -@ifinfo -@format -START-INFO-DIR-ENTRY -* Reno 1: (reno-1). The GNU C++ Renovation Project, Phase 1. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@ifinfo -Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo - -@setchapternewpage odd -@settitle GNU C++ Renovation Project -@c @smallbook - -@titlepage -@finalout -@title GNU C++ Renovation Project -@subtitle Phase 1.3 -@author Brendan Kehoe, Jason Merrill, -@author Mike Stump, Michael Tiemann -@page - -Edited March, 1994 by Roland Pesch (@code{pesch@@cygnus.com}) -@vskip 0pt plus 1filll -Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end titlepage - -@ifinfo -@node Top -@top @sc{gnu} C++ Renovation Project - -This file describes the goals of the @sc{gnu} C++ Renovation Project, -and its accomplishments to date (as of Phase 1.3). - -It also discusses the remaining divergences from @sc{gnu} C++, and how the -name encoding in @sc{gnu} C++ differs from the sample encoding in -@cite{The Annotated C++ Reference Manual}. -@c This is not a good place to introduce the acronym ARM because it's -@c info-only. - -@menu -* Introduction:: What is the GNU C++ Renovation Project? -* Changes:: Summary of changes since previous GNU C++ releases. -* Plans:: Plans for Reno-2. -* Templates:: The template implementation. -* ANSI:: GNU C++ conformance to ANSI C++. -* Encoding:: Name encoding in GNU C++. -@end menu - -@end ifinfo - -@node Introduction -@chapter Introduction - -As you may remember, @sc{gnu} C++ was the first native-code C++ -compiler available under Unix (December 1987). In November 1988, it was -judged superior to the AT&T compiler in a Unix World review. In 1990 it -won a Sun Observer ``Best-Of'' award. But now, with new requirements -coming out of the @sc{ansi} C++ committee and a growing backlog of bugs, it's -clear that @sc{gnu} C++ needs an overhaul. - -The C++ language has been under development since 1982. It has -evolved significantly since its original incarnation (C with Classes), -addressing many commercial needs and incorporating many lessons -learned as more and more people started using ``object-oriented'' -programming techniques. In 1989, the first X3J16 committee meeting -was held in Washington DC; in the interest of users, C++ was going to -be standardized. - -As C++ has become more popular, more demands have been placed on its -compilers. Some compilers are up to the demands, others are not. -@sc{gnu} C++ was used to prototype several features which have since -been incorporated into the standard, most notably exception handling. -While @sc{gnu} C++ has been an excellent experimental vehicle, it did -not have the resources that AT&T, Borland, or Microsoft have at their -disposal. - -We believe that @sc{gnu} C++ is an important compiler, providing users with -many of the features that have made @sc{gnu} C so popular: fast compilation, -good error messages, innovative features, and full sources that may be -freely redistributed. The purpose of this overhaul, dubbed the @var{@sc{gnu} -C++ Renovation Project}, is to take advantage of the functionality that -@sc{gnu} C++ offers today, to strengthen its base technology, and put it in a -position to remain---as other @sc{gnu} software currently is---the technical -leader in the field. - -This release represents the latest phase of work in strengthening the -compiler on a variety of points. It includes many months of -work concentrated on fixing many of the more egregious bugs that -presented themselves in the compiler recently. -@ignore -@c FIXME-- update? -Nearly 85% of all bugs reported in the period of February to September -of 1992 were fixed as part of the work in the first phase. -@end ignore -In the coming months, we hope to continue expanding and enhancing the -quality and dependability of the industry's only freely redistributable -C++ compiler. - -@node Changes -@chapter Changes in Behavior in @sc{gnu} C++ - -The @sc{gnu} C++ compiler continues to improve and change. A major goal -of our work has been to continue to bring the compiler into compliance -with the draft @sc{ansi} C++ standard, and with @cite{The Annotated C++ -Reference Manual} (the @sc{arm}). This section outlines most of the -user-noticeable changes that might be encountered during the normal -course of use. - -@menu -* Summary of Phase 1.3:: -* Major changes:: -* New features:: -* Enhancements and bug fixes:: -* Problems with debugging:: -@end menu - -@node Summary of Phase 1.3 -@section Summary of Changes in Phase 1.3 - -The bulk of this note discusses the cumulative effects of the @sc{gnu} C++ -Renovation Project to date. The work during its most recent phase (1.3) -had these major effects: - -@itemize @bullet -@item The standard compiler driver @code{g++} is now the faster compiled -version, rather than a shell script. - -@item Nested types work much better; notably, nesting is no longer -restricted to nine levels. - -@item Better @sc{arm} conformance on member access control. - -@item The compiler now always generates default assignment operators -(@samp{operator =}), copy constructors (@samp{X::X(X&)}), and default -constructors (@samp{X::X()}) whenever they are required. - -@item The new draft @sc{ansi} standard keyword @code{mutable} is supported. - -@item @samp{-fansi-overloading} is the default, to comply better with -the @sc{arm} (at some cost in compatibility to earlier versions of @sc{gnu} C++). - -@item More informative error messages. - -@item System include files are automatically treated as if they were -wrapped in @samp{extern "C" @{ @}}. - -@item The new option @samp{-falt-external-templates} provides alternate -template instantiation semantics. - -@item Operator declarations are now checked more strictly. - -@item You can now use template type arguments in the template parameter list. - -@item You can call the destructor for any type. - -@item The compiler source code is better organized. - -@item You can specify where to instantiate template definitions explicitly. -@end itemize - -Much of the work in Phase 1.3 went to elimination of known bugs, as well -as the major items above. - -During the span of Phase 1.3, there were also two changes associated -with the compiler that, while not specifically part of the C++ -Renovation project, may be of interest: - -@itemize @bullet -@item @code{gcov}, a code coverage tool for @sc{gnu cc}, is now available -from Cygnus Support. (@code{gcov} is free software, but the @sc{fsf} has not -yet accepted it.) @xref{Gcov,, @code{gcov}: a Test Coverage Program, -gcc.info, Using GNU CC}, for more information (in Cygnus releases of -that manual). - -@item @sc{gnu} C++ now supports @dfn{signatures}, a language extension to -provide more flexibility in abstract type definitions. @xref{C++ -Signatures,, Type Abstraction using Signatures, gcc.info, Using GNU CC}. -@end itemize - -@node Major changes -@section Major Changes - -This release includes four wholesale rewrites of certain areas of -compiler functionality: - -@enumerate 1 -@item Argument matching. @sc{gnu} C++ is more compliant with the rules -described in Chapter 13, ``Overloading'', of the @sc{arm}. This behavior is -the default, though you can specify it explicitly with -@samp{-fansi-overloading}. For compatibility with earlier releases of -@sc{gnu} C++, specify @samp{-fno-ansi-overloading}; this makes the compiler -behave as it used to with respect to argument matching and name overloading. - -@item Default constructors/destructors. Section 12.8 of the @sc{arm}, ``Copying -Class Objects'', and Section 12.1, ``Constructors'', state that a -compiler must declare such default functions if the user does not -specify them. @sc{gnu} C++ now declares, and generates when necessary, -the defaults for constructors and destructors you might omit. In -particular, assignment operators (@samp{operator =}) behave the same way -whether you define them, or whether the compiler generates them by -default; taking the address of the default @samp{operator =} is now -guaranteed to work. Default copy constructors (@samp{X::X(X&)}) now -function correctly, rather than calling the copy assignment operator for -the base class. Finally, constructors (@samp{X::X()}), as well as -assignment operators and copy constructors, are now available whenever -they are required. - -@c XXX This may be taken out eventually... -@item Binary incompatibility. There are no new binary incompatibilities -in Phase 1.3, but Phase 1.2 introduced two binary incompatibilities with -earlier releases. First, the functionality of @samp{operator -new} and @samp{operator delete} changed. Name encoding -(``mangling'') of virtual table names changed as well. Libraries -built with versions of the compiler earlier than Phase 1.2 must be -compiled with the new compiler. (This includes the Cygnus Q2 -progressive release and the FSF 2.4.5 release.) - -@item New @code{g++} driver. -A new binary @code{g++} compiler driver replaces the shell script. -The new driver executes faster. -@end enumerate - -@node New features -@section New features - -@itemize @bullet -@item -The compiler warns when a class contains only private constructors -or destructors, and has no friends. At the request of some of our -customers, we have added a new option, @samp{-Wctor-dtor-privacy} (on by -default), and its negation, @samp{-Wno-ctor-dtor-privacy}, to control -the emission of this warning. If, for example, you are working towards -making your code compile warning-free, you can use @w{@samp{-Wall --Wno-ctor-dtor-privacy}} to find the most common warnings. - -@item -There is now a mechanism which controls exactly when templates are -expanded, so that you can reduce memory usage and program size and also -instantiate them exactly once. You can control this mechanism with the -option @samp{-fexternal-templates} and its corresponding negation -@samp{-fno-external-templates}. Without this feature, space consumed by -template instantiations can grow unacceptably in large-scale projects -with many different source files. The default is -@samp{-fno-external-templates}. - -You do not need to use the @samp{-fexternal-templates} option when -compiling a file that does not define and instantiate templates used in -other files, even if those files @emph{are} compiled with -@samp{-fexternal-templates}. The only side effect is an increase in -object size for each file that was compiled without -@samp{-fexternal-templates}. - -When your code is compiled with @samp{-fexternal-templates}, all -template instantiations are external; this requires that the templates -be under the control of @samp{#pragma interface} and @samp{#pragma -implementation}. All instantiations that will be needed should be in -the implementation file; you can do this with a @code{typedef} that -references the instantiation needed. Conversely, when you compile using -the option @samp{-fno-external-templates}, all template instantiations are -explicitly internal. - -@samp{-fexternal-templates} also allows you to finally separate class -template function definitions from their declarations, thus speeding up -compilation times for every file that includes the template declaration. -Now you can have tens or even hundreds of lines in template -declarations, and thousands or tens of thousands of lines in template -definitions, with the definitions only going through the compiler once -instead of once for each source file. It is important to note that you -must remember to externally instantiate @emph{all} templates that are -used from template declarations in interface files. If you forget to do -this, unresolved externals will occur. - -In the example below, the object file generated (@file{example.o}) will -contain the global instantiation for @samp{Stack<int>}. If other types -of @samp{Stack} are needed, they can be added to @file{example.cc} or -placed in a new file, in the same spirit as @file{example.cc}. - -@code{foo.h}: -@smallexample -@group -#pragma interface "foo.h" -template<class T> -class Stack @{ - static int statc; - static T statc2; - Stack() @{ @} - virtual ~Stack() @{ @} - int bar(); -@}; -@end group -@end smallexample - -@code{example.cc}: -@smallexample -@group -#pragma implementation "foo.h" -#include "foo.h" - -typedef Stack<int> t; -int Stack<int>::statc; -int Stack<int>::statc2; -int Stack<int>::bar() @{ @} -@end group -@end smallexample - -Note that using @samp{-fexternal-templates} does not reduce memory usage -from completely different instantiations (@samp{Stack<Name>} vs. -@samp{Stack<Net_Connection>}), but only collapses different occurrences -of @samp{Stack<Name>} so that only one @samp{Stack<Name>} is generated. - -@samp{-falt-external-templates} selects a slight variation in the -semantics described above (incidentally, you need not specify both -options; @samp{-falt-external-templates} implies -@samp{-fexternal-templates}). - -With @samp{-fexternal-templates}, the compiler emits a definition in the -implementation file that includes the header definition, @emph{even if} -instantiation is triggered from a @emph{different} implementation file -(e.g. with a template that uses another template). - -With @samp{-falt-external-templates}, the definition always goes in the -implementation file that triggers instantiation. - -For instance, with these two header files--- - -@example -@exdent @file{a.h}: -#pragma interface -template <class T> class A @{ @dots{} @}; - -@exdent @file{b.h}: -#pragma interface -class B @{ @dots{} @}; -void f (A<B>); -@end example - -Under @samp{-fexternal-templates}, the definition of @samp{A<B>} ends up -in the implementation file that includes @file{a.h}. Under -@samp{-falt-external-templates}, the same definition ends up in the -implementation file that includes @file{b.h}. - -@item -You can control explicitly where a template is instantiated, without -having to @emph{use} the template to get an instantiation. - -To instantiate a class template explicitly, write @samp{template -class @var{name}<paramvals>}, where @var{paramvals} is a list of values -for the template parameters. For example, you might write - -@example -template class A<int> -@end example - -Similarly, to instantiate a function template explicitly, write -@samp{template @var{fnsign}} where @var{fnsign} is the particular -function signature you need. For example, you might write - -@example -template void foo (int, int) -@end example - -This syntax for explicit template instantiation agrees with recent -extensions to the draft @sc{ansi} standard. - -@item -The compiler's actions on @sc{ansi}-related warnings and errors have -been further enhanced. The @samp{-pedantic-errors} option produces -error messages in a number of new situations: using @code{return} in a -non-@code{void} function (one returning a value); declaring a local -variable that shadows a parameter (e.g., the function takes an argument -@samp{a}, and has a local variable @samp{a}); and use of the @samp{asm} -keyword. Finally, the compiler by default now issues a warning when -converting from an @code{int} to an enumerated type. This is likely to -cause many new warnings in code that hadn't triggered them before. For -example, when you compile this code, - -@smallexample -@group -enum boolean @{ false, true @}; -void -f () -@{ - boolean x; - - x = 1; //@i{assigning an @code{int} to an @code{enum} now triggers a warning} -@} -@end group -@end smallexample - -@noindent -you should see the warning ``@code{anachronistic conversion from integer -type to enumeral type `boolean'}''. Instead of assigning the value 1, -assign the original enumerated value @samp{true}. -@end itemize - -@node Enhancements and bug fixes -@section Enhancements and bug fixes - -@itemize @bullet -@cindex nested types in template parameters -@item -You can now use nested types in a template parameter list, even if the nested -type is defined within the same class that attempts to use the template. -For example, given a template @code{list}, the following now works: - -@smallexample -struct glyph @{ - @dots{} - struct stroke @{ @dots{} @}; - list<stroke> l; - @dots{} -@} -@end smallexample - -@cindex function pointers vs template parameters -@item -Function pointers now work in template parameter lists. For -example, you might want to instantiate a parameterized @code{list} class -in terms of a pointer to a function like this: - -@smallexample -list<int (*)(int, void *)> fnlist; -@end smallexample - -@item -@c FIXME! Really no limit? Jason said "deeper than 9" now OK... -Nested types are now handled correctly. In particular, there is no -longer a limit to how deeply you can nest type definitions. - -@item -@sc{gnu} C++ now conforms to the specifications in Chapter 11 of the -@sc{arm}, ``Member Access Control''. - -@item -The @sc{ansi} C++ committee has introduced a new keyword @code{mutable}. -@sc{gnu} C++ supports it. Use @code{mutable} to specify that some -particular members of a @code{const} class are @emph{not} constant. For -example, you can use this to include a cache in a data structure that -otherwise represents a read-only database. - -@item -Error messages now explicitly specify the declaration, type, or -expression that contains an error. - -@item -To avoid copying and editing all system include files during @sc{gnu} -C++ installation, the compiler now automatically recognizes system -include files as C language definitions, as if they were wrapped in -@samp{extern "C" @{ @dots{} @}}. - -@item -The compiler checks operator declarations more strictly. For example, -you may no longer declare an @samp{operator +} with three arguments. - -@item -You can now use template type arguments in the same template -parameter list where the type argument is specified (as well as in the -template body). For example, you may write - -@example -template <class T, T t> class A @{ @dots{} @}; -@end example - -@item -Destructors are now available for all types, even built-in ones; for -example, you can call @samp{int::~int}. (Destructors for types like -@code{int} do not actually do anything, but their existence provides a -level of generality that permits smooth template expansion in more -cases.) - -@item -Enumerated types declared inside a class are now handled correctly. - -@item -An argument list for a function may not use an initializer list for its default -value. For example, @w{@samp{void foo ( T x = @{ 1, 2 @} )}} is not permitted. - -@item -A significant amount of work went into improving the ability of the -compiler to act accurately on multiple inheritance and virtual -functions. Virtual function dispatch has been enhanced as well. - -@item -The warning concerning a virtual inheritance environment with a -non-virtual destructor has been disabled, since it is not clear that -such a warning is warranted. - -@item -Until exception handling is fully implemented in the Reno-2 release, use -of the identifiers @samp{catch}, @samp{throw}, or @samp{try} results -in the warning: - -@smallexample -t.C:1: warning: `catch', `throw', and `try' - are all C++ reserved words -@end smallexample - -@item -When giving a warning or error concerning initialization of a member in a -class, the compiler gives the name of the member if it has one. - -@item -Detecting friendship between classes is more accurately checked. - -@item -The syntaxes of @w{@samp{#pragma implementation "file.h"}} and -@samp{#pragma interface} are now more strictly controlled. The compiler -notices (and warns) when any text follows @file{file.h} in the -implementation pragma, or follows the word @samp{interface}. Any such -text is otherwise ignored. - -@item -Trying to declare a template on a variable or type is now considered an -error, not an unimplemented feature. - -@item -When an error occurs involving a template, the compiler attempts to -tell you at which point of instantiation the error occurred, in -addition to noting the line in the template declaration which had the -actual error. - -@item -The symbol names for function templates in the resulting assembly file -are now encoded according to the arguments, rather than just being -emitted as, for example, two definitions of a function @samp{foo}. - -@item -Template member functions that are declared @code{static} no longer -receive a @code{this} pointer. - -@item -Case labels are no longer allowed to have commas to make up their -expressions. - -@item -Warnings concerning the shift count of a left or right shift now tell -you if it was a @samp{left} or @samp{right} shift. - -@item -The compiler now warns when a decimal constant is so large that it -becomes @code{unsigned}. - -@item -Union initializers which are raw constructors are now handled properly. - -@item -The compiler no longer gives incorrect errors when initializing a -union with an empty initializer list. - -@item -Anonymous unions are now correctly used when nested inside a class. - -@item -Anonymous unions declared as static class members are now handled -properly. - -@item -The compiler now notices when a field in a class is declared both as -a type and a non-type. - -@item -The compiler now warns when a user-defined function shadows a -built-in function, rather than emitting an error. - -@item -A conflict between two function declarations now produces an error -regardless of their language context. - -@item -Duplicate definitions of variables with @samp{extern "C"} linkage are no -longer considered in error. (Note in C++ linkage---the default---you may -not have more than one definition of a variable.) - -@item -Referencing a label that is not defined in any function is now an error. - -@item -The syntax for pointers to methods has been improved; there are still -some minor bugs, but a number of cases should now be accepted by the -compiler. - -@item -In error messages, arguments are now numbered starting at 1, instead of -0. Therefore, in the function @samp{void foo (int a, int b)}, the -argument @samp{a} is argument 1, and @samp{b} is argument 2. There is -no longer an argument 0. - -@item -The tag for an enumerator, rather than its value, used as a default -argument is now shown in all error messages. For example, @w{@samp{void -foo (enum x (= true))}} is shown instead of @w{@samp{void foo (enum x (= -1))}}. - -@item -The @samp{__asm__} keyword is now accepted by the C++ front-end. - -@item -Expressions of the form @samp{foo->~Class()} are now handled properly. - -@item -The compiler now gives better warnings for situations which result in -integer overflows (e.g., in storage sizes, enumerators, unary -expressions, etc). - -@item -@code{unsigned} bitfields are now promoted to @code{signed int} if the -field isn't as wide as an @code{int}. - -@item -Declaration and usage of prefix and postfix @samp{operator ++} and -@samp{operator --} are now handled correctly. For example, - -@smallexample -@group -class foo -@{ -public: - operator ++ (); - operator ++ (int); - operator -- (); - operator -- (int); -@}; - -void -f (foo *f) -@{ - f++; // @i{call @code{f->operator++(int)}} - ++f; // @i{call @code{f->operator++()}} - f--; // @i{call @code{f->operator++(int)}} - --f; // @i{call @code{f->operator++()}} -@} -@end group -@end smallexample - -@item -In accordance with @sc{arm} section 10.1.1, ambiguities and dominance are now -handled properly. The rules described in section 10.1.1 are now fully -implemented. - -@end itemize - -@node Problems with debugging -@section Problems with debugging - -Two problems remain with regard to debugging: - -@itemize @bullet -@item -Debugging of anonymous structures on the IBM RS/6000 host is incorrect. - -@item -Symbol table size is overly large due to redundant symbol information; -this can make @code{gdb} coredump under certain circumstances. This -problem is not host-specific. -@end itemize - -@node Plans -@chapter Plans for Reno-2 - -The overall goal for the second phase of the @sc{gnu} C++ Renovation -Project is to bring @sc{gnu} C++ to a new level of reliability, quality, -and competitiveness. As particular elements of this strategy, we intend -to: - -@enumerate 0 -@item -Fully implement @sc{ansi} exception handling. - -@item -With the exception handling, add Runtime Type Identification -(@sc{rtti}), if the @sc{ansi} committee adopts it into the standard. - -@item -Bring the compiler into closer compliance with the @sc{arm} and the draft -@sc{ansi} standard, and document what points in the @sc{arm} we do not yet comply, -or agree, with. - -@item -Add further support for the @sc{dwarf} debugging format. - -@item -Finish the work to make the compiler compliant with @sc{arm} Section 12.6.2, -initializing base classes in declaration order, rather than in the order -that you specify them in a @var{mem-initializer} list. - -@item -Perform a full coverage analysis on the compiler, and weed out unused -code, for a gain in performance and a reduction in the size of the compiler. - -@item -Further improve the multiple inheritance implementation in the -compiler to make it cleaner and more complete. -@end enumerate - -@noindent -As always, we encourage you to make suggestions and ask questions about -@sc{gnu} C++ as a whole, so we can be sure that the end of this project -will bring a compiler that everyone will find essential for C++ and will -meet the needs of the world's C++ community. - -@include templates.texi - -@include gpcompare.texi - -@contents - -@bye diff --git a/contrib/gcc/cp/templates.texi b/contrib/gcc/cp/templates.texi deleted file mode 100644 index 2a6db07f42b25..0000000000000 --- a/contrib/gcc/cp/templates.texi +++ /dev/null @@ -1,235 +0,0 @@ -@node Templates -@chapter The Template Implementation - -@cindex templates -@cindex function templates -@cindex class templates -@cindex parameterized types -@cindex types, parameterized -The C++ template@footnote{Class templates are also known as -@dfn{parameterized types}.} facility, which effectively allows use of -variables for types in declarations, is one of the newest features of -the language. - -@sc{gnu} C++ is one of the first compilers to implement many -of the template facilities currently defined by the @sc{ansi} committee. - -Nevertheless, the template implementation is not yet complete. This -chapter maps the current limitations of the @sc{gnu} C++ template -implementation. - -@menu -* Template limitations:: Limitations for function and class templates -* Function templates:: Limitations for function templates -* Class templates:: Limitations for class templates -* Template debugging:: Debugging information for templates -@end menu - -@node Template limitations -@section Limitations for function and class templates - -@cindex template limitations -@cindex template bugs -@cindex bugs, templates -These limitations apply to any use of templates (function templates or -class templates) with @sc{gnu} C++: - -@table @emph -@item Template definitions must be visible -When you compile code with templates, the template definitions must come -first (before the compiler needs to expand them), and template -definitions you use must be visible in the current scope. -@c FIXME! Is this a defined property of templates, rather than a -@c temporary limitation? -@c ANSWER: It's a limitation, but it's hard to say why it's a limitation -@c to someone. We need an infinite link-cycle, in one camp, to -@c accomplish things so you don't need the template definitions around. - -@cindex static data in template classes -@cindex template classes, static data in -@item Individual initializers needed for static data -Templates for static data in template classes do not work. @xref{Class -templates,,Limitations for class templates}. -@end table - -@node Function templates -@section Limitations for function templates - -@cindex function template limitations -Function templates are implemented for the most part. The compiler can -correctly determine template parameter values, and will delay -instantiation of a function that uses templates until the requisite type -information is available. - -@noindent -The following limitations remain: - -@itemize @bullet -@cindex template vs declaration, functions -@cindex declaration vs template, functions -@cindex function declaration vs template -@item -Narrowed specification: function declarations should not prevent -template expansion. When you declare a function, @sc{gnu} C++ -interprets the declaration as an indication that you will provide a -definition for that function. Therefore, @sc{gnu} C++ does not use a -template expansion if there is also an applicable declaration. @sc{gnu} -C++ only expands the template when there is no such declaration. - -The specification in Bjarne Stroustrup's @cite{The C++ Programming -Language, Second Edition} is narrower, and the @sc{gnu} C++ -implementation is now clearly incorrect. With this new specification, a -declaration that corresponds to an instantiation of a function template -only affects whether conversions are needed to use that version of the -function. It should no longer prevent expansion of the template -definition. - -For example, this code fragment must be treated differently: - -@smallexample -template <class X> X min (X& x1, X& x2) @{ @dots{} @} -int min (int, int); -@dots{} -int i; short s; -min (i, s); // @r{should call} min(int,int) - // @r{derived from template} -@dots{} -@end smallexample - -@item -The compiler does not yet understand function signatures where types are -nested within template parameters. For example, a function like the -following produces a syntax error on the closing @samp{)} of the -definition of the function @code{f}: - -@smallexample -template <class T> class A @{ public: T x; class Y @{@}; @}; -template <class X> int f (A<X>::Y y) @{ @dots{} @} -@end smallexample - -@cindex @code{inline} and function templates -@cindex function templates and @code{inline} -@item -If you declare an @code{inline} function using templates, the compiler -can only inline the code @emph{after} the first time you use -that function with whatever particular type signature the template -was instantiated. - -Removing this limitation is akin to supporting nested function -definitions in @sc{gnu} C++; the limitation will probably remain until the -more general problem of nested functions is solved. - -@item -All the @emph{method} templates (templates for member functions) for a -class must be visible to the compiler when the class template is -instantiated. -@end itemize - -@node Class templates -@section Limitations for class templates - -@cindex class template limitations -@ignore -FIXME!! Include a comprehensible version of this if someone can explain it. - (Queried Brendan and Raeburn w/full orig context, 26may1993---pesch) - - [RHP: I don't understand what the following fragment refers to. If it's - the "BIG BUG" section in the original, why does it say "overriding class - declarations" here when the more detailed text refers to *function* - declarations? Here's the fragment I don't understand:] - there are problems with user-supplied overriding class declarations (see - below). -@end ignore - -@itemize @bullet -@ignore -@cindex static data, not working in templates -@item -Templates for static data in template classes do not work. -Currently, you must initialize each case of such data -individually. -@c FIXME!! Brendan to see if still true. -@c ANSWER: This section presumes that it's incorrect to have to -@c initialize for each type you instantiate with. It's not, it's the -@c right way to do it. -@end ignore - -Unfortunately, individual initializations of this sort are likely to be -considered errors eventually; since they're needed now, you might want to -flag places where you use them with comments to mark the need for a -future transition. - -@cindex nested type results vs templates -@item -Member functions in template classes may not have results of nested -type; @sc{gnu} C++ signals a syntax error on the attempt. The following -example illustrates this problem with an @code{enum} type @code{alph}: - -@smallexample -template <class T> class list @{ - @dots{} - enum alph @{a,b,c@}; - alph bar(); - @dots{} -@}; - -template <class T> -list<int>::alph list<int>::bar() // @i{Syntax error here} -@{ -@dots{} -@} -@end smallexample - -@cindex preprocessor conditionals in templates -@cindex conditionals (preprocessor) in templates -@item -A parsing bug makes it difficult to use preprocessor conditionals within -templates. For example, in this code: - -@smallexample -template <class T> -class list @{ - @dots{} -#ifdef SYSWRONG - T x; -#endif - @dots{} -@} -@end smallexample - -The preprocessor output leaves sourcefile line number information (lines -like @samp{# 6 "foo.cc"} when it expands the @code{#ifdef} block. These -lines confuse the compiler while parsing templates, giving a syntax -error. - -If you cannot avoid preprocessor conditionals in templates, you can -suppress the line number information using the @samp{-P} preprocessor -option (but this will make debugging more difficult), by compiling the -affected modules like this: - -@smallexample -g++ -P foo.cc -o foo -@end smallexample - -@cindex parsing errors, templates -@item -Parsing errors are reported when templates are first -@emph{instantiated}---not on the template definition itself. In -particular, if you do not instantiate a template definition at all, the -compiler never reports any parsing errors that may be in the template -definition. -@end itemize - -@node Template debugging -@section Debugging information for templates - -@cindex templates and debugging information -@cindex debugging information and templates -Debugging information for templates works for some object code formats, -but not others. It works for stabs@footnote{Except that insufficient -debugging information for methods of template classes is generated in -stabs.} (used primarily in @sc{a.out} object code, but also in the Solaris 2 -version of @sc{elf}), and the @sc{mips} version of @sc{coff} debugging -format. - -@sc{dwarf} support is currently minimal, and requires further -development. diff --git a/contrib/gcc/cp/tree.def b/contrib/gcc/cp/tree.def deleted file mode 100644 index 82b7954e29c0d..0000000000000 --- a/contrib/gcc/cp/tree.def +++ /dev/null @@ -1,116 +0,0 @@ -/* This file contains the definitions and documentation for the - additional tree codes used in the GNU C++ compiler (see tree.def - for the standard codes). - Copyright (C) 1987, 1988, 1990, 1993 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@cygnus.com) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -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, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -/* Reference to the contents of an offset - (a value whose type is an OFFSET_TYPE). - Operand 0 is the object within which the offset is taken. - Operand 1 is the offset. The language independent OFFSET_REF - just won't work for us. */ -DEFTREECODE (CP_OFFSET_REF, "cp_offset_ref", "r", 2) - -/* For DELETE_EXPR, operand 0 is the store to be destroyed. - Operand 1 is the value to pass to the destroying function - saying whether the store should be deallocated as well. */ -DEFTREECODE (DELETE_EXPR, "dl_expr", "e", 2) -DEFTREECODE (VEC_DELETE_EXPR, "vec_dl_expr", "e", 2) - -/* For a UNSAVE_EXPR, operand 0 is the value to unsave. By unsave, we - mean that all _EXPRs such as TARGET_EXPRs, SAVE_EXPRs, - WITH_CLEANUP_EXPRs, CALL_EXPRs and RTL_EXPRs, that are protected - from being evaluated more than once should be reset so that a new - expand_expr call of this expr will cause those to be re-evaluated. - This is useful when we want to reuse a tree in different places, - but where we must re-expand. */ -DEFTREECODE (UNSAVE_EXPR, "unsave_expr", "e", 1) - -/* Value is reference to particular overloaded class method. - Operand 0 is the class name (an IDENTIFIER_NODE); - operand 1 is the field (also an IDENTIFIER_NODE). - The COMPLEXITY field holds the class level (usually 0). */ -DEFTREECODE (SCOPE_REF, "scope_ref", "r", 2) - -/* When composing an object with a member, this is the result. - Operand 0 is the object. Operand 1 is the member (usually - a dereferenced pointer to member). */ -DEFTREECODE (MEMBER_REF, "member_ref", "r", 2) - -/* Type conversion operator in C++. TREE_TYPE is type that this - operator converts to. Operand is expression to be converted. */ -DEFTREECODE (TYPE_EXPR, "type_expr", "e", 1) - -/* For CPLUS_NEW_EXPR, operand 0 is function which performs initialization, - operand 1 is argument list to initialization function, - and operand 2 is the slot which was allocated for this expression. */ -DEFTREECODE (NEW_EXPR, "nw_expr", "e", 3) -DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", "e", 3) - -/* A throw expression. operand 0 is the expression, if there was one, - else it is NULL_TREE. */ -DEFTREECODE (THROW_EXPR, "throw_expr", "e", 1) - -/* Template definition. The following fields have the specified uses, - although there are other macros in cp-tree.h that should be used for - accessing this data. - DECL_ARGUMENTS template parm vector - DECL_TEMPLATE_INFO template text &c - DECL_VINDEX list of instantiations already produced; - only done for functions so far - For class template: - DECL_INITIAL associated templates (methods &c) - DECL_RESULT null - For non-class templates: - TREE_TYPE type of object to be constructed - DECL_RESULT decl for object to be created - (e.g., FUNCTION_DECL with tmpl parms used) - */ -DEFTREECODE (TEMPLATE_DECL, "template_decl", "d", 0) - -/* Index into a template parameter list. This parameter must be a type. - Use TYPE_FIELDS to find parmlist and index. */ -DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", "t", 0) - -/* Index into a template parameter list. This parameter must not be a - type. */ -DEFTREECODE (TEMPLATE_CONST_PARM, "template_const_parm", "c", 2) - -/* For uninstantiated parameterized types. - TYPE_VALUES tree list: - TREE_PURPOSE template decl - TREE_VALUE parm vector - TREE_CHAIN null - Other useful fields to be defined later. */ -DEFTREECODE (UNINSTANTIATED_P_TYPE, "uninstantiated_p_type", "t", 0) - -/* A thunk is a stub function. - - Thunks are used to implement multiple inheritance: - At run-time, such a thunk subtracts THUNK_DELTA (an int, not a tree) - from the this pointer, and then jumps to DECL_INITIAL - (which is an ADDR_EXPR whose operand is a FUNCTION_DECL). - - Other kinds of thunks may be defined later. */ -DEFTREECODE (THUNK_DECL, "thunk_decl", "d", 0) - -/* A namespace declaration. */ -DEFTREECODE (NAMESPACE_DECL, "namespace_decl", "d", 0) |