forked from OSchip/llvm-project
When -Woverloaded-virtual is triggered, call HandleFunctionTypeMismatch to add
more information to the notes. This information is already present on other diagnostic messages that involves overloads. llvm-svn: 178923
This commit is contained in:
parent
31ba23aa56
commit
05c4d023f3
|
@ -4686,7 +4686,16 @@ def warn_overloaded_virtual : Warning<
|
|||
"%q0 hides overloaded virtual %select{function|functions}1">,
|
||||
InGroup<OverloadedVirtual>, DefaultIgnore;
|
||||
def note_hidden_overloaded_virtual_declared_here : Note<
|
||||
"hidden overloaded virtual function %q0 declared here">;
|
||||
"hidden overloaded virtual function %q0 declared here"
|
||||
"%select{|: different classes%diff{ ($ vs $)|}2,3"
|
||||
"|: different number of parameters (%2 vs %3)"
|
||||
"|: type mismatch at %ordinal2 parameter%diff{ ($ vs $)|}3,4"
|
||||
"|: different return type%diff{ ($ vs $)|}2,3"
|
||||
"|: different qualifiers ("
|
||||
"%select{none|const|restrict|const and restrict|volatile|const and volatile|"
|
||||
"volatile and restrict|const, volatile, and restrict}2 vs "
|
||||
"%select{none|const|restrict|const and restrict|volatile|const and volatile|"
|
||||
"volatile and restrict|const, volatile, and restrict}3)}1">;
|
||||
def warn_using_directive_in_header : Warning<
|
||||
"using namespace directive in global context in header">,
|
||||
InGroup<HeaderHygiene>, DefaultIgnore;
|
||||
|
|
|
@ -5409,8 +5409,10 @@ void Sema::DiagnoseHiddenVirtualMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) {
|
|||
|
||||
for (unsigned i = 0, e = Data.OverloadedMethods.size(); i != e; ++i) {
|
||||
CXXMethodDecl *overloadedMD = Data.OverloadedMethods[i];
|
||||
Diag(overloadedMD->getLocation(),
|
||||
PartialDiagnostic PD = PDiag(
|
||||
diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
|
||||
HandleFunctionTypeMismatch(PD, MD->getType(), overloadedMD->getType());
|
||||
Diag(overloadedMD->getLocation(), PD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,3 +120,21 @@ struct MostDerived: Derived3, Derived2 {
|
|||
void func();
|
||||
};
|
||||
}
|
||||
|
||||
namespace {
|
||||
class A {
|
||||
virtual int foo(bool) const;
|
||||
// expected-note@-1{{type mismatch at 1st parameter ('bool' vs 'int')}}
|
||||
virtual int foo(int, int) const;
|
||||
// expected-note@-1{{different number of parameters (2 vs 1)}}
|
||||
virtual int foo(int*) const;
|
||||
// expected-note@-1{{type mismatch at 1st parameter ('int *' vs 'int')}}
|
||||
virtual int foo(int) volatile;
|
||||
// expected-note@-1{{different qualifiers (volatile vs const)}}
|
||||
};
|
||||
|
||||
class B : public A {
|
||||
virtual int foo(int) const;
|
||||
// expected-warning@-1{{hides overloaded virtual functions}}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue