xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/c-family/c-objc.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
1 /* Definitions of Objective-C front-end entry points used for C and C++.
2    Copyright (C) 1987-2020 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10 
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along 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.  */
24 enum 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 
39 enum 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_MAX
48 };
49 
50 enum objc_property_attribute_kind
51 {
52   OBJC_PROPERTY_ATTR_UNKNOWN =		0|OBJC_PROPATTR_GROUP_UNKNOWN,
53   OBJC_PROPERTY_ATTR_GETTER =		( 1 << 8)|OBJC_PROPATTR_GROUP_GETTER,
54   OBJC_PROPERTY_ATTR_SETTER =		( 2 << 8)|OBJC_PROPATTR_GROUP_SETTER,
55   OBJC_PROPERTY_ATTR_READONLY =		( 3 << 8)|OBJC_PROPATTR_GROUP_READWRITE,
56   OBJC_PROPERTY_ATTR_READWRITE =	( 4 << 8)|OBJC_PROPATTR_GROUP_READWRITE,
57   OBJC_PROPERTY_ATTR_ASSIGN =		( 5 << 8)|OBJC_PROPATTR_GROUP_ASSIGN,
58   OBJC_PROPERTY_ATTR_RETAIN =		( 6 << 8)|OBJC_PROPATTR_GROUP_ASSIGN,
59   OBJC_PROPERTY_ATTR_COPY =		( 7 << 8)|OBJC_PROPATTR_GROUP_ASSIGN,
60   OBJC_PROPERTY_ATTR_ATOMIC =		( 8 << 8)|OBJC_PROPATTR_GROUP_ATOMIC,
61   OBJC_PROPERTY_ATTR_NONATOMIC =	( 9 << 8)|OBJC_PROPATTR_GROUP_ATOMIC,
62   OBJC_PROPERTY_ATTR_MAX =		(255 << 8|OBJC_PROPATTR_GROUP_MAX)
63 };
64 
65 #define OBJC_PROPATTR_GROUP_MASK 0x0f
66 
67 /* To contain parsed, but unverified, information about a single property
68    attribute.  */
69 struct property_attribute_info
70 {
property_attribute_infoproperty_attribute_info71   property_attribute_info (tree name, location_t loc,
72 			   enum objc_property_attribute_kind k)
73    : name (name), ident (NULL_TREE), prop_loc (loc), prop_kind (k),
74      parse_error (false) {}
75 
groupproperty_attribute_info76   enum objc_property_attribute_group group ()
77     {
78       return (enum objc_property_attribute_group)
79 	((unsigned)prop_kind & OBJC_PROPATTR_GROUP_MASK);
80     }
81 
82   tree name; /* Name of the attribute.  */
83   tree ident; /* For getter/setter cases, the method/selector name.  */
84   location_t prop_loc; /* Extended location covering the parsed attr.  */
85   enum objc_property_attribute_kind prop_kind : 16;
86   unsigned parse_error : 1; /* The C/C++ parser saw an error in this attr.  */
87 };
88 
89 extern enum objc_property_attribute_kind objc_prop_attr_kind_for_rid (enum rid);
90 
91 /* Objective-C / Objective-C++ entry points.  */
92 
93 /* The following ObjC/ObjC++ functions are called by the C and/or C++
94    front-ends; they all must have corresponding stubs in stub-objc.c.  */
95 extern void objc_write_global_declarations (void);
96 extern tree objc_is_class_name (tree);
97 extern tree objc_is_object_ptr (tree);
98 extern void objc_check_decl (tree);
99 extern void objc_check_global_decl (tree);
100 extern tree objc_common_type (tree, tree);
101 extern bool objc_compare_types (tree, tree, int, tree);
102 extern bool objc_have_common_type (tree, tree, int, tree);
103 extern bool objc_diagnose_private_ivar (tree);
104 extern void objc_volatilize_decl (tree);
105 extern tree objc_rewrite_function_call (tree, tree);
106 extern tree objc_message_selector (void);
107 extern tree objc_lookup_ivar (tree, tree);
108 extern void objc_clear_super_receiver (void);
109 extern int objc_is_public (tree, tree);
110 extern tree objc_is_id (tree);
111 extern void objc_declare_alias (tree, tree);
112 extern void objc_declare_class (tree);
113 extern void objc_declare_protocol (tree, tree);
114 extern tree objc_build_message_expr (tree, tree);
115 extern tree objc_finish_message_expr (tree, tree, tree, tree*);
116 extern tree objc_build_selector_expr (location_t, tree);
117 extern tree objc_build_protocol_expr (tree);
118 extern tree objc_build_encode_expr (tree);
119 extern tree objc_build_string_object (tree);
120 extern tree objc_get_protocol_qualified_type (tree, tree);
121 extern tree objc_get_class_reference (tree);
122 extern tree objc_get_class_ivars (tree);
123 extern bool objc_detect_field_duplicates (bool);
124 extern void objc_start_class_interface (tree, tree, tree, tree);
125 extern void objc_start_category_interface (tree, tree, tree, tree);
126 extern void objc_start_protocol (tree, tree, tree);
127 extern void objc_continue_interface (void);
128 extern void objc_finish_interface (void);
129 extern void objc_start_class_implementation (tree, tree);
130 extern void objc_start_category_implementation (tree, tree);
131 extern void objc_continue_implementation (void);
132 extern void objc_finish_implementation (void);
133 extern void objc_set_visibility (objc_ivar_visibility_kind);
134 extern tree objc_build_method_signature (bool, tree, tree, tree, bool);
135 extern void objc_add_method_declaration (bool, tree, tree);
136 extern bool objc_start_method_definition (bool, tree, tree, tree);
137 extern void objc_finish_method_definition (tree);
138 extern void objc_add_instance_variable (tree);
139 extern tree objc_build_keyword_decl (tree, tree, tree, tree);
140 extern tree objc_build_throw_stmt (location_t, tree);
141 extern void objc_begin_try_stmt (location_t, tree);
142 extern tree objc_finish_try_stmt (void);
143 extern void objc_begin_catch_clause (tree);
144 extern void objc_finish_catch_clause (void);
145 extern void objc_build_finally_clause (location_t, tree);
146 extern tree objc_build_synchronized (location_t, tree, tree);
147 extern int objc_static_init_needed_p (void);
148 extern tree objc_generate_static_init_call (tree);
149 extern tree objc_generate_write_barrier (tree, enum tree_code, tree);
150 extern void objc_set_method_opt (bool);
151 extern void objc_finish_foreach_loop (location_t, tree, tree, tree, tree, tree);
152 extern bool  objc_method_decl (enum tree_code);
153 extern void objc_add_property_declaration (location_t, tree,
154 					   vec<property_attribute_info *>&);
155 extern tree objc_maybe_build_component_ref (tree, tree);
156 extern tree objc_build_class_component_ref (tree, tree);
157 extern tree objc_maybe_build_modify_expr (tree, tree);
158 extern tree objc_build_incr_expr_for_property_ref (location_t, enum tree_code,
159 						   tree, tree);
160 extern void objc_add_synthesize_declaration (location_t, tree);
161 extern void objc_add_dynamic_declaration (location_t, tree);
162 extern const char * objc_maybe_printable_name (tree, int);
163 extern bool objc_is_property_ref (tree);
164 extern bool objc_non_constant_expr_p (tree);
165 extern bool objc_string_ref_type_p (tree);
166 extern void objc_check_format_arg (tree, tree);
167 extern void objc_finish_function (void);
168 extern void objc_maybe_warn_exceptions (location_t);
169 
170 /* The following are provided by the C and C++ front-ends, and called by
171    ObjC/ObjC++.  */
172 extern void *objc_get_current_scope (void);
173 extern void objc_mark_locals_volatile (void *);
174 
175 #endif /* ! GCC_C_COMMON_OBJC_H */
176