diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-04 15:10:38 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-04 15:10:38 -0400 |
commit | 8859913ea3cbefdcf1aaec654744a358420d8138 (patch) | |
tree | 0fd46e7296c58e37e894045a3f26e87ef3841209 | |
parent | 3dba92a96d5d11dbf34f5d92cec63739657c5369 (diff) | |
download | gcc-8859913ea3cbefdcf1aaec654744a358420d8138.zip gcc-8859913ea3cbefdcf1aaec654744a358420d8138.tar.gz gcc-8859913ea3cbefdcf1aaec654744a358420d8138.tar.bz2 |
PR c++/85200 - ICE with constexpr if in generic lambda.
* tree.c (cp_walk_subtrees): Walk into DECL_EXPR in templates.
From-SVN: r259099
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/tree.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/constexpr-if18.C | 15 |
3 files changed, 23 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9b75419..12d0c10 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2018-04-04 Jason Merrill <jason@redhat.com> + PR c++/85200 - ICE with constexpr if in generic lambda. + * tree.c (cp_walk_subtrees): Walk into DECL_EXPR in templates. + PR c++/84221 - bogus -Wunused with attribute and template. * decl2.c (is_late_template_attribute): Handle unused and used normally on non-TYPE_DECL. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7ddc2cb..d0835cf 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4894,10 +4894,12 @@ cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func, /* User variables should be mentioned in BIND_EXPR_VARS and their initializers and sizes walked when walking the containing BIND_EXPR. Compiler temporaries are - handled here. */ + handled here. And also normal variables in templates, + since do_poplevel doesn't build a BIND_EXPR then. */ if (VAR_P (TREE_OPERAND (*tp, 0)) - && DECL_ARTIFICIAL (TREE_OPERAND (*tp, 0)) - && !TREE_STATIC (TREE_OPERAND (*tp, 0))) + && (processing_template_decl + || (DECL_ARTIFICIAL (TREE_OPERAND (*tp, 0)) + && !TREE_STATIC (TREE_OPERAND (*tp, 0))))) { tree decl = TREE_OPERAND (*tp, 0); WALK_SUBTREE (DECL_INITIAL (decl)); diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if18.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if18.C new file mode 100644 index 0000000..03ad620 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if18.C @@ -0,0 +1,15 @@ +// PR c++/85200 +// { dg-additional-options -std=c++17 } + +template <typename T> +void f(){ + [](auto v, auto b){ + if constexpr (sizeof(v) == sizeof(int)) { + auto x = b; + } + }(0, 1); +} + +int main(){ + f<int>(); +} |