Commit ad13f229 by Dodji Seketeli Committed by Jakub Jelinek

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
parent f145213f
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.
......
......@@ -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))
......
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
......
/* 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment