Commit eebeecac by Eric Botcazou Committed by Eric Botcazou

re PR middle-end/18820 (ACATS c95300[123] and c980002 fail at runtime)

	PR middle-end/18820
	* varasm.c (initializer_constant_valid_p) <ADDR_EXPR>: Return
	zero for nested functions needing a static chain or functions
	with a non-constant address.

From-SVN: r93633
parent 84973b27
2005-01-14 Eric Botcazou <ebotcazou@libertysurf.fr>
PR middle-end/18820
* varasm.c (initializer_constant_valid_p) <ADDR_EXPR>: Return
zero for nested functions needing a static chain or functions
with a non-constant address.
2005-01-13 Roger Sayle <roger@eyesopen.com>
* simplify-rtx.c (simplify_binary_operation) <AND>: Optimize
......
2005-01-14 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/nested-func-2.c: New test.
* ada/acats/norun.lst: Remove c953002.
2005-01-12 Ulrich Weigand <uweigand@de.ibm.com>
* gcc.dg/ftrapv-2.c (labsv): Call labs instead of abs.
......
c380004
c953002
cdd2a03
templat
# Tests must be sorted in alphabetical order
# c380004: should be front-end compile time error, PR ada/18817
# c953002: often hanging, PR ada/18820
# cdd2a03: new Ada ruling not supported yet, PR ada/19323
/* PR middle-end/18820 */
/* Check that we reject nested functions as initializers
of static variables. */
/* { dg-do compile } */
/* { dg-options "" } */
struct S {
void (*f)(int);
};
extern void baz(struct S *);
extern void p(int);
void foo(void)
{
int u;
void bar(int val)
{
u = val;
}
static struct S s = { bar }; /* { dg-error "(is not constant)|(near initialization)" } */
baz(&s);
p(u);
}
......@@ -3501,6 +3501,12 @@ initializer_constant_valid_p (tree value, tree endtype)
&& TREE_CODE (value) == INDIRECT_REF
&& TREE_CONSTANT (TREE_OPERAND (value, 0)))
return null_pointer_node;
/* Taking the address of a nested function involves a trampoline. */
if (value
&& TREE_CODE (value) == FUNCTION_DECL
&& ((decl_function_context (value) && !DECL_NO_STATIC_CHAIN (value))
|| DECL_NON_ADDR_CONST_P (value)))
return NULL_TREE;
return value;
case VIEW_CONVERT_EXPR:
......
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