From c5d01958a7b919d0407e8982d70e52fafa8588d2 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 31 May 2010 11:43:31 +0000 Subject: [PATCH] cgraphunit.c (cgraph_decide_is_function_needed): Really return false for nested functions in non-optimized compilation. * cgraphunit.c (cgraph_decide_is_function_needed): Really return false for nested functions in non-optimized compilation. From-SVN: r160068 --- gcc/ChangeLog | 7 ++++++- gcc/cgraphunit.c | 8 +++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/nested-func-7.c | 15 +++++++++++++++ gcc/testsuite/gnat.dg/frame_overflow.adb | 5 ++--- 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/nested-func-7.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 48206e579fc..c1b62ce5fde 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-05-31 Eric Botcazou + + * cgraphunit.c (cgraph_decide_is_function_needed): Really return false + for nested functions in non-optimized compilation. + 2010-05-31 Richard Guenther * tree-ssa-structalias.c (find_func_aliases): Handle @@ -35,7 +40,7 @@ 2010-05-30 Jan Hubicka * toplev.c (wrapup_global_declaration_2): Avoid creation of new varpool - nodes + nodes. 2010-05-30 Richard Guenther diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 3dfbc927d13..1d5ed0d5ed8 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -352,13 +352,15 @@ cgraph_decide_is_function_needed (struct cgraph_node *node, tree decl) When not optimizing, also output the static functions. (see PR24561), but don't do so for always_inline functions, functions - declared inline and nested functions. These was optimized out + declared inline and nested functions. These were optimized out in the original implementation and it is unclear whether we want to change the behavior here. */ if (((TREE_PUBLIC (decl) - || (!optimize && !node->local.disregard_inline_limits + || (!optimize + && !node->local.disregard_inline_limits && !DECL_DECLARED_INLINE_P (decl) - && !node->origin)) + && !(DECL_CONTEXT (decl) + && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL))) && !flag_whole_program && !flag_lto && !flag_whopr) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 43f44786694..69808cd39dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-05-31 Eric Botcazou + + * gcc.dg/nested-func-7.c: New test. + * gnat.dg/frame_overflow.adb: Adjust directives. + 2010-05-30 Eric Botcazou * gnat.dg/prot2.ad[sb]: New test. diff --git a/gcc/testsuite/gcc.dg/nested-func-7.c b/gcc/testsuite/gcc.dg/nested-func-7.c new file mode 100644 index 00000000000..764beb45373 --- /dev/null +++ b/gcc/testsuite/gcc.dg/nested-func-7.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-optimized" } */ + +void foo (void) +{ + int a; + + void bar (void) + { + a = 1; + } +} + +/* { dg-final { scan-tree-dump-not "bar" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gnat.dg/frame_overflow.adb b/gcc/testsuite/gnat.dg/frame_overflow.adb index 055fa283f19..e1ff4d36533 100644 --- a/gcc/testsuite/gnat.dg/frame_overflow.adb +++ b/gcc/testsuite/gnat.dg/frame_overflow.adb @@ -1,5 +1,4 @@ -- { dg-do compile } --- { dg-xfail-if "missing late warning" { *-*-* } { "-flto" } { "" } } with System; @@ -11,8 +10,8 @@ procedure frame_overflow is type Bitmap_T is record Bits : Bitmap_Array_T := (others => False); end record; - - function -- { dg-error "too large" } + + function Set_In (Bitmap : Bitmap_T; Bitpos : Bitpos_Range_T) return Bitmap_T is Result: Bitmap_T := Bitmap; -- { dg-error "Storage_Error" } -- 2.30.2