diff options
author | msebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-21 22:33:39 +0000 |
---|---|---|
committer | msebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-21 22:33:39 +0000 |
commit | da7a26fca86f7257b5bcb365c68b3727d0f1fad6 (patch) | |
tree | b6e3dbc7ba092a9077d668b134400cb6a5ce690d /gcc/c-family | |
parent | fcd8b5ad239bc8970a30c54e4529ab29832697b7 (diff) | |
download | gcc-da7a26fca86f7257b5bcb365c68b3727d0f1fad6.tar.gz |
PR c++/79548 - missing -Wunused-variable on a typedef'd variable in a function template
gcc/c-family/ChangeLog:
PR c++/79548
* c-common.c (set_underlying_type): Mark type used only when
original del is declared unused.
gcc/testsuite/ChangeLog:
PR c++/79548
* g++.dg/warn/Wunused-var-26.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@246335 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0a7fef1d3ee..4afb4b8af6e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-03-21 Martin Sebor <msebor@redhat.com> + + PR c++/79548 + * c-common.c (set_underlying_type): Mark type used only when + original del is declared unused. + 2017-03-10 David Malcolm <dmalcolm@redhat.com> PR translation/79848 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 885ea6d2d70..65ffd8cd7bd 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -7476,7 +7476,12 @@ set_underlying_type (tree x) tt = build_variant_type_copy (tt); TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (DECL_ORIGINAL_TYPE (x)); TYPE_NAME (tt) = x; - TREE_USED (tt) = TREE_USED (x); + + /* Mark the type as used only when its type decl is decorated + with attribute unused. */ + if (lookup_attribute ("unused", DECL_ATTRIBUTES (x))) + TREE_USED (tt) = 1; + TREE_TYPE (x) = tt; } } |