1*e4b17023SJohn Marino /* Language-dependent hooks for Objective-C++.
2*e4b17023SJohn Marino Copyright 2005, 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
3*e4b17023SJohn Marino Contributed by Ziemowit Laski <zlaski@apple.com>
4*e4b17023SJohn Marino
5*e4b17023SJohn Marino This file is part of GCC.
6*e4b17023SJohn Marino
7*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify
8*e4b17023SJohn Marino it under the terms of the GNU General Public License as published by
9*e4b17023SJohn Marino the Free Software Foundation; either version 3, or (at your option)
10*e4b17023SJohn Marino any later version.
11*e4b17023SJohn Marino
12*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful,
13*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
14*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15*e4b17023SJohn Marino GNU General Public License for more details.
16*e4b17023SJohn Marino
17*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
18*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see
19*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */
20*e4b17023SJohn Marino
21*e4b17023SJohn Marino #include "config.h"
22*e4b17023SJohn Marino #include "system.h"
23*e4b17023SJohn Marino #include "coretypes.h"
24*e4b17023SJohn Marino #include "tm.h"
25*e4b17023SJohn Marino #include "tree.h"
26*e4b17023SJohn Marino #include "cp-tree.h"
27*e4b17023SJohn Marino #include "c-family/c-common.h"
28*e4b17023SJohn Marino #include "c-family/c-objc.h"
29*e4b17023SJohn Marino #include "objc-act.h"
30*e4b17023SJohn Marino #include "langhooks.h"
31*e4b17023SJohn Marino #include "langhooks-def.h"
32*e4b17023SJohn Marino #include "target.h"
33*e4b17023SJohn Marino #include "cp-objcp-common.h"
34*e4b17023SJohn Marino
35*e4b17023SJohn Marino enum c_language_kind c_language = clk_objcxx;
36*e4b17023SJohn Marino static void objcxx_init_ts (void);
37*e4b17023SJohn Marino
38*e4b17023SJohn Marino /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
39*e4b17023SJohn Marino consequently, there should be very few hooks below. */
40*e4b17023SJohn Marino
41*e4b17023SJohn Marino #undef LANG_HOOKS_NAME
42*e4b17023SJohn Marino #define LANG_HOOKS_NAME "GNU Objective-C++"
43*e4b17023SJohn Marino #undef LANG_HOOKS_INIT
44*e4b17023SJohn Marino #define LANG_HOOKS_INIT objc_init
45*e4b17023SJohn Marino #undef LANG_HOOKS_GIMPLIFY_EXPR
46*e4b17023SJohn Marino #define LANG_HOOKS_GIMPLIFY_EXPR objc_gimplify_expr
47*e4b17023SJohn Marino #undef LANG_HOOKS_INIT_TS
48*e4b17023SJohn Marino #define LANG_HOOKS_INIT_TS objcxx_init_ts
49*e4b17023SJohn Marino
50*e4b17023SJohn Marino /* Each front end provides its own lang hook initializer. */
51*e4b17023SJohn Marino struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
52*e4b17023SJohn Marino
53*e4b17023SJohn Marino /* Lang hook routines common to C++ and ObjC++ appear in cp/cp-objcp-common.c;
54*e4b17023SJohn Marino there should be very few (if any) routines below. */
55*e4b17023SJohn Marino
56*e4b17023SJohn Marino tree
objcp_tsubst_copy_and_build(tree t,tree args,tsubst_flags_t complain,tree in_decl,bool function_p ATTRIBUTE_UNUSED)57*e4b17023SJohn Marino objcp_tsubst_copy_and_build (tree t, tree args, tsubst_flags_t complain,
58*e4b17023SJohn Marino tree in_decl, bool function_p ATTRIBUTE_UNUSED)
59*e4b17023SJohn Marino {
60*e4b17023SJohn Marino #define RECURSE(NODE) \
61*e4b17023SJohn Marino tsubst_copy_and_build (NODE, args, complain, in_decl, \
62*e4b17023SJohn Marino /*function_p=*/false, \
63*e4b17023SJohn Marino /*integral_constant_expression_p=*/false)
64*e4b17023SJohn Marino
65*e4b17023SJohn Marino /* The following two can only occur in Objective-C++. */
66*e4b17023SJohn Marino
67*e4b17023SJohn Marino switch ((int) TREE_CODE (t))
68*e4b17023SJohn Marino {
69*e4b17023SJohn Marino case MESSAGE_SEND_EXPR:
70*e4b17023SJohn Marino return objc_finish_message_expr
71*e4b17023SJohn Marino (RECURSE (TREE_OPERAND (t, 0)),
72*e4b17023SJohn Marino TREE_OPERAND (t, 1), /* No need to expand the selector. */
73*e4b17023SJohn Marino RECURSE (TREE_OPERAND (t, 2)), NULL);
74*e4b17023SJohn Marino
75*e4b17023SJohn Marino case CLASS_REFERENCE_EXPR:
76*e4b17023SJohn Marino return objc_get_class_reference
77*e4b17023SJohn Marino (RECURSE (TREE_OPERAND (t, 0)));
78*e4b17023SJohn Marino
79*e4b17023SJohn Marino default:
80*e4b17023SJohn Marino break;
81*e4b17023SJohn Marino }
82*e4b17023SJohn Marino
83*e4b17023SJohn Marino /* Fall back to C++ processing. */
84*e4b17023SJohn Marino return NULL_TREE;
85*e4b17023SJohn Marino
86*e4b17023SJohn Marino #undef RECURSE
87*e4b17023SJohn Marino }
88*e4b17023SJohn Marino
89*e4b17023SJohn Marino static void
objcxx_init_ts(void)90*e4b17023SJohn Marino objcxx_init_ts (void)
91*e4b17023SJohn Marino {
92*e4b17023SJohn Marino objc_common_init_ts ();
93*e4b17023SJohn Marino cp_common_init_ts ();
94*e4b17023SJohn Marino
95*e4b17023SJohn Marino init_shadowed_var_for_decl ();
96*e4b17023SJohn Marino }
97*e4b17023SJohn Marino
98*e4b17023SJohn Marino #include "gtype-objcp.h"
99