summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-12-11 17:42:11 +0000
committerHans Wennborg <hans@hanshq.net>2013-12-11 17:42:11 +0000
commit2545efe20c2dbcc210573a51fe94c7fd57482e7c (patch)
tree46667c4ca79a9df5a3426575febf702e0dca9415 /clang/lib/Sema/SemaDeclCXX.cpp
parent439e8f9e384403ac47a1cf2ace497998eddb2b67 (diff)
downloadbcm5719-llvm-2545efe20c2dbcc210573a51fe94c7fd57482e7c.tar.gz
bcm5719-llvm-2545efe20c2dbcc210573a51fe94c7fd57482e7c.zip
Better diagnostic for static override when methods are thiscall by default
Methods are thiscall by default in the MS ABI, and also in MinGW targetting GCC 4.7 or later. This changes the diagnostic from the technically correct but hard to understand: virtual function 'foo' has different calling convention attributes ('void ()') than the function it overrides (which has calling convention 'void () __attribute__((thiscall))') to the more intuitive and also correct: 'static' member function 'foo' overrides a virtual function We already have a test for this. Let's just run it in both ABI modes. Differential Revision: http://llvm-reviews.chandlerc.com/D2375 llvm-svn: 197055
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1a4ced78708..76623a90d56 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -12058,6 +12058,13 @@ bool Sema::CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
if (NewCC == OldCC)
return false;
+ // If the calling conventions mismatch because the new function is static,
+ // suppress the calling convention mismatch error; the error about static
+ // function override (err_static_overrides_virtual from
+ // Sema::CheckFunctionDeclaration) is more clear.
+ if (New->getStorageClass() == SC_Static)
+ return false;
+
Diag(New->getLocation(),
diag::err_conflicting_overriding_cc_attributes)
<< New->getDeclName() << New->getType() << Old->getType();
OpenPOWER on IntegriCloud