xref: /openbsd-src/gnu/gcc/gcc/cp/cp-lang.c (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert /* Language-dependent hooks for C++.
2*404b540aSrobert    Copyright 2001, 2002, 2004 Free Software Foundation, Inc.
3*404b540aSrobert    Contributed by Alexandre Oliva  <aoliva@redhat.com>
4*404b540aSrobert 
5*404b540aSrobert This file is part of GCC.
6*404b540aSrobert 
7*404b540aSrobert GCC is free software; you can redistribute it and/or modify
8*404b540aSrobert it under the terms of the GNU General Public License as published by
9*404b540aSrobert the Free Software Foundation; either version 2, or (at your option)
10*404b540aSrobert any later version.
11*404b540aSrobert 
12*404b540aSrobert GCC is distributed in the hope that it will be useful,
13*404b540aSrobert but WITHOUT ANY WARRANTY; without even the implied warranty of
14*404b540aSrobert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*404b540aSrobert GNU General Public License for more details.
16*404b540aSrobert 
17*404b540aSrobert You should have received a copy of the GNU General Public License
18*404b540aSrobert along with GCC; see the file COPYING.  If not, write to
19*404b540aSrobert the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20*404b540aSrobert Boston, MA 02110-1301, USA.  */
21*404b540aSrobert 
22*404b540aSrobert #include "config.h"
23*404b540aSrobert #include "system.h"
24*404b540aSrobert #include "coretypes.h"
25*404b540aSrobert #include "tm.h"
26*404b540aSrobert #include "tree.h"
27*404b540aSrobert #include "cp-tree.h"
28*404b540aSrobert #include "c-common.h"
29*404b540aSrobert #include "toplev.h"
30*404b540aSrobert #include "langhooks.h"
31*404b540aSrobert #include "langhooks-def.h"
32*404b540aSrobert #include "diagnostic.h"
33*404b540aSrobert #include "debug.h"
34*404b540aSrobert #include "cp-objcp-common.h"
35*404b540aSrobert #include "hashtab.h"
36*404b540aSrobert 
37*404b540aSrobert enum c_language_kind c_language = clk_cxx;
38*404b540aSrobert static void cp_init_ts (void);
39*404b540aSrobert 
40*404b540aSrobert /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
41*404b540aSrobert    consequently, there should be very few hooks below.  */
42*404b540aSrobert 
43*404b540aSrobert #undef LANG_HOOKS_NAME
44*404b540aSrobert #define LANG_HOOKS_NAME "GNU C++"
45*404b540aSrobert #undef LANG_HOOKS_INIT
46*404b540aSrobert #define LANG_HOOKS_INIT cxx_init
47*404b540aSrobert #undef LANG_HOOKS_DECL_PRINTABLE_NAME
48*404b540aSrobert #define LANG_HOOKS_DECL_PRINTABLE_NAME	cxx_printable_name
49*404b540aSrobert #undef LANG_HOOKS_FOLD_OBJ_TYPE_REF
50*404b540aSrobert #define LANG_HOOKS_FOLD_OBJ_TYPE_REF cp_fold_obj_type_ref
51*404b540aSrobert #undef LANG_HOOKS_INIT_TS
52*404b540aSrobert #define LANG_HOOKS_INIT_TS cp_init_ts
53*404b540aSrobert 
54*404b540aSrobert /* Each front end provides its own lang hook initializer.  */
55*404b540aSrobert const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
56*404b540aSrobert 
57*404b540aSrobert /* Tree code classes.  */
58*404b540aSrobert 
59*404b540aSrobert #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
60*404b540aSrobert 
61*404b540aSrobert const enum tree_code_class tree_code_type[] = {
62*404b540aSrobert #include "tree.def"
63*404b540aSrobert   tcc_exceptional,
64*404b540aSrobert #include "c-common.def"
65*404b540aSrobert   tcc_exceptional,
66*404b540aSrobert #include "cp-tree.def"
67*404b540aSrobert };
68*404b540aSrobert #undef DEFTREECODE
69*404b540aSrobert 
70*404b540aSrobert /* Table indexed by tree code giving number of expression
71*404b540aSrobert    operands beyond the fixed part of the node structure.
72*404b540aSrobert    Not used for types or decls.  */
73*404b540aSrobert 
74*404b540aSrobert #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
75*404b540aSrobert 
76*404b540aSrobert const unsigned char tree_code_length[] = {
77*404b540aSrobert #include "tree.def"
78*404b540aSrobert   0,
79*404b540aSrobert #include "c-common.def"
80*404b540aSrobert   0,
81*404b540aSrobert #include "cp-tree.def"
82*404b540aSrobert };
83*404b540aSrobert #undef DEFTREECODE
84*404b540aSrobert 
85*404b540aSrobert /* Names of tree components.
86*404b540aSrobert    Used for printing out the tree and error messages.  */
87*404b540aSrobert #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
88*404b540aSrobert 
89*404b540aSrobert const char *const tree_code_name[] = {
90*404b540aSrobert #include "tree.def"
91*404b540aSrobert   "@@dummy",
92*404b540aSrobert #include "c-common.def"
93*404b540aSrobert   "@@dummy",
94*404b540aSrobert #include "cp-tree.def"
95*404b540aSrobert };
96*404b540aSrobert #undef DEFTREECODE
97*404b540aSrobert 
98*404b540aSrobert /* Lang hook routines common to C++ and ObjC++ appear in cp/cp-objcp-common.c;
99*404b540aSrobert    there should be very few routines below.  */
100*404b540aSrobert 
101*404b540aSrobert /* The following function does something real, but only in Objective-C++.  */
102*404b540aSrobert 
103*404b540aSrobert 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)104*404b540aSrobert objcp_tsubst_copy_and_build (tree t ATTRIBUTE_UNUSED,
105*404b540aSrobert 			     tree args ATTRIBUTE_UNUSED,
106*404b540aSrobert 			     tsubst_flags_t complain ATTRIBUTE_UNUSED,
107*404b540aSrobert 			     tree in_decl ATTRIBUTE_UNUSED,
108*404b540aSrobert 			     bool function_p ATTRIBUTE_UNUSED)
109*404b540aSrobert {
110*404b540aSrobert   return NULL_TREE;
111*404b540aSrobert }
112*404b540aSrobert 
113*404b540aSrobert 
114*404b540aSrobert static void
cp_init_ts(void)115*404b540aSrobert cp_init_ts (void)
116*404b540aSrobert {
117*404b540aSrobert   tree_contains_struct[NAMESPACE_DECL][TS_DECL_NON_COMMON] = 1;
118*404b540aSrobert   tree_contains_struct[USING_DECL][TS_DECL_NON_COMMON] = 1;
119*404b540aSrobert   tree_contains_struct[TEMPLATE_DECL][TS_DECL_NON_COMMON] = 1;
120*404b540aSrobert 
121*404b540aSrobert   tree_contains_struct[NAMESPACE_DECL][TS_DECL_WITH_VIS] = 1;
122*404b540aSrobert   tree_contains_struct[USING_DECL][TS_DECL_WITH_VIS] = 1;
123*404b540aSrobert   tree_contains_struct[TEMPLATE_DECL][TS_DECL_WITH_VIS] = 1;
124*404b540aSrobert 
125*404b540aSrobert   tree_contains_struct[NAMESPACE_DECL][TS_DECL_WRTL] = 1;
126*404b540aSrobert   tree_contains_struct[USING_DECL][TS_DECL_WRTL] = 1;
127*404b540aSrobert   tree_contains_struct[TEMPLATE_DECL][TS_DECL_WRTL] = 1;
128*404b540aSrobert 
129*404b540aSrobert   tree_contains_struct[NAMESPACE_DECL][TS_DECL_COMMON] = 1;
130*404b540aSrobert   tree_contains_struct[USING_DECL][TS_DECL_COMMON] = 1;
131*404b540aSrobert   tree_contains_struct[TEMPLATE_DECL][TS_DECL_COMMON] = 1;
132*404b540aSrobert 
133*404b540aSrobert   tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
134*404b540aSrobert   tree_contains_struct[USING_DECL][TS_DECL_MINIMAL] = 1;
135*404b540aSrobert   tree_contains_struct[TEMPLATE_DECL][TS_DECL_MINIMAL] = 1;
136*404b540aSrobert 
137*404b540aSrobert   init_shadowed_var_for_decl ();
138*404b540aSrobert 
139*404b540aSrobert }
140*404b540aSrobert 
141*404b540aSrobert void
finish_file(void)142*404b540aSrobert finish_file (void)
143*404b540aSrobert {
144*404b540aSrobert   cp_finish_file ();
145*404b540aSrobert }
146*404b540aSrobert 
147*404b540aSrobert #include "gtype-cp.h"
148