Patchwork [Fortran] (3/n) Fix bit/logical bugs found by Coverity

login
register
mail settings
Submitter Tobias Burnus
Date Sept. 16, 2012, 12:19 p.m.
Message ID <5055C3CF.7020206@net-b.de>
Download mbox | patch
Permalink /patch/184127/
State New
Headers show

Comments

Tobias Burnus - Sept. 16, 2012, 12:19 p.m.
Committed as obvious (Rev. 191358) after building and successfully 
regtesting on x86-64-linux.

I collected some futher bugs in 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54599. There several 
additional ones, but many are bogus. I think the most common "defect" is 
that one dereferences a pointer and either before or afterwards one 
checks whether it is NULL. And there are several places where gfortran 
leaks memory.

Tobias

Patch

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(Revision 191357)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,3 +1,10 @@ 
+2012-09-16  Tobias Burnus  <burnus@net-b.de>
+
+	* trans-decl.c (gfc_generate_function_code): Fix
+	gfc_option.coarray check.
+	* trans-stmt.c (compute_inner_temp_size): Fix handling
+	of gfc_option.rtcheck.
+
 2012-09-16  Mikael Morin  <mikael@gcc.gnu.org>
 
 	* symbol.c (gfc_undo_symbols): Correctly undo namelists.
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(Revision 191357)
+++ gcc/fortran/trans-decl.c	(Arbeitskopie)
@@ -5480,7 +5480,7 @@  gfc_generate_function_code (gfc_namespace * ns)
     }
   current_function_decl = old_context;
 
-  if (decl_function_context (fndecl) && !gfc_option.coarray == GFC_FCOARRAY_LIB
+  if (decl_function_context (fndecl) && gfc_option.coarray != GFC_FCOARRAY_LIB
       && has_coarray_vars)
     /* Register this function with cgraph just far enough to get it
        added to our parent's nested function list.
Index: gcc/fortran/trans-stmt.c
===================================================================
--- gcc/fortran/trans-stmt.c	(Revision 191357)
+++ gcc/fortran/trans-stmt.c	(Arbeitskopie)
@@ -3132,7 +3132,7 @@  compute_inner_temp_size (gfc_expr *expr1, gfc_expr
 
       /* Calculate the bounds of the scalarization.  */
       save_flag = gfc_option.rtcheck;
-      gfc_option.rtcheck &= !GFC_RTCHECK_BOUNDS;
+      gfc_option.rtcheck &= ~GFC_RTCHECK_BOUNDS;
       gfc_conv_ss_startstride (&loop);
       gfc_option.rtcheck = save_flag;
       gfc_conv_loop_setup (&loop, &expr2->where);