front-end, but 'finish_class_member_access_expr' seems to be
a worthy substitute. */
#ifdef OBJCPLUS
- return finish_class_member_access_expr (datum, component);
+ return finish_class_member_access_expr (datum, component, false);
#else
return build_component_ref (datum, component);
#endif
(xref_tag (RECORD_TYPE,
get_identifier (UTAG_IVAR_LIST)));
+ /* TREE_NOTHROW is cleared for the message-sending functions,
+ because the function that gets called can throw in Obj-C++, or
+ could itself call something that can throw even in Obj-C. */
+
if (flag_next_runtime)
{
/* NB: In order to call one of the ..._stret (struct-returning)
type, 0, NOT_BUILT_IN,
NULL, NULL_TREE);
+ /* These can throw, because the function that gets called can throw
+ in Obj-C++, or could itself call something that can throw even
+ in Obj-C. */
+ TREE_NOTHROW (umsg_decl) = 0;
+ TREE_NOTHROW (umsg_nonnil_decl) = 0;
+ TREE_NOTHROW (umsg_stret_decl) = 0;
+ TREE_NOTHROW (umsg_nonnil_stret_decl) = 0;
+
/* id objc_msgSend_Fast (id, SEL, ...)
__attribute__ ((hard_coded_address (OFFS_MSGSEND_FAST))); */
#ifdef OFFS_MSGSEND_FAST
umsg_fast_decl = builtin_function (TAG_MSGSEND_FAST,
type, 0, NOT_BUILT_IN,
NULL, NULL_TREE);
+ TREE_NOTHROW (umsg_fast_decl) = 0;
DECL_ATTRIBUTES (umsg_fast_decl)
= tree_cons (get_identifier ("hard_coded_address"),
build_int_cst (NULL_TREE, OFFS_MSGSEND_FAST),
umsg_super_stret_decl = builtin_function (TAG_MSGSENDSUPER_STRET,
type, 0, NOT_BUILT_IN, 0,
NULL_TREE);
+ TREE_NOTHROW (umsg_super_decl) = 0;
+ TREE_NOTHROW (umsg_super_stret_decl) = 0;
}
else
{
umsg_decl = builtin_function (TAG_MSGSEND,
type, 0, NOT_BUILT_IN,
NULL, NULL_TREE);
+ TREE_NOTHROW (umsg_decl) = 0;
/* IMP objc_msg_lookup_super (struct objc_super *, SEL); */
type
umsg_super_decl = builtin_function (TAG_MSGSENDSUPER,
type, 0, NOT_BUILT_IN,
NULL, NULL_TREE);
+ TREE_NOTHROW (umsg_super_decl) = 0;
/* The following GNU runtime entry point is called to initialize
each module:
size_in_bytes (objc_module_template));
initlist = tree_cons (NULL_TREE, expr, initlist);
- /* name = { ..., "foo.m", ... } */
+ /* Don't provide any file name for security reasons. */
+ /* name = { ..., "", ... } */
- expr = add_objc_string (get_identifier (input_filename), class_names);
+ expr = add_objc_string (get_identifier (""), class_names);
initlist = tree_cons (NULL_TREE, expr, initlist);
/* symtab = { ..., _OBJC_SYMBOLS, ... } */
finish_var_decl (static_instances_decl, expr);
}
-/* Output all strings. */
-
-static void
-generate_strings (void)
-{
- tree chain, string_expr;
- tree string, decl, type;
-
- for (chain = class_names_chain; chain; chain = TREE_CHAIN (chain))
- {
- string = TREE_VALUE (chain);
- decl = TREE_PURPOSE (chain);
- type = build_array_type
- (char_type_node,
- build_index_type
- (build_int_cst (NULL_TREE,
- IDENTIFIER_LENGTH (string))));
- decl = start_var_decl (type, IDENTIFIER_POINTER (DECL_NAME (decl)));
- string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1,
- IDENTIFIER_POINTER (string));
- finish_var_decl (decl, string_expr);
- }
-
- for (chain = meth_var_names_chain; chain; chain = TREE_CHAIN (chain))
- {
- string = TREE_VALUE (chain);
- decl = TREE_PURPOSE (chain);
- type = build_array_type
- (char_type_node,
- build_index_type
- (build_int_cst (NULL_TREE,
- IDENTIFIER_LENGTH (string))));
- decl = start_var_decl (type, IDENTIFIER_POINTER (DECL_NAME (decl)));
- string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1,
- IDENTIFIER_POINTER (string));
- finish_var_decl (decl, string_expr);
- }
-
- for (chain = meth_var_types_chain; chain; chain = TREE_CHAIN (chain))
- {
- string = TREE_VALUE (chain);
- decl = TREE_PURPOSE (chain);
- type = build_array_type
- (char_type_node,
- build_index_type
- (build_int_cst (NULL_TREE,
- IDENTIFIER_LENGTH (string))));
- decl = start_var_decl (type, IDENTIFIER_POINTER (DECL_NAME (decl)));
- string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1,
- IDENTIFIER_POINTER (string));
- finish_var_decl (decl, string_expr);
- }
-}
-
static GTY(()) int selector_reference_idx;
static tree
static tree
add_objc_string (tree ident, enum string_section section)
{
- tree *chain, decl;
+ tree *chain, decl, type, string_expr;
if (section == class_names)
chain = &class_names_chain;
}
decl = build_objc_string_decl (section);
+
+ type = build_array_type
+ (char_type_node,
+ build_index_type
+ (build_int_cst (NULL_TREE,
+ IDENTIFIER_LENGTH (ident))));
+ decl = start_var_decl (type, IDENTIFIER_POINTER (DECL_NAME (decl)));
+ string_expr = my_build_string (IDENTIFIER_LENGTH (ident) + 1,
+ IDENTIFIER_POINTER (ident));
+ finish_var_decl (decl, string_expr);
*chain = tree_cons (decl, ident, NULL_TREE);
return var;
}
else
- return build (EXC_PTR_EXPR, objc_object_type);
+ return build0 (EXC_PTR_EXPR, objc_object_type);
}
/* Build "objc_exception_try_exit(&_stack)". */
t = tree_cons (NULL, t, NULL);
sj = build_function_call (objc_setjmp_decl, t);
- cond = build (COMPOUND_EXPR, TREE_TYPE (sj), enter, sj);
+ cond = build2 (COMPOUND_EXPR, TREE_TYPE (sj), enter, sj);
cond = c_common_truthvalue_conversion (cond);
- return build (COND_EXPR, void_type_node, cond, NULL, NULL);
+ return build3 (COND_EXPR, void_type_node, cond, NULL, NULL);
}
-/* Build
- DECL = objc_exception_extract(&_stack);
-*/
+/* Build:
+
+ DECL = objc_exception_extract(&_stack); */
static tree
next_sjlj_build_exc_extract (tree decl)
t = tree_cons (NULL, t, NULL);
t = build_function_call (objc_exception_extract_decl, t);
t = convert (TREE_TYPE (decl), t);
- t = build (MODIFY_EXPR, void_type_node, decl, t);
+ t = build2 (MODIFY_EXPR, void_type_node, decl, t);
return t;
}
t = build_function_call (objc_exception_match_decl, args);
cond = c_common_truthvalue_conversion (t);
}
- t = build (COND_EXPR, void_type_node, cond, body, NULL);
+ t = build3 (COND_EXPR, void_type_node, cond, body, NULL);
SET_EXPR_LOCUS (t, EXPR_LOCUS (stmt));
*last = t;
if (!saw_id)
{
- t = build (MODIFY_EXPR, void_type_node, cur_try_context->rethrow_decl,
- cur_try_context->caught_decl);
+ t = build2 (MODIFY_EXPR, void_type_node, cur_try_context->rethrow_decl,
+ cur_try_context->caught_decl);
SET_EXPR_LOCATION (t, cur_try_context->end_catch_locus);
append_to_statement_list (t, last);
TREE_CHAIN (rethrow_decl) = stack_decl;
/* Build the outermost variable binding level. */
- bind = build (BIND_EXPR, void_type_node, rethrow_decl, NULL, NULL);
+ bind = build3 (BIND_EXPR, void_type_node, rethrow_decl, NULL, NULL);
SET_EXPR_LOCATION (bind, cur_try_context->try_locus);
TREE_SIDE_EFFECTS (bind) = 1;
/* Initialize rethrow_decl. */
- t = build (MODIFY_EXPR, void_type_node, rethrow_decl,
- convert (objc_object_type, null_pointer_node));
+ t = build2 (MODIFY_EXPR, void_type_node, rethrow_decl,
+ convert (objc_object_type, null_pointer_node));
SET_EXPR_LOCATION (t, cur_try_context->try_locus);
append_to_statement_list (t, &BIND_EXPR_BODY (bind));
/* Build the outermost TRY_FINALLY_EXPR. */
- try_fin = build (TRY_FINALLY_EXPR, void_type_node, NULL, NULL);
+ try_fin = build2 (TRY_FINALLY_EXPR, void_type_node, NULL, NULL);
SET_EXPR_LOCATION (try_fin, cur_try_context->try_locus);
TREE_SIDE_EFFECTS (try_fin) = 1;
append_to_statement_list (try_fin, &BIND_EXPR_BODY (bind));
{
tree caught_decl = objc_build_exc_ptr ();
catch_seq = build_stmt (BIND_EXPR, caught_decl, NULL, NULL);
+ TREE_SIDE_EFFECTS (catch_seq) = 1;
t = next_sjlj_build_exc_extract (caught_decl);
append_to_statement_list (t, &BIND_EXPR_BODY (catch_seq));
/* Initialize the decl from the EXC_PTR_EXPR we get from the runtime. */
t = objc_build_exc_ptr ();
t = convert (TREE_TYPE (decl), t);
- t = build (MODIFY_EXPR, void_type_node, decl, t);
+ t = build2 (MODIFY_EXPR, void_type_node, decl, t);
add_stmt (t);
}
struct _objc_exception_data
{
- int buf[_JBLEN];
+ int buf[JBLEN];
void *pointers[4];
}; */
#ifdef TARGET_POWERPC
/* snarfed from /usr/include/ppc/setjmp.h */
-#define _JBLEN (26 + 36 + 129 + 1)
+#define JBLEN (26 + 36 + 129 + 1)
#else
/* snarfed from /usr/include/i386/{setjmp,signal}.h */
-#define _JBLEN 18
+#define JBLEN 18
#endif
static void
objc_exception_data_template
= start_struct (RECORD_TYPE, get_identifier (UTAG_EXCDATA));
- /* int buf[_JBLEN]; */
+ /* int buf[JBLEN]; */
- index = build_index_type (build_int_cst (NULL_TREE, _JBLEN - 1));
+ index = build_index_type (build_int_cst (NULL_TREE, JBLEN - 1));
field_decl = create_field_decl (build_array_type (integer_type_node, index),
"buf");
field_decl_chain = field_decl;
}
/* Count only the fields occurring in T. */
+
static int
ivar_list_length (tree t)
{
/* ??? Selector is not at this point something we can use inside
the compiler itself. Set it to garbage for the nonce. */
- t = build (OBJ_TYPE_REF, sender_cast, method, lookup_object, size_zero_node);
+ t = build3 (OBJ_TYPE_REF, sender_cast, method, lookup_object, size_zero_node);
return build_function_call (t, method_params);
}
\f
/* Add the method to the hash list if it doesn't contain an identical
method already. */
+
static void
add_method_to_hash_list (hash *hash_list, tree method)
{
return 1;
#endif
+ if (TREE_TYPE (expr) == error_mark_node)
+ return 1;
+
basetype = TYPE_MAIN_VARIANT (TREE_TYPE (expr));
if (basetype && TREE_CODE (basetype) == RECORD_TYPE)
return;
}
- sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC,
- (TREE_INT_CST_LOW (an_int_cst)
- / TREE_INT_CST_LOW (TYPE_SIZE (array_of))));
+ if (TREE_INT_CST_LOW (TYPE_SIZE (array_of)) == 0)
+ sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT)0);
+ else
+ sprintf (buffer, "[" HOST_WIDE_INT_PRINT_DEC,
+ TREE_INT_CST_LOW (an_int_cst)
+ / TREE_INT_CST_LOW (TYPE_SIZE (array_of)));
obstack_grow (&util_obstack, buffer, strlen (buffer));
encode_type (array_of, curtype, format);
else if (code == FUNCTION_TYPE) /* '?' */
obstack_1grow (&util_obstack, '?');
+
+ else if (code == COMPLEX_TYPE)
+ {
+ obstack_1grow (&util_obstack, 'j');
+ encode_type (TREE_TYPE (type), curtype, format);
+ }
}
static void
if (TREE_CODE (type) == TYPE_DECL && DECL_NAME (type))
type = DECL_NAME (type);
- strcat (errbuf, IDENTIFIER_POINTER (type));
+ strcat (errbuf, TREE_CODE (type) == IDENTIFIER_NODE
+ ? IDENTIFIER_POINTER (type)
+ : "");
/* For 'id' and 'Class', adopted protocols are stored in the pointee. */
if (objc_is_id (orig))
(mangled[1] == 'i' || mangled[1] == 'c') &&
mangled[2] == '_')
{
- cp = demangled = xmalloc(strlen(mangled) + 2);
+ cp = demangled = XNEWVEC (char, strlen(mangled) + 2);
if (mangled[1] == 'i')
*cp++ = '-'; /* for instance method */
else
gcc_obstack_init (&util_obstack);
util_firstobj = (char *) obstack_finish (&util_obstack);
- errbuf = (char *) xmalloc (1024 * 10);
+ errbuf = XNEWVEC (char, 1024 * 10);
hash_init ();
synth_module_prologue ();
}
for (impent = imp_list; impent; impent = impent->next)
handle_impent (impent);
- /* Dump the string table last. */
-
- generate_strings ();
-
if (warn_selector)
{
int slot;
DECL_INITIAL (decl) = exp;
TREE_STATIC (decl) = 1;
TREE_USED (decl) = 1;
+ /* Force the output of the decl as this forces the reference of the class. */
+ mark_decl_referenced (decl);
pushdecl (decl);
rest_of_decl_compilation (decl, 0, 0);
&& TREE_CODE (TREE_OPERAND (TREE_OPERAND (function, 0), 0))
== FUNCTION_DECL)
{
- function = build (OBJ_TYPE_REF, TREE_TYPE (function),
- TREE_OPERAND (function, 0),
- TREE_VALUE (params), size_zero_node);
+ function = build3 (OBJ_TYPE_REF, TREE_TYPE (function),
+ TREE_OPERAND (function, 0),
+ TREE_VALUE (params), size_zero_node);
}
return function;