diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-02-12 16:10:22 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-02-12 16:10:22 +0000 |
commit | 6ca01870c76fc20e212ebb54fb24457b04203c7a (patch) | |
tree | 88035cf4c2b5a23c7b58223152ddcf7032fd5e6a /gcc/fortran | |
parent | 2572b605aec59ecf2645bd7e50cdc10090078d92 (diff) | |
download | gcc-6ca01870c76fc20e212ebb54fb24457b04203c7a.tar.gz |
2017-02-12 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/65542
* intrinsic.c (gfc_intrinsic_func_interface): Return an error
for -std=f95 for disallowed transformational functions in
initialization expressions.
2017-02-12 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/65542
* gfortran.dg/spread_init_expr_2.f90: New test case.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245376 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.c | 21 |
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3488f01e7cd..dc5e50e9ab9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2017-02-12 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/65542 + * intrinsic.c (gfc_intrinsic_func_interface): Return an error + for -std=f95 for disallowed transformational functions in + initialization expressions. + 2017-02-09 Cesar Philippidis <cesar@codesourcery.com> Joseph Myers <joseph@codesourcery.com> diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index e059a312dfd..923572d888c 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -4680,6 +4680,27 @@ gfc_intrinsic_func_interface (gfc_expr *expr, int error_flag) return MATCH_ERROR; } + /* F95, 7.1.6.1: Only transformational functions REPEAT, RESHAPE, + SELECTED_INT_KIND, SELECTED_REAL_KIND, TRANSFER, and TRIM are allowed in + initialization expressions. */ + + if (gfc_init_expr_flag && isym->transformational) + { + gfc_isym_id id = isym->id; + if (id != GFC_ISYM_REPEAT && id != GFC_ISYM_RESHAPE + && id != GFC_ISYM_SI_KIND && id != GFC_ISYM_SR_KIND + && id != GFC_ISYM_TRANSFER && id != GFC_ISYM_TRIM + && !gfc_notify_std (GFC_STD_F2003, "Transformational function %qs " + "at %L is invalid in an initialization " + "expression", name, &expr->where)) + { + if (!error_flag) + gfc_pop_suppress_errors (); + + return MATCH_ERROR; + } + } + gfc_current_intrinsic_where = &expr->where; /* Bypass the generic list for min, max and ISO_C_Binding's c_loc. */ |