This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][C] Move C lang_decl and lang_type to language specific header (need help with gc)
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Thu, 20 Aug 2009 16:10:21 +0200 (CEST)
- Subject: Re: [PATCH][C] Move C lang_decl and lang_type to language specific header (need help with gc)
- References: <alpine.LNX.2.00.0908201442570.16347@zhemvz.fhfr.qr>
On Thu, 20 Aug 2009, Richard Guenther wrote:
>
> This removes lang_decl for C (it's empty) and moves lang_type to
> c-lang.h. This avoids having two different lang_decl / lang_type
> definitions in the cc1plus executable (and thus cc1plus build with -flto
> fails).
>
> I need help with the GTY machinery - either I get undefined
> references to gt_pch_nx_lang_decl or I get incomplete lang_type
> in gtype-desc.c. Any ideas?
>
> The lang_decl removal bootstrapped and tested ok.
The following seems to work. Ok if it bootstraps and tests ok?
Thanks,
Richard.
2009-08-20 Richard Guenther <rguenther@suse.de>
* c-objc-common.h (LANG_HOOKS_DUP_LANG_SPECIFIC_DECL): Do not
define.
* c-tree.h (c_dup_lang_specific_decl): Remove.
(struct lang_decl, struct lang_type): Move definitions ...
* c-lang.h: ... here. New file.
* c-decl.c: Include c-lang.h.
(c_dup_lang_specific_decl): Remove.
* c-typeck.c: Include c-lang.h.
* Makefile.in (c-decl.o): Add c-lang.h dependency.
(c-typeck.o): Likewise.
* c-config-lang.in (gtfiles): Add c-lang.h.
* gengtype.c (get_output_file_with_visibility): Handle c-lang.h
like c-tree.h.
objc/
* objc-act.c: Include c-lang.h
* Make-lang.in (objc/objc-act.o): Add c-lang.h dependency.
Index: gcc/c-objc-common.h
===================================================================
*** gcc/c-objc-common.h.orig 2009-08-20 15:43:13.000000000 +0200
--- gcc/c-objc-common.h 2009-08-20 16:07:18.000000000 +0200
*************** along with GCC; see the file COPYING3.
*** 54,61 ****
#define LANG_HOOKS_TYPES_COMPATIBLE_P c_types_compatible_p
#undef LANG_HOOKS_MISSING_NORETURN_OK_P
#define LANG_HOOKS_MISSING_NORETURN_OK_P c_missing_noreturn_ok_p
- #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
- #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL c_dup_lang_specific_decl
#undef LANG_HOOKS_BUILTIN_FUNCTION
#define LANG_HOOKS_BUILTIN_FUNCTION c_builtin_function
#undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE
--- 54,59 ----
Index: gcc/c-tree.h
===================================================================
*** gcc/c-tree.h.orig 2009-08-20 15:43:13.000000000 +0200
--- gcc/c-tree.h 2009-08-20 16:07:18.000000000 +0200
*************** along with GCC; see the file COPYING3.
*** 31,42 ****
#define C_SIZEOF_STRUCT_LANG_IDENTIFIER \
(sizeof (struct c_common_identifier) + 3 * sizeof (void *))
- /* Language-specific declaration information. */
-
- struct GTY(()) lang_decl {
- char dummy;
- };
-
/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1 (TYPE)
--- 31,36 ----
*************** struct GTY(()) lang_decl {
*** 56,73 ****
and C_RID_YYCODE is the token number wanted by Yacc. */
#define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_0 (ID)
- struct GTY(()) lang_type {
- /* In a RECORD_TYPE, a sorted array of the fields of the type. */
- struct sorted_fields_type * GTY ((reorder ("resort_sorted_fields"))) s;
- /* In an ENUMERAL_TYPE, the min and max values. */
- tree enum_min;
- tree enum_max;
- /* In a RECORD_TYPE, information specific to Objective-C, such
- as a list of adopted protocols or a pointer to a corresponding
- @interface. See objc/objc-act.h for details. */
- tree objc_info;
- };
-
/* Record whether a type or decl was written with nonconstant size.
Note that TYPE_SIZE may have simplified to a constant. */
#define C_TYPE_VARIABLE_SIZE(TYPE) TYPE_LANG_FLAG_1 (TYPE)
--- 50,55 ----
*************** extern void c_bindings_end_stmt_expr (st
*** 444,450 ****
extern void record_inline_static (location_t, tree, tree,
enum c_inline_static_type);
extern void c_init_decl_processing (void);
- extern void c_dup_lang_specific_decl (tree);
extern void c_print_identifier (FILE *, tree, int);
extern int quals_from_declspecs (const struct c_declspecs *);
extern struct c_declarator *build_array_declarator (location_t, tree,
--- 426,431 ----
Index: gcc/c-decl.c
===================================================================
*** gcc/c-decl.c.orig 2009-08-20 15:43:13.000000000 +0200
--- gcc/c-decl.c 2009-08-20 16:07:18.000000000 +0200
*************** along with GCC; see the file COPYING3.
*** 50,55 ****
--- 50,56 ----
#include "timevar.h"
#include "c-common.h"
#include "c-pragma.h"
+ #include "c-lang.h"
#include "langhooks.h"
#include "tree-mudflap.h"
#include "gimple.h"
*************** c_pop_function_context (void)
*** 8136,8156 ****
warn_about_return_type = p->warn_about_return_type;
}
- /* Copy the DECL_LANG_SPECIFIC data associated with DECL. */
-
- void
- c_dup_lang_specific_decl (tree decl)
- {
- struct lang_decl *ld;
-
- if (!DECL_LANG_SPECIFIC (decl))
- return;
-
- ld = GGC_NEW (struct lang_decl);
- memcpy (ld, DECL_LANG_SPECIFIC (decl), sizeof (struct lang_decl));
- DECL_LANG_SPECIFIC (decl) = ld;
- }
-
/* The functions below are required for functionality of doing
function at once processing in the C front end. Currently these
functions are not called from anywhere in the C front end, but as
--- 8137,8142 ----
Index: gcc/Makefile.in
===================================================================
*** gcc/Makefile.in.orig 2009-08-20 15:43:13.000000000 +0200
--- gcc/Makefile.in 2009-08-20 16:07:18.000000000 +0200
*************** c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM
*** 1925,1935 ****
opts.h $(C_PRAGMA_H) gt-c-decl.h $(CGRAPH_H) $(HASHTAB_H) libfuncs.h \
$(EXCEPT_H) $(LANGHOOKS_DEF_H) $(TREE_DUMP_H) $(C_COMMON_H) $(CPPLIB_H) \
$(DIAGNOSTIC_H) $(INPUT_H) langhooks.h $(GIMPLE_H) tree-mudflap.h \
! pointer-set.h $(BASIC_BLOCK_H) $(GIMPLE_H) tree-iterator.h
c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(C_TREE_H) $(TARGET_H) $(FLAGS_H) intl.h output.h $(EXPR_H) \
$(RTL_H) $(TOPLEV_H) $(TM_P_H) langhooks.h $(GGC_H) $(TREE_FLOW_H) \
! $(GIMPLE_H) tree-iterator.h
c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) $(DIAGNOSTIC_H) \
$(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-c.h \
--- 1925,1935 ----
opts.h $(C_PRAGMA_H) gt-c-decl.h $(CGRAPH_H) $(HASHTAB_H) libfuncs.h \
$(EXCEPT_H) $(LANGHOOKS_DEF_H) $(TREE_DUMP_H) $(C_COMMON_H) $(CPPLIB_H) \
$(DIAGNOSTIC_H) $(INPUT_H) langhooks.h $(GIMPLE_H) tree-mudflap.h \
! pointer-set.h $(BASIC_BLOCK_H) $(GIMPLE_H) tree-iterator.h c-lang.h
c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(C_TREE_H) $(TARGET_H) $(FLAGS_H) intl.h output.h $(EXPR_H) \
$(RTL_H) $(TOPLEV_H) $(TM_P_H) langhooks.h $(GGC_H) $(TREE_FLOW_H) \
! $(GIMPLE_H) tree-iterator.h c-lang.h
c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) $(DIAGNOSTIC_H) \
$(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-c.h \
Index: gcc/c-config-lang.in
===================================================================
*** gcc/c-config-lang.in.orig 2009-08-20 15:43:13.000000000 +0200
--- gcc/c-config-lang.in 2009-08-20 16:07:18.000000000 +0200
***************
*** 22,25 ****
# files used by C that have garbage collection GTY macros in them
# which therefore need to be scanned by gengtype.c.
! gtfiles="\$(srcdir)/c-lang.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.h \$(srcdir)/c-pragma.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-parser.c"
--- 22,25 ----
# files used by C that have garbage collection GTY macros in them
# which therefore need to be scanned by gengtype.c.
! gtfiles="\$(srcdir)/c-lang.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.h \$(srcdir)/c-pragma.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-parser.c \$(srcdir)/c-lang.h"
Index: gcc/c-lang.h
===================================================================
*** /dev/null 1970-01-01 00:00:00.000000000 +0000
--- gcc/c-lang.h 2009-08-20 16:07:18.000000000 +0200
***************
*** 0 ****
--- 1,43 ----
+ /* Definitions for C language specific types.
+ Copyright (C) 2009
+ Free Software Foundation, Inc.
+
+ 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 3, 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 COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+ #ifndef GCC_C_LANG_H
+ #define GCC_C_LANG_H
+
+ #include "c-common.h"
+ #include "ggc.h"
+
+ struct GTY(()) lang_type {
+ /* In a RECORD_TYPE, a sorted array of the fields of the type. */
+ struct sorted_fields_type * GTY ((reorder ("resort_sorted_fields"))) s;
+ /* In an ENUMERAL_TYPE, the min and max values. */
+ tree enum_min;
+ tree enum_max;
+ /* In a RECORD_TYPE, information specific to Objective-C, such
+ as a list of adopted protocols or a pointer to a corresponding
+ @interface. See objc/objc-act.h for details. */
+ tree objc_info;
+ };
+
+ struct GTY(()) lang_decl {
+ char dummy;
+ };
+
+ #endif /* ! GCC_C_LANG_H */
Index: gcc/c-typeck.c
===================================================================
*** gcc/c-typeck.c.orig 2009-08-20 15:43:13.000000000 +0200
--- gcc/c-typeck.c 2009-08-20 16:07:18.000000000 +0200
*************** along with GCC; see the file COPYING3.
*** 33,38 ****
--- 33,39 ----
#include "tree.h"
#include "langhooks.h"
#include "c-tree.h"
+ #include "c-lang.h"
#include "tm_p.h"
#include "flags.h"
#include "output.h"
Index: gcc/gengtype.c
===================================================================
*** gcc/gengtype.c.orig 2009-08-20 15:43:13.000000000 +0200
--- gcc/gengtype.c 2009-08-20 16:07:18.000000000 +0200
*************** get_output_file_with_visibility (const c
*** 1741,1746 ****
--- 1741,1748 ----
headers with source files (and their special purpose gt-*.h headers). */
else if (strcmp (basename, "c-common.h") == 0)
output_name = "gt-c-common.h", for_name = "c-common.c";
+ else if (strcmp (basename, "c-lang.h") == 0)
+ output_name = "gt-c-decl.h", for_name = "c-decl.c";
else if (strcmp (basename, "c-tree.h") == 0)
output_name = "gt-c-decl.h", for_name = "c-decl.c";
else if (strncmp (basename, "cp", 2) == 0 && IS_DIR_SEPARATOR (basename[2])
Index: gcc/objc/Make-lang.in
===================================================================
*** gcc/objc/Make-lang.in.orig 2009-07-16 12:09:33.000000000 +0200
--- gcc/objc/Make-lang.in 2009-08-20 16:08:10.000000000 +0200
*************** objc/objc-act.o : objc/objc-act.c \
*** 79,85 ****
$(EXPR_H) $(TARGET_H) $(C_TREE_H) $(DIAGNOSTIC_H) toplev.h $(FLAGS_H) \
objc/objc-act.h input.h $(FUNCTION_H) output.h debug.h langhooks.h \
$(LANGHOOKS_DEF_H) $(HASHTAB_H) $(C_PRAGMA_H) gt-objc-objc-act.h \
! $(GIMPLE_H)
objc.srcextra:
--- 79,85 ----
$(EXPR_H) $(TARGET_H) $(C_TREE_H) $(DIAGNOSTIC_H) toplev.h $(FLAGS_H) \
objc/objc-act.h input.h $(FUNCTION_H) output.h debug.h langhooks.h \
$(LANGHOOKS_DEF_H) $(HASHTAB_H) $(C_PRAGMA_H) gt-objc-objc-act.h \
! $(GIMPLE_H) c-lang.h
objc.srcextra:
Index: gcc/objc/objc-act.c
===================================================================
*** gcc/objc/objc-act.c.orig 2009-07-17 11:07:17.000000000 +0200
--- gcc/objc/objc-act.c 2009-08-20 16:07:42.000000000 +0200
*************** along with GCC; see the file COPYING3.
*** 56,61 ****
--- 56,62 ----
#include "c-common.h"
#include "c-pragma.h"
+ #include "c-lang.h"
#include "flags.h"
#include "langhooks.h"
#include "objc-act.h"