Make-lang.in (CXX_AND_OBJCXX_OBJS): Add cp/cp-objcp-common.o.
authorZiemowit Laski <zlaski@apple.com>
Tue, 31 Aug 2004 18:51:08 +0000 (18:51 +0000)
committerZiemowit Laski <zlaski@gcc.gnu.org>
Tue, 31 Aug 2004 18:51:08 +0000 (18:51 +0000)
2004-08-31  Ziemowit Laski  <zlaski@apple.com>

        * Make-lang.in (CXX_AND_OBJCXX_OBJS): Add cp/cp-objcp-common.o.
        (cp/cp-lang.o): Depend on debug.h, gtype-cp.h and cp/cp-objcp-common.h.
        (cp/cp-decl.c): Do not depend on gtype-cp.h.
        (cp/cp-objcp-common.o): New target.
        * cp-lang.c: Include debug.h, cp-objcp-common.h and gtype-cp.h.
        (cxx_get_alias_set, cxx_warn_unused_global_decl, cp_expr_size,
        cp_tree_size, cp_var_mod_type_p, cxx_initialize_diagnostics): Move
        prototypes and definitions to cp-objcp-common.h and cp-objcp-common.c,
        respectively.
        (LANG_HOOKS_TREE_SIZE, LANG_HOOKS_FINISH,
        LANG_HOOKS_CLEAR_BINDING_STACK, LANG_HOOKS_INIT_OPTIONS,
        LANG_HOOKS_INITIALIZE_DIAGNOSTICS, LANG_HOOKS_HANDLE_OPTION,
        LANG_HOOKS_HANDLE_FILENAME, LANG_HOOKS_MISSING_ARGUMENT,
        LANG_HOOKS_POST_OPTIONS, LANG_HOOKS_GET_ALIAS_SET,
        LANG_HOOKS_EXPAND_CONSTANT, LANG_HOOKS_EXPAND_EXPR,
        LANG_HOOKS_EXPAND_DECL, LANG_HOOKS_PARSE_FILE,
        LANG_HOOKS_DUP_LANG_SPECIFIC_DECL, LANG_HOOKS_TRUTHVALUE_CONVERSION,
        LANG_HOOKS_SET_DECL_ASSEMBLER_NAME, LANG_HOOKS_MARK_ADDRESSABLE,
        LANG_HOOKS_PRINT_STATISTICS, LANG_HOOKS_PRINT_XNODE,
        LANG_HOOKS_PRINT_DECL, LANG_HOOKS_PRINT_TYPE,
        LANG_HOOKS_PRINT_IDENTIFIER, LANG_HOOKS_PRINT_ERROR_FUNCTION,
        LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, LANG_HOOKS_WRITE_GLOBALS,
        LANG_HOOKS_FUNCTION_INIT, LANG_HOOKS_FUNCTION_FINAL,
        LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P,
        LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE,
        LANG_HOOKS_ATTRIBUTE_TABLE, LANG_HOOKS_TREE_INLINING_WALK_SUBTREES,
        LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN,
        LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS,
        LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P,
        LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P,
        LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P,
        LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN,
        LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN, LANG_HOOKS_EXPR_SIZE,
        LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR,
        LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION, LANG_HOOKS_MAKE_TYPE,
        LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE,
        LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
        LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, LANG_HOOKS_INCOMPLETE_TYPE_ERROR,
        LANG_HOOKS_TYPE_PROMOTES_TO, LANG_HOOKS_REGISTER_BUILTIN_TYPE,
        LANG_HOOKS_GIMPLIFY_EXPR, LANG_HOOKS_FOLD_OBJ_TYPE_REF): Move
        hooks to cp-objcp-common.h.
        (finish_file): New function.
        * cp-objcp-common.c: New file.
        * cp-objcp-common.h: New file.
        * cp-tree.h (cp_finish_file): New prototype.
        * decl.c: Do not include gtype-cp.h.
        * decl2.c (finish_file): Rename to cp_finish_file.

From-SVN: r86837

gcc/cp/ChangeLog
gcc/cp/Make-lang.in
gcc/cp/cp-lang.c
gcc/cp/cp-objcp-common.c [new file with mode: 0644]
gcc/cp/cp-objcp-common.h [new file with mode: 0644]
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c

index 2aaca7d43a2b1511ad246e48067201759ab78825..b942b8202d44314e28a674713082ad36f631c99f 100644 (file)
@@ -1,3 +1,53 @@
+2004-08-31  Ziemowit Laski  <zlaski@apple.com>
+
+       * Make-lang.in (CXX_AND_OBJCXX_OBJS): Add cp/cp-objcp-common.o.
+       (cp/cp-lang.o): Depend on debug.h, gtype-cp.h and cp/cp-objcp-common.h.
+       (cp/cp-decl.c): Do not depend on gtype-cp.h.
+       (cp/cp-objcp-common.o): New target.
+       * cp-lang.c: Include debug.h, cp-objcp-common.h and gtype-cp.h.
+       (cxx_get_alias_set, cxx_warn_unused_global_decl, cp_expr_size,
+       cp_tree_size, cp_var_mod_type_p, cxx_initialize_diagnostics): Move
+       prototypes and definitions to cp-objcp-common.h and cp-objcp-common.c,
+       respectively.
+       (LANG_HOOKS_TREE_SIZE, LANG_HOOKS_FINISH,
+       LANG_HOOKS_CLEAR_BINDING_STACK, LANG_HOOKS_INIT_OPTIONS,
+       LANG_HOOKS_INITIALIZE_DIAGNOSTICS, LANG_HOOKS_HANDLE_OPTION,
+       LANG_HOOKS_HANDLE_FILENAME, LANG_HOOKS_MISSING_ARGUMENT,
+       LANG_HOOKS_POST_OPTIONS, LANG_HOOKS_GET_ALIAS_SET,
+       LANG_HOOKS_EXPAND_CONSTANT, LANG_HOOKS_EXPAND_EXPR,
+       LANG_HOOKS_EXPAND_DECL, LANG_HOOKS_PARSE_FILE,
+       LANG_HOOKS_DUP_LANG_SPECIFIC_DECL, LANG_HOOKS_TRUTHVALUE_CONVERSION,
+       LANG_HOOKS_SET_DECL_ASSEMBLER_NAME, LANG_HOOKS_MARK_ADDRESSABLE,
+       LANG_HOOKS_PRINT_STATISTICS, LANG_HOOKS_PRINT_XNODE,
+       LANG_HOOKS_PRINT_DECL, LANG_HOOKS_PRINT_TYPE,
+       LANG_HOOKS_PRINT_IDENTIFIER, LANG_HOOKS_PRINT_ERROR_FUNCTION,
+       LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, LANG_HOOKS_WRITE_GLOBALS,
+       LANG_HOOKS_FUNCTION_INIT, LANG_HOOKS_FUNCTION_FINAL,
+       LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P,
+       LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE,
+       LANG_HOOKS_ATTRIBUTE_TABLE, LANG_HOOKS_TREE_INLINING_WALK_SUBTREES,
+       LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN,
+       LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS,
+       LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P, 
+       LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P,
+       LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P,
+       LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN,
+       LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN, LANG_HOOKS_EXPR_SIZE,
+       LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR,
+       LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION, LANG_HOOKS_MAKE_TYPE,
+       LANG_HOOKS_TYPE_FOR_MODE, LANG_HOOKS_TYPE_FOR_SIZE,
+       LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
+       LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, LANG_HOOKS_INCOMPLETE_TYPE_ERROR,
+       LANG_HOOKS_TYPE_PROMOTES_TO, LANG_HOOKS_REGISTER_BUILTIN_TYPE,
+       LANG_HOOKS_GIMPLIFY_EXPR, LANG_HOOKS_FOLD_OBJ_TYPE_REF): Move
+       hooks to cp-objcp-common.h.
+       (finish_file): New function.
+       * cp-objcp-common.c: New file.
+       * cp-objcp-common.h: New file.
+       * cp-tree.h (cp_finish_file): New prototype.
+       * decl.c: Do not include gtype-cp.h.
+       * decl2.c (finish_file): Rename to cp_finish_file.
+       
 2004-08-31  Richard Henderson  <rth@redhat.com>
 
        PR c++/17221
index 1d1017776a63792a5e5f87c9b04e1eadde526c1f..3e91bf9078076e1ab7eb3205df6dfffb63acc1bf 100644 (file)
@@ -81,7 +81,7 @@ CXX_AND_OBJCXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
  cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o \
  cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
  cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o cp/optimize.o \
- cp/mangle.o cp/name-lookup.o cp/cxx-pretty-print.o \
+ cp/mangle.o cp/cp-objcp-common.o cp/name-lookup.o cp/cxx-pretty-print.o \
  cp/cp-gimplify.o tree-mudflap.o $(CXX_C_OBJS)
 
 # Language-specific object files for C++.
@@ -224,14 +224,19 @@ CXX_PRETTY_PRINT_H = cp/cxx-pretty-print.h $(C_PRETTY_PRINT_H)
 
 cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) flags.h \
   c-pragma.h toplev.h output.h input.h cp/operators.def $(TM_P_H)
-cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h langhooks.h \
-  $(LANGHOOKS_DEF_H) c-common.h $(CXX_PRETTY_PRINT_H) $(DIAGNOSTIC_H)
+cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h debug.h langhooks.h \
+  $(LANGHOOKS_DEF_H) c-common.h gtype-cp.h $(CXX_PRETTY_PRINT_H) $(DIAGNOSTIC_H) \
+  cp/cp-objcp-common.h
 cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/decl.h stack.h \
   output.h $(EXPR_H) except.h toplev.h $(HASHTAB_H) $(RTL_H) \
   cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h c-pragma.h \
-  debug.h gt-cp-decl.h gtype-cp.h timevar.h $(TREE_FLOW_H)
+  debug.h gt-cp-decl.h timevar.h $(TREE_FLOW_H)
 cp/decl2.o: cp/decl2.c $(CXX_TREE_H) $(TM_H) flags.h cp/decl.h $(EXPR_H) \
   output.h except.h toplev.h $(RTL_H) c-common.h gt-cp-decl2.h cgraph.h
+cp/cp-objcp-common.o : cp/cp-objcp-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
+  $(TM_H) $(TREE_H) $(CXX_TREE_H) c-common.h toplev.h langhooks.h \
+  $(LANGHOOKS_DEF_H) $(DIAGNOSTIC_H) debug.h $(CXX_PRETTY_PRINT_H) \
+  cp/cp-objcp-common.h
 cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h output.h $(TM_P_H) \
    diagnostic.h gt-cp-typeck2.h
 cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
index a1359cd7c869347b6c1f8c032a0345c3b6951ca1..ac89be0f682654046879080ff793cb4f31380ad7 100644 (file)
@@ -31,146 +31,26 @@ Boston, MA 02111-1307, USA.  */
 #include "langhooks-def.h"
 #include "diagnostic.h"
 #include "cxx-pretty-print.h"
+#include "debug.h"
+#include "cp-objcp-common.h"
 
 enum c_language_kind c_language = clk_cxx;
 
-static HOST_WIDE_INT cxx_get_alias_set (tree);
-static bool cxx_warn_unused_global_decl (tree);
-static tree cp_expr_size (tree);
-static size_t cp_tree_size (enum tree_code);
-static bool cp_var_mod_type_p (tree, tree);
+/* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
+   consequently, there should be very few hooks below.  */
+
 static int cxx_types_compatible_p (tree, tree);
-static void cxx_initialize_diagnostics (diagnostic_context *);
 
 #undef LANG_HOOKS_NAME
 #define LANG_HOOKS_NAME "GNU C++"
-#undef LANG_HOOKS_TREE_SIZE
-#define LANG_HOOKS_TREE_SIZE cp_tree_size
 #undef LANG_HOOKS_INIT
 #define LANG_HOOKS_INIT cxx_init
-#undef LANG_HOOKS_FINISH
-#define LANG_HOOKS_FINISH cxx_finish
-#undef LANG_HOOKS_CLEAR_BINDING_STACK
-#define LANG_HOOKS_CLEAR_BINDING_STACK pop_everything
-#undef LANG_HOOKS_INIT_OPTIONS
-#define LANG_HOOKS_INIT_OPTIONS c_common_init_options
-#undef LANG_HOOKS_INITIALIZE_DIAGNOSTICS
-#define LANG_HOOKS_INITIALIZE_DIAGNOSTICS cxx_initialize_diagnostics
-#undef LANG_HOOKS_HANDLE_OPTION
-#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
-#undef LANG_HOOKS_HANDLE_FILENAME
-#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
-#undef LANG_HOOKS_MISSING_ARGUMENT
-#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
-#undef LANG_HOOKS_POST_OPTIONS
-#define LANG_HOOKS_POST_OPTIONS c_common_post_options
-#undef LANG_HOOKS_GET_ALIAS_SET
-#define LANG_HOOKS_GET_ALIAS_SET cxx_get_alias_set
-#undef LANG_HOOKS_EXPAND_CONSTANT
-#define LANG_HOOKS_EXPAND_CONSTANT cplus_expand_constant
-#undef LANG_HOOKS_EXPAND_EXPR
-#define LANG_HOOKS_EXPAND_EXPR cxx_expand_expr
-#undef LANG_HOOKS_EXPAND_DECL
-#define LANG_HOOKS_EXPAND_DECL c_expand_decl
-#undef LANG_HOOKS_PARSE_FILE
-#define LANG_HOOKS_PARSE_FILE c_common_parse_file
-#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
-#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL cxx_dup_lang_specific_decl
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
-#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
-#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME mangle_decl
-#undef LANG_HOOKS_MARK_ADDRESSABLE
-#define LANG_HOOKS_MARK_ADDRESSABLE cxx_mark_addressable
-#undef LANG_HOOKS_PRINT_STATISTICS
-#define LANG_HOOKS_PRINT_STATISTICS cxx_print_statistics
-#undef LANG_HOOKS_PRINT_XNODE
-#define LANG_HOOKS_PRINT_XNODE cxx_print_xnode
-#undef LANG_HOOKS_PRINT_DECL
-#define LANG_HOOKS_PRINT_DECL cxx_print_decl
-#undef LANG_HOOKS_PRINT_TYPE
-#define LANG_HOOKS_PRINT_TYPE cxx_print_type
-#undef LANG_HOOKS_PRINT_IDENTIFIER
-#define LANG_HOOKS_PRINT_IDENTIFIER cxx_print_identifier
 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
 #define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name
-#undef LANG_HOOKS_PRINT_ERROR_FUNCTION
-#define LANG_HOOKS_PRINT_ERROR_FUNCTION        cxx_print_error_function
-#undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
-#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
-#undef LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS lhd_do_nothing
-
-
-#undef LANG_HOOKS_FUNCTION_INIT
-#define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context
-#undef LANG_HOOKS_FUNCTION_FINAL
-#define LANG_HOOKS_FUNCTION_FINAL cxx_pop_function_context
-#undef LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P
-#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P cp_missing_noreturn_ok_p
-
-/* Attribute hooks.  */
-#undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
-#define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE c_common_attribute_table
-#undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE
-#define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE c_common_format_attribute_table
-#undef LANG_HOOKS_ATTRIBUTE_TABLE
-#define LANG_HOOKS_ATTRIBUTE_TABLE cxx_attribute_table
-
-#undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
-#define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES \
-  cp_walk_subtrees
-#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
-#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
-  cp_cannot_inline_tree_fn
-#undef LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS
-#define LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS \
-  cp_add_pending_fn_decls
-#undef LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P
-#define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P \
-  cp_auto_var_in_fn_p
-#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
-#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P anon_aggr_type_p
-#undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P
-#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P cp_var_mod_type_p
-#undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
-#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree
-#undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
-#define LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN cp_type_quals
-#undef LANG_HOOKS_EXPR_SIZE
-#define LANG_HOOKS_EXPR_SIZE cp_expr_size
-
-#undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR
-#define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr
-#undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
-#define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION expand_body
-
-#undef LANG_HOOKS_MAKE_TYPE
-#define LANG_HOOKS_MAKE_TYPE cxx_make_type
-#undef LANG_HOOKS_TYPE_FOR_MODE
-#define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode
-#undef LANG_HOOKS_TYPE_FOR_SIZE
-#define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
-#undef LANG_HOOKS_SIGNED_TYPE
-#define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
-#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
-#undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
-#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error
-#undef LANG_HOOKS_TYPE_PROMOTES_TO
-#define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to
 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
 #define LANG_HOOKS_TYPES_COMPATIBLE_P cxx_types_compatible_p
-#undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
-#define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type
-#undef LANG_HOOKS_GIMPLIFY_EXPR
-#define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr
-#undef LANG_HOOKS_FOLD_OBJ_TYPE_REF
-#define LANG_HOOKS_FOLD_OBJ_TYPE_REF cp_fold_obj_type_ref
 
-/* Each front end provides its own hooks, for toplev.c.  */
+/* Each front end provides its own lang hook initializer.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
 /* Tree code classes.  */
@@ -214,104 +94,8 @@ const char *const tree_code_name[] = {
 };
 #undef DEFTREECODE
 
-/* Special routine to get the alias set for C++.  */
-
-static HOST_WIDE_INT
-cxx_get_alias_set (tree t)
-{
-  if (IS_FAKE_BASE_TYPE (t))
-    /* The base variant of a type must be in the same alias set as the
-       complete type.  */
-    return get_alias_set (TYPE_CONTEXT (t));
-
-  /* Punt on PMFs until we canonicalize functions properly.  */
-  if (TYPE_PTRMEMFUNC_P (t))
-    return 0;
-
-  return c_common_get_alias_set (t);
-}
-
-/* Called from check_global_declarations.  */
-
-static bool
-cxx_warn_unused_global_decl (tree decl)
-{
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
-    return false;
-  if (DECL_IN_SYSTEM_HEADER (decl))
-    return false;
-
-  /* Const variables take the place of #defines in C++.  */
-  if (TREE_CODE (decl) == VAR_DECL && TREE_READONLY (decl))
-    return false;
-
-  return true;
-}
-
-/* Langhook for expr_size: Tell the backend that the value of an expression
-   of non-POD class type does not include any tail padding; a derived class
-   might have allocated something there.  */
-
-static tree
-cp_expr_size (tree exp)
-{
-  if (CLASS_TYPE_P (TREE_TYPE (exp)))
-    {
-      /* The backend should not be interested in the size of an expression
-        of a type with both of these set; all copies of such types must go
-        through a constructor or assignment op.  */
-      gcc_assert (!TYPE_HAS_COMPLEX_INIT_REF (TREE_TYPE (exp))
-                 || !TYPE_HAS_COMPLEX_ASSIGN_REF (TREE_TYPE (exp))
-                 /* But storing a CONSTRUCTOR isn't a copy.  */
-                 || TREE_CODE (exp) == CONSTRUCTOR);
-      
-      /* This would be wrong for a type with virtual bases, but they are
-        caught by the assert above.  */
-      return (is_empty_class (TREE_TYPE (exp))
-             ? size_zero_node
-             : CLASSTYPE_SIZE_UNIT (TREE_TYPE (exp)));
-    }
-  else
-    /* Use the default code.  */
-    return lhd_expr_size (exp);
-}
-
-/* Langhook for tree_size: determine size of our 'x' and 'c' nodes.  */
-static size_t
-cp_tree_size (enum tree_code code)
-{
-  switch (code)
-    {
-    case TINST_LEVEL:          return sizeof (struct tinst_level_s);
-    case PTRMEM_CST:           return sizeof (struct ptrmem_cst);
-    case BASELINK:             return sizeof (struct tree_baselink);
-    case TEMPLATE_PARM_INDEX:  return sizeof (template_parm_index);
-    case DEFAULT_ARG:          return sizeof (struct tree_default_arg);
-    case OVERLOAD:             return sizeof (struct tree_overload);
-    default:
-      gcc_unreachable ();
-    }
-  /* NOTREACHED */
-}
-
-/* Returns true if T is a variably modified type, in the sense of C99.
-   FN is as passed to variably_modified_p.
-   This routine needs only check cases that cannot be handled by the
-   language-independent logic in tree.c.  */
-
-static bool
-cp_var_mod_type_p (tree type, tree fn)
-{
-  /* If TYPE is a pointer-to-member, it is variably modified if either
-     the class or the member are variably modified.  */
-  if (TYPE_PTR_TO_MEMBER_P (type))
-    return (variably_modified_type_p (TYPE_PTRMEM_CLASS_TYPE (type), fn)
-           || variably_modified_type_p (TYPE_PTRMEM_POINTED_TO_TYPE (type),
-                                        fn));
-
-  /* All other types are not variably modified.  */
-  return false;
-}
+/* Lang hook routines common to C++ and ObjC++ appear in cp/cp-objcp-common.c;
+   there should be very few routines below.  */
 
 /* This compares two types for equivalence ("compatible" in C-based languages).
    This routine should only return 1 if it is sure.  It should not be used
@@ -332,35 +116,21 @@ static int cxx_types_compatible_p (tree x, tree y)
   return 0;
 }
 
-/* Construct a C++-aware pretty-printer for CONTEXT.  It is assumed
-   that CONTEXT->printer is an already constructed basic pretty_printer.  */
-static void
-cxx_initialize_diagnostics (diagnostic_context *context)
-{
-  pretty_printer *base = context->printer;
-  cxx_pretty_printer *pp = xmalloc (sizeof (cxx_pretty_printer));
-  memcpy (pp_base (pp), base, sizeof (pretty_printer));
-  pp_cxx_pretty_printer_init (pp);
-  context->printer = (pretty_printer *) pp;
+/* The following function does something real, but only in Objective-C++.  */
 
-  /* It is safe to free this object because it was previously malloc()'d.  */
-  free (base);
-}
-
-/* Stubs to keep c-opts.c happy.  */
-void
-push_file_scope (void)
+tree
+objcp_tsubst_copy_and_build (tree t ATTRIBUTE_UNUSED, tree args ATTRIBUTE_UNUSED, 
+                            tsubst_flags_t complain ATTRIBUTE_UNUSED, 
+                            tree in_decl ATTRIBUTE_UNUSED,
+                            bool function_p ATTRIBUTE_UNUSED)
 {
+  return NULL_TREE;
 }
 
 void
-pop_file_scope (void)
+finish_file (void)
 {
+  cp_finish_file ();
 }
 
-/* c-pragma.c needs to query whether a decl has extern "C" linkage.  */
-bool
-has_c_linkage (tree decl)
-{
-  return DECL_EXTERN_C_P (decl);
-}
+#include "gtype-cp.h"
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
new file mode 100644 (file)
index 0000000..b8b8bad
--- /dev/null
@@ -0,0 +1,167 @@
+/* Some code common to C++ and ObjC++ front ends.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Contributed by Ziemowit Laski  <zlaski@apple.com>
+
+This file is part of GCC.
+
+GCC 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.
+
+GCC 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 GCC; 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 "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "c-common.h"
+#include "toplev.h"
+#include "langhooks.h"
+#include "langhooks-def.h"
+#include "diagnostic.h"
+#include "debug.h"
+#include "cxx-pretty-print.h"
+#include "cp-objcp-common.h"
+
+/* Special routine to get the alias set for C++.  */
+
+HOST_WIDE_INT
+cxx_get_alias_set (tree t)
+{
+  if (IS_FAKE_BASE_TYPE (t))
+    /* The base variant of a type must be in the same alias set as the
+       complete type.  */
+    return get_alias_set (TYPE_CONTEXT (t));
+
+  /* Punt on PMFs until we canonicalize functions properly.  */
+  if (TYPE_PTRMEMFUNC_P (t))
+    return 0;
+
+  return c_common_get_alias_set (t);
+}
+
+/* Called from check_global_declarations.  */
+
+bool
+cxx_warn_unused_global_decl (tree decl)
+{
+  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
+    return false;
+  if (DECL_IN_SYSTEM_HEADER (decl))
+    return false;
+
+  /* Const variables take the place of #defines in C++.  */
+  if (TREE_CODE (decl) == VAR_DECL && TREE_READONLY (decl))
+    return false;
+
+  return true;
+}
+
+/* Langhook for expr_size: Tell the backend that the value of an expression
+   of non-POD class type does not include any tail padding; a derived class
+   might have allocated something there.  */
+
+tree
+cp_expr_size (tree exp)
+{
+  if (CLASS_TYPE_P (TREE_TYPE (exp)))
+    {
+      /* The backend should not be interested in the size of an expression
+        of a type with both of these set; all copies of such types must go
+        through a constructor or assignment op.  */
+      gcc_assert (!TYPE_HAS_COMPLEX_INIT_REF (TREE_TYPE (exp))
+                 || !TYPE_HAS_COMPLEX_ASSIGN_REF (TREE_TYPE (exp))
+                 /* But storing a CONSTRUCTOR isn't a copy.  */
+                 || TREE_CODE (exp) == CONSTRUCTOR);
+      
+      /* This would be wrong for a type with virtual bases, but they are
+        caught by the assert above.  */
+      return (is_empty_class (TREE_TYPE (exp))
+             ? size_zero_node
+             : CLASSTYPE_SIZE_UNIT (TREE_TYPE (exp)));
+    }
+  else
+    /* Use the default code.  */
+    return lhd_expr_size (exp);
+}
+
+/* Langhook for tree_size: determine size of our 'x' and 'c' nodes.  */
+size_t
+cp_tree_size (enum tree_code code)
+{
+  switch (code)
+    {
+    case TINST_LEVEL:          return sizeof (struct tinst_level_s);
+    case PTRMEM_CST:           return sizeof (struct ptrmem_cst);
+    case BASELINK:             return sizeof (struct tree_baselink);
+    case TEMPLATE_PARM_INDEX:  return sizeof (template_parm_index);
+    case DEFAULT_ARG:          return sizeof (struct tree_default_arg);
+    case OVERLOAD:             return sizeof (struct tree_overload);
+    default:
+      gcc_unreachable ();
+    }
+  /* NOTREACHED */
+}
+
+/* Returns true if T is a variably modified type, in the sense of C99.
+   FN is as passed to variably_modified_p.
+   This routine needs only check cases that cannot be handled by the
+   language-independent logic in tree.c.  */
+
+bool
+cp_var_mod_type_p (tree type, tree fn)
+{
+  /* If TYPE is a pointer-to-member, it is variably modified if either
+     the class or the member are variably modified.  */
+  if (TYPE_PTR_TO_MEMBER_P (type))
+    return (variably_modified_type_p (TYPE_PTRMEM_CLASS_TYPE (type), fn)
+           || variably_modified_type_p (TYPE_PTRMEM_POINTED_TO_TYPE (type),
+                                        fn));
+
+  /* All other types are not variably modified.  */
+  return false;
+}
+
+/* Construct a C++-aware pretty-printer for CONTEXT.  It is assumed
+   that CONTEXT->printer is an already constructed basic pretty_printer.  */
+void
+cxx_initialize_diagnostics (diagnostic_context *context)
+{
+  pretty_printer *base = context->printer;
+  cxx_pretty_printer *pp = xmalloc (sizeof (cxx_pretty_printer));
+  memcpy (pp_base (pp), base, sizeof (pretty_printer));
+  pp_cxx_pretty_printer_init (pp);
+  context->printer = (pretty_printer *) pp;
+
+  /* It is safe to free this object because it was previously malloc()'d.  */
+  free (base);
+}
+
+/* Stubs to keep c-opts.c happy.  */
+void
+push_file_scope (void)
+{
+}
+
+void
+pop_file_scope (void)
+{
+}
+
+/* c-pragma.c needs to query whether a decl has extern "C" linkage.  */
+bool
+has_c_linkage (tree decl)
+{
+  return DECL_EXTERN_C_P (decl);
+}
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
new file mode 100644 (file)
index 0000000..1599080
--- /dev/null
@@ -0,0 +1,162 @@
+/* Language hooks common to C++ and ObjC++ front ends.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Contributed by Ziemowit Laski  <zlaski@apple.com>
+
+This file is part of GCC.
+
+GCC 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.
+
+GCC 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 GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#ifndef GCC_CP_OBJCP_COMMON
+#define GCC_CP_OBJCP_COMMON
+
+/* In cp/cp-objcp-common.c.  */
+
+extern HOST_WIDE_INT cxx_get_alias_set (tree);
+extern bool cxx_warn_unused_global_decl (tree);
+extern tree cp_expr_size (tree);
+extern size_t cp_tree_size (enum tree_code);
+extern bool cp_var_mod_type_p (tree, tree);
+extern void cxx_initialize_diagnostics (struct diagnostic_context *);
+
+/* In cp/cp-lang.c and objcp/objcp-lang.c.  */
+
+extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t, 
+                                        tree, bool);
+
+/* Lang hooks that are shared between C++ and ObjC++ are defined here.  Hooks
+   specific to C++ or ObjC++ go in cp/cp-lang.c and objcp/objcp-lang.c,
+   respectively.  */
+
+#undef LANG_HOOKS_TREE_SIZE
+#define LANG_HOOKS_TREE_SIZE cp_tree_size
+#undef LANG_HOOKS_FINISH
+#define LANG_HOOKS_FINISH cxx_finish
+#undef LANG_HOOKS_CLEAR_BINDING_STACK
+#define LANG_HOOKS_CLEAR_BINDING_STACK pop_everything
+#undef LANG_HOOKS_INIT_OPTIONS
+#define LANG_HOOKS_INIT_OPTIONS c_common_init_options
+#undef LANG_HOOKS_INITIALIZE_DIAGNOSTICS
+#define LANG_HOOKS_INITIALIZE_DIAGNOSTICS cxx_initialize_diagnostics
+#undef LANG_HOOKS_HANDLE_OPTION
+#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
+#undef LANG_HOOKS_HANDLE_FILENAME
+#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
+#undef LANG_HOOKS_MISSING_ARGUMENT
+#define LANG_HOOKS_MISSING_ARGUMENT c_common_missing_argument
+#undef LANG_HOOKS_POST_OPTIONS
+#define LANG_HOOKS_POST_OPTIONS c_common_post_options
+#undef LANG_HOOKS_GET_ALIAS_SET
+#define LANG_HOOKS_GET_ALIAS_SET cxx_get_alias_set
+#undef LANG_HOOKS_EXPAND_CONSTANT
+#define LANG_HOOKS_EXPAND_CONSTANT cplus_expand_constant
+#undef LANG_HOOKS_EXPAND_EXPR
+#define LANG_HOOKS_EXPAND_EXPR cxx_expand_expr
+#undef LANG_HOOKS_EXPAND_DECL
+#define LANG_HOOKS_EXPAND_DECL c_expand_decl
+#undef LANG_HOOKS_PARSE_FILE
+#define LANG_HOOKS_PARSE_FILE c_common_parse_file
+#undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
+#define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL cxx_dup_lang_specific_decl
+#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
+#undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
+#define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME mangle_decl
+#undef LANG_HOOKS_MARK_ADDRESSABLE
+#define LANG_HOOKS_MARK_ADDRESSABLE cxx_mark_addressable
+#undef LANG_HOOKS_PRINT_STATISTICS
+#define LANG_HOOKS_PRINT_STATISTICS cxx_print_statistics
+#undef LANG_HOOKS_PRINT_XNODE
+#define LANG_HOOKS_PRINT_XNODE cxx_print_xnode
+#undef LANG_HOOKS_PRINT_DECL
+#define LANG_HOOKS_PRINT_DECL cxx_print_decl
+#undef LANG_HOOKS_PRINT_TYPE
+#define LANG_HOOKS_PRINT_TYPE cxx_print_type
+#undef LANG_HOOKS_PRINT_IDENTIFIER
+#define LANG_HOOKS_PRINT_IDENTIFIER cxx_print_identifier
+#undef LANG_HOOKS_PRINT_ERROR_FUNCTION
+#define LANG_HOOKS_PRINT_ERROR_FUNCTION        cxx_print_error_function
+#undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
+#define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl
+#undef LANG_HOOKS_WRITE_GLOBALS
+#define LANG_HOOKS_WRITE_GLOBALS lhd_do_nothing
+
+#undef LANG_HOOKS_FUNCTION_INIT
+#define LANG_HOOKS_FUNCTION_INIT cxx_push_function_context
+#undef LANG_HOOKS_FUNCTION_FINAL
+#define LANG_HOOKS_FUNCTION_FINAL cxx_pop_function_context
+#undef LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P
+#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P cp_missing_noreturn_ok_p
+
+/* Attribute hooks.  */
+#undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
+#define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE c_common_attribute_table
+#undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE
+#define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE c_common_format_attribute_table
+#undef LANG_HOOKS_ATTRIBUTE_TABLE
+#define LANG_HOOKS_ATTRIBUTE_TABLE cxx_attribute_table
+
+#undef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES
+#define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES \
+  cp_walk_subtrees
+#undef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN
+#define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \
+  cp_cannot_inline_tree_fn
+#undef LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS
+#define LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS \
+  cp_add_pending_fn_decls
+#undef LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P
+#define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P \
+  cp_auto_var_in_fn_p
+#undef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P
+#define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P anon_aggr_type_p
+#undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P
+#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P cp_var_mod_type_p
+#undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
+#define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree
+#undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
+#define LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN cp_type_quals
+#undef LANG_HOOKS_EXPR_SIZE
+#define LANG_HOOKS_EXPR_SIZE cp_expr_size
+
+#undef LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR
+#define LANG_HOOKS_CALLGRAPH_ANALYZE_EXPR cxx_callgraph_analyze_expr
+#undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
+#define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION expand_body
+
+#undef LANG_HOOKS_MAKE_TYPE
+#define LANG_HOOKS_MAKE_TYPE cxx_make_type
+#undef LANG_HOOKS_TYPE_FOR_MODE
+#define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode
+#undef LANG_HOOKS_TYPE_FOR_SIZE
+#define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
+#undef LANG_HOOKS_SIGNED_TYPE
+#define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
+#undef LANG_HOOKS_UNSIGNED_TYPE
+#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
+#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
+#undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
+#define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error
+#undef LANG_HOOKS_TYPE_PROMOTES_TO
+#define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to
+#undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
+#define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type
+#undef LANG_HOOKS_GIMPLIFY_EXPR
+#define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr
+#undef LANG_HOOKS_FOLD_OBJ_TYPE_REF
+#define LANG_HOOKS_FOLD_OBJ_TYPE_REF cp_fold_obj_type_ref
+
+#endif /* GCC_CP_OBJCP_COMMON */
index 9e894ff2370a18102966f57fe75c14b239d5a73b..8267f725139699588bd9392e187f83b99e602ead 100644 (file)
@@ -3815,6 +3815,7 @@ extern tree groktypefield                 (tree, tree);
 extern void cplus_decl_attributes (tree *, tree, int);
 extern void finish_anon_union (tree);
 extern tree finish_table (tree, tree, tree, int);
+extern void cp_finish_file (void);
 extern tree coerce_new_type (tree);
 extern tree coerce_delete_type (tree);
 extern void comdat_linkage (tree);
index 2932ae9a484fce3af031909ec8729f13c107ed05..55db551001b9f65f93ec665cdaab37e6464c9e3c 100644 (file)
@@ -10834,4 +10834,3 @@ cp_missing_noreturn_ok_p (tree decl)
 }
 
 #include "gt-cp-decl.h"
-#include "gtype-cp.h"
index 5e0651e79bdf16073daf6b4d6119a6f6ab9cc668..33a9ef52243b64377e276deb3a3cebc56f011a4c 100644 (file)
@@ -1399,7 +1399,7 @@ maybe_make_one_only (tree decl)
   if (! flag_weak)
     return;
 
-  /* We can't set DECL_COMDAT on functions, or finish_file will think
+  /* We can't set DECL_COMDAT on functions, or cp_finish_file will think
      we can get away with not emitting them if they aren't used.  We need
      to for variables so that cp_finish_decl will update their linkage,
      because their DECL_INITIAL may not have been set properly yet.  */
@@ -2709,7 +2709,7 @@ cxx_callgraph_analyze_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
    first, since that way we only need to reverse the decls once.  */
 
 void
-finish_file (void)
+cp_finish_file (void)
 {
   tree vars;
   bool reconsider;