This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


-  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 prefer

        else if (DECL_CONTEXT (p) == current_function_decl
                    && !TREE_THIS_VOLATILE (p))

which concises the logic and avoids indent change

Thanks,
Joey

On Thu, Nov 7, 2013 at 3:37 PM, Bin.Cheng <amker.cheng@gmail.com> wrote:
> On Thu, Nov 7, 2013 at 11:53 AM, Mingjie Xing <mingjie.xing@gmail.com> wrote:
>> 2013/11/6 Richard Biener <richard.guenther@gmail.com>:
>>> 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
>
> Should be:
>            PR c/57258
>
> Thanks,
> bin
>>         * c-decl.c (pop_scope): Don't emit unused variable warnings for
>>         accessed volatile variables.
>>
>> testsuite/ChangeLog
>>
>>         * gcc.dg/Wunused-var-4.c: New test.
>>
>> Mingjie
>
>
>
> --
> Best Regards.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]