diff options
| author | Reid Kleckner <reid@kleckner.net> | 2013-10-08 22:45:29 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2013-10-08 22:45:29 +0000 |
| commit | be7a446637613f17ec94d34c18847d563064a539 (patch) | |
| tree | 4bbb296eafc9ffea49825b6818f1cf03119039a8 | |
| parent | 0a903478c642c19b416aacdbef3e2e1859b11c18 (diff) | |
| download | bcm5719-llvm-be7a446637613f17ec94d34c18847d563064a539.tar.gz bcm5719-llvm-be7a446637613f17ec94d34c18847d563064a539.zip | |
-Wmicrosoft: Don't warn on non-inline pure virtual method definitions
MSVC and clang with -fms-extensions allow pure virtual methods to be
defined inline after the "= 0" tokens. Clang warns on these because it
is not standard, but incorrectly warns on out-of-line definitions, which
are standard.
With this change, clang will only warn on inline definitions of pure
virtual methods.
Fixes some self-host warnings on out-of-line definitions of pure virtual
destructors.
llvm-svn: 192244
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Parser/MicrosoftExtensions.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index ba1822cfc43..52297d7f6ff 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9633,7 +9633,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, // 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()) + if (getLangOpts().MicrosoftExt && FD->isPure() && FD->isCanonicalDecl()) Diag(FD->getLocation(), diag::warn_pure_function_definition); if (!FD->isInvalidDecl()) { diff --git a/clang/test/Parser/MicrosoftExtensions.cpp b/clang/test/Parser/MicrosoftExtensions.cpp index 0327499f272..efb5c3ce1fd 100644 --- a/clang/test/Parser/MicrosoftExtensions.cpp +++ b/clang/test/Parser/MicrosoftExtensions.cpp @@ -331,6 +331,15 @@ class inline_definition_pure_spec { virtual int f2() = 0; }; +struct pure_virtual_dtor { + virtual ~pure_virtual_dtor() = 0; +}; +pure_virtual_dtor::~pure_virtual_dtor() { } + +struct pure_virtual_dtor_inline { + virtual ~pure_virtual_dtor_inline() = 0 { }// expected-warning {{function definition with pure-specifier is a Microsoft extension}} +}; + int main () { // Necessary to force instantiation in -fdelayed-template-parsing mode. |

