From d7e7759d8c887ba7867d19f33b1a317dc459e336 Mon Sep 17 00:00:00 2001 From: Benjamin Chelf Date: Wed, 14 Jun 2000 17:26:18 +0000 Subject: [PATCH] c-common.h (IF_COND): Moved here from cp/cp-tree.h. * c-common.h (IF_COND): Moved here from cp/cp-tree.h. (THEN_CLAUSE): Likewise. (ELSE_CLAUSE): Likewise. (WHILE_COND): Likewise. (WHILE_BODY): Likewise. (DO_COND): Likewise. (DO_BODY): Likewise. (RETURN_EXPR): Likewise. (EXPR_STMT_EXPR): Likewise. (FOR_INIT_STMT): Likewise. (FOR_COND): Likewise. (FOR_EXPR): Likewise. (FOR_BODY): Likewise. (SWITCH_COND): Likewise. (SWITCH_BODY): Likewise. (CASE_LOW): Likewise. (CASE_HIGH): Likewise. (GOTO_DESTINATION): Likewise. (COMPOUND_BODY): Likewise. (ASM_CV_QUAL): Likewise. (ASM_STRING): Likewise. (ASM_OUTPUTS): Likewise. (ASM_INPUTS): Likewise. (ASM_CLOBBERS): Likewise. (DECL_STMT_DECL): Likewise. (STMT_EXPR_STMT): Likewise. (LABEL_STMT_LABEL): Likewise. (SCOPE_BEGIN_P): Likewise. (SCOPE_END_P): Likewise. (SCOPE_STMT_BLOCK): Likewise. (SCOPE_NULLIFIED_P): Likewise. (SCOPE_NO_CLEANUPS_P): Likewise. (SCOPE_PARTIAL_P): Likewise. (ASM_VOLATILE_P): Likewise. (STMT_LINENO): Likewise. (STMT_LINENO_FOR_FN_P): Likewise. * c-common.def: Added SRCLOC, SIZEOF_EXPR, ARROW_EXPR, ALIGNOF_EXPR, EXPR_STMT, COMPOUND_STMT, DECL_STMT, IF_STMT, FOR_STMT, WHILE_STMT, DO_STMT, RETURN_STMT, BREAK_STMT, CONTINUE_STMT, SWITCH_STMT, GOTO_STMT, LABEL_STMT, ASM_STMT, SCOPE_STMT, CASE_LABEL, STMT_EXPR. * gencheck.c (tree_codes[]): Added '#include "c-common.def"'. * cp/cp-tree.h (IF_COND): Move to c-common.h. (THEN_CLAUSE): Likewise. (ELSE_CLAUSE): Likewise. (WHILE_COND): Likewise. (WHILE_BODY): Likewise. (DO_COND): Likewise. (DO_BODY): Likewise. (RETURN_EXPR): Likewise. (EXPR_STMT_EXPR): Likewise. (FOR_INIT_STMT): Likewise. (FOR_COND): Likewise. (FOR_EXPR): Likewise. (FOR_BODY): Likewise. (SWITCH_COND): Likewise. (SWITCH_BODY): Likewise. (CASE_LOW): Likewise. (CASE_HIGH): Likewise. (GOTO_DESTINATION): Likewise. (COMPOUND_BODY): Likewise. (ASM_CV_QUAL): Likewise. (ASM_STRING): Likewise. (ASM_OUTPUTS): Likewise. (ASM_INPUTS): Likewise. (ASM_CLOBBERS): Likewise. (DECL_STMT_DECL): Likewise. (STMT_EXPR_STMT): Likewise. (LABEL_STMT_LABEL): Likewise. (SCOPE_BEGIN_P): Likewise. (SCOPE_END_P): Likewise. (SCOPE_STMT_BLOCK): Likewise. (SCOPE_NULLIFIED_P): Likewise. (SCOPE_NO_CLEANUPS_P): Likewise. (SCOPE_PARTIAL_P): Likewise. (ASM_VOLATILE_P): Likewise. (STMT_LINENO): Likewise. (STMT_LINENO_FOR_FN_P): Likewise. * cp/cp-tree.def: Removed SRCLOC, SIZEOF_EXPR, ARROW_EXPR, ALIGNOF_EXPR, EXPR_STMT, COMPOUND_STMT, DECL_STMT, IF_STMT, FOR_STMT, WHILE_STMT, DO_STMT, RETURN_STMT, BREAK_STMT, CONTINUE_STMT, SWITCH_STMT, GOTO_STMT, LABEL_STMT, ASM_STMT, SCOPE_STMT, CASE_LABEL, STMT_EXPR. * cp/Makefile.in (CXX_TREE_H): Added $(srcdir)/../c-common.def. * cp/Make-lang.in (CXX_SRCS): Added $(srcdir)/c-common.def. (cc1plus$(exeext)): Added $(srcdir)/c-common.def. * cp/lex.c (cplus_tree_code_type[]): Added '#include "c-common.def"'. (cplus_tree_code_length[]): Added '#include "c-common.def"'. (cplus_tree_code_name[]): Added '#include "c-common.def"'. From-SVN: r34552 --- gcc/ChangeLog | 47 +++++++++++++ gcc/c-common.def | 63 +++++++++++++++++ gcc/c-common.h | 83 ++++++++++++++++++++++ gcc/cp/ChangeLog | 54 ++++++++++++++ gcc/cp/Make-lang.in | 3 +- gcc/cp/Makefile.in | 2 +- gcc/cp/cp-tree.def | 32 --------- gcc/cp/cp-tree.h | 166 +++++++++++++++----------------------------- gcc/cp/lex.c | 3 + gcc/gencheck.c | 1 + 10 files changed, 310 insertions(+), 144 deletions(-) create mode 100644 gcc/c-common.def diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cd707c3083d..57aac54ec4c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,50 @@ +2000-06-14 Benjamin Chelf + + * c-common.h (IF_COND): Moved here from cp/cp-tree.h. + (THEN_CLAUSE): Likewise. + (ELSE_CLAUSE): Likewise. + (WHILE_COND): Likewise. + (WHILE_BODY): Likewise. + (DO_COND): Likewise. + (DO_BODY): Likewise. + (RETURN_EXPR): Likewise. + (EXPR_STMT_EXPR): Likewise. + (FOR_INIT_STMT): Likewise. + (FOR_COND): Likewise. + (FOR_EXPR): Likewise. + (FOR_BODY): Likewise. + (SWITCH_COND): Likewise. + (SWITCH_BODY): Likewise. + (CASE_LOW): Likewise. + (CASE_HIGH): Likewise. + (GOTO_DESTINATION): Likewise. + (COMPOUND_BODY): Likewise. + (ASM_CV_QUAL): Likewise. + (ASM_STRING): Likewise. + (ASM_OUTPUTS): Likewise. + (ASM_INPUTS): Likewise. + (ASM_CLOBBERS): Likewise. + (DECL_STMT_DECL): Likewise. + (STMT_EXPR_STMT): Likewise. + (LABEL_STMT_LABEL): Likewise. + (SCOPE_BEGIN_P): Likewise. + (SCOPE_END_P): Likewise. + (SCOPE_STMT_BLOCK): Likewise. + (SCOPE_NULLIFIED_P): Likewise. + (SCOPE_NO_CLEANUPS_P): Likewise. + (SCOPE_PARTIAL_P): Likewise. + (ASM_VOLATILE_P): Likewise. + (STMT_LINENO): Likewise. + (STMT_LINENO_FOR_FN_P): Likewise. + + * c-common.def: Added SRCLOC, SIZEOF_EXPR, ARROW_EXPR, + ALIGNOF_EXPR, EXPR_STMT, COMPOUND_STMT, DECL_STMT, IF_STMT, + FOR_STMT, WHILE_STMT, DO_STMT, RETURN_STMT, BREAK_STMT, + CONTINUE_STMT, SWITCH_STMT, GOTO_STMT, LABEL_STMT, ASM_STMT, + SCOPE_STMT, CASE_LABEL, STMT_EXPR. + + * gencheck.c (tree_codes[]): Added '#include "c-common.def"'. + 2000-06-14 David O'Brien * gcc.c (main): Quiet compiler warnings. argv is assumed to be diff --git a/gcc/c-common.def b/gcc/c-common.def new file mode 100644 index 00000000000..03ac0546d1a --- /dev/null +++ b/gcc/c-common.def @@ -0,0 +1,63 @@ +/* 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, 1997, 1998, + 1999, 2000 Free Software Foundation, Inc. + Written by Benjamin Chelf + +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. */ + +/* Tree nodes relevent to both C and C++. These were originally in +cp-tree.def in the cp subdir. */ + +/* A node to remember a source position. */ +DEFTREECODE (SRCLOC, "srcloc", 'x', 2) + +/* A whole bunch of tree codes for the initial, superficial parsing of + templates. */ +DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", '1', 1) +DEFTREECODE (ARROW_EXPR, "arrow_expr", 'e', 1) +DEFTREECODE (ALIGNOF_EXPR, "alignof_expr", '1', 1) + +DEFTREECODE (EXPR_STMT, "expr_stmt", 'e', 1) +DEFTREECODE (COMPOUND_STMT, "compound_stmt", 'e', 1) +DEFTREECODE (DECL_STMT, "decl_stmt", 'e', 1) +DEFTREECODE (IF_STMT, "if_stmt", 'e', 3) +DEFTREECODE (FOR_STMT, "for_stmt", 'e', 4) +DEFTREECODE (WHILE_STMT, "while_stmt", 'e', 2) +DEFTREECODE (DO_STMT, "do_stmt", 'e', 2) +DEFTREECODE (RETURN_STMT, "return_stmt", 'e', 1) +DEFTREECODE (BREAK_STMT, "break_stmt", 'e', 0) +DEFTREECODE (CONTINUE_STMT, "continue_stmt", 'e', 0) +DEFTREECODE (SWITCH_STMT, "switch_stmt", 'e', 2) +DEFTREECODE (GOTO_STMT, "goto_stmt", 'e', 1) +DEFTREECODE (LABEL_STMT, "label_stmt", 'e', 1) +DEFTREECODE (ASM_STMT, "asm_stmt", 'e', 5) + +/* A SCOPE_STMT marks the beginning or end of a scope. If + SCOPE_BEGIN_P holds, then this is the start of a scope. If + SCOPE_END_P holds, then this is the end of a scope. If + SCOPE_NULLIFIED_P holds then there turned out to be no variables in + this scope. The SCOPE_STMT_BLOCK is the BLOCK containing the + variables declared in this scope. */ +DEFTREECODE (SCOPE_STMT, "scope_stmt", 'e', 1) +DEFTREECODE (CASE_LABEL, "case_label", 'e', 2) + +/* A STMT_EXPR represents a statement-expression. The + STMT_EXPR_STMT is the statement given by the expression. */ +DEFTREECODE (STMT_EXPR, "stmt_expr", 'e', 1) diff --git a/gcc/c-common.h b/gcc/c-common.h index 8953d7037ec..4b5cb97760a 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -163,3 +163,86 @@ extern tree build_va_arg PARAMS ((tree, tree)); extern int self_promoting_args_p PARAMS ((tree)); extern tree simple_type_promotes_to PARAMS ((tree)); + + +/* These macros provide convenient access to the various _STMT nodes + created when parsing template declarations. */ +#define IF_COND(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 0) +#define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1) +#define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2) +#define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0) +#define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1) +#define DO_COND(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 0) +#define DO_BODY(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 1) +#define RETURN_EXPR(NODE) TREE_OPERAND (RETURN_STMT_CHECK (NODE), 0) +#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0) +#define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0) +#define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1) +#define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2) +#define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3) +#define SWITCH_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0) +#define SWITCH_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1) +#define CASE_LOW(NODE) TREE_OPERAND (CASE_LABEL_CHECK (NODE), 0) +#define CASE_HIGH(NODE) TREE_OPERAND (CASE_LABEL_CHECK (NODE), 1) +#define GOTO_DESTINATION(NODE) TREE_OPERAND (GOTO_STMT_CHECK (NODE), 0) +#define COMPOUND_BODY(NODE) TREE_OPERAND (COMPOUND_STMT_CHECK (NODE), 0) +#define ASM_CV_QUAL(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 0) +#define ASM_STRING(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 1) +#define ASM_OUTPUTS(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 2) +#define ASM_INPUTS(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 3) +#define ASM_CLOBBERS(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 4) +#define DECL_STMT_DECL(NODE) TREE_OPERAND (DECL_STMT_CHECK (NODE), 0) +#define STMT_EXPR_STMT(NODE) TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0) +#define LABEL_STMT_LABEL(NODE) TREE_OPERAND (LABEL_STMT_CHECK (NODE), 0) + +/* Nonzero if this SCOPE_STMT is for the beginning of a scope. */ +#define SCOPE_BEGIN_P(NODE) \ + (TREE_LANG_FLAG_0 (SCOPE_STMT_CHECK (NODE))) + +/* Nonzero if this SCOPE_STMT is for the end of a scope. */ +#define SCOPE_END_P(NODE) \ + (!SCOPE_BEGIN_P (SCOPE_STMT_CHECK (NODE))) + +/* The BLOCK containing the declarations contained in this scope. */ +#define SCOPE_STMT_BLOCK(NODE) \ + (TREE_OPERAND (SCOPE_STMT_CHECK (NODE), 0)) + +/* Nonzero for a SCOPE_STMT if there were no variables in this scope. */ +#define SCOPE_NULLIFIED_P(NODE) \ + (SCOPE_STMT_BLOCK ((NODE)) == NULL_TREE) + +/* Nonzero for a SCOPE_STMT which represents a lexical scope, but + which should be treated as non-existant from the point of view of + running cleanup actions. */ +#define SCOPE_NO_CLEANUPS_P(NODE) \ + (TREE_LANG_FLAG_3 (SCOPE_STMT_CHECK (NODE))) + +/* Nonzero for a SCOPE_STMT if this statement is for a partial scope. + For example, in: + + S s; + l: + S s2; + goto l; + + there is (implicitly) a new scope after `l', even though there are + no curly braces. In particular, when we hit the goto, we must + destroy s2 and then re-construct it. For the implicit scope, + SCOPE_PARTIAL_P will be set. */ +#define SCOPE_PARTIAL_P(NODE) \ + (TREE_LANG_FLAG_4 (SCOPE_STMT_CHECK (NODE))) + +/* Nonzero for an ASM_STMT if the assembly statement is volatile. */ +#define ASM_VOLATILE_P(NODE) \ + (ASM_CV_QUAL (ASM_STMT_CHECK (NODE)) != NULL_TREE) + +/* The line-number at which a statement began. But if + STMT_LINENO_FOR_FN_P does holds, then this macro gives the + line number for the end of the current function instead. */ +#define STMT_LINENO(NODE) \ + (TREE_COMPLEXITY ((NODE))) + +/* If non-zero, the STMT_LINENO for NODE is the line at which the + function ended. */ +#define STMT_LINENO_FOR_FN_P(NODE) \ + (TREE_LANG_FLAG_2 ((NODE))) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1cf4879cf0f..6ddb75803b1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,57 @@ +2000-06-14 Benjamin Chelf + + * cp-tree.h (IF_COND): Move to c-common.h. + (THEN_CLAUSE): Likewise. + (ELSE_CLAUSE): Likewise. + (WHILE_COND): Likewise. + (WHILE_BODY): Likewise. + (DO_COND): Likewise. + (DO_BODY): Likewise. + (RETURN_EXPR): Likewise. + (EXPR_STMT_EXPR): Likewise. + (FOR_INIT_STMT): Likewise. + (FOR_COND): Likewise. + (FOR_EXPR): Likewise. + (FOR_BODY): Likewise. + (SWITCH_COND): Likewise. + (SWITCH_BODY): Likewise. + (CASE_LOW): Likewise. + (CASE_HIGH): Likewise. + (GOTO_DESTINATION): Likewise. + (COMPOUND_BODY): Likewise. + (ASM_CV_QUAL): Likewise. + (ASM_STRING): Likewise. + (ASM_OUTPUTS): Likewise. + (ASM_INPUTS): Likewise. + (ASM_CLOBBERS): Likewise. + (DECL_STMT_DECL): Likewise. + (STMT_EXPR_STMT): Likewise. + (LABEL_STMT_LABEL): Likewise. + (SCOPE_BEGIN_P): Likewise. + (SCOPE_END_P): Likewise. + (SCOPE_STMT_BLOCK): Likewise. + (SCOPE_NULLIFIED_P): Likewise. + (SCOPE_NO_CLEANUPS_P): Likewise. + (SCOPE_PARTIAL_P): Likewise. + (ASM_VOLATILE_P): Likewise. + (STMT_LINENO): Likewise. + (STMT_LINENO_FOR_FN_P): Likewise. + + * cp-tree.def: Removed SRCLOC, SIZEOF_EXPR, ARROW_EXPR, + ALIGNOF_EXPR, EXPR_STMT, COMPOUND_STMT, DECL_STMT, IF_STMT, + FOR_STMT, WHILE_STMT, DO_STMT, RETURN_STMT, BREAK_STMT, + CONTINUE_STMT, SWITCH_STMT, GOTO_STMT, LABEL_STMT, ASM_STMT, + SCOPE_STMT, CASE_LABEL, STMT_EXPR. + + * Makefile.in (CXX_TREE_H): Added $(srcdir)/../c-common.def. + + * Make-lang.in (CXX_SRCS): Added $(srcdir)/c-common.def. + (cc1plus$(exeext)): Added $(srcdir)/c-common.def. + + * lex.c (cplus_tree_code_type[]): Added '#include "c-common.def"'. + (cplus_tree_code_length[]): Added '#include "c-common.def"'. + (cplus_tree_code_name[]): Added '#include "c-common.def"'. + 2000-06-14 Mark Mitchell * cp-tree.h (BINFO_OVERRIDE_ALONG_VIRTUAL_PATH): New macro. diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 0c1f67fa962..6763d624573 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -110,6 +110,7 @@ $(DEMANGLER_PROG): cxxmain.o underscore.o $(LIBDEPS) cxxmain.o underscore.o $(LIBS) CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/class.c $(srcdir)/cp/cp-tree.def \ + $(srcdir)/c-common.def \ $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cvt.c $(srcdir)/cp/decl.c \ $(srcdir)/cp/decl.h $(srcdir)/cp/decl2.c $(srcdir)/cp/dump.c \ $(srcdir)/cp/errfn.c $(srcdir)/cp/error.c $(srcdir)/cp/except.c \ @@ -123,7 +124,7 @@ CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/class.c $(srcdir)/cp/cp-tree.def \ cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o \ c-pragma.o $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def \ - $(srcdir)/cp/gxx.gperf $(srcdir)/cp/cfns.gperf hash.o \ + $(srcdir)/c-common.def $(srcdir)/cp/gxx.gperf $(srcdir)/cp/cfns.gperf hash.o \ $(srcdir)/cp/operators.def cd cp; $(MAKE) $(LANG_FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus$(exeext) # diff --git a/gcc/cp/Makefile.in b/gcc/cp/Makefile.in index 2e437cb67db..51708f84310 100644 --- a/gcc/cp/Makefile.in +++ b/gcc/cp/Makefile.in @@ -203,7 +203,7 @@ RTL_H = $(srcdir)/../rtl.h $(srcdir)/../rtl.def \ TREE_H = $(srcdir)/../tree.h $(srcdir)/../real.h $(srcdir)/../tree.def \ $(srcdir)/../machmode.h $(srcdir)/../machmode.def CXX_TREE_H = $(TREE_H) cp-tree.h $(srcdir)/../c-common.h cp-tree.def \ - $(srcdir)/../function.h $(srcdir)/../varray.h \ + $(srcdir)/../c-common.def $(srcdir)/../function.h $(srcdir)/../varray.h \ $(srcdir)/../../include/splay-tree.h \ $(srcdir)/../system.h $(CONFIG_H) PARSE_H = $(srcdir)/parse.h diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def index ead42bef0d1..6cc3af61123 100644 --- a/gcc/cp/cp-tree.def +++ b/gcc/cp/cp-tree.def @@ -185,9 +185,6 @@ DEFTREECODE (OVERLOAD, "overload", 'x', 1) tree structure. */ DEFTREECODE (WRAPPER, "wrapper", 'x', 1) -/* A node to remember a source position. */ -DEFTREECODE (SRCLOC, "srcloc", 'x', 2) - /* Used to represent deferred name lookup for dependent names while parsing a template declaration. The first argument is an IDENTIFIER_NODE for the name in question. The TREE_TYPE is @@ -205,27 +202,10 @@ DEFTREECODE (REINTERPRET_CAST_EXPR, "reinterpret_cast_expr", '1', 1) DEFTREECODE (CONST_CAST_EXPR, "const_cast_expr", '1', 1) DEFTREECODE (STATIC_CAST_EXPR, "static_cast_expr", '1', 1) DEFTREECODE (DYNAMIC_CAST_EXPR, "dynamic_cast_expr", '1', 1) -DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", '1', 1) -DEFTREECODE (ALIGNOF_EXPR, "alignof_expr", '1', 1) -DEFTREECODE (ARROW_EXPR, "arrow_expr", 'e', 1) DEFTREECODE (DOTSTAR_EXPR, "dotstar_expr", 'e', 2) DEFTREECODE (TYPEID_EXPR, "typeid_expr", 'e', 1) DEFTREECODE (PSEUDO_DTOR_EXPR, "pseudo_dtor_expr", 'e', 3) -DEFTREECODE (EXPR_STMT, "expr_stmt", 'e', 1) -DEFTREECODE (COMPOUND_STMT, "compound_stmt", 'e', 1) -DEFTREECODE (DECL_STMT, "decl_stmt", 'e', 1) -DEFTREECODE (IF_STMT, "if_stmt", 'e', 3) -DEFTREECODE (FOR_STMT, "for_stmt", 'e', 4) -DEFTREECODE (WHILE_STMT, "while_stmt", 'e', 2) -DEFTREECODE (DO_STMT, "do_stmt", 'e', 2) -DEFTREECODE (RETURN_STMT, "return_stmt", 'e', 1) -DEFTREECODE (BREAK_STMT, "break_stmt", 'e', 0) -DEFTREECODE (CONTINUE_STMT, "continue_stmt", 'e', 0) -DEFTREECODE (SWITCH_STMT, "switch_stmt", 'e', 2) -DEFTREECODE (GOTO_STMT, "goto_stmt", 'e', 1) -DEFTREECODE (LABEL_STMT, "label_stmt", 'e', 1) -DEFTREECODE (ASM_STMT, "asm_stmt", 'e', 5) /* A SUBOBJECT statement marks the point at which a sub-object is fully constructed. After this point, the SUBOBJECT_CLEANUP must be run if an exception is thrown before the end of the enclosing @@ -244,23 +224,11 @@ DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", 'e', 2) the START_CATCH_TYPE. If this is CATCH_ALL_TYPE, then the handler catches all types. */ DEFTREECODE (START_CATCH_STMT, "start_catch_stmt", 'e', 0) -/* A SCOPE_STMT marks the beginning or end of a scope. If - SCOPE_BEGIN_P holds, then this is the start of a scope. If - SCOPE_END_P holds, then this is the end of a scope. If - SCOPE_NULLIFIED_P holds then there turned out to be no variables in - this scope. The SCOPE_STMT_BLOCK is the BLOCK containing the - variables declared in this scope. */ -DEFTREECODE (SCOPE_STMT, "scope_stmt", 'e', 1) DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", 'e', 2) -DEFTREECODE (CASE_LABEL, "case_label", 'e', 2) DEFTREECODE (RETURN_INIT, "return_init", 'e', 2) DEFTREECODE (TRY_BLOCK, "try_block", 'e', 2) DEFTREECODE (HANDLER, "handler", 'e', 2) -/* A STMT_EXPR represents a statement-expression. The - STMT_EXPR_STMT is the statement given by the expression. */ -DEFTREECODE (STMT_EXPR, "stmt_expr", 'e', 1) - DEFTREECODE (TAG_DEFN, "tag_defn", 'e', 0) /* And some codes for expressing conversions for overload resolution. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 9418b2aa7df..9d5bb9273e0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -20,7 +20,6 @@ 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 "c-common.h" #include "function.h" #include "splay-tree.h" #include "varray.h" @@ -28,6 +27,8 @@ Boston, MA 02111-1307, USA. */ #ifndef _CP_TREE_H #define _CP_TREE_H +#include "c-common.h" + /* Usage of TREE_LANG_FLAG_?: 0: BINFO_MARKED (BINFO nodes). COMPOUND_STMT_NO_SCOPE (in COMPOUND_STMT). @@ -207,6 +208,7 @@ Boston, MA 02111-1307, USA. */ #define RECORD_OR_UNION_TYPE_CHECK(NODE) NODE #endif + /* ABI control. */ @@ -352,6 +354,37 @@ typedef struct ptrmem_cst #define SET_IDENTIFIER_NAMESPACE_VALUE(NODE, VAL) \ set_namespace_binding (NODE, current_namespace, VAL) +#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE)) +#define CLEANUP_DECL(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 0) +#define CLEANUP_EXPR(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 1) + +/* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual + sense of `same'. */ +#define same_type_p(type1, type2) \ + comptypes ((type1), (type2), COMPARE_STRICT) + +/* Returns nonzero iff TYPE1 and TYPE2 are the same type, ignoring + top-level qualifiers. */ +#define same_type_ignoring_top_level_qualifiers_p(type1, type2) \ + same_type_p (TYPE_MAIN_VARIANT (type1), TYPE_MAIN_VARIANT (type2)) + +/* Non-zero if we are presently building a statement tree, rather + than expanding each statement as we encounter it. */ +#define building_stmt_tree() (last_tree != NULL_TREE) + +/* Returns non-zero iff NODE is a declaration for the global function + `main'. */ +#define DECL_MAIN_P(NODE) \ + (DECL_EXTERN_C_FUNCTION_P (NODE) \ + && DECL_NAME (NODE) != NULL_TREE \ + && MAIN_NAME_P (DECL_NAME (NODE))) + +/* Returns non-zero iff ID_NODE is an IDENTIFIER_NODE whose name is + `main'. */ +#define MAIN_NAME_P(ID_NODE) \ + (strcmp (IDENTIFIER_POINTER (ID_NODE), "main") == 0) + + struct tree_binding { struct tree_common common; @@ -1233,6 +1266,7 @@ extern void (*back_end_hook) PARAMS ((tree)); #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, enum cplus_tree_code { __DUMMY = LAST_AND_UNUSED_TREE_CODE, +#include "c-common.def" #include "cp-tree.def" LAST_CPLUS_TREE_CODE }; @@ -1939,10 +1973,26 @@ struct lang_decl } u2; }; +/* An un-parsed default argument looks like an identifier. */ +#define DEFARG_LENGTH(NODE) (DEFAULT_ARG_CHECK(NODE)->identifier.length) +#define DEFARG_POINTER(NODE) (DEFAULT_ARG_CHECK(NODE)->identifier.pointer) + /* Non-zero if NODE is a _DECL with TREE_READONLY set. */ #define TREE_READONLY_DECL_P(NODE) \ (TREE_READONLY (NODE) && DECL_P (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. We need + anything that isn't comdat, but we don't know for sure whether or + not something is comdat until end-of-file. */ +#define DECL_NEEDED_P(DECL) \ + ((at_eof && !DECL_COMDAT (DECL)) \ + || (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME ((DECL)))) \ + || (flag_syntax_only && TREE_USED ((DECL)))) + /* Non-zero iff DECL is memory-based. The DECL_RTL of certain const variables might be a CONST_INT, or a REG in some cases. We cannot use `memory_operand' as a test @@ -3107,74 +3157,19 @@ extern int flag_new_for_scope; #define THUNK_VCALL_OFFSET(DECL) \ (DECL_LANG_SPECIFIC (DECL)->decl_flags.u2.vcall_offset) -/* 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. We need - anything that isn't comdat, but we don't know for sure whether or - not something is comdat until end-of-file. */ -#define DECL_NEEDED_P(DECL) \ - ((at_eof && !DECL_COMDAT (DECL)) \ - || (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME ((DECL)))) \ - || (flag_syntax_only && TREE_USED ((DECL)))) - -/* An un-parsed default argument looks like an identifier. */ -#define DEFARG_LENGTH(NODE) (DEFAULT_ARG_CHECK(NODE)->identifier.length) -#define DEFARG_POINTER(NODE) (DEFAULT_ARG_CHECK(NODE)->identifier.pointer) /* These macros provide convenient access to the various _STMT nodes created when parsing template declarations. */ -#define IF_COND(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 0) -#define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1) -#define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2) -#define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0) -#define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1) -#define DO_COND(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 0) -#define DO_BODY(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 1) -#define RETURN_EXPR(NODE) TREE_OPERAND (RETURN_STMT_CHECK (NODE), 0) -#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0) -#define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0) -#define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1) -#define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2) -#define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3) -#define SWITCH_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0) -#define SWITCH_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1) -#define CASE_LOW(NODE) TREE_OPERAND (CASE_LABEL_CHECK (NODE), 0) -#define CASE_HIGH(NODE) TREE_OPERAND (CASE_LABEL_CHECK (NODE), 1) -#define GOTO_DESTINATION(NODE) TREE_OPERAND (GOTO_STMT_CHECK (NODE), 0) #define TRY_STMTS(NODE) TREE_OPERAND (TRY_BLOCK_CHECK (NODE), 0) #define TRY_HANDLERS(NODE) TREE_OPERAND (TRY_BLOCK_CHECK (NODE), 1) -#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE)) + /* Nonzero if this try block is a function try block. */ #define FN_TRY_BLOCK_P(NODE) TREE_LANG_FLAG_3 (TRY_BLOCK_CHECK (NODE)) #define HANDLER_PARMS(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 0) #define HANDLER_BODY(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 1) -#define COMPOUND_BODY(NODE) TREE_OPERAND (COMPOUND_STMT_CHECK (NODE), 0) -#define ASM_CV_QUAL(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 0) -#define ASM_STRING(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 1) -#define ASM_OUTPUTS(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 2) -#define ASM_INPUTS(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 3) -#define ASM_CLOBBERS(NODE) TREE_OPERAND (ASM_STMT_CHECK (NODE), 4) -#define DECL_STMT_DECL(NODE) TREE_OPERAND (DECL_STMT_CHECK (NODE), 0) -#define STMT_EXPR_STMT(NODE) TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0) #define SUBOBJECT_CLEANUP(NODE) TREE_OPERAND (SUBOBJECT_CHECK (NODE), 0) -#define CLEANUP_DECL(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 0) -#define CLEANUP_EXPR(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 1) #define START_CATCH_TYPE(NODE) TREE_TYPE (START_CATCH_STMT_CHECK (NODE)) -#define LABEL_STMT_LABEL(NODE) TREE_OPERAND (LABEL_STMT_CHECK (NODE), 0) -/* Nonzero if this SCOPE_STMT is for the beginning of a scope. */ -#define SCOPE_BEGIN_P(NODE) \ - (TREE_LANG_FLAG_0 (SCOPE_STMT_CHECK (NODE))) - -/* Nonzero if this SCOPE_STMT is for the end of a scope. */ -#define SCOPE_END_P(NODE) \ - (!SCOPE_BEGIN_P (SCOPE_STMT_CHECK (NODE))) - -/* The BLOCK containing the declarations contained in this scope. */ -#define SCOPE_STMT_BLOCK(NODE) \ - (TREE_OPERAND (SCOPE_STMT_CHECK (NODE), 0)) /* Nonzero if this CTOR_STMT is for the beginning of a constructor. */ #define CTOR_BEGIN_P(NODE) \ @@ -3184,46 +3179,6 @@ extern int flag_new_for_scope; #define CTOR_END_P(NODE) \ (!CTOR_BEGIN_P (NODE)) -/* Nonzero for a SCOPE_STMT if there were no variables in this scope. */ -#define SCOPE_NULLIFIED_P(NODE) \ - (SCOPE_STMT_BLOCK ((NODE)) == NULL_TREE) - -/* Nonzero for a SCOPE_STMT which represents a lexical scope, but - which should be treated as non-existant from the point of view of - running cleanup actions. */ -#define SCOPE_NO_CLEANUPS_P(NODE) \ - (TREE_LANG_FLAG_3 (SCOPE_STMT_CHECK (NODE))) - -/* Nonzero for a SCOPE_STMT if this statement is for a partial scope. - For example, in: - - S s; - l: - S s2; - goto l; - - there is (implicitly) a new scope after `l', even though there are - no curly braces. In particular, when we hit the goto, we must - destroy s2 and then re-construct it. For the implicit scope, - SCOPE_PARTIAL_P will be set. */ -#define SCOPE_PARTIAL_P(NODE) \ - (TREE_LANG_FLAG_4 (SCOPE_STMT_CHECK (NODE))) - -/* Nonzero for an ASM_STMT if the assembly statement is volatile. */ -#define ASM_VOLATILE_P(NODE) \ - (ASM_CV_QUAL (ASM_STMT_CHECK (NODE)) != NULL_TREE) - -/* The line-number at which a statement began. But if - STMT_LINENO_FOR_FN_P does holds, then this macro gives the - line number for the end of the current function instead. */ -#define STMT_LINENO(NODE) \ - (TREE_COMPLEXITY ((NODE))) - -/* If non-zero, the STMT_LINENO for NODE is the line at which the - function ended. */ -#define STMT_LINENO_FOR_FN_P(NODE) \ - (TREE_LANG_FLAG_2 ((NODE))) - /* The parameters for a call-declarator. */ #define CALL_DECLARATOR_PARMS(NODE) \ (TREE_PURPOSE (TREE_OPERAND ((NODE), 1))) @@ -3793,15 +3748,6 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG }; in the class body. */ #define SF_EXPAND 4 /* Generate RTL for this function. */ -/* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual - sense of `same'. */ -#define same_type_p(type1, type2) \ - comptypes ((type1), (type2), COMPARE_STRICT) - -/* Returns nonzero iff TYPE1 and TYPE2 are the same type, ignoring - top-level qualifiers. */ -#define same_type_ignoring_top_level_qualifiers_p(type1, type2) \ - same_type_p (TYPE_MAIN_VARIANT (type1), TYPE_MAIN_VARIANT (type2)) /* Returns nonzero iff TYPE1 and TYPE2 are the same type, or if TYPE2 is derived from TYPE1, or if TYPE2 is a pointer (reference) to a @@ -3855,6 +3801,10 @@ enum tree_string_flags }; /* in lex.c */ +/* Indexed by TREE_CODE, these tables give C-looking names to + operators represented by TREE_CODES. For example, + opname_tab[(int) MINUS_EXPR] == "-". */ +extern const char **opname_tab, **assignop_tab; typedef struct operator_name_info_t { @@ -3871,7 +3821,6 @@ extern operator_name_info_t operator_name_info[]; /* Similar, but for assignment operators. */ extern operator_name_info_t assignment_operator_name_info[]; - /* in call.c */ extern int check_dtor_name PARAMS ((tree, tree)); extern int get_arglist_len_in_bytes PARAMS ((tree)); @@ -4546,9 +4495,6 @@ extern void prep_stmt PARAMS ((tree)); extern tree add_scope_stmt PARAMS ((int, int)); extern void do_pushlevel PARAMS ((void)); extern tree do_poplevel PARAMS ((void)); -/* Non-zero if we are presently building a statement tree, rather - than expanding each statement as we encounter it. */ -#define building_stmt_tree() (last_tree != NULL_TREE) /* in spew.c */ extern void init_spew PARAMS ((void)); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index a4dc2cf30b6..234207f2c18 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -349,6 +349,7 @@ get_time_identifier (name) static char cplus_tree_code_type[] = { 'x', +#include "c-common.def" #include "cp-tree.def" }; #undef DEFTREECODE @@ -361,6 +362,7 @@ static char cplus_tree_code_type[] = { static int cplus_tree_code_length[] = { 0, +#include "c-common.def" #include "cp-tree.def" }; #undef DEFTREECODE @@ -371,6 +373,7 @@ static int cplus_tree_code_length[] = { static const char *cplus_tree_code_name[] = { "@@dummy", +#include "c-common.def" #include "cp-tree.def" }; #undef DEFTREECODE diff --git a/gcc/gencheck.c b/gcc/gencheck.c index 110897ff10c..12cc03823a0 100644 --- a/gcc/gencheck.c +++ b/gcc/gencheck.c @@ -25,6 +25,7 @@ Boston, MA 02111-1307, USA. */ const char *tree_codes[] = { #include "tree.def" +#include "c-common.def" #include "gencheck.h" (char*)0 };