1/* Definitions of Objective-C front-end entry points used for C and C++.
2 Copyright (C) 1987-2023 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_C_COMMON_OBJC_H
21#define GCC_C_COMMON_OBJC_H
22
23/* ObjC ivar visibility types. */
24enum GTY(()) objc_ivar_visibility_kind {
25 OBJC_IVAR_VIS_PROTECTED = 0,
26 OBJC_IVAR_VIS_PUBLIC = 1,
27 OBJC_IVAR_VIS_PRIVATE = 2,
28 OBJC_IVAR_VIS_PACKAGE = 3
29};
30
31/* ObjC property attribute kinds.
32 These have two fields; a unique value (that identifies which attribute)
33 and a group key that indicates membership of an exclusion group.
34 Only one member may be present from an exclusion group in a given attribute
35 list.
36 getters and setters have additional rules, since they are excluded from
37 non-overlapping group sets. */
38
39enum objc_property_attribute_group
40{
41 OBJC_PROPATTR_GROUP_UNKNOWN = 0,
42 OBJC_PROPATTR_GROUP_GETTER,
43 OBJC_PROPATTR_GROUP_SETTER,
44 OBJC_PROPATTR_GROUP_READWRITE,
45 OBJC_PROPATTR_GROUP_ASSIGN,
46 OBJC_PROPATTR_GROUP_ATOMIC,
47 OBJC_PROPATTR_GROUP_NULLABLE,
48 OBJC_PROPATTR_GROUP_CLASS,
49 OBJC_PROPATTR_GROUP_MAX
50};
51
52enum objc_property_attribute_kind
53{
54 OBJC_PROPERTY_ATTR_UNKNOWN = 0|OBJC_PROPATTR_GROUP_UNKNOWN,
55 OBJC_PROPERTY_ATTR_GETTER = ( 1 << 8)|OBJC_PROPATTR_GROUP_GETTER,
56 OBJC_PROPERTY_ATTR_SETTER = ( 2 << 8)|OBJC_PROPATTR_GROUP_SETTER,
57 OBJC_PROPERTY_ATTR_READONLY = ( 3 << 8)|OBJC_PROPATTR_GROUP_READWRITE,
58 OBJC_PROPERTY_ATTR_READWRITE = ( 4 << 8)|OBJC_PROPATTR_GROUP_READWRITE,
59 OBJC_PROPERTY_ATTR_ASSIGN = ( 5 << 8)|OBJC_PROPATTR_GROUP_ASSIGN,
60 OBJC_PROPERTY_ATTR_RETAIN = ( 6 << 8)|OBJC_PROPATTR_GROUP_ASSIGN,
61 OBJC_PROPERTY_ATTR_COPY = ( 7 << 8)|OBJC_PROPATTR_GROUP_ASSIGN,
62 OBJC_PROPERTY_ATTR_ATOMIC = ( 8 << 8)|OBJC_PROPATTR_GROUP_ATOMIC,
63 OBJC_PROPERTY_ATTR_NONATOMIC = ( 9 << 8)|OBJC_PROPATTR_GROUP_ATOMIC,
64 OBJC_PROPERTY_ATTR_NULL_UNSPECIFIED = (12 << 8)|OBJC_PROPATTR_GROUP_NULLABLE,
65 OBJC_PROPERTY_ATTR_NULLABLE = (13 << 8)|OBJC_PROPATTR_GROUP_NULLABLE,
66 OBJC_PROPERTY_ATTR_NONNULL = (14 << 8)|OBJC_PROPATTR_GROUP_NULLABLE,
67 OBJC_PROPERTY_ATTR_NULL_RESETTABLE = (15 << 8)|OBJC_PROPATTR_GROUP_NULLABLE,
68 OBJC_PROPERTY_ATTR_CLASS = (16 << 8)|OBJC_PROPATTR_GROUP_CLASS,
69 OBJC_PROPERTY_ATTR_MAX = (255 << 8|OBJC_PROPATTR_GROUP_MAX)
70};
71
72#define OBJC_PROPATTR_GROUP_MASK 0x0f
73
74/* To contain parsed, but unverified, information about a single property
75 attribute. */
76struct property_attribute_info
77{
78 property_attribute_info () = default;
79 property_attribute_info (tree name, location_t loc,
80 enum objc_property_attribute_kind k)
81 : name (name), ident (NULL_TREE), prop_loc (loc), prop_kind (k),
82 parse_error (false) {}
83
84 enum objc_property_attribute_group group ()
85 {
86 return (enum objc_property_attribute_group)
87 ((unsigned)prop_kind & OBJC_PROPATTR_GROUP_MASK);
88 }
89
90 tree name; /* Name of the attribute. */
91 tree ident; /* For getter/setter cases, the method/selector name. */
92 location_t prop_loc; /* Extended location covering the parsed attr. */
93 enum objc_property_attribute_kind prop_kind : 16;
94 unsigned parse_error : 1; /* The C/C++ parser saw an error in this attr. */
95};
96
97extern enum objc_property_attribute_kind objc_prop_attr_kind_for_rid (enum rid);
98
99/* Objective-C / Objective-C++ entry points. */
100
101/* The following ObjC/ObjC++ functions are called by the C and/or C++
102 front-ends; they all must have corresponding stubs in stub-objc.cc. */
103extern void objc_write_global_declarations (void);
104extern tree objc_is_class_name (tree);
105extern tree objc_is_object_ptr (tree);
106extern void objc_check_decl (tree);
107extern void objc_check_global_decl (tree);
108extern tree objc_common_type (tree, tree);
109extern bool objc_compare_types (tree, tree, int, tree);
110extern bool objc_have_common_type (tree, tree, int, tree);
111extern bool objc_diagnose_private_ivar (tree);
112extern void objc_volatilize_decl (tree);
113extern tree objc_rewrite_function_call (tree, tree);
114extern tree objc_message_selector (void);
115extern tree objc_lookup_ivar (tree, tree);
116extern void objc_clear_super_receiver (void);
117extern int objc_is_public (tree, tree);
118extern tree objc_is_id (tree);
119extern void objc_declare_alias (tree, tree);
120extern void objc_declare_class (tree);
121extern void objc_declare_protocol (tree, tree);
122extern tree objc_build_message_expr (tree, tree);
123extern tree objc_finish_message_expr (tree, tree, tree, tree*);
124extern tree objc_build_selector_expr (location_t, tree);
125extern tree objc_build_protocol_expr (tree);
126extern tree objc_build_encode_expr (tree);
127extern tree objc_build_string_object (tree);
128extern tree objc_get_protocol_qualified_type (tree, tree);
129extern tree objc_get_class_reference (tree);
130extern tree objc_get_class_ivars (tree);
131extern bool objc_detect_field_duplicates (bool);
132extern void objc_start_class_interface (tree, location_t, tree, tree, tree);
133extern void objc_start_category_interface (tree, tree, tree, tree);
134extern void objc_start_protocol (tree, tree, tree);
135extern void objc_continue_interface (void);
136extern void objc_finish_interface (void);
137extern void objc_start_class_implementation (tree, tree);
138extern void objc_start_category_implementation (tree, tree);
139extern void objc_continue_implementation (void);
140extern void objc_finish_implementation (void);
141extern void objc_set_visibility (objc_ivar_visibility_kind);
142extern tree objc_build_method_signature (bool, tree, tree, tree, bool);
143extern void objc_add_method_declaration (bool, tree, tree);
144extern bool objc_start_method_definition (bool, tree, tree, tree);
145extern void objc_finish_method_definition (tree);
146extern void objc_add_instance_variable (tree);
147extern tree objc_build_keyword_decl (tree, tree, tree, tree);
148extern tree objc_build_throw_stmt (location_t, tree);
149extern void objc_begin_try_stmt (location_t, tree);
150extern tree objc_finish_try_stmt (void);
151extern void objc_begin_catch_clause (tree);
152extern void objc_finish_catch_clause (void);
153extern void objc_build_finally_clause (location_t, tree);
154extern tree objc_build_synchronized (location_t, tree, tree);
155extern int objc_static_init_needed_p (void);
156extern tree objc_generate_static_init_call (tree);
157extern tree objc_generate_write_barrier (tree, enum tree_code, tree);
158extern void objc_set_method_opt (bool);
159extern void objc_finish_foreach_loop (location_t, tree, tree, tree, tree, tree);
160extern bool objc_method_decl (enum tree_code);
161extern void objc_add_property_declaration (location_t, tree,
162 vec<property_attribute_info *>&);
163extern tree objc_maybe_build_component_ref (tree, tree);
164extern tree objc_build_class_component_ref (tree, tree);
165extern tree objc_maybe_build_modify_expr (tree, tree);
166extern tree objc_build_incr_expr_for_property_ref (location_t, enum tree_code,
167 tree, tree);
168extern void objc_add_synthesize_declaration (location_t, tree);
169extern void objc_add_dynamic_declaration (location_t, tree);
170extern const char * objc_maybe_printable_name (tree, int);
171extern bool objc_is_property_ref (tree);
172extern bool objc_non_constant_expr_p (tree);
173extern bool objc_string_ref_type_p (tree);
174extern void objc_check_format_arg (tree, tree);
175extern void objc_finish_function (void);
176extern void objc_maybe_warn_exceptions (location_t);
177
178/* The following are provided by the C and C++ front-ends, and called by
179 ObjC/ObjC++. */
180extern void *objc_get_current_scope (void);
181extern void objc_mark_locals_volatile (void *);
182
183#endif /* ! GCC_C_COMMON_OBJC_H */
184

source code of gcc/c-family/c-objc.h