mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-11 15:10:12 +08:00
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
This commit is contained in:
parent
84973b27e8
commit
eebeecacfb
@ -1,3 +1,10 @@
|
||||
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
|
||||
|
@ -1,3 +1,8 @@
|
||||
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.
|
||||
|
@ -1,8 +1,6 @@
|
||||
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
|
||||
|
28
gcc/testsuite/gcc.dg/nested-func-2.c
Normal file
28
gcc/testsuite/gcc.dg/nested-func-2.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* 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:
|
||||
|
Loading…
Reference in New Issue
Block a user