[cfe-commits] r99382 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/SemaCXX/new-delete-predefined-decl-2.cpp
Douglas Gregor
dgregor at apple.com
Tue Mar 23 22:07:21 PDT 2010
Author: dgregor
Date: Wed Mar 24 00:07:21 2010
New Revision: 99382
URL: http://llvm.org/viewvc/llvm-project?rev=99382&view=rev
Log:
When performing name lookup for the allocation or deallocation
operators, make sure that the implicitly-declared global new and
delete operators are always available. Fixes PR5904.
Added:
cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp (with props)
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=99382&r1=99381&r2=99382&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Mar 24 00:07:21 2010
@@ -304,6 +304,23 @@
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
Added: cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp?rev=99382&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp (added)
+++ cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp Wed Mar 24 00:07:21 2010
@@ -0,0 +1,13 @@
+// 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);
+}
Propchange: cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/SemaCXX/new-delete-predefined-decl-2.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list