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++ PATCH for c++/84221, bogus -Wunused with unused attribute on template


On Wed, Apr 4, 2018 at 3:58 PM, Jason Merrill <jason@redhat.com> wrote:
> On Wed, Apr 4, 2018 at 3:52 PM, Martin Sebor <msebor@gmail.com> wrote:
>> On 04/04/2018 01:04 PM, Jason Merrill wrote:
>>>
>>> For bugs 54372 and 60063, we changed attributes used and unused to be
>>> applied immediately in a template even if what they apply to is
>>> dependent, to avoid bogus warnings from
>>> maybe_warn_unused_local_typedefs.  But that's only an issue for
>>> TYPE_DECL, so we can use the normal logic for other things.
>>
>> In our discussion of attributes I thought we decided that explicit
>> specializations would not inherit attributes from the primary.
>> IIUC, this change does the opposite for class templates declared
>> unused so we end up with an inconsistency with function templates:
>
> I thought about that as well, tested with the explicit specialization
> removed, and found that still failed.  So that's the bug I fixed.
>
> We do still warn on the testcase from the PR; I should add that to the
> testcase I checked in.

Thus.
commit 2ddab1fb8b6b919ab8dc460efe96e1b114f90a2e
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 4 15:58:11 2018 -0400

    PR c++/84221
    * g++.dg/warn/Wunused-var-32.C: Test explicit specialization.

diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-32.C b/gcc/testsuite/g++.dg/warn/Wunused-var-32.C
index 5558f9361fc..8aaf381ffa6 100644
--- a/gcc/testsuite/g++.dg/warn/Wunused-var-32.C
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-32.C
@@ -2,8 +2,10 @@
 // { dg-additional-options -Wunused }
 
 template <class T> struct __attribute((unused)) A { };
+template <> struct A<char> { };
 
 void f (void)
 {
   A<int> a;   // shouldn't warn
+  A<char> ac; // { dg-warning "unused" }
 }              

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