[PATCH] Some set but not used warnings workarounds (take 2)

Jakub Jelinek jakub@redhat.com
Sat Nov 28 11:29:00 GMT 2009


Hi!

On Fri, Nov 27, 2009 at 05:43:31AM -0500, Jakub Jelinek wrote:
> 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?

Here is an updated patch with several more workarounds, IMHO they should be
committed only when the warning patch is.

2009-11-28  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.
	* tree-outof-ssa.c (FOR_EACH_ELIM_GRAPH_SUCC,
	FOR_EACH_ELIM_GRAPH_PRED): Avoid set but not used warnings.
	* tree-ssa-operands.h (FOR_EACH_SSA_TREE_OPERAND): Likewise.
	* tree-flow.h (FOR_EACH_IMM_USE_FAST, FOR_EACH_IMM_USE_STMT):
	Likewise.
	* tree.h (FOR_EACH_CONSTRUCTOR_ELT): Likewise.
	* tree.c (PROCESS_ARG): Likewise.
libjava/classpath/
	* native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c
	(Java_gnu_javax_sound_midi_alsa_AlsaPortDevice_run_1receiver_1thread_1):
	Avoid set but not used warning.
libiberty/
	* regex.c (byte_re_match_2_internal): Avoid set but not used
	warning.
gcc/testsuite/
	* 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/tree-outof-ssa.c.jj	2009-11-25 16:47:37.000000000 +0100
+++ gcc/tree-outof-ssa.c	2009-11-27 14:57:14.000000000 +0100
@@ -431,8 +431,9 @@ do {									\
       y_ = VEC_index (int, (GRAPH)->edge_list, x_);			\
       if (y_ != (NODE))							\
         continue;							\
-      (VAR) = VEC_index (int, (GRAPH)->edge_list, x_ + 1);		\
-      (LOCUS) = VEC_index (source_location, (GRAPH)->edge_locus, x_ / 2); \
+      (void) ((VAR) = VEC_index (int, (GRAPH)->edge_list, x_ + 1));	\
+      (void) ((LOCUS) = VEC_index (source_location,			\
+				   (GRAPH)->edge_locus, x_ / 2));	\
       CODE;								\
     }									\
 } while (0)
@@ -451,8 +452,9 @@ do {									\
       y_ = VEC_index (int, (GRAPH)->edge_list, x_ + 1);			\
       if (y_ != (NODE))							\
         continue;							\
-      (VAR) = VEC_index (int, (GRAPH)->edge_list, x_);			\
-      (LOCUS) = VEC_index (source_location, (GRAPH)->edge_locus, x_ / 2); \
+      (void) ((VAR) = VEC_index (int, (GRAPH)->edge_list, x_));		\
+      (void) ((LOCUS) = VEC_index (source_location,			\
+				   (GRAPH)->edge_locus, x_ / 2));	\
       CODE;								\
     }									\
 } while (0)
--- gcc/tree-flow.h.jj	2009-11-25 16:47:37.000000000 +0100
+++ gcc/tree-flow.h	2009-11-27 14:58:54.000000000 +0100
@@ -256,17 +256,17 @@ typedef struct immediate_use_iterator_d
 /* Use this iterator when simply looking at stmts.  Adding, deleting or
    modifying stmts will cause this iterator to malfunction.  */
 
-#define FOR_EACH_IMM_USE_FAST(DEST, ITER, SSAVAR)			\
+#define FOR_EACH_IMM_USE_FAST(DEST, ITER, SSAVAR)		\
   for ((DEST) = first_readonly_imm_use (&(ITER), (SSAVAR));	\
        !end_readonly_imm_use_p (&(ITER));			\
-       (DEST) = next_readonly_imm_use (&(ITER)))
+       (void) ((DEST) = next_readonly_imm_use (&(ITER))))
 
 /* Use this iterator to visit each stmt which has a use of SSAVAR.  */
 
 #define FOR_EACH_IMM_USE_STMT(STMT, ITER, SSAVAR)		\
   for ((STMT) = first_imm_use_stmt (&(ITER), (SSAVAR));		\
        !end_imm_use_stmt_p (&(ITER));				\
-       (STMT) = next_imm_use_stmt (&(ITER)))
+       (void) ((STMT) = next_imm_use_stmt (&(ITER))))
 
 /* Use this to terminate the FOR_EACH_IMM_USE_STMT loop early.  Failure to
    do so will result in leaving a iterator marker node in the immediate
--- gcc/tree.h.jj	2009-11-27 13:00:10.000000000 +0100
+++ gcc/tree.h	2009-11-27 16:14:33.000000000 +0100
@@ -1510,9 +1510,9 @@ struct GTY(()) tree_vec {
 #define FOR_EACH_CONSTRUCTOR_ELT(V, IX, INDEX, VAL) \
   for (IX = 0; (IX >= VEC_length (constructor_elt, V)) \
 	       ? false \
-	       : ((VAL = VEC_index (constructor_elt, V, IX)->value), \
+	       : (((void) (VAL = VEC_index (constructor_elt, V, IX)->value)), \
 		  (INDEX = VEC_index (constructor_elt, V, IX)->index), \
-	       true); \
+		  true); \
        (IX)++)
 
 /* Append a new constructor element to V, with the specified INDEX and VAL.  */
--- gcc/tree.c.jj	2009-11-25 16:47:35.000000000 +0100
+++ gcc/tree.c	2009-11-27 15:13:11.000000000 +0100
@@ -3640,9 +3640,9 @@ build1_stat (enum tree_code code, tree t
 	  side_effects = 1;			\
         if (!TREE_READONLY (arg##N)		\
 	    && !CONSTANT_CLASS_P (arg##N))	\
-	  read_only = 0;			\
+	  (void) (read_only = 0);		\
         if (!TREE_CONSTANT (arg##N))		\
-	  constant = 0;				\
+	  (void) (constant = 0);		\
       }						\
   } while (0)
 
--- gcc/genemit.c.jj	2009-11-27 12:36:45.000000000 +0100
+++ gcc/genemit.c	2009-11-27 13:00:46.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/tree-ssa-operands.h.jj	2009-11-25 16:47:35.000000000 +0100
+++ gcc/tree-ssa-operands.h	2009-11-27 15:00:35.000000000 +0100
@@ -160,7 +160,7 @@ typedef struct ssa_operand_iterator_d
 #define FOR_EACH_SSA_TREE_OPERAND(TREEVAR, STMT, ITER, FLAGS)	\
   for (TREEVAR = op_iter_init_tree (&(ITER), STMT, FLAGS);	\
        !op_iter_done (&(ITER));					\
-       TREEVAR = op_iter_next_tree (&(ITER)))
+       (void) (TREEVAR = op_iter_next_tree (&(ITER))))
 
 /* This macro executes a loop over the operands of STMT specified in FLAG,
    returning each operand as a 'use_operand_p' in the variable USEVAR.
--- libjava/classpath/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c.jj	2008-09-05 12:57:59.000000000 +0200
+++ libjava/classpath/native/jni/midi-alsa/gnu_javax_sound_midi_alsa_AlsaPortDevice.c	2009-11-27 17:34:12.000000000 +0100
@@ -48,7 +48,7 @@ Java_gnu_javax_sound_midi_alsa_AlsaPortD
   (JNIEnv *env, jobject this __attribute__((unused)), 
    jlong client, jlong port, jobject receiver)
 {
-  int rc;
+  int rc __attribute__((unused));
   snd_seq_port_info_t *pinfo, *sinfo;
   snd_seq_port_subscribe_t *subs;
   snd_seq_addr_t sender, dest;
--- libiberty/regex.c.jj	2009-10-02 10:02:01.000000000 +0200
+++ libiberty/regex.c	2009-11-27 17:33:04.000000000 +0100
@@ -7140,8 +7140,8 @@ byte_re_match_2_internal (struct re_patt
                register from the stack, since lowest will == highest in
                `pop_failure_point'.  */
             active_reg_t dummy_low_reg, dummy_high_reg;
-            UCHAR_T *pdummy = NULL;
-            const CHAR_T *sdummy = NULL;
+            UCHAR_T *pdummy ATTRIBUTE_UNUSED = NULL;
+            const CHAR_T *sdummy ATTRIBUTE_UNUSED = NULL;
 
             DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
             POP_FAILURE_POINT (sdummy, pdummy,
--- gcc/testsuite/gcc.dg/builtin-choose-expr.c.jj	2009-11-27 12:25:18.000000000 +0100
+++ gcc/testsuite/gcc.dg/builtin-choose-expr.c	2009-11-27 13:00:46.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	2009-11-27 12:25:18.000000000 +0100
+++ gcc/testsuite/gcc.dg/trunc-1.c	2009-11-27 13:00:46.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	2009-11-27 12:25:18.000000000 +0100
+++ gcc/testsuite/gcc.dg/vla-9.c	2009-11-27 13:00:46.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-11-27 12:25:18.000000000 +0100
+++ gcc/testsuite/gcc.dg/dfp/composite-type.c	2009-11-27 13:00:46.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



More information about the Gcc-patches mailing list