1 /* Definitions of Objective-C front-end entry points used for C and C++. 2 Copyright (C) 1987-2022 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_NULLABLE, 48 OBJC_PROPATTR_GROUP_CLASS, 49 OBJC_PROPATTR_GROUP_MAX 50 }; 51 52 enum 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. */ 76 struct property_attribute_info 77 { 78 property_attribute_info () = default; property_attribute_infoproperty_attribute_info79 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 groupproperty_attribute_info84 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 97 extern 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. */ 103 extern void objc_write_global_declarations (void); 104 extern tree objc_is_class_name (tree); 105 extern tree objc_is_object_ptr (tree); 106 extern void objc_check_decl (tree); 107 extern void objc_check_global_decl (tree); 108 extern tree objc_common_type (tree, tree); 109 extern bool objc_compare_types (tree, tree, int, tree); 110 extern bool objc_have_common_type (tree, tree, int, tree); 111 extern bool objc_diagnose_private_ivar (tree); 112 extern void objc_volatilize_decl (tree); 113 extern tree objc_rewrite_function_call (tree, tree); 114 extern tree objc_message_selector (void); 115 extern tree objc_lookup_ivar (tree, tree); 116 extern void objc_clear_super_receiver (void); 117 extern int objc_is_public (tree, tree); 118 extern tree objc_is_id (tree); 119 extern void objc_declare_alias (tree, tree); 120 extern void objc_declare_class (tree); 121 extern void objc_declare_protocol (tree, tree); 122 extern tree objc_build_message_expr (tree, tree); 123 extern tree objc_finish_message_expr (tree, tree, tree, tree*); 124 extern tree objc_build_selector_expr (location_t, tree); 125 extern tree objc_build_protocol_expr (tree); 126 extern tree objc_build_encode_expr (tree); 127 extern tree objc_build_string_object (tree); 128 extern tree objc_get_protocol_qualified_type (tree, tree); 129 extern tree objc_get_class_reference (tree); 130 extern tree objc_get_class_ivars (tree); 131 extern bool objc_detect_field_duplicates (bool); 132 extern void objc_start_class_interface (tree, location_t, tree, tree, tree); 133 extern void objc_start_category_interface (tree, tree, tree, tree); 134 extern void objc_start_protocol (tree, tree, tree); 135 extern void objc_continue_interface (void); 136 extern void objc_finish_interface (void); 137 extern void objc_start_class_implementation (tree, tree); 138 extern void objc_start_category_implementation (tree, tree); 139 extern void objc_continue_implementation (void); 140 extern void objc_finish_implementation (void); 141 extern void objc_set_visibility (objc_ivar_visibility_kind); 142 extern tree objc_build_method_signature (bool, tree, tree, tree, bool); 143 extern void objc_add_method_declaration (bool, tree, tree); 144 extern bool objc_start_method_definition (bool, tree, tree, tree); 145 extern void objc_finish_method_definition (tree); 146 extern void objc_add_instance_variable (tree); 147 extern tree objc_build_keyword_decl (tree, tree, tree, tree); 148 extern tree objc_build_throw_stmt (location_t, tree); 149 extern void objc_begin_try_stmt (location_t, tree); 150 extern tree objc_finish_try_stmt (void); 151 extern void objc_begin_catch_clause (tree); 152 extern void objc_finish_catch_clause (void); 153 extern void objc_build_finally_clause (location_t, tree); 154 extern tree objc_build_synchronized (location_t, tree, tree); 155 extern int objc_static_init_needed_p (void); 156 extern tree objc_generate_static_init_call (tree); 157 extern tree objc_generate_write_barrier (tree, enum tree_code, tree); 158 extern void objc_set_method_opt (bool); 159 extern void objc_finish_foreach_loop (location_t, tree, tree, tree, tree, tree); 160 extern bool objc_method_decl (enum tree_code); 161 extern void objc_add_property_declaration (location_t, tree, 162 vec<property_attribute_info *>&); 163 extern tree objc_maybe_build_component_ref (tree, tree); 164 extern tree objc_build_class_component_ref (tree, tree); 165 extern tree objc_maybe_build_modify_expr (tree, tree); 166 extern tree objc_build_incr_expr_for_property_ref (location_t, enum tree_code, 167 tree, tree); 168 extern void objc_add_synthesize_declaration (location_t, tree); 169 extern void objc_add_dynamic_declaration (location_t, tree); 170 extern const char * objc_maybe_printable_name (tree, int); 171 extern bool objc_is_property_ref (tree); 172 extern bool objc_non_constant_expr_p (tree); 173 extern bool objc_string_ref_type_p (tree); 174 extern void objc_check_format_arg (tree, tree); 175 extern void objc_finish_function (void); 176 extern 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++. */ 180 extern void *objc_get_current_scope (void); 181 extern void objc_mark_locals_volatile (void *); 182 183 #endif /* ! GCC_C_COMMON_OBJC_H */ 184