[V2,3/4] Work around bootstrap failure in Fortran front end.

Message ID 20200813163432.1067-4-sandra@codesourcery.com
State New
Headers show
Series
  • Unify C and C++ handling of loops and switches
Related show

Commit Message

Sandra Loosemore Aug. 13, 2020, 4:34 p.m.
Switching the C++ front end to lower loops the same was as the C front
end triggered this error when bootstrapping the Fortran front end:

/path/to/gcc/fortran/interface.c:3546:12: error: '*new_arg' may be used uninitialized [-Werror=maybe-uninitialized]
 3546 |   new_arg[i]->next = NULL;
      |   ~~~~~~~~~^

Work around this by adding an assertion, which seems appropriate for
documentation and good coding practices anyway.

2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/fortran/
	* interface.c (gfc_compare_actual_formal): Add assertion after
	main processing loop to silence maybe-uninitialized error.
---
 gcc/fortran/interface.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.8.1

Comments

Christophe Lyon via Gcc-patches Aug. 15, 2020, 6:24 p.m. | #1
Hi,

the change looks good to me, OK for master.

Regards

	Thomas
> This arose from work by Sandra on "Unify C and C++ handling of loops and 

> switches"

> 

> Kind regards,

> Toon.

> 

> -------- Forwarded Message --------

> Subject: [PATCH V2 3/4] Work around bootstrap failure in Fortran front end.

> Date: Thu, 13 Aug 2020 10:34:31 -0600

> From: Sandra Loosemore <sandra@codesourcery.com>

> To: gcc-patches@gcc.gnu.org

> 

> Switching the C++ front end to lower loops the same was as the C front

> end triggered this error when bootstrapping the Fortran front end:

> 

> /path/to/gcc/fortran/interface.c:3546:12: error: '*new_arg' may be used 

> uninitialized [-Werror=maybe-uninitialized]

>   3546 |   new_arg[i]->next = NULL;

>        |   ~~~~~~~~~^

> 

> Work around this by adding an assertion, which seems appropriate for

> documentation and good coding practices anyway.

> 

> 2020-08-12  Sandra Loosemore  <sandra@codesourcery.com>

> 

>      gcc/fortran/

>      * interface.c (gfc_compare_actual_formal): Add assertion after

>      main processing loop to silence maybe-uninitialized error.

> ---

>   gcc/fortran/interface.c | 4 ++++

>   1 file changed, 4 insertions(+)

> 

> diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c

> index 7985fc7..9fea94c 100644

> --- a/gcc/fortran/interface.c

> +++ b/gcc/fortran/interface.c

> @@ -3527,6 +3527,10 @@ gfc_compare_actual_formal (gfc_actual_arglist 

> **ap, gfc_formal_arglist *formal,

>       }

>       }

>   +  /* We should have handled the cases where the formal arglist is null

> +     already.  */

> +  gcc_assert (n > 0);

> +

>     /* The argument lists are compatible.  We now relink a new actual

>        argument list with null arguments in the right places.  The head

>        of the list remains the head.  */

Patch

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 7985fc7..9fea94c 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -3527,6 +3527,10 @@  gfc_compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal,
 	}
     }
 
+  /* We should have handled the cases where the formal arglist is null
+     already.  */
+  gcc_assert (n > 0);
+
   /* The argument lists are compatible.  We now relink a new actual
      argument list with null arguments in the right places.  The head
      of the list remains the head.  */