diff options
author | Marek Polacek <polacek@redhat.com> | 2018-12-21 03:34:06 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-12-21 03:34:06 +0000 |
commit | 906a9283a5d53f21f032af8e4a22358b1b0f1ec9 (patch) | |
tree | 004d3f42778cd2106784612f357fe3cf9efb6f2f | |
parent | 6647c1e86f3b311d906a19b85182eed010ec03cf (diff) | |
download | gcc-906a9283a5d53f21f032af8e4a22358b1b0f1ec9.zip gcc-906a9283a5d53f21f032af8e4a22358b1b0f1ec9.tar.gz gcc-906a9283a5d53f21f032af8e4a22358b1b0f1ec9.tar.bz2 |
PR c++/88196 - ICE with class non-type template parameter.
* pt.c (convert_nontype_argument): If the expr is a PTRMEM_CST, also
check if the type we're converting it to is TYPE_PTRMEM_P.
* g++.dg/cpp0x/ptrmem-cst-arg1.C: Tweak dg-error.
* g++.dg/cpp2a/nontype-class10.C: New test.
* g++.dg/template/pr54858.C: Tweak dg-error.
From-SVN: r267319
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/nontype-class10.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/pr54858.C | 24 |
6 files changed, 33 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f6e07a3..f4295f3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-12-20 Marek Polacek <polacek@redhat.com> + + PR c++/88196 - ICE with class non-type template parameter. + * pt.c (convert_nontype_argument): If the expr is a PTRMEM_CST, also + check if the type we're converting it to is TYPE_PTRMEM_P. + 2018-12-20 H.J. Lu <hongjiu.lu@intel.com> PR c/51628 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d4ac034..18b093e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6775,7 +6775,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain) to a null value, but otherwise still need to be of a specific form. */ if (cxx_dialect >= cxx11) { - if (TREE_CODE (expr) == PTRMEM_CST) + if (TREE_CODE (expr) == PTRMEM_CST && TYPE_PTRMEM_P (type)) /* A PTRMEM_CST is already constant, and a valid template argument for a parameter of pointer to member type, we just want to leave it in that form rather than lower it to a diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8a32fa8..d814641 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-12-20 Marek Polacek <polacek@redhat.com> + + PR c++/88196 - ICE with class non-type template parameter. + * g++.dg/cpp0x/ptrmem-cst-arg1.C: Tweak dg-error. + * g++.dg/cpp2a/nontype-class10.C: New test. + * g++.dg/template/pr54858.C: Tweak dg-error. + 2018-12-20 H.J. Lu <hongjiu.lu@intel.com> PR c/51628 diff --git a/gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C b/gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C index ed12655..38b3e24 100644 --- a/gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C +++ b/gcc/testsuite/g++.dg/cpp0x/ptrmem-cst-arg1.C @@ -5,5 +5,5 @@ template<int> struct A {}; struct B { int i; - A<&B::i> a; // { dg-error "could not convert template argument" } + A<&B::i> a; // { dg-error "could not convert" } }; diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class10.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class10.C new file mode 100644 index 0000000..5cc1793 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class10.C @@ -0,0 +1,6 @@ +// PR c++/88196 +// { dg-do compile { target c++2a } } + +struct C { C *c; }; +template <C> struct D; +D <&C::c> d; // { dg-error "could not convert" } diff --git a/gcc/testsuite/g++.dg/template/pr54858.C b/gcc/testsuite/g++.dg/template/pr54858.C index 51610ad..6d23dec 100644 --- a/gcc/testsuite/g++.dg/template/pr54858.C +++ b/gcc/testsuite/g++.dg/template/pr54858.C @@ -5,17 +5,17 @@ template <int> struct A {}; template <typename T, T *> struct B {}; template <typename D> struct C { - A<0> c0; B<A<0>, &C::c0> d0; // { dg-error "could not convert template argument" } - A<0> c1; B<A<0>, &C::c1> d1; // { dg-error "could not convert template argument" } - A<0> c2; B<A<0>, &C::c2> d2; // { dg-error "could not convert template argument" } - A<0> c3; B<A<0>, &C::c3> d3; // { dg-error "could not convert template argument" } - A<0> c4; B<A<0>, &C::c4> d4; // { dg-error "could not convert template argument" } - A<0> c5; B<A<0>, &C::c5> d5; // { dg-error "could not convert template argument" } - A<0> c6; B<A<0>, &C::c6> d6; // { dg-error "could not convert template argument" } - A<0> c7; B<A<0>, &C::c7> d7; // { dg-error "could not convert template argument" } - A<0> c8; B<A<0>, &C::c8> d8; // { dg-error "could not convert template argument" } - A<0> c9; B<A<0>, &C::c9> d9; // { dg-error "could not convert template argument" } - A<0> ca; B<A<0>, &C::ca> da; // { dg-error "could not convert template argument" } - A<0> cb; B<A<0>, &C::cb> db; // { dg-error "could not convert template argument" } + A<0> c0; B<A<0>, &C::c0> d0; // { dg-error "could not convert" } + A<0> c1; B<A<0>, &C::c1> d1; // { dg-error "could not convert" } + A<0> c2; B<A<0>, &C::c2> d2; // { dg-error "could not convert" } + A<0> c3; B<A<0>, &C::c3> d3; // { dg-error "could not convert" } + A<0> c4; B<A<0>, &C::c4> d4; // { dg-error "could not convert" } + A<0> c5; B<A<0>, &C::c5> d5; // { dg-error "could not convert" } + A<0> c6; B<A<0>, &C::c6> d6; // { dg-error "could not convert" } + A<0> c7; B<A<0>, &C::c7> d7; // { dg-error "could not convert" } + A<0> c8; B<A<0>, &C::c8> d8; // { dg-error "could not convert" } + A<0> c9; B<A<0>, &C::c9> d9; // { dg-error "could not convert" } + A<0> ca; B<A<0>, &C::ca> da; // { dg-error "could not convert" } + A<0> cb; B<A<0>, &C::cb> db; // { dg-error "could not convert" } }; C<int> e; |