]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/objcp/objcp-decl.c
tree-core.h: Include symtab.h.
[thirdparty/gcc.git] / gcc / objcp / objcp-decl.c
CommitLineData
b2e61dde
MS
1/* Process the ObjC-specific declarations and variables for
2 the Objective-C++ compiler.
5624e564 3 Copyright (C) 2005-2015 Free Software Foundation, Inc.
b2e61dde
MS
4 Contributed by Ziemowit Laski <zlaski@apple.com>
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
af84f9c5 10Software Foundation; either version 3, or (at your option) any later
b2e61dde
MS
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
af84f9c5
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
b2e61dde
MS
21
22#include "config.h"
23#include "system.h"
24#include "coretypes.h"
25#include "tm.h"
40e23961 26#include "vec.h"
40e23961 27#include "alias.h"
c7131fb2 28#include "tree.h"
40e23961 29#include "options.h"
40e23961 30#include "inchash.h"
b2e61dde 31#include "cp-tree.h"
b2e61dde 32
61d3ce20 33#include "c-family/c-objc.h"
b2e61dde
MS
34#include "objc-act.h"
35#include "objcp-decl.h"
36
37/* Hacks to simulate start_struct() and finish_struct(). */
38
39tree
c2255bc4
AH
40objcp_start_struct (location_t loc ATTRIBUTE_UNUSED,
41 enum tree_code code ATTRIBUTE_UNUSED, tree name)
b2e61dde
MS
42{
43 tree s;
44 /* The idea here is to mimic the actions that the C++ parser takes when
45 constructing 'extern "C" struct NAME {'. */
46 push_lang_context (lang_name_c);
18d311d8 47
b2e61dde
MS
48 if (!name)
49 name = make_anon_name ();
18d311d8
ZL
50
51 s = xref_tag (record_type, name, ts_global, 0);
b2e61dde
MS
52 CLASSTYPE_DECLARED_CLASS (s) = 0; /* this is a 'struct', not a 'class'. */
53 xref_basetypes (s, NULL_TREE); /* no base classes here! */
54
e3c888eb 55 return begin_class_definition (s);
b2e61dde
MS
56}
57
58tree
c2255bc4
AH
59objcp_finish_struct (location_t loc ATTRIBUTE_UNUSED,
60 tree t, tree fieldlist, tree attributes)
b2e61dde
MS
61{
62 tree field, next_field;
63
64 for (field = fieldlist; field; field = next_field)
65 {
66 next_field = TREE_CHAIN (field); /* insert one field at a time; */
67 TREE_CHAIN (field) = NULL_TREE; /* otherwise, grokfield croaks. */
68 finish_member_declaration (field);
69 }
70 t = finish_struct (t, attributes);
c0c24aa4
NP
71
72 /* If we are inside an @interface and are generating the list of
73 ivars, we need to check for duplicate ivars.
74 */
75 if (fieldlist)
0dc33c3c 76 objc_detect_field_duplicates (true);
c0c24aa4 77
b2e61dde
MS
78 pop_lang_context ();
79
80 return t;
81}
82
83void
84objcp_finish_function (void)
85{
86 /* The C++ flavor of 'finish_function' does not generate RTL -- one has
87 to call 'expand_or_defer_fn' to do that. */
88 expand_or_defer_fn (finish_function (0));
89}
90
b2e61dde
MS
91tree
92objcp_xref_tag (enum tree_code code ATTRIBUTE_UNUSED, tree name)
93{
18d311d8 94 return xref_tag (record_type, name, ts_global, false);
b2e61dde
MS
95}
96
97int
98objcp_comptypes (tree type1, tree type2)
99{
96d84882 100 return comptypes (type1, type2, COMPARE_STRICT);
b2e61dde
MS
101}
102
103tree
104objcp_begin_compound_stmt (int flags ATTRIBUTE_UNUSED)
105{
106 return begin_compound_stmt (0);
107}
108
109tree
110objcp_end_compound_stmt (tree stmt, int flags ATTRIBUTE_UNUSED)
111{
112 /* The following has been snarfed from
113 cp/semantics.c:finish_compound_stmt(). */
114 if (TREE_CODE (stmt) == BIND_EXPR)
115 BIND_EXPR_BODY (stmt) = do_poplevel (BIND_EXPR_BODY (stmt));
116 else if (STATEMENT_LIST_NO_SCOPE (stmt))
117 stmt = pop_stmt_list (stmt);
118 else
119 stmt = do_poplevel (stmt);
120
121 return stmt;
122}