aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2010-05-17 17:24:32 +0000
committerJakub Jelinek <jakub@gcc.gnu.org>2010-05-17 19:24:32 +0200
commitad13f2299cefa72529059e21385c4c49f1491181 (patch)
tree786dcd92a7ad0fc0015905fd8c1894a4eca21613 /gcc
parentf145213fcc63518e181ae5b74a38f75555f6a741 (diff)
downloadgcc-ad13f2299cefa72529059e21385c4c49f1491181.zip
gcc-ad13f2299cefa72529059e21385c4c49f1491181.tar.gz
gcc-ad13f2299cefa72529059e21385c4c49f1491181.tar.bz2
re PR c++/44108 (-Wunused-but-set-variable does not consider array sizing use of a const variable)
PR c++/44108 * decl.c (compute_array_index_type): Call mark_rvalue_use. * c-c++-common/Wunused-var-8.c: New test. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r159497
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/c-c++-common/Wunused-var-8.c19
4 files changed, 33 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 84b8ae5..acc111f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-17 Dodji Seketeli <dodji@redhat.com>
+ Jason Merrill <jason@redhat.com>
+
+ PR c++/44108
+ * decl.c (compute_array_index_type): Call mark_rvalue_use.
+
2010-05-15 Jason Merrill <jason@redhat.com>
* cp-tree.h (TYPE_NOEXCEPT_P): New macro.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 148bcf5..0636aba 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7369,6 +7369,8 @@ compute_array_index_type (tree name, tree size)
/* The size might be the result of a cast. */
STRIP_TYPE_NOPS (size);
+ size = mark_rvalue_use (size);
+
/* It might be a const variable or enumeration constant. */
size = integral_constant_value (size);
if (error_operand_p (size))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fcc6968..2d31000 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-17 Dodji Seketeli <dodji@redhat.com>
+ Jason Merrill <jason@redhat.com>
+
+ PR c++/44108
+ * c-c++-common/Wunused-var-8.c: New test.
+
2010-05-17 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/42347
diff --git a/gcc/testsuite/c-c++-common/Wunused-var-8.c b/gcc/testsuite/c-c++-common/Wunused-var-8.c
new file mode 100644
index 0000000..0923b35
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wunused-var-8.c
@@ -0,0 +1,19 @@
+/* Origin: PR c++/44108 */
+/* { dg-options "-Wunused" } */
+/* { dg-do compile } */
+
+int
+foo ()
+{
+ unsigned int M = 2;
+ const unsigned int M_CONST = 2;
+ static unsigned int M_STATIC = 2;
+ static const unsigned int M_STATIC_CONST = 2;
+
+ char n1[M];
+ char n2[M_CONST];
+ char n3[M_STATIC];
+ char n4[M_STATIC_CONST];
+
+ return sizeof (n1) + sizeof (n2) + sizeof (n3) + sizeof (n4);
+}