This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix PR18963


 Hi,

  This chunk of code is useless now that static function declarations are
thrown away when they are not at file scope.  It also gets rid of the ICE
caused in pr18963.  Bootstrapped and regtested on sparc-linux with no new
regressions (the patch for pr18596 was applied).  This also fixes the
testcase attached.  Ok for mainline?

-- 
Thanks,
Jim

http://www.student.cs.uwaterloo.ca/~ja2morri/
http://phython.blogspot.com
http://open.nit.ca/wiki/?page=jim

/* { 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);
}
2004-12-19  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.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.612
diff -u -p -r1.612 c-decl.c
--- c-decl.c	30 Nov 2004 00:32:23 -0000	1.612
+++ c-decl.c	19 Dec 2004 17:54:26 -0000
@@ -2057,30 +2057,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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]