1 /* Process the ObjC-specific declarations and variables for
2 the Objective-C++ compiler.
3 Copyright (C) 2005-2015 Free Software Foundation, Inc.
4 Contributed by Ziemowit Laski <zlaski@apple.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
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/>. */
24 #include "coretypes.h"
35 #include "c-family/c-objc.h"
37 #include "objcp-decl.h"
39 /* Hacks to simulate start_struct() and finish_struct(). */
42 objcp_start_struct (location_t loc ATTRIBUTE_UNUSED
,
43 enum tree_code code ATTRIBUTE_UNUSED
, tree name
)
46 /* The idea here is to mimic the actions that the C++ parser takes when
47 constructing 'extern "C" struct NAME {'. */
48 push_lang_context (lang_name_c
);
51 name
= make_anon_name ();
53 s
= xref_tag (record_type
, name
, ts_global
, 0);
54 CLASSTYPE_DECLARED_CLASS (s
) = 0; /* this is a 'struct', not a 'class'. */
55 xref_basetypes (s
, NULL_TREE
); /* no base classes here! */
57 return begin_class_definition (s
);
61 objcp_finish_struct (location_t loc ATTRIBUTE_UNUSED
,
62 tree t
, tree fieldlist
, tree attributes
)
64 tree field
, next_field
;
66 for (field
= fieldlist
; field
; field
= next_field
)
68 next_field
= TREE_CHAIN (field
); /* insert one field at a time; */
69 TREE_CHAIN (field
) = NULL_TREE
; /* otherwise, grokfield croaks. */
70 finish_member_declaration (field
);
72 t
= finish_struct (t
, attributes
);
74 /* If we are inside an @interface and are generating the list of
75 ivars, we need to check for duplicate ivars.
78 objc_detect_field_duplicates (true);
86 objcp_finish_function (void)
88 /* The C++ flavor of 'finish_function' does not generate RTL -- one has
89 to call 'expand_or_defer_fn' to do that. */
90 expand_or_defer_fn (finish_function (0));
94 objcp_xref_tag (enum tree_code code ATTRIBUTE_UNUSED
, tree name
)
96 return xref_tag (record_type
, name
, ts_global
, false);
100 objcp_comptypes (tree type1
, tree type2
)
102 return comptypes (type1
, type2
, COMPARE_STRICT
);
106 objcp_begin_compound_stmt (int flags ATTRIBUTE_UNUSED
)
108 return begin_compound_stmt (0);
112 objcp_end_compound_stmt (tree stmt
, int flags ATTRIBUTE_UNUSED
)
114 /* The following has been snarfed from
115 cp/semantics.c:finish_compound_stmt(). */
116 if (TREE_CODE (stmt
) == BIND_EXPR
)
117 BIND_EXPR_BODY (stmt
) = do_poplevel (BIND_EXPR_BODY (stmt
));
118 else if (STATEMENT_LIST_NO_SCOPE (stmt
))
119 stmt
= pop_stmt_list (stmt
);
121 stmt
= do_poplevel (stmt
);