Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Mike Stump
On Nov 8, 2013, at 2:35 AM, Mingjie Xing wrote: > Oops, if it is not a bug, please close the report > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57258 Well, I've stated my position. I can be swayed by a good argument, if someone has one. I'd give people a chance to weigh in if they can think

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Mike Stump
On Nov 8, 2013, at 2:25 AM, Bin.Cheng wrote: > Thanks for elaborating. The warning message is actually for no-use of > variable, and it has few things to do with whether it's accessed or > not. I disagree. If you examine why the warning was put in, you realize it was put in so that lazy progra

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Mingjie Xing
Oops, if it is not a bug, please close the report http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57258 Thanks, Mingjie 2013/11/8 Richard Biener : > On Fri, Nov 8, 2013 at 10:39 AM, Mike Stump wrote: >> >> On Nov 8, 2013, at 1:32 AM, Bin.Cheng wrote: >> >>> On Fri, Nov 8, 2013 at 5:03 PM, Mike Stum

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Bin.Cheng
On Fri, Nov 8, 2013 at 5:39 PM, Mike Stump wrote: > > On Nov 8, 2013, at 1:32 AM, Bin.Cheng wrote: > >> On Fri, Nov 8, 2013 at 5:03 PM, Mike Stump wrote: >>> On Nov 7, 2013, at 5:13 PM, Mingjie Xing wrote: Well, it is my understanding that the warning should be emitted for a volatile

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Richard Biener
On Fri, Nov 8, 2013 at 10:39 AM, Mike Stump wrote: > > On Nov 8, 2013, at 1:32 AM, Bin.Cheng wrote: > >> On Fri, Nov 8, 2013 at 5:03 PM, Mike Stump wrote: >>> On Nov 7, 2013, at 5:13 PM, Mingjie Xing wrote: Well, it is my understanding that the warning should be emitted for a volatile

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Mike Stump
On Nov 8, 2013, at 1:32 AM, Bin.Cheng wrote: > On Fri, Nov 8, 2013 at 5:03 PM, Mike Stump wrote: >> On Nov 7, 2013, at 5:13 PM, Mingjie Xing wrote: >>> Well, it is my understanding that the warning should be emitted for a >>> volatile variable only if it is not accessed. Initialization means

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Bin.Cheng
On Fri, Nov 8, 2013 at 5:03 PM, Mike Stump wrote: > On Nov 7, 2013, at 5:13 PM, Mingjie Xing wrote: >> Well, it is my understanding that the warning should be emitted for a >> volatile variable only if it is not accessed. Initialization means >> accessing, even though it is not used anywhere. >

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-08 Thread Mike Stump
On Nov 7, 2013, at 5:13 PM, Mingjie Xing wrote: > Well, it is my understanding that the warning should be emitted for a > volatile variable only if it is not accessed. Initialization means > accessing, even though it is not used anywhere. Let me try. A warning is useful, if there is no way a co

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-07 Thread Mingjie Xing
2013/11/7 Joseph S. Myers : > On Thu, 7 Nov 2013, Mingjie Xing wrote: > >> 2013/11/6 Richard Biener : >> > You miss a testcase. >> > >> > Also why should the warning be omitted for unused automatic >> > volatile variables? They cannot be used in any way. >> > >> > Richard. >> >> Thanks. I've upda

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-07 Thread Joseph S. Myers
On Thu, 7 Nov 2013, Mingjie Xing wrote: > 2013/11/6 Richard Biener : > > You miss a testcase. > > > > Also why should the warning be omitted for unused automatic > > volatile variables? They cannot be used in any way. > > > > Richard. > > Thanks. I've updated the patch with a test case. You do

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-07 Thread Joey Ye
- warning_at (DECL_SOURCE_LOCATION (p), - OPT_Wunused_but_set_variable, - "variable %qD set but not used", p); + { +if (!TREE_THIS_VOLATILE (p)) + warning_at (DECL_SOURCE_LOCATION (p), +OPT_Wunused_but_set_variable, +"variable %qD set but not used", p); + } I'd prefe

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-06 Thread Bin.Cheng
On Thu, Nov 7, 2013 at 11:53 AM, Mingjie Xing wrote: > 2013/11/6 Richard Biener : >> You miss a testcase. >> >> Also why should the warning be omitted for unused automatic >> volatile variables? They cannot be used in any way. >> >> Richard. > > Thanks. I've updated the patch with a test case. >

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-06 Thread Mingjie Xing
2013/11/6 Richard Biener : > You miss a testcase. > > Also why should the warning be omitted for unused automatic > volatile variables? They cannot be used in any way. > > Richard. Thanks. I've updated the patch with a test case. c/ChangeLog PR 57258 * c-decl.c (pop_scope): Don

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-06 Thread Joseph S. Myers
On Wed, 6 Nov 2013, Mingjie Xing wrote: > * c/c-decl.c (pop_scope): Skip volatile variables while emit > warnings for unused variables. c/ has its own ChangeLog, so no c/ in the ChangeLog entries. This patch doesn't include a testsuite addition. -- Joseph S. Myers jos...@codesourcery.c

Re: [C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-06 Thread Richard Biener
On Wed, Nov 6, 2013 at 8:40 AM, Mingjie Xing wrote: > Hi, > > Changes: > > * c/c-decl.c (pop_scope): Skip volatile variables while emit > warnings for unused variables. > > Tested on i686-pc-linux-gnu. > > OK? You miss a testcase. Also why should the warning be omitted for unused automat

[C] Fix PR57258: unused variable warning is emitted for volatile variables

2013-11-05 Thread Mingjie Xing
Hi, Changes: * c/c-decl.c (pop_scope): Skip volatile variables while emit warnings for unused variables. Tested on i686-pc-linux-gnu. OK? Mingjie Index: gcc/c/c-decl.c === --- gcc/c/c-decl.c (revision 204285) +++ gcc/c/c-d