operators, make sure that the implicitly-declared global new and
delete operators are always available. Fixes PR5904.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99382
91177308-0d34-0410-b5e6-
96231b3b80d8
SemaRef.getLangOptions().CPlusPlus,
isForRedeclaration());
IsAcceptableFn = getResultFilter(LookupKind);
+
+ // If we're looking for one of the allocation or deallocation
+ // operators, make sure that the implicitly-declared new and delete
+ // operators can be found.
+ if (!isForRedeclaration()) {
+ switch (Name.getCXXOverloadedOperator()) {
+ case OO_New:
+ case OO_Delete:
+ case OO_Array_New:
+ case OO_Array_Delete:
+ SemaRef.DeclareGlobalNewDelete();
+ break;
+
+ default:
+ break;
+ }
+ }
}
// Necessary because CXXBasePaths is not complete in Sema.h
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DQUALIFIED -fsyntax-only -verify %s
+
+// PR5904
+void f0(int *ptr) {
+#ifndef QUALIFIED
+ operator delete(ptr);
+#endif
+}
+
+void f1(int *ptr) {
+ ::operator delete[](ptr);
+}