[PATCH] [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for 'final'
Reid Kleckner
rnk at google.com
Wed Oct 16 09:30:25 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 ?
----------------
We set -std=c++11 in clang-cl, so I don't think we need this.
================
Comment at: lib/Sema/SemaDeclCXX.cpp:1379
@@ -1379,1 +1378,3 @@
+ << CXXBaseDecl->getDeclName()
+ << (FA->getIsSpelledSealed() ? "sealed" : "final");
Diag(CXXBaseDecl->getLocation(), diag::note_previous_decl)
----------------
"getIsSpelledSealed" is kinda funny but it's tablegenned so whatever.
================
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);
----------------
Can you factor out the diagnostic?
================
Comment at: lib/Sema/SemaExprCXX.cpp:3311
@@ +3310,3 @@
+ if (FinalAttr *FA = RD->getAttr<FinalAttr>())
+ return FA->getIsSpelledSealed();
+ return false;
----------------
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.
================
Comment at: test/SemaCXX/MicrosoftExtensions.cpp:401
@@ +400,2 @@
+ virtual void OverrideMe() override;
+};
----------------
I don't see a test for __is_sealed.
http://llvm-reviews.chandlerc.com/D1948
More information about the cfe-commits
mailing list