Ilod created this revision. Clang emits a warning when using pure specifier =0 in function definition at class scope, which is a MS-specific construct, when using -fms-extensions. However, to detect this, it was using FD->isCanonicalDecl() on function declaration, which was also detecting out-of-class definition of member functions of template class. This fix it by instead of !FD->isOutOfLine() to detect the places where we must emit the warning. This will fix https://llvm.org/bugs/show_bug.cgi?id=21334
https://reviews.llvm.org/D29707 Files: lib/Sema/SemaDecl.cpp test/Parser/MicrosoftExtensions.cpp Index: test/Parser/MicrosoftExtensions.cpp =================================================================== --- test/Parser/MicrosoftExtensions.cpp +++ test/Parser/MicrosoftExtensions.cpp @@ -290,6 +290,17 @@ virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} }; +template<typename T> struct pure_virtual_dtor_template { + virtual ~pure_virtual_dtor_template() = 0; +}; +template<typename T> pure_virtual_dtor_template<T>::~pure_virtual_dtor_template() { } +template struct pure_virtual_dtor_template<int>; + +template<typename T> struct pure_virtual_dtor_template_inline { + virtual ~pure_virtual_dtor_template_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} expected-warning {{function definition with pure-specifier is a Microsoft extension}} +}; +template struct pure_virtual_dtor_template_inline<int>;// expected-note {{in instantiation of member function}} + int main () { // Necessary to force instantiation in -fdelayed-template-parsing mode. Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -12025,7 +12025,7 @@ // MSVC permits the use of pure specifier (=0) on function definition, // defined at class scope, warn about this non-standard construct. - if (getLangOpts().MicrosoftExt && FD->isPure() && FD->isCanonicalDecl()) + if (getLangOpts().MicrosoftExt && FD->isPure() && !FD->isOutOfLine()) Diag(FD->getLocation(), diag::ext_pure_function_definition); if (!FD->isInvalidDecl()) {
Index: test/Parser/MicrosoftExtensions.cpp =================================================================== --- test/Parser/MicrosoftExtensions.cpp +++ test/Parser/MicrosoftExtensions.cpp @@ -290,6 +290,17 @@ virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} }; +template<typename T> struct pure_virtual_dtor_template { + virtual ~pure_virtual_dtor_template() = 0; +}; +template<typename T> pure_virtual_dtor_template<T>::~pure_virtual_dtor_template() { } +template struct pure_virtual_dtor_template<int>; + +template<typename T> struct pure_virtual_dtor_template_inline { + virtual ~pure_virtual_dtor_template_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} expected-warning {{function definition with pure-specifier is a Microsoft extension}} +}; +template struct pure_virtual_dtor_template_inline<int>;// expected-note {{in instantiation of member function}} + int main () { // Necessary to force instantiation in -fdelayed-template-parsing mode. Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -12025,7 +12025,7 @@ // MSVC permits the use of pure specifier (=0) on function definition, // defined at class scope, warn about this non-standard construct. - if (getLangOpts().MicrosoftExt && FD->isPure() && FD->isCanonicalDecl()) + if (getLangOpts().MicrosoftExt && FD->isPure() && !FD->isOutOfLine()) Diag(FD->getLocation(), diag::ext_pure_function_definition); if (!FD->isInvalidDecl()) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits