summaryrefslogtreecommitdiff
path: root/test/SemaTemplate
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-10-27 18:13:31 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-10-27 18:13:31 +0000
commit1c09b76713c0a3521937e035b3ab4edef687e7ee (patch)
tree72dc065615701109fbb95696b41b5c82bfb8cb74 /test/SemaTemplate
parentd64b9c663c0575c69a772118b184928319e4689c (diff)
downloadclang-1c09b76713c0a3521937e035b3ab4edef687e7ee.tar.gz
[Sema] Fix an assert-on-invalid by avoiding function template specialisation
deduction for invalid functions The fabricated template parameters cause an assertion because their depth is invalid. rdar://34109988 Differential Revision: https://reviews.llvm.org/D37341 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/deduction-crash.cpp17
-rw-r--r--test/SemaTemplate/explicit-specialization-member.cpp12
2 files changed, 21 insertions, 8 deletions
diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp
index 74a25865aa..2c58fefa06 100644
--- a/test/SemaTemplate/deduction-crash.cpp
+++ b/test/SemaTemplate/deduction-crash.cpp
@@ -144,3 +144,20 @@ namespace var_template_partial_spec_incomplete {
template<typename T, typename U = void> int n<T *>; // expected-error +{{}} expected-note {{}}
int k = n<void *>;
}
+
+namespace deduceFunctionSpecializationForInvalidOutOfLineFunction {
+
+template <typename InputT, typename OutputT>
+struct SourceSelectionRequirement {
+ template<typename T>
+ OutputT evaluateSelectionRequirement(InputT &&Value) {
+ }
+};
+
+template <typename InputT, typename OutputT>
+OutputT SourceSelectionRequirement<InputT, OutputT>::
+evaluateSelectionRequirement<void>(InputT &&Value) { // expected-error {{cannot specialize a member of an unspecialized template}}
+ return Value;
+}
+
+}
diff --git a/test/SemaTemplate/explicit-specialization-member.cpp b/test/SemaTemplate/explicit-specialization-member.cpp
index c0c36808b4..e8165ac9ca 100644
--- a/test/SemaTemplate/explicit-specialization-member.cpp
+++ b/test/SemaTemplate/explicit-specialization-member.cpp
@@ -38,24 +38,20 @@ namespace PR18246 {
template<typename T>
template<int N>
- void Baz<T>::bar() { // expected-note {{couldn't infer template argument 'N'}}
+ void Baz<T>::bar() {
}
- // FIXME: We shouldn't try to match this against a prior declaration if
- // template parameter matching failed.
template<typename T>
- void Baz<T>::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}} \
- // expected-error {{no function template matches}}
+ void Baz<T>::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}}
}
}
namespace PR19340 {
template<typename T> struct Helper {
- template<int N> static void func(const T *m) {} // expected-note {{failed template argument deduction}}
+ template<int N> static void func(const T *m) {}
};
-template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}} \
- // expected-error {{no function template matches}}
+template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}}
}
namespace SpecLoc {