aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-05-26 11:17:54 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-05-26 11:17:54 +0200
commit6fc9f7aa731e895585c47d740509b5cd1591e797 (patch)
treed6a31e869ca764436905f87f10676d248ddddf01 /gcc/cp/decl2.c
parent28e0e05badfbdf7930bbd6f3051b07dd7ec37ae2 (diff)
downloadgcc-6fc9f7aa731e895585c47d740509b5cd1591e797.zip
gcc-6fc9f7aa731e895585c47d740509b5cd1591e797.tar.gz
gcc-6fc9f7aa731e895585c47d740509b5cd1591e797.tar.bz2
cp-tree.h (struct lang_decl_decomp): New type.
* cp-tree.h (struct lang_decl_decomp): New type. (struct lang_decl): Add u.decomp. (LANG_DECL_DECOMP_CHECK): Define. (DECL_DECOMPOSITION_P): Note it is set also on the vars for user identifiers. (DECL_DECOMP_BASE): Define. (retrofit_lang_decl): Add extra int = 0 argument. * lex.c (retrofit_lang_decl): Add SEL argument, if non-zero use it to influence the selector choices and for selector 0 to non-zero transition copy old content. (cxx_dup_lang_specific_decl): Handle DECL_DECOMPOSITION_P. * decl.c (poplevel): For DECL_DECOMPOSITION_P, check !DECL_DECOMP_BASE instead of !DECL_VALUE_EXPR. Adjust warning wording if decl is a structured binding. (cp_finish_decomp): Pass 4 as the new argument to retrofit_lang_decl. Set DECL_DECOMP_BASE. Ignore DECL_READ_P sets from initialization of individual variables for tuple structured bindings. (grokdeclarator): Pass 4 as the new argument to retrofit_lang_decl. Clear DECL_DECOMP_BASE. * decl2.c (mark_used): Mark DECL_DECOMP_BASE TREE_USED as well. * pt.c (tsubst_decomp_names): Assert DECL_DECOMP_BASE matches what is expected. * expr.c (mark_exp_read): Recurse on DECL_DECOMP_BASE instead of DECL_VALUE_EXPR. * g++.dg/cpp1z/decomp29.C (p): New variable. (main): Add further tests. From-SVN: r248483
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 85310e0..73eeb01 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5027,6 +5027,9 @@ mark_used (tree decl, tsubst_flags_t complain)
/* Set TREE_USED for the benefit of -Wunused. */
TREE_USED (decl) = 1;
+ /* And for structured bindings also the underlying decl. */
+ if (DECL_DECOMPOSITION_P (decl) && DECL_DECOMP_BASE (decl))
+ TREE_USED (DECL_DECOMP_BASE (decl)) = 1;
if (TREE_CODE (decl) == TEMPLATE_DECL)
return true;