* varasm.c (initializer_constant_valid_p) <ADDR_EXPR>: Return
zero for nested functions needing a static chain or functions
with a non-constant address.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@93633
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
--- /dev/null
+/* 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);
+}
&& 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: