cgraphunit.c (cgraph_decide_is_function_needed): Really return false for nested funct...
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 31 May 2010 11:43:31 +0000 (11:43 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 31 May 2010 11:43:31 +0000 (11:43 +0000)
* cgraphunit.c (cgraph_decide_is_function_needed): Really return false
for nested functions in non-optimized compilation.

From-SVN: r160068

gcc/ChangeLog
gcc/cgraphunit.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/nested-func-7.c [new file with mode: 0644]
gcc/testsuite/gnat.dg/frame_overflow.adb

index 48206e579fcc4bd62b6cc3f97f750e70968e9531..c1b62ce5fde5b6308e1672f867407a421e845014 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-31  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * cgraphunit.c (cgraph_decide_is_function_needed): Really return false
+       for nested functions in non-optimized compilation.
+
 2010-05-31  Richard Guenther  <rguenther@suse.de>
 
        * tree-ssa-structalias.c (find_func_aliases): Handle
@@ -35,7 +40,7 @@
 2010-05-30  Jan Hubicka  <jh@suse.cz>
 
        * toplev.c (wrapup_global_declaration_2): Avoid creation of new varpool
-       nodes 
+       nodes.
 
 2010-05-30  Richard Guenther  <rguenther@suse.de>
 
index 3dfbc927d1370bbc89174184a2afedd230df18df..1d5ed0d5ed877b94edec7242932cde1ccb1b0f26 100644 (file)
@@ -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)
index 43f447866946e123ca29704a11f08c800c145e2c..69808cd39dddf9e9b4c40f6c430f25da5b9c2077 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-31  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.dg/nested-func-7.c: New test.
+       * gnat.dg/frame_overflow.adb: Adjust directives.
+
 2010-05-30  Eric Botcazou  <ebotcazou@adacore.com>
 
        * 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 (file)
index 0000000..764beb4
--- /dev/null
@@ -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" } } */
index 055fa283f19f3a944923df60d229350c4e29457e..e1ff4d3653351503de4cf7054af96034c41240cf 100644 (file)
@@ -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" }