aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/call.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/lookup/new1.C13
4 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f611cb3..a760aa9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2004-07-05 Giovanni Bajo <giovannibajo@gcc.gnu.org>
+
+ PR c++/2518
+ * call.c (build_operator_new_call): Look only at global scope.
+
2004-07-05 Nathan Sidwell <nathan@codesourcery.com>
* call.c (enforce_access): Expect TREE_BINFO.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 82355c29..b698386 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2812,7 +2812,10 @@ build_operator_new_call (tree fnname, tree args, tree *size, tree *cookie_size)
if (args == error_mark_node)
return args;
+ /* A global operator new must be looked up only at global scope. */
+ push_to_top_level();
fns = lookup_function_nonclass (fnname, args);
+ pop_from_top_level();
/* Figure out what function is being called. */
cand = perform_overload_resolution (fns, args, &candidates, &any_viable_p);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3b0a5d1..e12cd88 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-07-05 Giovanni Bajo <giovannibajo@gcc.gnu.org>
+
+ PR c++/2518
+ * g++.dg/lookup/new1.C: New test.
+
2004-07-05 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/11406
diff --git a/gcc/testsuite/g++.dg/lookup/new1.C b/gcc/testsuite/g++.dg/lookup/new1.C
new file mode 100644
index 0000000..a28d3e8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/new1.C
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// Origin: <igodard at rational dot com>
+// PR c++/2518: operator new must not be looked up in local scope
+
+int main() {
+ int i;
+ void* operator new(unsigned s, int* p);
+ int* e = new(&i) int; // { dg-error "no matching function" }
+ int* f = new int;
+ return 0;
+}
+
+// { dg-excess-errors "operator new" "list of candidates" }