[PATCH] PR fortran/77372
Fritz Reese
fritzoreese@gmail.com
Fri Aug 26 11:02:00 GMT 2016
On Thu, Aug 25, 2016 at 6:13 PM, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> I plan to commit the following patch on Saturday if
> no one objects in the next 40 or so hours.
>
> 2016-08-25 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/77372
> simplify.c (simplify_ieee_selected_real_kind): Check for NULL pointers.
>
> 2016-08-25 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/77372
> gfortran.dg/pr77372.f90: New test.
>
> Index: gcc/fortran/simplify.c
> ===================================================================
> --- gcc/fortran/simplify.c (revision 239762)
> +++ gcc/fortran/simplify.c (working copy)
> @@ -7044,9 +7044,19 @@ gfc_simplify_compiler_version (void)
> gfc_expr *
> simplify_ieee_selected_real_kind (gfc_expr *expr)
> {
> - gfc_actual_arglist *arg = expr->value.function.actual;
> - gfc_expr *p = arg->expr, *q = arg->next->expr,
> - *rdx = arg->next->next->expr;
> + gfc_actual_arglist *arg;
> + gfc_expr *p = NULL, *q = NULL, *rdx = NULL;
> +
> + arg = expr->value.function.actual;
> + if (arg->expr)
> + p = arg->expr;
> + if (arg->next)
> + {
> + if (arg->next->expr)
> + q = arg->next->expr;
> + if (arg->next->next && arg->next->next->expr)
> + rdx = arg->next->next->expr;
> + }
>
(snip)
Technically there are three superfluous conditions. The following is equivalent:
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 8096a92..a3d42e1 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -7045,8 +7045,15 @@ gfc_expr *
simplify_ieee_selected_real_kind (gfc_expr *expr)
{
- gfc_actual_arglist *arg = expr->value.function.actual;
- gfc_expr *p = arg->expr, *q = arg->next->expr,
- *rdx = arg->next->next->expr;
+ gfc_actual_arglist *arg;
+ gfc_expr *p = NULL, *q = NULL, *rdx = NULL;
+
+ arg = expr->value.function.actual;
+ p = arg->expr;
+ if (arg->next)
+ {
+ q = arg->next->expr;
+ if (arg->next->next)
+ rdx = arg->next->next->expr;
+ }
/* Currently, if IEEE is supported and this module is built, it means
all our floating-point types conform to IEEE. Hence, we simply handle
More information about the Gcc-patches
mailing list