annotate gcc/objcp/objcp-decl.c @ 131:84e7813d76e9

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