PR c++/87152 - range-based for loops with initializer broken in templates.
authorMarek Polacek <polacek@redhat.com>
Fri, 7 Sep 2018 14:12:48 +0000 (14:12 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 7 Sep 2018 14:12:48 +0000 (14:12 +0000)
commit8112667c8cb2fe109bc169561d68277277d35dc8
treed8b5de955e6ab86691eb6cf20cdd7c9733cf9009
parent6bf9284fbfe4f37cdb02c502b211dd28317710a6
PR c++/87152 - range-based for loops with initializer broken in templates.

* constexpr.c (potential_constant_expression_1) <case RANGE_FOR_STMT>:
Recur into RANGE_FOR_INIT_STMT.
* cp-tree.def: Add RANGE_FOR_INIT_STMT to RANGE_FOR_STMT.
* cp-tree.h (RANGE_FOR_INIT_STMT): Define.
* dump.c (cp_dump_tree) <case RANGE_FOR_STMT>: Also dump
RANGE_FOR_INIT_STMT.
* pt.c (tsubst_expr) <case RANGE_FOR_STMT>: Recur into
RANGE_FOR_INIT_STMT.
* semantics.c (begin_range_for_stmt): Adjust call to build_stmt.
Do put the init statement in RANGE_FOR_INIT_STMT.
(finish_range_for_decl): Pop it for templates.

* g++.dg/cpp2a/range-for11.C: New test.
* g++.dg/cpp2a/range-for12.C: New test.
* g++.dg/cpp2a/range-for13.C: New test.
* g++.dg/cpp2a/range-for14.C: New test.
* g++.dg/cpp2a/range-for15.C: New test.
* g++.dg/cpp2a/range-for16.C: New test.
* g++.dg/cpp2a/range-for17.C: New test.
* g++.dg/cpp2a/range-for18.C: New test.
* g++.dg/parse/error61.C (foo): Adjust dg-error.

From-SVN: r264158
17 files changed:
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/dump.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/range-for11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/range-for12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/range-for13.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/range-for14.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/range-for15.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/range-for16.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/range-for17.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/range-for18.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/error61.C