]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39803 (Bogus 'unused value' warning on declarations of non-POD arrays)
authorLe-Chun Wu <lcwu@gcc.gnu.org>
Mon, 20 Apr 2009 21:13:08 +0000 (21:13 +0000)
committerLe-Chun Wu <lcwu@gcc.gnu.org>
Mon, 20 Apr 2009 21:13:08 +0000 (21:13 +0000)
        PR c++/39803
* gcc/cp/init.c (build_vec_init): Set TREE_NO_WARNING on the
compiler-generated INDIRECT_REF expression.
* gcc/testsuite/g++.dg/warn/Wunused-14.C: New test.

From-SVN: r146454

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wunused-14.C [new file with mode: 0644]

index 0d014f57a17883bd9126353641f23f3c3e0a0eaf..15f83d9fb88a122062fadd6351626c90edb81ffb 100644 (file)
@@ -1,3 +1,9 @@
+2009-04-20  Le-Chun Wu  <lcwu@google.com>
+
+       PR c++/39803
+       * init.c (build_vec_init): Set TREE_NO_WARNING on the
+       compiler-generated INDIRECT_REF expression.
+
 2009-04-20  Ian Lance Taylor  <iant@google.com>
 
        * typeck.c (build_function_call_vec): New function.
@@ -34,7 +40,7 @@
        * cp-tree.h (enum tsubst_flags): Rename from enum tsubst_flags_t.
        (tsubst_flags_t): Change typedef from enum type to int.
 
-2009-04-16  Le-Chun Wu  <lcwu@google.com>
+2009-04-16  Paolo Bonzini  <bonzini@gnu.org>
 
        * decl.c (check_initializer): Use TYPE_VECTOR_OPAQUE
        instead of targetm.vector_opaque_p.
index 812042d7f7fde7c732c4176b495969bd853800d9..d40a5e7e53fd344d274ce7602b36b3391b830a70 100644 (file)
@@ -2920,6 +2920,7 @@ build_vec_init (tree base, tree maxindex, tree init,
       atype = build_pointer_type (atype);
       stmt_expr = build1 (NOP_EXPR, atype, stmt_expr);
       stmt_expr = cp_build_indirect_ref (stmt_expr, NULL, complain);
+      TREE_NO_WARNING (stmt_expr) = 1;
     }
 
   current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps;
index 478e893681287e3a182791efa3de2d8f2cc16cd3..c58967338c159fa1e0f8a4a0426e740c3176c96d 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-20  Le-Chun Wu  <lcwu@google.com>
+
+       PR c++/39803
+       * g++.dg/warn/Wunused-14.C: New test.
+
 2009-04-20  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/specs/small_alignment.ads: New test.
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-14.C b/gcc/testsuite/g++.dg/warn/Wunused-14.C
new file mode 100644 (file)
index 0000000..b325ccb
--- /dev/null
@@ -0,0 +1,14 @@
+// Test that -Wunused should not emit a warning on the initialization of
+// non-POD arrays. See PR c++/39803.
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+#include <utility>
+
+using std::pair;
+
+int foo() {
+  pair<int, const char*> components[3]; // { dg-bogus "value computed is not used" }
+  components[0].first = 0;
+  return 0;
+}