static struct c_expr c_parser_postfix_expression_after_primary (c_parser *parser, struct c_expr expr) { tree ident, idx, exprlist; while (true) { switch (c_parser_peek_token (parser)->type) { case CPP_OPEN_PAREN: /* Function call. */ c_parser_consume_token (parser); #if 0 if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) exprlist = NULL_TREE; else #endif #if 0 exprlist = c_parser_expr_list (parser, true); #endif c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); #if 0 expr.value = build_function_call (expr.value, exprlist); #endif expr.original_code = ERROR_MARK; break; default: return expr; } } }
void c_objc_common_finish_file (void) { if (pch_file) c_common_write_pch (); /* If multiple translation units were built, copy information between them based on linkage rules. */ merge_translation_unit_decls (); cgraph_finalize_compilation_unit (); cgraph_optimize (); if (static_ctors) { tree body = start_cdtor ('I'); for (; static_ctors; static_ctors = TREE_CHAIN (static_ctors)) c_expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors), NULL_TREE)); finish_cdtor (body); } if (static_dtors) { tree body = start_cdtor ('D'); for (; static_dtors; static_dtors = TREE_CHAIN (static_dtors)) c_expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors), NULL_TREE)); finish_cdtor (body); } { int flags; FILE *stream = dump_begin (TDI_all, &flags); if (stream) { dump_node (getdecls (), flags & ~TDF_SLIM, stream); dump_end (TDI_all, stream); } } }
static tree do_free_exception (tree ptr) { tree fn; fn = get_identifier ("__cxa_free_exception"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void __cxa_free_exception (void *). */ fn = push_void_library_fn (fn, tree_cons (NULL_TREE, ptr_type_node, void_list_node)); } return build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE)); }
static tree do_allocate_exception (tree type) { tree fn; fn = get_identifier ("__cxa_allocate_exception"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void *__cxa_allocate_exception(size_t). */ tree tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } return build_function_call (fn, tree_cons (NULL_TREE, size_in_bytes (type), NULL_TREE)); }
static tree do_begin_catch (void) { tree fn; fn = get_identifier ("__cxa_begin_catch"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void* __cxa_begin_catch (void *). */ tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } return build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), NULL_TREE)); }
static tree do_end_catch (tree type) { tree fn, cleanup; fn = get_identifier ("__cxa_end_catch"); if (!get_global_value_if_present (fn, &fn)) { /* Declare void __cxa_end_catch (). */ fn = push_void_library_fn (fn, void_list_node); /* This can throw if the destructor for the exception throws. */ TREE_NOTHROW (fn) = 0; } cleanup = build_function_call (fn, NULL_TREE); TREE_NOTHROW (cleanup) = dtor_nothrow (type); return cleanup; }
static tree /* APPLE LOCAL radar 2848255 */ do_begin_catch (tree type) { tree fn; /* APPLE LOCAL begin radar 2848255 */ if (c_dialect_objc () && objc2_valid_objc_catch_type (type)) fn = get_identifier ("objc_begin_catch"); else fn = get_identifier ("__cxa_begin_catch"); /* APPLE LOCAL end radar 2848255 */ if (!get_global_value_if_present (fn, &fn)) { /* Declare void* __cxa_begin_catch (void *). */ tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp)); } return build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), NULL_TREE)); }
static tree do_end_catch (tree type) { tree fn, cleanup; /* APPLE LOCAL begin radar 2848255 */ if (c_dialect_objc () && objc2_valid_objc_catch_type (type)) fn = get_identifier ("objc_end_catch"); else fn = get_identifier ("__cxa_end_catch"); /* APPLE LOCAL end radar 2848255 */ if (!get_global_value_if_present (fn, &fn)) { /* Declare void __cxa_end_catch (). */ fn = push_void_library_fn (fn, void_list_node); /* This can throw if the destructor for the exception throws. */ TREE_NOTHROW (fn) = 0; } cleanup = build_function_call (fn, NULL_TREE); TREE_NOTHROW (cleanup) = dtor_nothrow (type); return cleanup; }
static tree call_eh_info () { tree fn; fn = get_identifier ("__start_cp_handler"); if (IDENTIFIER_GLOBAL_VALUE (fn)) fn = IDENTIFIER_GLOBAL_VALUE (fn); else { tree t1, t, fields[7]; /* Declare cp_eh_info * __start_cp_handler (void), as defined in exception.cc. */ /* struct cp_eh_info. This must match exception.cc. Note that this type is not pushed anywhere. */ t1= make_aggr_type (RECORD_TYPE); fields[0] = build_decl (FIELD_DECL, get_identifier ("handler_label"), ptr_type_node); fields[1] = build_decl (FIELD_DECL, get_identifier ("dynamic_handler_chain"), ptr_type_node); fields[2] = build_decl (FIELD_DECL, get_identifier ("info"), ptr_type_node); fields[3] = build_decl (FIELD_DECL, get_identifier ("table_index"), ptr_type_node); /* N.B.: The fourth field LEN is expected to be the number of fields - 1, not the total number of fields. */ finish_builtin_type (t1, "eh_context", fields, 3, ptr_type_node); t1 = build_pointer_type (t1); t1= make_aggr_type (RECORD_TYPE); #ifdef TARG_XTENSA fields[0] = build_decl (FIELD_DECL, get_identifier ("version"), integer_type_node); /* N.B.: The fourth field LEN is expected to be the number of fields - 1, not the total number of fields. */ finish_builtin_type (t1, "__eh_info", fields, 0, ptr_type_node); #else fields[0] = build_decl (FIELD_DECL, get_identifier ("match_function"), ptr_type_node); fields[1] = build_decl (FIELD_DECL, get_identifier ("language"), short_integer_type_node); fields[2] = build_decl (FIELD_DECL, get_identifier ("version"), short_integer_type_node); /* N.B.: The fourth field LEN is expected to be the number of fields - 1, not the total number of fields. */ finish_builtin_type (t1, "__eh_info", fields, 2, ptr_type_node); #endif t = make_aggr_type (RECORD_TYPE); fields[0] = build_decl (FIELD_DECL, get_identifier ("eh_info"), t1); fields[1] = build_decl (FIELD_DECL, get_identifier ("value"), ptr_type_node); fields[2] = build_decl (FIELD_DECL, get_identifier ("type"), ptr_type_node); fields[3] = build_decl (FIELD_DECL, get_identifier ("cleanup"), build_pointer_type (build_function_type (ptr_type_node, tree_cons (NULL_TREE, ptr_type_node, void_list_node)))); fields[4] = build_decl (FIELD_DECL, get_identifier ("caught"), boolean_type_node); fields[5] = build_decl (FIELD_DECL, get_identifier ("next"), build_pointer_type (t)); fields[6] = build_decl (FIELD_DECL, get_identifier ("handlers"), long_integer_type_node); /* N.B.: The fourth field LEN is expected to be the number of fields - 1, not the total number of fields. */ finish_builtin_type (t, "cp_eh_info", fields, 6, ptr_type_node); t = build_pointer_type (t); /* And now the function. */ fn = push_library_fn (fn, build_function_type (t, void_list_node)); } return build_function_call (fn, NULL_TREE); }
/* target hook for resolve_overloaded_builtin(). Returns a function call RTX if we can resolve the overloaded builtin */ tree spu_resolve_overloaded_builtin (tree fndecl, tree fnargs) { #define SCALAR_TYPE_P(t) (INTEGRAL_TYPE_P (t) \ || SCALAR_FLOAT_TYPE_P (t) \ || POINTER_TYPE_P (t)) int new_fcode, fcode = DECL_FUNCTION_CODE (fndecl) - END_BUILTINS; struct spu_builtin_description *desc; tree match = NULL_TREE; /* The vector types are not available if the backend is not initialized. */ gcc_assert (!flag_preprocess_only); desc = &spu_builtins[fcode]; if (desc->type != B_OVERLOAD) return NULL_TREE; /* Compare the signature of each internal builtin function with the function arguments until a match is found. */ for (new_fcode = fcode + 1; spu_builtins[new_fcode].type == B_INTERNAL; new_fcode++) { tree decl = spu_builtins[new_fcode].fndecl; tree params = TYPE_ARG_TYPES (TREE_TYPE (decl)); tree arg, param; bool all_scalar; int p; /* Check whether all parameters are scalar. */ all_scalar = true; for (param = params; param != void_list_node; param = TREE_CHAIN (param)) if (!SCALAR_TYPE_P (TREE_VALUE (param))) all_scalar = false; for (param = params, arg = fnargs, p = 0; param != void_list_node; param = TREE_CHAIN (param), arg = TREE_CHAIN (arg), p++) { tree var, arg_type, param_type = TREE_VALUE (param); if (!arg) { error ("insufficient arguments to overloaded function %s", desc->name); return error_mark_node; } var = TREE_VALUE (arg); if (TREE_CODE (var) == NON_LVALUE_EXPR) var = TREE_OPERAND (var, 0); if (TREE_CODE (var) == ERROR_MARK) return NULL_TREE; /* Let somebody else deal with the problem. */ arg_type = TREE_TYPE (var); /* The intrinsics spec does not specify precisely how to resolve generic intrinsics. We require an exact match for vector types and let C do it's usual parameter type checking/promotions for scalar arguments, except for the first argument of intrinsics which don't have a vector parameter. */ if ((!SCALAR_TYPE_P (param_type) || !SCALAR_TYPE_P (arg_type) || (all_scalar && p == 0)) && !lang_hooks.types_compatible_p (param_type, arg_type)) break; } if (param == void_list_node) { if (arg) { error ("too many arguments to overloaded function %s", desc->name); return error_mark_node; } match = decl; break; } } if (match == NULL_TREE) { error ("parameter list does not match a valid signature for %s()", desc->name); return error_mark_node; } return build_function_call (match, fnargs); #undef SCALAR_TYPE_P }
static expression build_taskid(module m, data_declaration taskdecl) { /* Build a unique identifier for a task whose declaration is taskdecl, in module m. Method: we add enum { m$taskdecl = unique("task-unique-string") }; to all_cdecls and return an identifier-expression referring to m$taskdecl */ location loc = taskdecl->ast->location; region r = parse_region; cstring idname; enumerator idast; struct data_declaration tempdecl; enum_ref idenum; tag_declaration enumdecl; data_decl iddecl; expression unique_id, unique_fn, unique_args, use_id; cstring silly_name; identifier_declarator silly_id; declarator silly_d; type_element silly_modifiers; rid silly_typedef; type silly_type; variable_decl silly_vd; data_decl silly_decl; /* Build unique("task-unique-string") */ unique_fn = build_identifier(r, loc, magic_unique); unique_args = build_string(r, loc, scheduler_unique_name); default_conversion(unique_args); unique_id = build_function_call(r, loc, unique_fn, unique_args); /* Build, declare enumerator taskdecl */ idname = str2cstring(r, taskdecl->name); idast = new_enumerator(r, loc, idname, unique_id, NULL); init_data_declaration(&tempdecl, CAST(declaration, idast), idname.data, int_type); tempdecl.kind = decl_constant; tempdecl.definition = tempdecl.ast; tempdecl.value = unique_id->cst; idast->ddecl = declare(m->ienv, &tempdecl, FALSE); /* Build the enum declaration */ idenum = new_enum_ref(r, loc, NULL, NULL, NULL, TRUE); idenum->fields = CAST(declaration, idast); idenum->tdecl = enumdecl = declare_tag(idenum); layout_enum_start(enumdecl); enumdecl->definition = idenum; enumdecl->defined = TRUE; layout_enum_end(enumdecl); /* Build the expression we will use in the wiring. */ use_id = build_identifier(r, loc, idast->ddecl); /* Hack: the use_id expression needs to be in the module's AST so that we do instantiation and constant folding on it. We build a silly typedef for that purpose: typedef int __nesc_sillytask_taskdecl[use_id] */ silly_name = alloc_cstring(r, strlen(taskdecl->name) + 17); sprintf(silly_name.data, "__nesc_sillytask_%s", taskdecl->name); silly_id = new_identifier_declarator(r, loc, silly_name); silly_type = make_array_type(int_type, use_id); type2ast(r, loc, silly_type, CAST(declarator, silly_id), &silly_d, &silly_modifiers); silly_typedef = new_rid(r, loc, RID_TYPEDEF); silly_vd = new_variable_decl(r, loc, silly_d, NULL, NULL, NULL, NULL/*ddecl*/); init_data_declaration(&tempdecl, CAST(declaration, silly_vd), silly_name.data, silly_type); tempdecl.kind = decl_typedef; tempdecl.definition = tempdecl.ast; silly_vd->ddecl = declare(m->ienv, &tempdecl, FALSE); silly_vd->declared_type = silly_type; silly_decl = new_data_decl(r, loc, type_element_chain(CAST(type_element, silly_typedef), silly_modifiers), CAST(declaration, silly_vd)); m->decls = declaration_chain(CAST(declaration, silly_decl), m->decls); /* Build the declaration and add it to the module's decls */ iddecl = new_data_decl(r, loc, CAST(type_element, idenum), NULL); m->decls = declaration_chain(CAST(declaration, iddecl), m->decls); return use_id; }