From 79ff2c6c8b8d900abc22a2030c61d4f538b75d4f Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Sun, 9 Apr 1995 11:41:24 +0000 Subject: [PATCH] 64th Cygnus<->FSF merge From-SVN: r9341 --- gcc/cp/ChangeLog | 50 ++++++++++++++++++++++ gcc/cp/Makefile.in | 2 +- gcc/cp/decl.c | 8 ++++ gcc/cp/decl2.c | 7 ++++ gcc/cp/lex.c | 9 +++- gcc/cp/repo.c | 102 +++++++++++++++++++++++++++++---------------- gcc/cp/typeck.c | 4 ++ 7 files changed, 145 insertions(+), 37 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9b417031d3b..719db74a7ae 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,53 @@ +Sat Apr 8 17:45:41 1995 Mike Stump + + * gc.c (build_headof): Use ptrdiff_type_node instead of + integer_type_node on pointer arithmetic. + +Sat Apr 8 11:57:04 1995 Jason Merrill + + * typeck.c (build_modify_expr): Undo previous change. + +Thu Apr 6 01:23:50 1995 Jason Merrill + + * Makefile.in (compiler): Remove ../cc1plus before rebuilding it. + + * repo.c (get_base_filename): Put the .rpo file in the directory + with the object file, not the source. + + * typeck.c (build_conditional_expr): Handle pmf's better. + + * repo.c (finish_repo): Also use ASM_OUTPUT_LABELREF to print out + the name of the symbol. + +Wed Apr 5 15:24:12 1995 Jason Merrill + + * repo.c (open_repo_file): Make repo filename DOS-compliant. + (*): Also write a new repo file if some previously-used + templates are no longer used. Only remember the identifier. + + * lex.c (cons_up_default_function): If this function belongs to a + template class, call repo_template_used for it. + + * repo.c (repo_template_used): Using a class means using its vtable, + if any. + (finish_repo): Ditto. + + * typeck.c (build_modify_expr): Only wrap TARGET_EXPRs in RTL_EXPRs + if the type has a complex copy constructor. + + * decl2.c (lang_decode_option): -frepo implies + -fno-implicit-templates. + + * decl.c (start_function): Clear current_{base,member}_init_list. + + * lex.c (init_lex): Also unset *_eq if ! flag_operator_names. + +Tue Apr 4 16:11:08 1995 Jason Merrill + + * decl.c (struct cp_function): Add {base,member}_init_list. + (push_cp_function_context): Save current_{base,member}_init_list. + (pop_cp_function_context): Restore them. + Mon Apr 3 16:55:08 1995 Jason Merrill * repo.c (get_base_filename): Take filename parm, fix logic bug. diff --git a/gcc/cp/Makefile.in b/gcc/cp/Makefile.in index 98fea7eb2ae..711985b0cce 100644 --- a/gcc/cp/Makefile.in +++ b/gcc/cp/Makefile.in @@ -167,7 +167,7 @@ OBJDEPS = ../stamp-objlist ../c-common.o ../c-pragma.o compiler: ../cc1plus ../cc1plus: $(P) $(CXX_OBJS) $(OBJDEPS) $(LIBDEPS) - rm -f $@ + rm -f ../cc1plus $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o ../cc1plus \ $(CXX_OBJS) $(OBJS) $(LIBS) diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index de9e5b72e4e..86534edeff8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10653,6 +10653,8 @@ start_function (declspecs, declarator, raises, pre_parsed_p) current_function_obstack_usage = 0; base_init_insns = NULL_RTX; protect_list = NULL_TREE; + current_base_init_list = NULL_TREE; + current_member_init_list = NULL_TREE; clear_temp_name (); @@ -12137,6 +12139,8 @@ struct cp_function tree ctor_label; tree dtor_label; tree protect_list; + tree base_init_list; + tree member_init_list; rtx result_rtx; rtx base_init_insns; struct cp_function *next; @@ -12177,6 +12181,8 @@ push_cp_function_context (context) p->base_init_insns = base_init_insns; p->protect_list = protect_list; p->temp_name_counter = temp_name_counter; + p->base_init_list = current_base_init_list; + p->member_init_list = current_member_init_list; } /* Restore the variables used during compilation of a C++ function. */ @@ -12224,6 +12230,8 @@ pop_cp_function_context (context) original_result_rtx = p->result_rtx; base_init_insns = p->base_init_insns; temp_name_counter = p->temp_name_counter; + current_base_init_list = p->base_init_list; + current_member_init_list = p->member_init_list; free (p); } diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 2a4068f9f2c..bb2bf538c42 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -494,6 +494,13 @@ lang_decode_option (p) else if (!strcmp (p, "ansi-overloading")) { warning ("-fansi-overloading is no longer meaningful"); + found = 1; + } + else if (!strcmp (p, "repo")) + { + flag_use_repository = 1; + flag_implicit_templates = 0; + found = 1; } else for (j = 0; !found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 6d46976769a..2392599ec8d 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -809,12 +809,16 @@ init_lex () { /* These are new ANSI keywords that may break code. */ UNSET_RESERVED_WORD ("and"); + UNSET_RESERVED_WORD ("and_eq"); UNSET_RESERVED_WORD ("bitand"); UNSET_RESERVED_WORD ("bitor"); UNSET_RESERVED_WORD ("compl"); UNSET_RESERVED_WORD ("not"); + UNSET_RESERVED_WORD ("not_eq"); UNSET_RESERVED_WORD ("or"); + UNSET_RESERVED_WORD ("or_eq"); UNSET_RESERVED_WORD ("xor"); + UNSET_RESERVED_WORD ("xor_eq"); } if (! flag_traditional) UNSET_RESERVED_WORD ("overload"); @@ -1784,7 +1788,10 @@ cons_up_default_function (type, full_name, kind) return fn; if (processing_template_defn) - SET_DECL_IMPLICIT_INSTANTIATION (fn); + { + SET_DECL_IMPLICIT_INSTANTIATION (fn); + repo_template_used (fn); + } if (CLASSTYPE_INTERFACE_KNOWN (type)) { diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index 9052eb89f9e..bc27a27cbcb 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -29,19 +29,19 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "tree.h" #include "cp-tree.h" #include "input.h" +#include "obstack.h" extern char * rindex (); extern char * getenv (); static tree pending_repo; +static tree original_repo; static char repo_name[1024]; static FILE *repo_file; extern int flag_use_repository; extern int errorcount, sorrycount; -static int repo_changed; - #define IDENTIFIER_REPO_USED(NODE) (TREE_LANG_FLAG_3 (NODE)) #define IDENTIFIER_REPO_CHOSEN(NODE) (TREE_LANG_FLAG_4 (NODE)) @@ -93,7 +93,10 @@ repo_template_used (t) if (TREE_CODE_CLASS (TREE_CODE (t)) == 't') { - id = DECL_ASSEMBLER_NAME (TYPE_MAIN_DECL (t)); + id = TYPE_BINFO_VTABLE (t); + if (id == NULL_TREE) + return; + id = DECL_ASSEMBLER_NAME (id); if (IDENTIFIER_REPO_CHOSEN (id)) mark_class_instantiated (t, 0); } @@ -108,10 +111,9 @@ repo_template_used (t) if (! IDENTIFIER_REPO_USED (id)) { - repo_changed = 1; IDENTIFIER_REPO_USED (id) = 1; + pending_repo = perm_tree_cons (NULL_TREE, id, pending_repo); } - pending_repo = perm_tree_cons (NULL_TREE, t, pending_repo); } /* Note that the vtable for a class has been used, and offer to emit it. */ @@ -160,11 +162,8 @@ save_string (s, len) char *s; int len; { - register char *result = xmalloc (len + 1); - - bcopy (s, result, len); - result[len] = 0; - return result; + extern struct obstack temporary_obstack; + return obstack_copy0 (&temporary_obstack, s, len); } static char * @@ -201,7 +200,18 @@ get_base_filename (filename) if (compiling && output) return output; - return save_string (filename, strlen (filename)); + if (p && ! compiling) + { + warning ("-frepo must be used with -c"); + flag_use_repository = 0; + return NULL; + } + + p = rindex (filename, '/'); + if (p) + return p+1; + else + return filename; } static void @@ -210,7 +220,12 @@ open_repo_file (filename) { register char *p, *q; char *file = get_base_filename (filename); - char *s = rindex (file, '/'); + char *s; + + if (file == NULL) + return; + + s = rindex (file, '/'); if (s == NULL) s = file; else @@ -218,16 +233,15 @@ open_repo_file (filename) for (p = repo_name, q = file; q < s; ) *p++ = *q++; - *p++ = '.'; +/* *p++ = '.'; */ if ((s = rindex (q, '.')) == NULL) strcpy (p, q); else for (; q < s;) *p++ = *q++; - strcat (p, ".repo"); + strcat (p, ".rpo"); repo_file = fopen (repo_name, "r"); - free (file); } void @@ -239,18 +253,13 @@ init_repo (filename) if (! flag_use_repository) return; - open_repo_file (); + open_repo_file (filename); if (repo_file == 0) return; while (fgets (buf, 1024, repo_file)) { - int len = strlen (buf) - 1; - if (buf[len] != '\n') - error ("repository info line too long in %s", repo_name); - buf[len] = '\0'; - switch (buf[0]) { case 'A': @@ -260,10 +269,16 @@ init_repo (filename) case 'C': case 'O': { - tree id = get_identifier (&buf[2]); - IDENTIFIER_REPO_USED (id) = 1; + char *q; + tree id; + + for (q = &buf[2]; *q && *q != ' ' && *q != '\n'; ++q) ; + q = save_string (&buf[2], q - &buf[2]); + id = get_identifier (q); + if (buf[0] == 'C') IDENTIFIER_REPO_CHOSEN (id) = 1; + original_repo = perm_tree_cons (NULL_TREE, id, original_repo); } break; default: @@ -293,12 +308,37 @@ finish_repo () { tree t; char *p; + int repo_changed = 0; if (! flag_use_repository) return; /* Do we have to write out a new info file? */ + /* Are there any old templates that aren't used any longer? */ + + for (t = original_repo; t; t = TREE_CHAIN (t)) + { + if (! IDENTIFIER_REPO_USED (TREE_VALUE (t))) + { + repo_changed = 1; + break; + } + IDENTIFIER_REPO_USED (TREE_VALUE (t)) = 0; + } + + /* Are there any templates that are newly used? */ + + if (! repo_changed) + for (t = pending_repo; t; t = TREE_CHAIN (t)) + { + if (IDENTIFIER_REPO_USED (TREE_VALUE (t))) + { + repo_changed = 1; + break; + } + } + if (! repo_changed || errorcount || sorrycount) goto out; @@ -320,19 +360,11 @@ finish_repo () for (t = pending_repo; t; t = TREE_CHAIN (t)) { tree val = TREE_VALUE (t); - char type; - - if (TREE_CODE_CLASS (TREE_CODE (val)) == 't') - val = TYPE_MAIN_DECL (val); - val = DECL_ASSEMBLER_NAME (val); - - if (! IDENTIFIER_REPO_USED (val)) - continue; - IDENTIFIER_REPO_USED (val) = 0; - - type = IDENTIFIER_REPO_CHOSEN (val) ? 'C' : 'O'; + char type = IDENTIFIER_REPO_CHOSEN (val) ? 'C' : 'O'; - fprintf (repo_file, "%c %s\n", type, IDENTIFIER_POINTER (val)); + fprintf (repo_file, "%c %s ", type, IDENTIFIER_POINTER (val)); + ASM_OUTPUT_LABELREF (repo_file, IDENTIFIER_POINTER (val)); + putc ('\n', repo_file); } out: diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6f261e9338a..d26be492652 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4769,6 +4769,10 @@ build_conditional_expr (ifexp, op1, op2) } } + if (TREE_CODE (result_type) == POINTER_TYPE + && TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE) + result_type = build_ptrmemfunc_type (result_type); + if (result_type != TREE_TYPE (op1)) op1 = convert_and_check (result_type, op1); if (result_type != TREE_TYPE (op2)) -- 2.30.2