Bug 53551 - -Wunused-local-typedefs misses uses
Summary: -Wunused-local-typedefs misses uses
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Dodji Seketeli
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-01 12:23 UTC by Akim Demaille
Modified: 2012-09-28 12:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-09-20 00:00:00


Attachments
Test case (122 bytes, application/octet-stream)
2012-06-01 12:24 UTC, Akim Demaille
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Akim Demaille 2012-06-01 12:23:13 UTC
Hi!

In the following example, the "context" struct provides types to a template class, "structure".  The provided type is used to define a member variable.  Yet G++ 4.8 claims:

g++-mp-4.8 -std=c++11 -Wall bar.cc
bar.cc: In function 'int main()':
bar.cc:12:21: warning: typedef 'using type = int' locally defined but not used [-Wunused-local-typedefs]
     using type = int;
                     ^

This is:

g++-mp-4.8 (MacPorts gcc48 4.8-20120527_1) 4.8.0 20120527 (experimental)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The program is:


template <typename C>
struct structure
{
  typename C::type val;
};

int
main()
{
  struct context
  {
    using type = int;
  };

  return structure<context>{42}.val;
}

Thanks!
Comment 1 Akim Demaille 2012-06-01 12:24:44 UTC
Created attachment 27539 [details]
Test case
Comment 2 Paolo Carlini 2012-08-24 12:07:57 UTC
Dodji, can we do something about this?
Comment 3 Dodji Seketeli 2012-09-20 13:46:59 UTC
Yes, I am testing a patch for this.
Comment 4 Dodji Seketeli 2012-09-20 20:23:35 UTC
A candidate patch was sent to http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01492.html
Comment 5 Dodji Seketeli 2012-09-28 12:21:49 UTC
Author: dodji
Date: Fri Sep 28 12:21:33 2012
New Revision: 191828

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191828
Log:
PR c++/53551 - -Wunused-local-typedefs misses uses

We don't record the use of a typedef when it's used through a
typename.  Fixed thus.

Tested on x86_64-unknown-linux-gnu against trunk.

gcc/cp/

	* decl.c (make_typename_type): Record the use of typedefs.

gcc/testsuite/

	* g++.dg/warn/Wunused-local-typedefs-2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Dodji Seketeli 2012-09-28 12:32:04 UTC
Fixed in trunk (4.8)