diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-31 23:23:25 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-08-31 23:23:25 +0000 |
commit | e4caa48dbb744fb809db1f6f09de2ed9576efcea (patch) | |
tree | 505582594879dcd41b23047a8bfffcff116dbd15 /clang/test/CXX | |
parent | 77807637ffb0fffd6f215187258b0e12c6b6a620 (diff) | |
download | bcm5719-llvm-e4caa48dbb744fb809db1f6f09de2ed9576efcea.tar.gz bcm5719-llvm-e4caa48dbb744fb809db1f6f09de2ed9576efcea.zip |
DR259: Demote the pedantic error for an explicit instantiation after an
explicit specialization to a warning for C++98 mode (this is a defect report
resolution, so per our informal policy it should apply in C++98), and turn
the warning on by default for C++11 and later. In all cases where it fires, the
right thing to do is to remove the pointless explicit instantiation.
llvm-svn: 280308
Diffstat (limited to 'clang/test/CXX')
-rw-r--r-- | clang/test/CXX/drs/dr2xx.cpp | 17 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp | 20 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp | 15 |
3 files changed, 23 insertions, 29 deletions
diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp index 25c853590ae..7372ecb26c8 100644 --- a/clang/test/CXX/drs/dr2xx.cpp +++ b/clang/test/CXX/drs/dr2xx.cpp @@ -679,17 +679,13 @@ namespace dr258 { // dr258: yes } f; // expected-error {{abstract}} } -namespace dr259 { // dr259: yes c++11 +namespace dr259 { // dr259: 4.0 template<typename T> struct A {}; template struct A<int>; // expected-note {{previous}} template struct A<int>; // expected-error {{duplicate explicit instantiation}} - // FIXME: We only apply this DR in C++11 mode. - template<> struct A<float>; - template struct A<float>; -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} expected-note@-3 {{here}} -#endif + template<> struct A<float>; // expected-note {{previous}} + template struct A<float>; // expected-warning {{has no effect}} template struct A<char>; // expected-note {{here}} template<> struct A<char>; // expected-error {{explicit specialization of 'dr259::A<char>' after instantiation}} @@ -702,11 +698,8 @@ namespace dr259 { // dr259: yes c++11 template<typename T> struct B; // expected-note {{here}} template struct B<int>; // expected-error {{undefined}} - template<> struct B<float>; - template struct B<float>; -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} expected-note@-3 {{here}} -#endif + template<> struct B<float>; // expected-note {{previous}} + template struct B<float>; // expected-warning {{has no effect}} } // FIXME: When dr260 is resolved, also add tests for DR507. diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp index d12feeff0bb..1af47a0ed56 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp @@ -223,8 +223,8 @@ namespace spec_vs_expl_inst { namespace SID { template <typename STRING_TYPE> class BasicStringPiece; - template <> class BasicStringPiece<int> { }; - template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} + template <> class BasicStringPiece<int> { }; // expected-note {{previous template specialization is here}} + template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} expected-warning {{has no effect}} extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}} } @@ -252,8 +252,8 @@ namespace spec_vs_expl_inst { namespace DSI { template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}} extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::DSI::BasicStringPiece<int>'}} - template <> class BasicStringPiece<int> { }; - template class BasicStringPiece<int>; + template <> class BasicStringPiece<int> { }; // expected-note {{previous}} + template class BasicStringPiece<int>; // expected-warning {{has no effect}} } // The same again, with a defined template class. @@ -267,8 +267,8 @@ namespace spec_vs_expl_inst { namespace SID_WithDefinedTemplate { template <typename STRING_TYPE> class BasicStringPiece {}; - template <> class BasicStringPiece<int> { }; - template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} + template <> class BasicStringPiece<int> { }; // expected-note {{previous}} + template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} expected-warning {{has no effect}} extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}} } @@ -304,15 +304,15 @@ namespace spec_vs_expl_inst { namespace SII_WithDefinedTemplate { template <typename STRING_TYPE> class BasicStringPiece {}; - template <> class BasicStringPiece<int> { }; - template class BasicStringPiece<int>; // expected-note {{previous explicit instantiation is here}} + template <> class BasicStringPiece<int> { }; // expected-note {{previous}} + template class BasicStringPiece<int>; // expected-note {{previous explicit instantiation is here}} expected-warning {{has no effect}} template class BasicStringPiece<int>; // expected-error {{duplicate explicit instantiation of 'BasicStringPiece<int>'}} } namespace SIS { template <typename STRING_TYPE> class BasicStringPiece; - template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}} - template class BasicStringPiece<int>; + template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}} expected-note {{previous}} + template class BasicStringPiece<int>; // expected-warning {{has no effect}} template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::SIS::BasicStringPiece<int>'}} } diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp index 09c428e01df..0a8a0ce9ff1 100644 --- a/clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s template<typename T> void f0(T); // expected-note{{here}} template void f0(int); // expected-error{{explicit instantiation of undefined function template}} @@ -17,19 +18,19 @@ template void X0<int>::f1(); // expected-error{{explicit instantiation of undefi template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}} template<> void f0(long); // expected-note{{previous template specialization is here}} -template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization will be ignored}} +template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization has no effect}} template<> void X0<long>::f1(); // expected-note{{previous template specialization is here}} -template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization will be ignored}} +template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization has no effect}} template<> struct X0<long>::Inner; // expected-note{{previous template specialization is here}} -template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization will be ignored}} +template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization has no effect}} template<> long X0<long>::value; // expected-note{{previous template specialization is here}} -template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization will be ignored}} +template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization has no effect}} template<> struct X0<double>; // expected-note{{previous template specialization is here}} -template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization will be ignored}} +template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization has no effect}} // PR 6458 namespace test0 { @@ -43,6 +44,6 @@ namespace test0 { // inappropriately instantiating this template. void *ptr = x; } - extern template class foo<char>; // expected-warning {{extern templates are a C++11 extension}} + extern template class foo<char>; // expected-warning 0-1{{extern templates are a C++11 extension}} template class foo<char>; } |