diff options
author | Martin Liska <mliska@suse.cz> | 2021-12-09 11:38:40 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2021-12-09 11:38:40 +0100 |
commit | 7a81590757659982cb9b93b922a4c182aa40e2d8 (patch) | |
tree | 6aa576127aba8f373e779fe7f82f4956a2d0861a /gcc/fortran/expr.c | |
parent | 4cba2fa027afd5f815bd9bf3965afe1972c7387c (diff) | |
parent | 5791bf7a0a7705be6c3989c445e7c739220f3290 (diff) | |
download | gcc-7a81590757659982cb9b93b922a4c182aa40e2d8.zip gcc-7a81590757659982cb9b93b922a4c182aa40e2d8.tar.gz gcc-7a81590757659982cb9b93b922a4c182aa40e2d8.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 4084d18..8708932 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2331,6 +2331,31 @@ gfc_simplify_expr (gfc_expr *p, int type) } +/* Try simplification of an expression via gfc_simplify_expr. + When an error occurs (arithmetic or otherwise), roll back. */ + +bool +gfc_try_simplify_expr (gfc_expr *e, int type) +{ + gfc_expr *n; + bool t, saved_div0; + + if (e == NULL || e->expr_type == EXPR_CONSTANT) + return true; + + saved_div0 = gfc_seen_div0; + gfc_seen_div0 = false; + n = gfc_copy_expr (e); + t = gfc_simplify_expr (n, type) && !gfc_seen_div0; + if (t) + gfc_replace_expr (e, n); + else + gfc_free_expr (n); + gfc_seen_div0 = saved_div0; + return t; +} + + /* Returns the type of an expression with the exception that iterator variables are automatically integers no matter what else they may be declared as. */ |