From a3d5bae2a5043c2d2b025ec39ba0a4743b90875d Mon Sep 17 00:00:00 2001 From: mmitchel Date: Wed, 29 Sep 1999 08:06:21 +0000 Subject: [PATCH] * cp-tree.h (UPT_TEMPLATE): Remove. (UPT_PARMS): Likewise. (DECL_NEEDED_P): New macro. * decl2.c (finish_vtable_vardecl): Use it. (finish_objects): Don't crash with -fsyntax-only. (finish_file): Use DECL_NEEDED_P. Don't prune vtables when -fsyntax-only. * pt.c (tsubst_friend_function): Remove FIXME that talks about obstacks. (tsubst_expr): Correct handling of function try-blocks. * semantics.c: Include flags.h. (expand_body): Don't do RTL generation if -fsyntax-only. * Makefile.in (semantics.o): Depends on flags.h. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29705 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 16 ++++++++++++++++ gcc/cp/Makefile.in | 3 ++- gcc/cp/cp-tree.h | 10 +++++++--- gcc/cp/decl2.c | 25 ++++++++++++++++++------- gcc/cp/pt.c | 7 ++++--- gcc/cp/semantics.c | 8 +++++++- 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fd957bf4b65..784939d434e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,19 @@ +1999-09-29 Mark Mitchell + + * cp-tree.h (UPT_TEMPLATE): Remove. + (UPT_PARMS): Likewise. + (DECL_NEEDED_P): New macro. + * decl2.c (finish_vtable_vardecl): Use it. + (finish_objects): Don't crash with -fsyntax-only. + (finish_file): Use DECL_NEEDED_P. Don't prune vtables when + -fsyntax-only. + * pt.c (tsubst_friend_function): Remove FIXME that talks about + obstacks. + (tsubst_expr): Correct handling of function try-blocks. + * semantics.c: Include flags.h. + (expand_body): Don't do RTL generation if -fsyntax-only. + * Makefile.in (semantics.o): Depends on flags.h. + 1999-09-28 Gabriel Dos Reis * pt.c (most_general_template): Adjust declaration. diff --git a/gcc/cp/Makefile.in b/gcc/cp/Makefile.in index 047f391eb86..d731a5808ca 100644 --- a/gcc/cp/Makefile.in +++ b/gcc/cp/Makefile.in @@ -294,7 +294,8 @@ errfn.o : errfn.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \ repo.o : repo.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h \ $(srcdir)/../toplev.h $(srcdir)/../ggc.h semantics.o: semantics.c $(CONFIG_H) $(CXX_TREE_H) lex.h \ - $(srcdir)/../except.h $(srcdir)/../system.h $(srcdir)/../toplev.h + $(srcdir)/../except.h $(srcdir)/../system.h $(srcdir)/../toplev.h \ + $(srcdir)/../flags.h dump.o: dump.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../system.h # diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 3627c53a06e..7920fdf5051 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2494,9 +2494,13 @@ extern int flag_new_for_scope; #define THUNK_DELTA(DECL) ((DECL)->decl.frame_size.i) -/* ...and for unexpanded-parameterized-type nodes. */ -#define UPT_TEMPLATE(NODE) TREE_PURPOSE(TYPE_VALUES(NODE)) -#define UPT_PARMS(NODE) TREE_VALUE(TYPE_VALUES(NODE)) +/* DECL_NEEDED_P holds of a declaration when we need to emit its + definition. This is true when the back-end tells us that + the symbol has been referenced in the generated code. If, however, + we are not generating code, then it is also true when a symbol has + just been used somewhere, even if it's not really needed. */ +#define DECL_NEEDED_P(DECL) \ + (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME ((DECL)))) \ /* An un-parsed default argument looks like an identifier. */ #define DEFARG_LENGTH(NODE) (DEFAULT_ARG_CHECK(NODE)->identifier.length) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index aed43747a2d..19868c300e5 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2556,7 +2556,7 @@ finish_vtable_vardecl (t, data) if (! DECL_EXTERNAL (vars) && (DECL_INTERFACE_KNOWN (vars) - || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (vars)) + || DECL_NEEDED_P (vars) || (hack_decl_function_context (vars) && TREE_USED (vars))) && ! TREE_ASM_WRITTEN (vars)) { @@ -2600,9 +2600,14 @@ finish_vtable_vardecl (t, data) if (flag_vtable_gc) output_vtable_inherit (vars); + /* Because we're only doing syntax-checking, we'll never end up + actually marking the variable as written. */ + if (flag_syntax_only) + TREE_ASM_WRITTEN (vars) = 1; + return 1; } - else if (! TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (vars))) + else if (!DECL_NEEDED_P (vars)) /* We don't know what to do with this one yet. */ return 0; @@ -2827,6 +2832,12 @@ finish_objects (method_type, initp, body) fn = finish_function (lineno, 0); expand_body (fn); + /* When only doing semantic analysis, and no RTL generation, we + can't call functions that directly emit assembly code; there is + no assembly file in which to put the code. */ + if (flag_syntax_only) + return; + fnname = XSTR (XEXP (DECL_RTL (fn), 0), 0); if (initp == DEFAULT_INIT_PRIORITY) { @@ -2835,7 +2846,6 @@ finish_objects (method_type, initp, body) else assemble_destructor (fnname); } - #if defined (ASM_OUTPUT_SECTION_NAME) && defined (ASM_OUTPUT_CONSTRUCTOR) /* If we're using init priority we can't use assemble_*tor, but on ELF targets we can stick the references into named sections for GNU ld @@ -3554,8 +3564,7 @@ finish_file () if (DECL_NOT_REALLY_EXTERN (decl) && DECL_INITIAL (decl) - && (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) - || !DECL_COMDAT (decl))) + && (DECL_NEEDED_P (decl) || !DECL_COMDAT (decl))) DECL_EXTERNAL (decl) = 0; } @@ -3603,8 +3612,10 @@ finish_file () /* Now delete from the chain of variables all virtual function tables. We output them all ourselves, because each will be treated - specially. */ - walk_globals (vtable_decl_p, prune_vtable_vardecl, /*data=*/0); + specially. We don't do this if we're just doing semantic + analysis, and not code-generation. */ + if (!flag_syntax_only) + walk_globals (vtable_decl_p, prune_vtable_vardecl, /*data=*/0); /* Now, issue warnings about static, but not defined, functions, etc., and emit debugging information. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 15ec4fd23b4..dc5beabe89b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4549,8 +4549,6 @@ tsubst_friend_function (decl, args) tsubst (DECL_TI_ARGS (decl), args, /*complain=*/1, NULL_TREE)); - /* FIXME: The decl we create via the next tsubst could be - created on a temporary obstack. */ new_friend = tsubst (decl, args, /*complain=*/1, NULL_TREE); tmpl = determine_specialization (template_id, new_friend, &new_args, @@ -7466,7 +7464,10 @@ tsubst_expr (t, args, complain, in_decl) handler = TRY_HANDLERS (t); for (; handler; handler = TREE_CHAIN (handler)) tsubst_expr (handler, args, complain, in_decl); - finish_handler_sequence (stmt); + if (FN_TRY_BLOCK_P (t)) + finish_function_handler_sequence (stmt); + else + finish_handler_sequence (stmt); } break; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ac7856bce58..8300f6fd93f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -31,6 +31,7 @@ #include "except.h" #include "lex.h" #include "toplev.h" +#include "flags.h" /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or @@ -2488,8 +2489,13 @@ expand_body (fn) && uses_template_parms (DECL_TI_ARGS (fn)))) return; + /* There's no reason to do any of the work here if we're only doing + semantic analysis; this code just generates RTL. */ + if (flag_syntax_only) + return; + /* Save the current file name and line number. When we expand the - body of the funciton, we'll set LINENO and INPUT_FILENAME so that + body of the function, we'll set LINENO and INPUT_FILENAME so that error-mesages come out in the right places. */ saved_lineno = lineno; saved_input_filename = input_filename; -- 2.11.4.GIT