Commit 46ff5047 by Mark Mitchell Committed by Mark Mitchell

re PR c++/4884 (g++ 3.0.2 problem with -fvolatile)

	PR c++/4884.
	* init.c (build_new_1): Allow for the fact the result of
	build_function_call may be a COMPOUND_EXPR.

	* g++.dg/init/new1.C: New test.

From-SVN: r51396
parent 6d4c57a0
2002-03-26 Mark Mitchell <mark@codesourcery.com>
PR c++/4884.
* init.c (build_new_1): Allow for the fact the result of
build_function_call may be a COMPOUND_EXPR.
2002-03-26 Nathan Sidwell <nathan@codesourcery.com> 2002-03-26 Nathan Sidwell <nathan@codesourcery.com>
PR c++/5682 PR c++/5682
......
...@@ -2189,6 +2189,7 @@ build_new_1 (exp) ...@@ -2189,6 +2189,7 @@ build_new_1 (exp)
tree full_type; tree full_type;
tree nelts = NULL_TREE; tree nelts = NULL_TREE;
tree alloc_call, alloc_expr, alloc_node; tree alloc_call, alloc_expr, alloc_node;
tree alloc_fn;
tree cookie_expr, init_expr; tree cookie_expr, init_expr;
int has_array = 0; int has_array = 0;
enum tree_code code; enum tree_code code;
...@@ -2329,13 +2330,14 @@ build_new_1 (exp) ...@@ -2329,13 +2330,14 @@ build_new_1 (exp)
if (alloc_call == error_mark_node) if (alloc_call == error_mark_node)
return error_mark_node; return error_mark_node;
/* The ALLOC_CALL should be a CALL_EXPR, and the first operand /* The ALLOC_CALL should be a CALL_EXPR -- or a COMPOUND_EXPR whose
should be the address of a known FUNCTION_DECL. */ right-hand-side is ultimately a CALL_EXPR -- and the first
my_friendly_assert (TREE_CODE (alloc_call) == CALL_EXPR, 20000521); operand should be the address of a known FUNCTION_DECL. */
t = TREE_OPERAND (alloc_call, 0); t = alloc_call;
my_friendly_assert (TREE_CODE (t) == ADDR_EXPR, 20000521); while (TREE_CODE (t) == COMPOUND_EXPR)
t = TREE_OPERAND (t, 0); t = TREE_OPERAND (t, 1);
my_friendly_assert (TREE_CODE (t) == FUNCTION_DECL, 20000521); alloc_fn = get_callee_fndecl (t);
my_friendly_assert (alloc_fn != NULL_TREE, 20020325);
/* Now, check to see if this function is actually a placement /* Now, check to see if this function is actually a placement
allocation function. This can happen even when PLACEMENT is NULL allocation function. This can happen even when PLACEMENT is NULL
because we might have something like: because we might have something like:
...@@ -2347,7 +2349,8 @@ build_new_1 (exp) ...@@ -2347,7 +2349,8 @@ build_new_1 (exp)
one argument, or there are variable arguments, then this is a one argument, or there are variable arguments, then this is a
placement allocation function. */ placement allocation function. */
placement_allocation_fn_p placement_allocation_fn_p
= (type_num_arguments (TREE_TYPE (t)) > 1 || varargs_function_p (t)); = (type_num_arguments (TREE_TYPE (alloc_fn)) > 1
|| varargs_function_p (alloc_fn));
/* unless an allocation function is declared with an empty excep- /* unless an allocation function is declared with an empty excep-
tion-specification (_except.spec_), throw(), it indicates failure to tion-specification (_except.spec_), throw(), it indicates failure to
...@@ -2359,11 +2362,7 @@ build_new_1 (exp) ...@@ -2359,11 +2362,7 @@ build_new_1 (exp)
So check for a null exception spec on the op new we just called. */ So check for a null exception spec on the op new we just called. */
/* The ADDR_EXPR. */ nothrow = TYPE_NOTHROW_P (TREE_TYPE (alloc_fn));
t = TREE_OPERAND (alloc_call, 0);
/* The function. */
t = TREE_OPERAND (t, 0);
nothrow = TYPE_NOTHROW_P (TREE_TYPE (t));
check_new = (flag_check_new || nothrow) && ! use_java_new; check_new = (flag_check_new || nothrow) && ! use_java_new;
alloc_expr = alloc_call; alloc_expr = alloc_call;
......
2002-03-26 Mark Mitchell <mark@codesourcery.com>
* g++.dg/init/new1.C: New test.
2002-03-26 Nathan Sidwell <nathan@codesourcery.com> 2002-03-26 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/abi/vbase9.C: New test. * g++.dg/abi/vbase9.C: New test.
......
// Origin: asharji@uwaterloo.ca
// { dg-do compile }
// { dg-options "-fvolatile" }
typedef unsigned int size_t;
class bar {
int i;
public :
void * operator new ( size_t , void * storage );
};
class foo {
int storage[ 5 ];
public:
void mem ( ) {
bar *s = new ( ( void * ) & storage ) bar;
}
};
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