diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-20 20:36:54 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-20 20:36:54 +0000 |
commit | a1f4b308d901f432651f13acb4d4501873aa2f1b (patch) | |
tree | 29be994555e93866fc5ce1615c37fce79f229e3d | |
parent | 96ffae616b7fdaae8382209c08ae563d9b54c9f3 (diff) |
PR c++/80096 - ICE with C++17 non-type auto.
* pt.c (tsubst): Delay tsubst of type of template non-type
parameter.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@246292 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1z/nontype-auto10.C | 9 |
3 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 428e07ccb0b..7dfa57771ad 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-03-20 Jason Merrill <jason@redhat.com> + PR c++/80096 - ICE with C++17 non-type auto. + * pt.c (tsubst): Delay tsubst of type of template non-type + parameter. + PR c++/79519 - ICE with deleted template friend. * decl.c (grokdeclarator): Complain about misplaced function definition using =, as well. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f1807106815..a4bf890dbfb 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13388,6 +13388,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (type && code != TYPENAME_TYPE && code != TEMPLATE_TYPE_PARM + && code != TEMPLATE_PARM_INDEX && code != IDENTIFIER_NODE && code != FUNCTION_TYPE && code != METHOD_TYPE) @@ -13690,6 +13691,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) break; case TEMPLATE_PARM_INDEX: + /* OK, now substitute the type of the non-type parameter. We + couldn't do it earlier because it might be an auto parameter, + and we wouldn't need to if we had an argument. */ + type = tsubst (type, args, complain, in_decl); r = reduce_template_parm_level (t, type, levels, args, complain); break; diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto10.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto10.C new file mode 100644 index 00000000000..381ed51a28f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto10.C @@ -0,0 +1,9 @@ +// PR c++/80096 +// { dg-options -std=c++1z } + +template<auto> struct A +{ + template<int> struct B {}; +}; + +A<0> a; |