summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/delete-and-function-templates.cpp
diff options
context:
space:
mode:
authorFaisal Vali <faisalv@yahoo.com>2016-06-14 03:23:15 +0000
committerFaisal Vali <faisalv@yahoo.com>2016-06-14 03:23:15 +0000
commit81a88beec4f8f4ca4e3dacf652231669c9a947fe (patch)
treef1ae12cb5a8e8b764a883331b868dd1eb539f261 /clang/test/SemaCXX/delete-and-function-templates.cpp
parentcccf4f01ada94aeafdef5ee03e9e4418e64b9e28 (diff)
downloadbcm5719-llvm-81a88beec4f8f4ca4e3dacf652231669c9a947fe.tar.gz
bcm5719-llvm-81a88beec4f8f4ca4e3dacf652231669c9a947fe.zip
Fix PR28100 - Allow redeclarations of deleted explicit specializations.
See https://llvm.org/bugs/show_bug.cgi?id=28100. In r266561 when I implemented allowing explicit specializations of function templates to override deleted status, I mistakenly assumed (and hence introduced a violable assertion) that when an explicit specialization was being declared, the corresponding specialization of the most specialized function template that it would get linked to would always be the one that was implicitly generated - and so if it was marked as 'deleted' it must have inherited it from the primary template and so should be safe to reset its deleted status, and set it to being an explicit specialization. Obviously during redeclaration of a deleted explicit specialization, in order to avoid a recursive reset, we need to check that the previous specialization is not an explicit specialization (instead of assuming and asserting it) and that it hasn't been referenced, and so only then is it safe to reset its 'deleted' status. All regression tests pass. Thanks to Zhendong Su for reporting the bug and David Majnemer for tracking it to my commit r266561, and promptly bringing it to my attention. llvm-svn: 272631
Diffstat (limited to 'clang/test/SemaCXX/delete-and-function-templates.cpp')
-rw-r--r--clang/test/SemaCXX/delete-and-function-templates.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/delete-and-function-templates.cpp b/clang/test/SemaCXX/delete-and-function-templates.cpp
index 418aa80e2fd..22e95cb7937 100644
--- a/clang/test/SemaCXX/delete-and-function-templates.cpp
+++ b/clang/test/SemaCXX/delete-and-function-templates.cpp
@@ -112,4 +112,22 @@ void foo() {
} // end ns3
+
+namespace ns4 {
+template < typename T> T* foo (T);
+template <> int* foo(int) = delete;
+template <> int* foo(int); //expected-note{{candidate}}
+
+int *IP = foo(2); //expected-error{{deleted}}
+double *DP = foo(3.14);
+} //end ns4
+
+namespace ns5 {
+template < typename T> T* foo (T);
+template <> int* foo(int); //expected-note{{previous}}
+template <> int* foo(int) = delete; //expected-error{{deleted definition must be first declaration}}
+
+} //end ns5
+
+
} // end test_explicit_specializations_and_delete
OpenPOWER on IntegriCloud