This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
I was using Mercurial wrong. I've been experimenting with using Mercurial to work with GCC and was doing the diff wrong. The attached file should be correct (fingers crossed).
* trans.c (gfc_allocate_with_status): Split into two functions gfc_allocate_using_malloc ad gfc_allocate_usig_lib.
@@ -4881,2 +4889,21 @@ gfc_trans_allocate (gfc_code * code)
+ /* Error checking -- Note: ERRMS only makes sense with STAT. */
@@ -676,2 +638,72 @@ gfc_allocate_with_status (stmtblock_t *
+/* Allocate memory, using an optional status argument. + + This function follows the following pseudo-code: + + void * + allocate (size_t size, integer_type stat) + { + void *newmem; + + if (stat requested) + stat = 0;
+ newmem = _caf_register ( size, regtype, NULL,&stat, NULL, NULL); + if (newmem == NULL) + { + if (!stat requested) + runtime_error ("Allocation would exceed memory limit"); + }
+ return newmem; + } */ +tree +gfc_allocate_using_lib (stmtblock_t * block, tree size, tree status, + tree errmsg, tree errlen) +{ + tree res, pstat; + tree status_type = status ? TREE_TYPE (status) : NULL_TREE; + + /* Evaluate size only once, and make sure it has the right type. */ + size = gfc_evaluate_now (size, block); + if (TREE_TYPE (size) != TREE_TYPE (size_type_node)) + size = fold_convert (size_type_node, size); + + /* Create a variable to hold the result. */ + res = gfc_create_var (prvoid_type_node, NULL); + + /* Set the optional status variable to zero. */ + if (status != NULL_TREE) + gfc_add_expr_to_block (block, + fold_build2_loc (input_location, MODIFY_EXPR, status_type, + status, build_int_cst (status_type, 0)));
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |