]> granicus.if.org Git - clang/commitdiff
-Wmicrosoft: Don't warn on non-inline pure virtual method definitions
authorReid Kleckner <reid@kleckner.net>
Tue, 8 Oct 2013 22:45:29 +0000 (22:45 +0000)
committerReid Kleckner <reid@kleckner.net>
Tue, 8 Oct 2013 22:45:29 +0000 (22:45 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192244 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Parser/MicrosoftExtensions.cpp

index ba1822cfc43fac19a039fc2f4bea38cb746b70d8..52297d7f6ffb42bafbbeadb41d44783a58f26bb5 100644 (file)
@@ -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()) {
index 0327499f272d25ea76e7301bf49eff0d8733da0b..efb5c3ce1fdcbca6523d3a213b8593f86edd54a1 100644 (file)
@@ -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.