public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] Some set but not used warnings workarounds
@ 2009-11-27 12:37 Uros Bizjak
  2009-11-27 12:39 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Uros Bizjak @ 2009-11-27 12:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek

Hello!

> 2009-11-27  Jakub Jelinek  <jakub@redhat.com>
>
> 	* genemit.c (gen_expand, gen_split): Avoid set but not used warnings
> 	when operandN variables aren't used in the body of the expander
> 	or splitter.
>
> 	* gcc.dg/builtin-choose-expr.c: Avoid set but not used warnings.
> 	* gcc.dg/trunc-1.c: Likewise.
> 	* gcc.dg/vla-9.c: Likewise.
> 	* gcc.dg/dfp/composite-type.c: Likewise.
>
> --- gcc/genemit.c.jj	2009-02-20 15:34:31.000000000 +0100
> +++ gcc/genemit.c	2009-11-26 17:36:35.000000000 +0100
> @@ -520,12 +520,13 @@ gen_expand (rtx expand)
>  	 (unless we aren't going to use them at all).  */
>        if (XVEC (expand, 1) != 0)
>  	{
> -	  for (i = 0; i < operands; i++)
> -	    printf ("    operand%d = operands[%d];\n", i, i);
> -	  for (; i <= max_dup_opno; i++)
> -	    printf ("    operand%d = operands[%d];\n", i, i);
> -	  for (; i <= max_scratch_opno; i++)
> -	    printf ("    operand%d = operands[%d];\n", i, i);
> +	  for (i = 0;
> +	       i < MAX (operands, MAX (max_scratch_opno, max_dup_opno) + 1);

	       i <= MAX (operands, MAX (max_scratch_opno, max_dup_opno));

Uros.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Some set but not used warnings workarounds
  2009-11-27 12:37 [PATCH] Some set but not used warnings workarounds Uros Bizjak
@ 2009-11-27 12:39 ` Jakub Jelinek
  2009-11-27 14:03   ` Uros Bizjak
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2009-11-27 12:39 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

On Fri, Nov 27, 2009 at 01:34:28PM +0100, Uros Bizjak wrote:
> > --- gcc/genemit.c.jj	2009-02-20 15:34:31.000000000 +0100
> > +++ gcc/genemit.c	2009-11-26 17:36:35.000000000 +0100
> > @@ -520,12 +520,13 @@ gen_expand (rtx expand)
> >  	 (unless we aren't going to use them at all).  */
> >        if (XVEC (expand, 1) != 0)
> >  	{
> > -	  for (i = 0; i < operands; i++)
> > -	    printf ("    operand%d = operands[%d];\n", i, i);
> > -	  for (; i <= max_dup_opno; i++)
> > -	    printf ("    operand%d = operands[%d];\n", i, i);
> > -	  for (; i <= max_scratch_opno; i++)
> > -	    printf ("    operand%d = operands[%d];\n", i, i);
> > +	  for (i = 0;
> > +	       i < MAX (operands, MAX (max_scratch_opno, max_dup_opno) + 1);
> 
> 	       i <= MAX (operands, MAX (max_scratch_opno, max_dup_opno));

That's not equivalent.  If say max_dup_opno and max_scratch_opno are
-1, that would iterate one more times than it is supposed to.

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Some set but not used warnings workarounds
  2009-11-27 12:39 ` Jakub Jelinek
@ 2009-11-27 14:03   ` Uros Bizjak
  0 siblings, 0 replies; 4+ messages in thread
From: Uros Bizjak @ 2009-11-27 14:03 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Fri, Nov 27, 2009 at 1:37 PM, Jakub Jelinek <jakub@redhat.com> wrote:

>> > -     for (i = 0; i < operands; i++)
>> > -       printf ("    operand%d = operands[%d];\n", i, i);
>> > -     for (; i <= max_dup_opno; i++)
>> > -       printf ("    operand%d = operands[%d];\n", i, i);
>> > -     for (; i <= max_scratch_opno; i++)
>> > -       printf ("    operand%d = operands[%d];\n", i, i);
>> > +     for (i = 0;
>> > +          i < MAX (operands, MAX (max_scratch_opno, max_dup_opno) + 1);
>>
>>              i <= MAX (operands, MAX (max_scratch_opno, max_dup_opno));
>
> That's not equivalent.  If say max_dup_opno and max_scratch_opno are
> -1, that would iterate one more times than it is supposed to.

Ouch, I didn't see the first MAX... Sorry for the noise.

Uros.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Some set but not used warnings workarounds
@ 2009-11-27 10:47 Jakub Jelinek
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2009-11-27 10:47 UTC (permalink / raw)
  To: gcc-patches

Hi!

This patch has some workarounds for the set but not used warnings, as these
aren't removals of the variables and the code isn't wrong, I guess it should
be probably folded into the set but not used warning patch itself, right?

2009-11-27  Jakub Jelinek  <jakub@redhat.com>

	* genemit.c (gen_expand, gen_split): Avoid set but not used warnings
	when operandN variables aren't used in the body of the expander
	or splitter.

	* gcc.dg/builtin-choose-expr.c: Avoid set but not used warnings.
	* gcc.dg/trunc-1.c: Likewise.
	* gcc.dg/vla-9.c: Likewise.
	* gcc.dg/dfp/composite-type.c: Likewise.

--- gcc/genemit.c.jj	2009-02-20 15:34:31.000000000 +0100
+++ gcc/genemit.c	2009-11-26 17:36:35.000000000 +0100
@@ -520,12 +520,13 @@ gen_expand (rtx expand)
 	 (unless we aren't going to use them at all).  */
       if (XVEC (expand, 1) != 0)
 	{
-	  for (i = 0; i < operands; i++)
-	    printf ("    operand%d = operands[%d];\n", i, i);
-	  for (; i <= max_dup_opno; i++)
-	    printf ("    operand%d = operands[%d];\n", i, i);
-	  for (; i <= max_scratch_opno; i++)
-	    printf ("    operand%d = operands[%d];\n", i, i);
+	  for (i = 0;
+	       i < MAX (operands, MAX (max_scratch_opno, max_dup_opno) + 1);
+	       i++)
+	    {
+	      printf ("    operand%d = operands[%d];\n", i, i);
+	      printf ("    (void) operand%d;\n", i);
+	    }
 	}
       printf ("  }\n");
     }
@@ -647,7 +648,10 @@ gen_split (rtx split)
 
   /* Output code to copy the arguments back out of `operands'  */
   for (i = 0; i < operands; i++)
-    printf ("  operand%d = operands[%d];\n", i, i);
+    {
+      printf ("  operand%d = operands[%d];\n", i, i);
+      printf ("  (void) operand%d;\n", i);
+    }
 
   /* Output code to construct the rtl for the instruction bodies.
      Use emit_insn to add them to the sequence being accumulated.
--- gcc/testsuite/gcc.dg/builtin-choose-expr.c.jj	2008-09-05 12:54:36.000000000 +0200
+++ gcc/testsuite/gcc.dg/builtin-choose-expr.c	2009-11-26 23:01:01.000000000 +0100
@@ -29,6 +29,8 @@
           t1 = t1b;						\
           t2 = t2a;						\
           t2 = t2b;						\
+          (void) t1;						\
+          (void) t2;						\
         } while (0)
 
 
--- gcc/testsuite/gcc.dg/trunc-1.c.jj	2008-09-05 12:54:37.000000000 +0200
+++ gcc/testsuite/gcc.dg/trunc-1.c	2009-11-26 23:04:08.000000000 +0100
@@ -11,5 +11,5 @@ main (void)
 
   len = ~(sizeof (size_t) - 1); /* { dg-bogus "truncated" "bogus truncation warning" } */
 
-  return 0;
+  return len - len;
 }
--- gcc/testsuite/gcc.dg/vla-9.c.jj	2008-09-05 12:54:36.000000000 +0200
+++ gcc/testsuite/gcc.dg/vla-9.c	2009-11-26 23:05:48.000000000 +0100
@@ -6,4 +6,5 @@ void f(__SIZE_TYPE__ d)
 {
   typedef int t[d];
   t *g = (__typeof (g)) d;
+  (void) g;
 }
--- gcc/testsuite/gcc.dg/dfp/composite-type.c.jj	2009-09-16 22:08:39.000000000 +0200
+++ gcc/testsuite/gcc.dg/dfp/composite-type.c	2009-11-26 22:59:19.000000000 +0100
@@ -30,18 +30,19 @@ do \
  d##TYPE = f2_##TYPE(h1_##TYPE); \
  d##TYPE = f2_##TYPE(h2_##TYPE); \
  d##TYPE = f2_##TYPE(h3_##TYPE); \
+ (void) d##TYPE; \
 } while(0)
  
 DECIMAL_COMPOSITE_DECL(32);  /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
-/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 35 } */
+/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 36 } */
 
 
 DECIMAL_COMPOSITE_DECL(64);  /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
-/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 39 } */
+/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 40 } */
 
 
 DECIMAL_COMPOSITE_DECL(128); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */
-/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 43 } */
+/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } 44 } */
 
 
 int main()

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-27 12:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-27 12:37 [PATCH] Some set but not used warnings workarounds Uros Bizjak
2009-11-27 12:39 ` Jakub Jelinek
2009-11-27 14:03   ` Uros Bizjak
  -- strict thread matches above, loose matches on Subject: below --
2009-11-27 10:47 Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).