PR c++/2518
* call.c (build_operator_new_call): Look only at global scope.
PR c++/2518
* g++.dg/lookup/new1.C: New test.
From-SVN: r84119
+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.
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);
+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
--- /dev/null
+// { 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" }