re PR c/18963 (static and nested declarations cause an ice)
authorJames A. Morrison <phython@gcc.gnu.org>
Tue, 21 Dec 2004 17:07:06 +0000 (17:07 +0000)
committerJames A. Morrison <phython@gcc.gnu.org>
Tue, 21 Dec 2004 17:07:06 +0000 (17:07 +0000)
2004-12-21  James A. Morrison  <phython@gcc.gnu.org>

       PR c/18963
       * c-decl.c (pushdecl): Remove block trying to merge static function
       declarations at block scope to file scope declarations.

testsuite:
        PR c/18963
        * gcc.dg/pr18963-1.c: New test.

From-SVN: r92460

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr18963-1.c [new file with mode: 0644]

index 3fc04174332503fbf0f13eea849375b1760191ed..71a1525bc42088e108197e1b051d83056a98c556 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-21  James A. Morrison  <phython@gcc.gnu.org>
+
+       PR c/18963
+       * c-decl.c (pushdecl): Remove block trying to merge static function
+       declarations at block scope to file scope declarations.
+
 2004-12-21  James A. Morrison  <phython@gcc.gnu.org>
 
        PR c/18596
index f881ea8e052135b31945a06ae72ad20570921954..975e281b5cf3291c952a6d6b002f90b5bfb89490 100644 (file)
@@ -2069,30 +2069,6 @@ pushdecl (tree x)
            }
        }
     }
-  /* Similarly, a declaration of a function with static linkage at
-     block scope must be checked against any existing declaration
-     of that function at file scope.  */
-  else if (TREE_CODE (x) == FUNCTION_DECL && scope != file_scope
-          && !TREE_PUBLIC (x) && !DECL_INITIAL (x))
-    {
-      if (warn_nested_externs && !DECL_IN_SYSTEM_HEADER (x))
-       warning ("nested static declaration of %qD", x);
-
-      while (b && !B_IN_FILE_SCOPE (b))
-       b = b->shadowed;
-
-      if (b && same_translation_unit_p (x, b->decl)
-         && duplicate_decls (x, b->decl))
-       {
-         bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true);
-         return b->decl;
-       }
-      else
-       {
-         bind (name, x, file_scope, /*invisible=*/true, /*nested=*/false);
-         nested = true;
-       }
-    }
 
   warn_if_shadowing (x);
 
index 0c742af3358d77ac3538419bee29bbb5124e5321..99ccef818632f12432999a2f14e08416b89f5c04 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-21  James A. Morrison  <phython@gcc.gnu.org>
+
+       PR c/18963
+       * gcc.dg/pr18963-1.c: New test.
+
 2004-12-21  James A. Morrison  <phython@gcc.gnu.org>
 
        PR c/18596
diff --git a/gcc/testsuite/gcc.dg/pr18963-1.c b/gcc/testsuite/gcc.dg/pr18963-1.c
new file mode 100644 (file)
index 0000000..df43c65
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "" } */
+
+static int barf ();
+
+int foo ()
+{ 
+  auto int barf ();
+  int j = 4;
+
+  int barf () {
+    return j;
+  }
+
+  return barf ();
+}
+
+static int barf () {
+  return 3;
+}
+
+extern void exit (int);
+extern void abort ();
+
+int main (int argc, char *argv[]) {
+  if (foo () != 4)
+    abort ();
+  exit (0);
+}