diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-03-02 22:31:40 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-03-02 22:31:40 +0100 |
commit | 50bea0c5ea3828c899470ec4c5feccb53e141736 (patch) | |
tree | fb97b540aa1f77b164ab1a7a004df1bd40c30e45 | |
parent | 2f9221bf7ef34e888ef527bc8e5eb5a8b5df7699 (diff) | |
download | gcc-50bea0c5ea3828c899470ec4c5feccb53e141736.zip gcc-50bea0c5ea3828c899470ec4c5feccb53e141736.tar.gz gcc-50bea0c5ea3828c899470ec4c5feccb53e141736.tar.bz2 |
re PR c++/79782 (ICE: tree check: expected tree_list, have void_type in emit_mem_initializers, at cp/init.c:1225)
PR c++/79782
* init.c (mark_exp_read_r): New function.
(emit_mem_initializers): Use cp_walk_tree with mark_exp_read_r on
whole arguments instead of plain mark_exp_read on TREE_LIST values.
* g++.dg/warn/Wunused-parm-10.C: New test.
From-SVN: r245853
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/init.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/Wunused-parm-10.C | 12 |
4 files changed, 36 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 405e3d5..04ae0de 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-03-02 Jakub Jelinek <jakub@redhat.com> + + PR c++/79782 + * init.c (mark_exp_read_r): New function. + (emit_mem_initializers): Use cp_walk_tree with mark_exp_read_r on + whole arguments instead of plain mark_exp_read on TREE_LIST values. + 2017-03-01 Jason Merrill <jason@redhat.com> Class template argument deduction in new-expression diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 191fe13..e4f0389 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1127,6 +1127,17 @@ sort_mem_initializers (tree t, tree mem_inits) return sorted_inits; } +/* Callback for cp_walk_tree to mark all PARM_DECLs in a tree as read. */ + +static tree +mark_exp_read_r (tree *tp, int *, void *) +{ + tree t = *tp; + if (TREE_CODE (t) == PARM_DECL) + mark_exp_read (t); + return NULL_TREE; +} + /* Initialize all bases and members of CURRENT_CLASS_TYPE. MEM_INITS is a TREE_LIST giving the explicit mem-initializer-list for the constructor. The TREE_PURPOSE of each entry is a subobject (a @@ -1221,8 +1232,7 @@ emit_mem_initializers (tree mem_inits) /* When not constructing vbases of abstract classes, at least mark the arguments expressions as read to avoid -Wunused-but-set-parameter false positives. */ - for (tree arg = arguments; arg; arg = TREE_CHAIN (arg)) - mark_exp_read (TREE_VALUE (arg)); + cp_walk_tree (&arguments, mark_exp_read_r, NULL, NULL); if (inherited_base) pop_deferring_access_checks (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0c798f7..b0034ed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-02 Jakub Jelinek <jakub@redhat.com> + + PR c++/79782 + * g++.dg/warn/Wunused-parm-10.C: New test. + 2017-03-02 Uros Bizjak <ubizjak@gmail.com> * gcc.dg/rtl/x86_64/*.c: Test for diff --git a/gcc/testsuite/g++.dg/warn/Wunused-parm-10.C b/gcc/testsuite/g++.dg/warn/Wunused-parm-10.C new file mode 100644 index 0000000..e641037 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-parm-10.C @@ -0,0 +1,12 @@ +// PR c++/79782 +// { dg-do compile { target c++11 } } +// { dg-options "-Wunused-but-set-parameter -Wunused-parameter" } + +struct E { virtual E *foo () const = 0; }; +struct F : virtual public E { }; +struct G : public virtual F { G (int x) : F () { } }; // { dg-warning "unused parameter" } +struct H : virtual public E { H (int x, int y); }; +struct I : public virtual H { I (int x, int y) : H (x, y) { } }; // { dg-bogus "set but not used" } +struct J : public virtual H { J (int x, int y) : H { x, y } { } }; // { dg-bogus "set but not used" } +struct K : public virtual H { K (int x, int y) : H (x * 0, y + 1) { } }; // { dg-bogus "set but not used" } +struct L : public virtual H { L (int x, int y) : H { x & 0, y | 1 } { } }; // { dg-bogus "set but not used" } |