OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [cp/] [cp-lang.c] - Blame information for rev 710

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 710 jeremybenn
/* Language-dependent hooks for C++.
2
   Copyright 2001, 2002, 2004, 2007, 2008, 2009, 2010
3
   Free Software Foundation, Inc.
4
   Contributed by Alexandre Oliva  <aoliva@redhat.com>
5
 
6
This file is part of GCC.
7
 
8
GCC is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 3, or (at your option)
11
any later version.
12
 
13
GCC is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with GCC; see the file COPYING3.  If not see
20
<http://www.gnu.org/licenses/>.  */
21
 
22
#include "config.h"
23
#include "system.h"
24
#include "coretypes.h"
25
#include "tm.h"
26
#include "tree.h"
27
#include "cp-tree.h"
28
#include "c-family/c-common.h"
29
#include "langhooks.h"
30
#include "langhooks-def.h"
31
#include "debug.h"
32
#include "cp-objcp-common.h"
33
#include "hashtab.h"
34
#include "target.h"
35
#include "parser.h"
36
 
37
enum c_language_kind c_language = clk_cxx;
38
static void cp_init_ts (void);
39
static const char * cxx_dwarf_name (tree t, int verbosity);
40
static enum classify_record cp_classify_record (tree type);
41
static tree cp_eh_personality (void);
42
static tree get_template_innermost_arguments_folded (const_tree);
43
static tree get_template_argument_pack_elems_folded (const_tree);
44
 
45
/* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
46
   consequently, there should be very few hooks below.  */
47
 
48
#undef LANG_HOOKS_NAME
49
#define LANG_HOOKS_NAME "GNU C++"
50
#undef LANG_HOOKS_INIT
51
#define LANG_HOOKS_INIT cxx_init
52
#undef LANG_HOOKS_CLASSIFY_RECORD
53
#define LANG_HOOKS_CLASSIFY_RECORD cp_classify_record
54
#undef LANG_HOOKS_GENERIC_TYPE_P
55
#define LANG_HOOKS_GENERIC_TYPE_P class_tmpl_impl_spec_p
56
 
57
#undef LANG_HOOKS_GET_INNERMOST_GENERIC_PARMS
58
#define LANG_HOOKS_GET_INNERMOST_GENERIC_PARMS \
59
        get_primary_template_innermost_parameters
60
#undef LANG_HOOKS_GET_INNERMOST_GENERIC_ARGS
61
#define LANG_HOOKS_GET_INNERMOST_GENERIC_ARGS \
62
        get_template_innermost_arguments_folded
63
#undef LANG_HOOKS_FUNCTION_PARAMETER_PACK_P
64
#define LANG_HOOKS_FUNCTION_PARAMETER_PACK_P \
65
        function_parameter_pack_p
66
#undef LANG_HOOKS_GET_ARGUMENT_PACK_ELEMS
67
#define LANG_HOOKS_GET_ARGUMENT_PACK_ELEMS \
68
        get_template_argument_pack_elems_folded
69
#undef LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P
70
#define LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P \
71
        template_template_parameter_p
72
#undef LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P
73
#define LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P \
74
        function_parameter_expanded_from_pack_p
75
#undef LANG_HOOKS_GET_GENERIC_FUNCTION_DECL
76
#define LANG_HOOKS_GET_GENERIC_FUNCTION_DECL get_function_template_decl
77
#undef LANG_HOOKS_DWARF_NAME
78
#define LANG_HOOKS_DWARF_NAME cxx_dwarf_name
79
#undef LANG_HOOKS_INIT_TS
80
#define LANG_HOOKS_INIT_TS cp_init_ts
81
#undef LANG_HOOKS_EH_PERSONALITY
82
#define LANG_HOOKS_EH_PERSONALITY cp_eh_personality
83
#undef LANG_HOOKS_EH_RUNTIME_TYPE
84
#define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type
85
 
86
/* Each front end provides its own lang hook initializer.  */
87
struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
88
 
89
/* Lang hook routines common to C++ and ObjC++ appear in cp/cp-objcp-common.c;
90
   there should be very few routines below.  */
91
 
92
/* The following function does something real, but only in Objective-C++.  */
93
 
94
tree
95
objcp_tsubst_copy_and_build (tree t ATTRIBUTE_UNUSED,
96
                             tree args ATTRIBUTE_UNUSED,
97
                             tsubst_flags_t complain ATTRIBUTE_UNUSED,
98
                             tree in_decl ATTRIBUTE_UNUSED,
99
                             bool function_p ATTRIBUTE_UNUSED)
100
{
101
  return NULL_TREE;
102
}
103
 
104
static void
105
cp_init_ts (void)
106
{
107
  cp_common_init_ts ();
108
 
109
  init_shadowed_var_for_decl ();
110
}
111
 
112
static const char *
113
cxx_dwarf_name (tree t, int verbosity)
114
{
115
  gcc_assert (DECL_P (t));
116
 
117
  if (DECL_NAME (t)
118
      && (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDANAME_P (DECL_NAME (t))))
119
    return NULL;
120
  if (verbosity >= 2)
121
    return decl_as_string (t,
122
                           TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME
123
                           | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS);
124
 
125
  return cxx_printable_name (t, verbosity);
126
}
127
 
128
static enum classify_record
129
cp_classify_record (tree type)
130
{
131
  if (CLASSTYPE_DECLARED_CLASS (type))
132
    return RECORD_IS_CLASS;
133
 
134
  return RECORD_IS_STRUCT;
135
}
136
 
137
static GTY(()) tree cp_eh_personality_decl;
138
 
139
static tree
140
cp_eh_personality (void)
141
{
142
  if (!cp_eh_personality_decl)
143
    {
144
      const char *lang = (pragma_java_exceptions ? "gcj" : "gxx");
145
      cp_eh_personality_decl = build_personality_function (lang);
146
    }
147
 
148
  return cp_eh_personality_decl;
149
}
150
 
151
/* This is a subroutine of fold_cplus_constants.  It returns TRUE if T
152
   is a C++ specific constant that needs to be folded further before
153
   being passed to the debug info emitter.  */
154
 
155
static bool
156
template_arg_needs_folding (const_tree t)
157
{
158
  /* For now only PTRMEM_CST nodes are to be folded further.  */
159
  if (TREE_CODE (t) == PTRMEM_CST)
160
    return true;
161
  return false;
162
}
163
 
164
/* Fold the elements of the TREE_VEC C which are C++ specific nodes
165
   that would need folding so that they can be processed by the debug
166
   info emitter. This is a subroutine of
167
   get_template_innermost_arguments_folded and
168
   get_template_argument_pack_elems_folded.  */
169
 
170
static tree
171
fold_cplus_constants (const_tree c)
172
{
173
  tree folded_elems, elems = CONST_CAST_TREE (c);
174
  int vec_len, i;
175
 
176
  if (elems == NULL_TREE || elems == error_mark_node)
177
    return elems;
178
 
179
  vec_len = TREE_VEC_LENGTH (elems);
180
 
181
  /* First check if there is at least one element that needs
182
     folding. If there is none, we just return ELEMS. Otherwise create
183
     and return a new tree vector that contains the folded versions of
184
     ELEMS. This is to avoid allocating memory if we don't need
185
     to.  */
186
  for (i = 0; i < vec_len; ++i)
187
    {
188
      if (template_arg_needs_folding (TREE_VEC_ELT (elems, i)))
189
        break;
190
    }
191
  if (i == vec_len)
192
    return elems;
193
 
194
  folded_elems = make_tree_vec (vec_len);
195
  for (i = 0; i < vec_len; ++i)
196
    {
197
      tree elem = TREE_VEC_ELT (elems, i);
198
      TREE_VEC_ELT (folded_elems, i) =
199
        (elem && !TYPE_P (elem)) ? cplus_expand_constant (elem) : elem;
200
 
201
    }
202
  return folded_elems;
203
}
204
 
205
/* The C++ implementation of the LANG_HOOKS_GET_INNERMOST_GENERIC_ARGS
206
   hook. It returns the innermost template arguments of type T, and
207
   makes sure those arguments are folded enough for the debug info
208
   emitter.  */
209
 
210
static tree
211
get_template_innermost_arguments_folded (const_tree t)
212
{
213
  return fold_cplus_constants (get_template_innermost_arguments (t));
214
}
215
 
216
static tree
217
get_template_argument_pack_elems_folded (const_tree t)
218
{
219
  return fold_cplus_constants (get_template_argument_pack_elems (t));
220
}
221
 
222
#include "gt-cp-cp-lang.h"
223
#include "gtype-cp.h"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.