diff options
| author | Hans Wennborg <hans@hanshq.net> | 2015-01-15 21:18:30 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2015-01-15 21:18:30 +0000 |
| commit | fd76d91366016494ef1915ae9481d81ed61d339d (patch) | |
| tree | 7ce3bda05b3757be60d8c0dd8c3ec6a412203bbd /clang/test/SemaCXX | |
| parent | e2ab0f17cf322b4384186ad392b1ea9abbbc23c4 (diff) | |
| download | bcm5719-llvm-fd76d91366016494ef1915ae9481d81ed61d339d.tar.gz bcm5719-llvm-fd76d91366016494ef1915ae9481d81ed61d339d.zip | |
Warn about dllexported explicit class template instantiation declarations (PR22035)
Clang would previously become confused and crash here.
It does not make a lot of sense to export these, so warning seems appropriate.
MSVC will export some member functions for this kind of specializations, whereas
MinGW ignores the dllexport-edness. The latter behaviour seems better.
Differential Revision: http://reviews.llvm.org/D6984
llvm-svn: 226208
Diffstat (limited to 'clang/test/SemaCXX')
| -rw-r--r-- | clang/test/SemaCXX/dllexport.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/dllexport.cpp b/clang/test/SemaCXX/dllexport.cpp index 5d002ac81e5..3bb9d224f72 100644 --- a/clang/test/SemaCXX/dllexport.cpp +++ b/clang/test/SemaCXX/dllexport.cpp @@ -353,10 +353,10 @@ ImplicitlyInstantiatedExportedTemplate<IncompleteType> implicitlyInstantiatedExp // Don't instantiate class members of templates with explicit instantiation declarations, even if they are exported. struct IncompleteType2; -template <typename T> struct __declspec(dllexport) ExportedTemplateWithExplicitInstantiationDecl { +template <typename T> struct __declspec(dllexport) ExportedTemplateWithExplicitInstantiationDecl { // expected-note{{attribute is here}} int f() { return sizeof(T); } // no-error }; -extern template struct ExportedTemplateWithExplicitInstantiationDecl<IncompleteType2>; +extern template struct ExportedTemplateWithExplicitInstantiationDecl<IncompleteType2>; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} // Instantiate class members for explicitly instantiated exported templates. struct IncompleteType3; // expected-note{{forward declaration of 'IncompleteType3'}} @@ -386,7 +386,12 @@ template <typename T> struct __declspec(dllexport) ExportedBaseClassTemplateOfEx }; struct __declspec(dllexport) ExportedBaseClass2 : public ExportedBaseClassTemplateOfExportedClass<IncompleteType5> {}; +// Warn about explicit instantiation declarations of dllexport classes. +template <typename T> struct ExplicitInstantiationDeclTemplate {}; +extern template struct __declspec(dllexport) ExplicitInstantiationDeclTemplate<int>; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} expected-note{{attribute is here}} +template <typename T> struct __declspec(dllexport) ExplicitInstantiationDeclExportedTemplate {}; // expected-note{{attribute is here}} +extern template struct ExplicitInstantiationDeclExportedTemplate<int>; // expected-warning{{explicit instantiation declaration should not be 'dllexport'}} //===----------------------------------------------------------------------===// // Classes with template base classes |

