diff options
author | Jason Merrill <jason@redhat.com> | 2016-12-21 14:38:35 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-12-21 14:38:35 -0500 |
commit | a9410b4fe946b3f82ff2254b46ef53573897d68e (patch) | |
tree | fcffa3b5c7642405863b779e6991c5dfc2a1ff09 | |
parent | a93634ba09c4b33d95233e48d9c452a529555d05 (diff) | |
download | gcc-a9410b4fe946b3f82ff2254b46ef53573897d68e.zip gcc-a9410b4fe946b3f82ff2254b46ef53573897d68e.tar.gz gcc-a9410b4fe946b3f82ff2254b46ef53573897d68e.tar.bz2 |
Check that a partial specialization is more specialized.
* pt.c (process_partial_specialization): Use
get_partial_spec_bindings to check that the partial specialization
is more specialized than the primary template.
From-SVN: r243868
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/pt.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/variadic82.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/variadic83.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/partial5.C | 2 |
6 files changed, 21 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4c68b1e..7faac15 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2016-12-21 Jason Merrill <jason@redhat.com> + * pt.c (process_partial_specialization): Use + get_partial_spec_bindings to check that the partial specialization + is more specialized than the primary template. + * pt.c (convert_template_argument): Pass args to do_auto_deduction. (mark_template_parm): Handle deducibility from type of non-type argument here. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9d9c35e..8abbcfb 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4606,9 +4606,20 @@ process_partial_specialization (tree decl) "primary template because it replaces multiple parameters " "with a pack expansion"); inform (DECL_SOURCE_LOCATION (maintmpl), "primary template here"); + /* Avoid crash in process_partial_specialization. */ return decl; } + /* If we aren't in a dependent class, we can actually try deduction. */ + else if (tpd.level == 1 + && !get_partial_spec_bindings (maintmpl, maintmpl, specargs)) + { + if (permerror (input_location, "partial specialization %qD is not " + "more specialized than", decl)) + inform (DECL_SOURCE_LOCATION (maintmpl), "primary template %qD", + maintmpl); + } + /* [temp.class.spec] A partially specialized non-type argument expression shall not diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C index 312760a..8981021 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-data2.C @@ -12,7 +12,7 @@ template<typename _Tp, _Tp v> }; // Partial specialization. -template<typename _Tp, _Tp v> +template<typename _Tp, _Tp* v> struct A3<_Tp*, v> { typedef _Tp* value_type; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic82.C b/gcc/testsuite/g++.dg/cpp0x/variadic82.C index f9bbc35..9ac59cd 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic82.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic82.C @@ -3,9 +3,9 @@ template<typename> struct A; -template<typename... T> struct A<T*...> // { dg-bogus "cannot expand" "" } +template<typename... T> struct A<T*...> // { dg-error "" } { struct B; }; -A<void*> a; // { dg-bogus "incomplete type" "" } +A<void*> a; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic83.C b/gcc/testsuite/g++.dg/cpp0x/variadic83.C index 507fc7e..c751e73 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic83.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic83.C @@ -3,6 +3,6 @@ template<typename> struct A; -template<typename... T> struct A<T...> { }; // { dg-bogus "cannot expand" "" } +template<typename... T> struct A<T...> { }; // { dg-error "" } -A<int> a; // { dg-bogus "incomplete type" "" } +A<int> a; diff --git a/gcc/testsuite/g++.dg/template/partial5.C b/gcc/testsuite/g++.dg/template/partial5.C index 2f400f7..1b56fb3 100644 --- a/gcc/testsuite/g++.dg/template/partial5.C +++ b/gcc/testsuite/g++.dg/template/partial5.C @@ -14,7 +14,7 @@ template<typename T, typename T::foo V> struct Y { }; template<typename T, typename U, U v> -struct Y<T, v> { }; // { dg-error "not deducible|U" "" { target { ! c++1z } } } +struct Y<T, v> { }; // { dg-error "" } template<typename T, T V> |