Commit 030bbecd by Giovanni Bajo

re PR c++/2518 (user-declared operator new hides standard one)

	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
parent 2709efd8
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.
......
......@@ -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);
......
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
......
// { 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" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment