Mercurial > hg > CbC > CbC_gcc
diff gcc/fortran/arith.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line diff
--- a/gcc/fortran/arith.c Fri Oct 27 22:46:09 2017 +0900 +++ b/gcc/fortran/arith.c Thu Oct 25 07:37:49 2018 +0900 @@ -1,5 +1,5 @@ /* Compiler arithmetic - Copyright (C) 2000-2017 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. Contributed by Andy Vaught This file is part of GCC. @@ -113,6 +113,11 @@ p = _("Integer outside symmetric range implied by Standard Fortran at %L"); break; + case ARITH_WRONGCONCAT: + p = + _("Illegal type in character concatenation at %L"); + break; + default: gfc_internal_error ("gfc_arith_error(): Bad error code"); } @@ -555,10 +560,10 @@ val = ARITH_OK; } - if (val != ARITH_OK) + if (val == ARITH_OK || val == ARITH_OVERFLOW) + *rp = r; + else gfc_free_expr (r); - else - *rp = r; return val; } @@ -980,9 +985,14 @@ gfc_arith_concat (gfc_expr *op1, gfc_expr *op2, gfc_expr **resultp) { gfc_expr *result; - int len; - - gcc_assert (op1->ts.kind == op2->ts.kind); + size_t len; + + /* By cleverly playing around with constructors, is is possible + to get mismaching types here. */ + if (op1->ts.type != BT_CHARACTER || op2->ts.type != BT_CHARACTER + || op1->ts.kind != op2->ts.kind) + return ARITH_WRONGCONCAT; + result = gfc_get_constant_expr (BT_CHARACTER, op1->ts.kind, &op1->where); @@ -1089,7 +1099,7 @@ int gfc_compare_string (gfc_expr *a, gfc_expr *b) { - int len, alen, blen, i; + size_t len, alen, blen, i; gfc_char_t ac, bc; alen = a->value.character.length; @@ -1116,7 +1126,7 @@ int gfc_compare_with_Cstring (gfc_expr *a, const char *b, bool case_sensitive) { - int len, alen, blen, i; + size_t len, alen, blen, i; gfc_char_t ac, bc; alen = a->value.character.length; @@ -1603,9 +1613,13 @@ if (rc != ARITH_OK) { gfc_error (gfc_arith_error (rc), &op1->where); + if (rc == ARITH_OVERFLOW) + goto done; return NULL; } +done: + gfc_free_expr (op1); gfc_free_expr (op2); return result; @@ -2514,6 +2528,18 @@ return result; } +/* Convert character to character. We only use wide strings internally, + so we only set the kind. */ + +gfc_expr * +gfc_character2character (gfc_expr *src, int kind) +{ + gfc_expr *result; + result = gfc_copy_expr (src); + result->ts.kind = kind; + + return result; +} /* Helper function to set the representation in a Hollerith conversion. This assumes that the ts.type and ts.kind of the result have already @@ -2604,6 +2630,7 @@ result = gfc_copy_expr (src); result->ts.type = BT_CHARACTER; result->ts.kind = kind; + result->ts.u.pad = 0; result->value.character.length = result->representation.length; result->value.character.string