aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/gcc/cp/cp-lang.c
blob: 4fe8c672739d7b12e9d165d0e2c206ea51344252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/* Language-dependent hooks for C++.
   Copyright 2001, 2002, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
   Contributed by Alexandre Oliva  <aoliva@redhat.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 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/>.  */

#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 "cp-objcp-common.h"
#include "hashtab.h"

enum c_language_kind c_language = clk_cxx;
static void cp_init_ts (void);
static const char * cxx_dwarf_name (tree t, int verbosity);
static enum classify_record cp_classify_record (tree type);
static bool cp_user_conv_function_p (tree);
static bool cp_is_decl_dtor_p (tree);
static bool cp_is_vptr_field_p (tree);
static bool cp_is_polymorphic_type_p (tree);
static bool cp_is_global_delete_fndecl_p (tree);

/* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
   consequently, there should be very few hooks below.  */

#undef LANG_HOOKS_NAME
#define LANG_HOOKS_NAME "GNU C++"
#undef LANG_HOOKS_INIT
#define LANG_HOOKS_INIT cxx_init
#undef LANG_HOOKS_CLASSIFY_RECORD
#define LANG_HOOKS_CLASSIFY_RECORD cp_classify_record
#undef LANG_HOOKS_GENERIC_TYPE_P
#define LANG_HOOKS_GENERIC_TYPE_P class_tmpl_impl_spec_p
#undef LANG_HOOKS_DECL_PRINTABLE_NAME
#define LANG_HOOKS_DECL_PRINTABLE_NAME	cxx_printable_name
#undef LANG_HOOKS_DWARF_NAME
#define LANG_HOOKS_DWARF_NAME cxx_dwarf_name
#undef LANG_HOOKS_GET_VIRTUAL_FUNCTION_DECL
#define LANG_HOOKS_GET_VIRTUAL_FUNCTION_DECL cp_get_virtual_function_decl
#undef LANG_HOOKS_FOLD_OBJ_TYPE_REF
#define LANG_HOOKS_FOLD_OBJ_TYPE_REF cp_fold_obj_type_ref
#undef LANG_HOOKS_INIT_TS
#define LANG_HOOKS_INIT_TS cp_init_ts
#undef LANG_HOOKS_USER_CONV_FUNCTION
#define LANG_HOOKS_USER_CONV_FUNCTION cp_user_conv_function_p
#undef LANG_HOOKS_IS_DECL_DTOR
#define LANG_HOOKS_IS_DECL_DTOR cp_is_decl_dtor_p
#undef LANG_HOOKS_IS_VPTR_FIELD
#define LANG_HOOKS_IS_VPTR_FIELD cp_is_vptr_field_p
#undef LANG_HOOKS_IS_TYPE_POLYMORPHIC
#define LANG_HOOKS_IS_TYPE_POLYMORPHIC cp_is_polymorphic_type_p
#undef LANG_HOOKS_IS_GLOBAL_DELETE_FNDECL
#define LANG_HOOKS_IS_GLOBAL_DELETE_FNDECL cp_is_global_delete_fndecl_p
#undef LANG_HOOKS_DECL_IS_BASE_FIELD
#define LANG_HOOKS_DECL_IS_BASE_FIELD cp_decl_is_base_field
#undef LANG_HOOKS_DECL_IS_CONSTRUCTOR
#define LANG_HOOKS_DECL_IS_CONSTRUCTOR cp_decl_is_constructor
#undef LANG_HOOKS_DECL_IS_DESTRUCTOR
#define LANG_HOOKS_DECL_IS_DESTRUCTOR cp_decl_is_destructor
#undef LANG_HOOKS_DECL_IS_CONST_MEMBER_FUNC
#define LANG_HOOKS_DECL_IS_CONST_MEMBER_FUNC cp_decl_is_const_member_func

/* LIPO support.  */
#undef LANG_HOOKS_ADD_BUILT_IN_DECL
#define LANG_HOOKS_ADD_BUILT_IN_DECL cp_add_built_in_decl
#undef LANG_HOOKS_SAVE_BUILT_IN_PRE
#define LANG_HOOKS_SAVE_BUILT_IN_PRE cp_save_built_in_decl_pre_parsing
#undef LANG_HOOKS_RESTORE_BUILT_IN_PRE
#define LANG_HOOKS_RESTORE_BUILT_IN_PRE cp_restore_built_in_decl_pre_parsing
#undef LANG_HOOKS_SAVE_BUILT_IN_POST
#define LANG_HOOKS_SAVE_BUILT_IN_POST cp_save_built_in_decl_post_parsing
#undef LANG_HOOKS_RESTORE_BUILT_IN_POST
#define LANG_HOOKS_RESTORE_BUILT_IN_POST cp_restore_built_in_decl_post_parsing
#undef LANG_HOOKS_CLEAR_NAME_BINDINGS
#define LANG_HOOKS_CLEAR_NAME_BINDINGS cp_clear_global_name_bindings
#undef LANG_HOOKS_HAS_GLOBAL_NAME
#define LANG_HOOKS_HAS_GLOBAL_NAME cp_is_non_sharable_global_decl
#undef LANG_HOOKS_GET_LANG_DECL_SIZE
#define LANG_HOOKS_GET_LANG_DECL_SIZE cp_get_lang_decl_size
#undef LANG_HOOKS_DUP_LANG_TYPE
#define LANG_HOOKS_DUP_LANG_TYPE cp_lipo_dup_lang_type
#undef LANG_HOOKS_COPY_LANG_TYPE
#define LANG_HOOKS_COPY_LANG_TYPE cp_lipo_copy_lang_type
#undef LANG_HOOKS_PROCESS_PENDING_DECLS
#define LANG_HOOKS_PROCESS_PENDING_DECLS cp_process_pending_declarations
#undef LANG_HOOKS_CLEAR_DEFFERED_FNS
#define LANG_HOOKS_CLEAR_DEFFERED_FNS cp_clear_deferred_fns
#undef LANG_HOOKS_IS_GENERATED_TYPE
#define LANG_HOOKS_IS_GENERATED_TYPE cp_is_compiler_generated_type
#undef LANG_HOOKS_CMP_LANG_TYPE
#define LANG_HOOKS_CMP_LANG_TYPE cp_cmp_lang_type

/* Each front end provides its own lang hook initializer.  */
const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;

/* Lang hook routines common to C++ and ObjC++ appear in cp/cp-objcp-common.c;
   there should be very few routines below.  */

/* The following function does something real, but only in Objective-C++.  */

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;
}


static void
cp_init_ts (void)
{
  tree_contains_struct[NAMESPACE_DECL][TS_DECL_NON_COMMON] = 1;
  tree_contains_struct[USING_DECL][TS_DECL_NON_COMMON] = 1;
  tree_contains_struct[TEMPLATE_DECL][TS_DECL_NON_COMMON] = 1;

  tree_contains_struct[NAMESPACE_DECL][TS_DECL_WITH_VIS] = 1;
  tree_contains_struct[USING_DECL][TS_DECL_WITH_VIS] = 1;
  tree_contains_struct[TEMPLATE_DECL][TS_DECL_WITH_VIS] = 1;

  tree_contains_struct[NAMESPACE_DECL][TS_DECL_WRTL] = 1;
  tree_contains_struct[USING_DECL][TS_DECL_WRTL] = 1;
  tree_contains_struct[TEMPLATE_DECL][TS_DECL_WRTL] = 1;

  tree_contains_struct[NAMESPACE_DECL][TS_DECL_COMMON] = 1;
  tree_contains_struct[USING_DECL][TS_DECL_COMMON] = 1;
  tree_contains_struct[TEMPLATE_DECL][TS_DECL_COMMON] = 1;

  tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
  tree_contains_struct[USING_DECL][TS_DECL_MINIMAL] = 1;
  tree_contains_struct[TEMPLATE_DECL][TS_DECL_MINIMAL] = 1;

  init_shadowed_var_for_decl ();

}

static const char *
cxx_dwarf_name (tree t, int verbosity)
{
  gcc_assert (DECL_P (t));

  if (verbosity >= 2)
    return decl_as_string (t,
			   TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME
			   | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS);

  return cxx_printable_name (t, verbosity);
}

static enum classify_record
cp_classify_record (tree type)
{
  if (CLASSTYPE_DECLARED_CLASS (type))
    return RECORD_IS_CLASS;

  return RECORD_IS_STRUCT;
}

static bool
cp_user_conv_function_p (tree decl)
{
  return DECL_CONV_FN_P (decl);
}


void
finish_file (void)
{
}

static bool
cp_is_decl_dtor_p (tree decl)
{
  return DECL_DESTRUCTOR_P (decl);
}

static bool
cp_is_vptr_field_p (tree field)
{
  tree type;

  type = DECL_FCONTEXT (field);
  if (!type)
    return false;
  if (TYPE_VFIELD (type) == field)
    return true;
  else
    return false;
}

static bool
cp_is_polymorphic_type_p (tree type)
{
  return TYPE_POLYMORPHIC_P (type);
}

static bool
cp_is_global_delete_fndecl_p (tree decl)
{
  return decl == global_delete_fndecl;
}

#include "gtype-cp.h"