[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-17 Thread dodji at gcc dot gnu dot org


--- Comment #3 from dodji at gcc dot gnu dot org  2010-05-17 12:30 ---
Created an attachment (id=20678)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20678action=view)
Candidate patch

On Fri, May 14, 2010 at 07:25:18AM -, jakub at gcc dot gnu dot org wrote:
 That said, it would be good to find out why we don't warn in that
 case; for [M_CONST + 6] we do warn.

I think we don't warn in that case because M_CONST in the expression
M_CONST + 6, M_CONST is an rvalue use and we recognize it as such via
default_conversion that should be called on the arguments of the + expression.

We fail to recognize the use of [M_CONST], because M_CONST gets folded
into it's value without us marking that folding as an rvalue use. I
am thus testing the attached patch. The reason why the patch seems
convoluted is that I don't want to mark a dependant value as a rvalue
use. I believe only full instantiations should be marked.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108



[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-17 Thread dodji at gcc dot gnu dot org


--- Comment #4 from dodji at gcc dot gnu dot org  2010-05-17 13:54 ---
Created an attachment (id=20681)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20681action=view)
Don't warn for integral constants

Jakub, this one line patch implements the first idea which is to not warn for
integral constants, as far as Wunused_but_set_variable is concerned.

I have tested it only for the reported error case. I haven't regtested it yet.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108



[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-17 Thread jakub at gcc dot gnu dot org


--- Comment #5 from jakub at gcc dot gnu dot org  2010-05-17 17:25 ---
Subject: Bug 44108

Author: jakub
Date: Mon May 17 17:24:32 2010
New Revision: 159497

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=159497
Log:
PR c++/44108
* decl.c (compute_array_index_type): Call mark_rvalue_use.

* c-c++-common/Wunused-var-8.c: New test.

Added:
trunk/gcc/testsuite/c-c++-common/Wunused-var-8.c
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108



[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-17 Thread dodji at gcc dot gnu dot org


--- Comment #6 from dodji at gcc dot gnu dot org  2010-05-17 19:45 ---
This should be fixed in trunk (4.6)


-- 

dodji at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108



[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-14 Thread dodji at gcc dot gnu dot org


-- 

dodji at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |dodji at gcc dot gnu dot org
   |dot org |
 Status|UNCONFIRMED |ASSIGNED
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2010-05-14 06:42:26
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108



[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-14 Thread jakub at gcc dot gnu dot org


--- Comment #2 from jakub at gcc dot gnu dot org  2010-05-14 07:25 ---
Perhaps we just shouldn't ever warn for TREE_CONSTANT decls with
-Wunused-but-set-* ?
Such variables can't be ever set (the set is just the definition),  
therefore all sets of TREE_USED for them are reads. 
That said, it would be good to find out why we don't warn in that  
case; for [M_CONST + 6] we do warn. 
Or for DECL_INTEGRAL_CONSTANT_VAR_P decls, or for decls for which  
integral_constant_value (decl) != decl not sure what is best.
In any case, compute_array_index_type (and probably many other spots)
calls integral_constant_value and thus
doesn't see the passed in decl anymore afterwards.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108



[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-13 Thread rubidium at openttd dot org


--- Comment #1 from rubidium at openttd dot org  2010-05-13 11:04 ---
Created an attachment (id=20655)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20655action=view)
Simple testcase

Compile with g++ -Wunused-but-set-variable testcase.cpp


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108



[Bug c++/44108] [4.6 Regression] -Wunused-but-set-variable does not consider array sizing use of a const variable

2010-05-13 Thread rguenth at gcc dot gnu dot org


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

   Target Milestone|--- |4.6.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44108