зеркало из https://github.com/microsoft/clang-1.git
allocation functions are always static.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88858 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
78f7455181
Коммит
67bf2e7706
|
@ -2612,10 +2612,19 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool isStatic = SC == FunctionDecl::Static;
|
||||
|
||||
// [class.free]p1:
|
||||
// Any allocation function for a class T is a static member
|
||||
// (even if not explicitly declared static).
|
||||
if (Name.getCXXOverloadedOperator() == OO_New ||
|
||||
Name.getCXXOverloadedOperator() == OO_Array_New)
|
||||
isStatic = true;
|
||||
|
||||
// This is a C++ method declaration.
|
||||
NewFD = CXXMethodDecl::Create(Context, cast<CXXRecordDecl>(DC),
|
||||
D.getIdentifierLoc(), Name, R, DInfo,
|
||||
(SC == FunctionDecl::Static), isInline);
|
||||
isStatic, isInline);
|
||||
|
||||
isVirtualOkay = (SC != FunctionDecl::Static);
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
#include <stddef.h>
|
||||
|
||||
struct A {
|
||||
void *operator new(size_t) {
|
||||
return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
|
||||
}
|
||||
void *operator new[](size_t) {
|
||||
return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
|
||||
}
|
||||
};
|
Загрузка…
Ссылка в новой задаче