Bug 33522 - Incorrect warning messages about uninitialized variables
Summary: Incorrect warning messages about uninitialized variables
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Francois-Xavier Coudert
URL:
Keywords: diagnostic, patch
: 33523 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-21 19:24 UTC by Dale Ranta
Modified: 2007-09-22 16:59 UTC (History)
2 users (show)

See Also:
Host: powerpc-apple-darwin8.10.0
Target:
Build:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2007-09-22 15:02:06


Attachments
The fortran source (654 bytes, text/plain)
2007-09-21 19:25 UTC, Dale Ranta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dale Ranta 2007-09-21 19:24:14 UTC
These incorrect messages have been appearing lately. The variables are always and only accessed in the save branch of the switch statements - so they will never and can never be used uninitialized.


[dranta:~/tests/gfortran-D] dir% gfortran -c -O2 -Wuninitialized module_files.f90
module_files.f90: In function 'my_sio_file_read_common':
module_files.f90:36: warning: 'scratch_r8.dim[1].stride' may be used uninitialized in this function
module_files.f90:36: warning: 'scratch_r8.offset' may be used uninitialized in this function
module_files.f90:35: warning: 'scratch_i4.dim[1].stride' may be used uninitialized in this function
module_files.f90:35: warning: 'scratch_i4.offset' may be used uninitialized in this function
[dranta:~/tests/gfortran-D] dir% gfortran --v
Using built-in specs.
Target: powerpc-apple-darwin8.10.0
Configured with: ../gcc/configure --disable-bootstrap --enable-multilib --prefix=/usr/local/gfortran --enable-languages=c,fortran
Thread model: posix
gcc version 4.3.0 20070921 (experimental) (GCC)
Comment 1 Dale Ranta 2007-09-21 19:25:18 UTC
Created attachment 14240 [details]
The fortran source
Comment 2 Francois-Xavier Coudert 2007-09-22 13:57:28 UTC
*** Bug 33523 has been marked as a duplicate of this bug. ***
Comment 3 Francois-Xavier Coudert 2007-09-22 15:02:05 UTC
Patch below fixes it:

Index: trans-types.c
===================================================================
--- trans-types.c       (revision 128661)
+++ trans-types.c       (working copy)
@@ -1088,16 +1088,19 @@ gfc_get_desc_dim_type (void)
   decl = build_decl (FIELD_DECL,
                     get_identifier ("stride"), gfc_array_index_type);
   DECL_CONTEXT (decl) = type;
+  TREE_NO_WARNING (decl) = 1;
   fieldlist = decl;
 
   decl = build_decl (FIELD_DECL,
                     get_identifier ("lbound"), gfc_array_index_type);
   DECL_CONTEXT (decl) = type;
+  TREE_NO_WARNING (decl) = 1;
   fieldlist = chainon (fieldlist, decl);
 
   decl = build_decl (FIELD_DECL,
                     get_identifier ("ubound"), gfc_array_index_type);
   DECL_CONTEXT (decl) = type;
+  TREE_NO_WARNING (decl) = 1;
   fieldlist = chainon (fieldlist, decl);
 
   /* Finish off the type.  */
@@ -1389,12 +1392,14 @@ gfc_get_array_descriptor_base (int dimen
   decl = build_decl (FIELD_DECL, get_identifier ("offset"),
                     gfc_array_index_type);
   DECL_CONTEXT (decl) = fat_type;
+  TREE_NO_WARNING (decl) = 1;
   fieldlist = chainon (fieldlist, decl);
 
   /* Add the dtype component.  */
   decl = build_decl (FIELD_DECL, get_identifier ("dtype"),
                     gfc_array_index_type);
   DECL_CONTEXT (decl) = fat_type;
+  TREE_NO_WARNING (decl) = 1;
   fieldlist = chainon (fieldlist, decl);
 
   /* Build the array type for the stride and bound components.  */
@@ -1406,6 +1411,7 @@ gfc_get_array_descriptor_base (int dimen
 
   decl = build_decl (FIELD_DECL, get_identifier ("dim"), arraytype);
   DECL_CONTEXT (decl) = fat_type;
+  TREE_NO_WARNING (decl) = 1;
   fieldlist = chainon (fieldlist, decl);
 
   /* Finish off the type.  */
Comment 4 Francois-Xavier Coudert 2007-09-22 16:55:08 UTC
Subject: Bug 33522

Author: fxcoudert
Date: Sat Sep 22 16:54:56 2007
New Revision: 128673

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128673
Log:
	PR fortran/33522
	* trans-types.c (gfc_get_desc_dim_type): Mark artificial
	variables with TREE_NO_WARNING.
	(gfc_get_array_descriptor_base): Likewise.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-types.c

Comment 5 Francois-Xavier Coudert 2007-09-22 16:59:05 UTC
Fixed.