[PATCH] [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for 'final'
David Majnemer
david.majnemer at gmail.com
Wed Oct 16 11:47:22 PDT 2013
================
Comment at: lib/Parse/ParseDeclCXX.cpp:1881
@@ -1875,3 +1880,3 @@
<< VirtSpecifiers::getSpecifierName(Specifier);
- } else {
+ } else if (!getLangOpts().MicrosoftExt) {
Diag(Tok.getLocation(), getLangOpts().CPlusPlus11 ?
----------------
Reid Kleckner wrote:
> We set -std=c++11 in clang-cl, so I don't think we need this.
But not everyone uses clang-cl.
================
Comment at: lib/Sema/SemaExprCXX.cpp:3311
@@ +3310,3 @@
+ if (FinalAttr *FA = RD->getAttr<FinalAttr>())
+ return FA->getIsSpelledSealed();
+ return false;
----------------
Reid Kleckner wrote:
> Why not let this be true for final classes as well? I see a use case for a user defining a final class and using that class with templates from a library that was written with __is_sealed for portability with older VS versions.
I originally did it that way but MSVC didn't think `final` classes are `__is_sealed`
================
Comment at: test/SemaCXX/MicrosoftExtensions.cpp:401
@@ +400,2 @@
+ virtual void OverrideMe() override;
+};
----------------
Reid Kleckner wrote:
> I don't see a test for __is_sealed.
Will do.
================
Comment at: lib/Sema/SemaDeclCXX.cpp:1760-1768
@@ -1758,10 +1759,11 @@
if (OverrideAttr *OA = D->getAttr<OverrideAttr>()) {
Diag(OA->getLocation(),
diag::override_keyword_hides_virtual_member_function)
<< "override" << (OverloadedMethods.size() > 1);
} else if (FinalAttr *FA = D->getAttr<FinalAttr>()) {
Diag(FA->getLocation(),
diag::override_keyword_hides_virtual_member_function)
- << "final" << (OverloadedMethods.size() > 1);
+ << (FA->getIsSpelledSealed() ? "sealed" : "final")
+ << (OverloadedMethods.size() > 1);
}
NoteHiddenVirtualMethods(MD, OverloadedMethods);
----------------
Reid Kleckner wrote:
> Can you factor out the diagnostic?
I'll try.
================
Comment at: lib/Sema/SemaDeclCXX.cpp:1379
@@ -1379,1 +1378,3 @@
+ << CXXBaseDecl->getDeclName()
+ << (FA->getIsSpelledSealed() ? "sealed" : "final");
Diag(CXXBaseDecl->getLocation(), diag::note_previous_decl)
----------------
Reid Kleckner wrote:
> "getIsSpelledSealed" is kinda funny but it's tablegenned so whatever.
Yep. If it's any consolation, it matches the other generated ones. I might whip up a patch this weekend to make it look less silly but that's a separate concern (tablegen pluming).
http://llvm-reviews.chandlerc.com/D1948
More information about the cfe-commits
mailing list