зеркало из https://github.com/microsoft/clang-1.git
A member function template cannot be virtual.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124031 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
15f6765f6e
Коммит
f1602a56f8
|
@ -642,6 +642,8 @@ def err_virtual_non_function : Error<
|
|||
"'virtual' can only appear on non-static member functions">;
|
||||
def err_virtual_out_of_class : Error<
|
||||
"'virtual' can only be specified inside the class definition">;
|
||||
def err_virtual_member_function_template : Error<
|
||||
"'virtual' can not be specified on member function templates">;
|
||||
def err_static_overrides_virtual : Error<
|
||||
"'static' member function %0 overrides a virtual function in a base class">;
|
||||
def err_explicit_non_function : Error<
|
||||
|
|
|
@ -3705,7 +3705,14 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
|||
diag::err_virtual_non_function);
|
||||
} else if (!CurContext->isRecord()) {
|
||||
// 'virtual' was specified outside of the class.
|
||||
Diag(D.getDeclSpec().getVirtualSpecLoc(), diag::err_virtual_out_of_class)
|
||||
Diag(D.getDeclSpec().getVirtualSpecLoc(),
|
||||
diag::err_virtual_out_of_class)
|
||||
<< FixItHint::CreateRemoval(D.getDeclSpec().getVirtualSpecLoc());
|
||||
} else if (NewFD->getDescribedFunctionTemplate()) {
|
||||
// C++ [temp.mem]p3:
|
||||
// A member function template shall not be virtual.
|
||||
Diag(D.getDeclSpec().getVirtualSpecLoc(),
|
||||
diag::err_virtual_member_function_template)
|
||||
<< FixItHint::CreateRemoval(D.getDeclSpec().getVirtualSpecLoc());
|
||||
} else {
|
||||
// Okay: Add virtual to the method.
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
template <class T> struct AA {
|
||||
template <class C> virtual void g(C); // expected-error{{'virtual' can not be specified on member function templates}}
|
||||
virtual void f();
|
||||
};
|
Загрузка…
Ссылка в новой задаче