diff mbox

Workaround -Wmaybe-uninitialized false positives during profiledbootstrap

Message ID 54BD1844.1060203@suse.cz
State New
Headers show

Commit Message

Martin Liška Jan. 19, 2015, 2:44 p.m. UTC
On 01/15/2015 12:35 PM, Richard Biener wrote:
> On Thu, Jan 15, 2015 at 12:29 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Thu, Jan 15, 2015 at 12:17:44PM +0100, Richard Biener wrote:
>>> On Thu, Jan 15, 2015 at 12:10 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>>>> Hi!
>>>>
>>>> I ran into -Werror=maybe-uninitialized errors during profiledbootstrap
>>>> (../configure --enable-languages=c,c++ --enable-checking=release;
>>>> make -j16 profiledboostrap) before I hit a miscompilation I'm going to file.
>>>>
>>>> Is this ok for trunk, or do we want to work around them differently?
>>>
>>> I wonder if we can arrange profiledbootstrap to use --disable-werror
>>> unless --enable-werror is specified explicitely...  Similarly useful
>>> if we could do a similar thing from non-standard build-configs...
>>
>> For non-standard ones I'm ok, but I've always hoped that profiledbootstrap
>> is considered standard.  It certainly worked fine with -Werror at least
>> for us in gcc 4.[4-9].
>
> Indeed it did (with release checking at least).
>
>>> I also wonder if we shouldn't simply fix the uninit pass ...
>>
>> If it is possible, sure, but it isn't always the case.
>>
>> We could also just use type var = var; if that is the way to avoid
>> the warnings and not generate extra code.
>
> Is that portable though?  (legal C, not subject to other compilers
> that it might be "hineous"...)
>
> Anyway, I guess the patch is ok if you add a comment after the inits
> /* initialize to avoid warnings with profiledbootstrap */
> or similar.  Otherwise people might be tempted to remove the
> init again (or wonder why it is there) as it works in regular bootstrap.
>
> Thanks,
> Richard.
>
>
>>          Jakub

Hello.

There's a bunch of another places that emit false positives. With following patch,
I am able to run profiledbootstrap on x86_64-linux-pc and ppc64-linux-pc.

Ready for trunk?

Thanks,
Martin

Comments

Jakub Jelinek Jan. 19, 2015, 2:48 p.m. UTC | #1
On Mon, Jan 19, 2015 at 03:44:20PM +0100, Martin Liška wrote:
> There's a bunch of another places that emit false positives. With following patch,
> I am able to run profiledbootstrap on x86_64-linux-pc and ppc64-linux-pc.

I don't know what we consider standard and where we allow warnings and thus
require --disable-werror, so will defer to Richard.

> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -3050,6 +3050,11 @@ tree_int_cst_elt_check (tree __t, int __i,
>    return &CONST_CAST_TREE (__t)->int_cst.val[__i];
>  }
>  
> +/* Workaround -Wstrict-overflow false positive during profiledbootstrap.  */
> +
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wstrict-overflow"

Just I wonder if this shouldn't be guarded by GCC_VERSION >= something
that actually supports those.
> +
>  inline tree *
>  tree_vec_elt_check (tree __t, int __i,
>                      const char *__f, int __l, const char *__g)
> @@ -3061,6 +3066,8 @@ tree_vec_elt_check (tree __t, int __i,
>    return &CONST_CAST_TREE (__t)->vec.a[__i];
>  }
>  
> +#pragma GCC diagnostic pop
> +
>  inline tree *
>  omp_clause_elt_check (tree __t, int __i,
>                        const char *__f, int __l, const char *__g)

	Jakub
diff mbox

Patch

From 53c21661d2371c513b5940ee534b89044c066d2a Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Mon, 19 Jan 2015 13:30:53 +0100
Subject: [PATCH] Remove false positives for warnings that break LTO profiled
 bootstrap.

gcc/ChangeLog:

2015-01-19  Martin Liska  <mliska@suse.cz>

	* tree.h (tree_vec_elt_check): Workaround -Wstrict-overflow
	false positive during profiledbootstrap.

gcc/fortran/ChangeLog:

2015-01-19  Martin Liska  <mliska@suse.cz>

	* decl.c (attr_decl1): Workaround -Wmaybe-uninitialized
	false positive during profiledbootstrap by initializing them.
	* matchexp.c (match_mult_operand): Likewise.
	* module.c (write_atom): Likewise.
	(read_module): Likewise.
---
 gcc/fortran/decl.c     | 5 ++++-
 gcc/fortran/matchexp.c | 4 +++-
 gcc/fortran/module.c   | 9 +++++++--
 gcc/tree.h             | 7 +++++++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 2a200fc..cc35c65 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -6391,7 +6391,10 @@  attr_decl1 (void)
 {
   char name[GFC_MAX_SYMBOL_LEN + 1];
   gfc_array_spec *as;
-  gfc_symbol *sym;
+
+  /* Workaround -Wmaybe-uninitialized false positive during
+     profiledbootstrap by initializing them.  */
+  gfc_symbol *sym = NULL;
   locus var_locus;
   match m;
 
diff --git a/gcc/fortran/matchexp.c b/gcc/fortran/matchexp.c
index ec07dfc..fc35c8c 100644
--- a/gcc/fortran/matchexp.c
+++ b/gcc/fortran/matchexp.c
@@ -258,7 +258,9 @@  match_add_op (void)
 static match
 match_mult_operand (gfc_expr **result)
 {
-  gfc_expr *e, *exp, *r;
+  /* Workaround -Wmaybe-uninitialized false positive during
+     profiledbootstrap by initializing them.  */
+  gfc_expr *e = NULL, *exp, *r;
   locus where;
   match m;
 
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index c47489a..4cfc0e2 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -1536,7 +1536,10 @@  static void
 write_atom (atom_type atom, const void *v)
 {
   char buffer[20];
-  int i, len;
+
+  /* Workaround -Wmaybe-uninitialized false positive during
+     profiledbootstrap by initializing them.  */
+  int i = 0, len;
   const char *p;
 
   switch (atom)
@@ -4908,7 +4911,9 @@  read_module (void)
   const char *p;
   char name[GFC_MAX_SYMBOL_LEN + 1];
   int i;
-  int ambiguous, j, nuse, symbol;
+  /* Workaround -Wmaybe-uninitialized false positive during
+     profiledbootstrap by initializing them.  */
+  int ambiguous = 0, j, nuse, symbol = 0;
   pointer_info *info, *q;
   gfc_use_rename *u = NULL;
   gfc_symtree *st;
diff --git a/gcc/tree.h b/gcc/tree.h
index 4f83b38..03a8303 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3050,6 +3050,11 @@  tree_int_cst_elt_check (tree __t, int __i,
   return &CONST_CAST_TREE (__t)->int_cst.val[__i];
 }
 
+/* Workaround -Wstrict-overflow false positive during profiledbootstrap.  */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-overflow"
+
 inline tree *
 tree_vec_elt_check (tree __t, int __i,
                     const char *__f, int __l, const char *__g)
@@ -3061,6 +3066,8 @@  tree_vec_elt_check (tree __t, int __i,
   return &CONST_CAST_TREE (__t)->vec.a[__i];
 }
 
+#pragma GCC diagnostic pop
+
 inline tree *
 omp_clause_elt_check (tree __t, int __i,
                       const char *__f, int __l, const char *__g)
-- 
2.1.2