[PATCH] Return false for DECL_EXTERNAL VAR_DECLs from auto_var_in_fn_p (PR debug/43942)

Jakub Jelinek jakub@redhat.com
Fri Apr 30 10:54:00 GMT 2010


Hi!

At least tree-tailcall wasn't expecting auto_var_in_fn_p to return
true for DECL_EXTERNAL VAR_DECLs (externs declared inside of a function).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.
No effect on the generated debug info size on gcc/*.o (appart from tree.o
obviously) nor on the generated code (H.J. changed the one occurrence where
this would trigger last night).

Ok for trunk?

2010-04-30  Jakub Jelinek  <jakub@redhat.com>

	PR debug/43942
	* tree.c (auto_var_in_fn_p): Return false for DECL_EXTERNAL vars.

	* c-c++-common/pr43942.c: New test.

--- gcc/tree.c.jj	2010-04-30 11:14:41.000000000 +0200
+++ gcc/tree.c	2010-04-30 12:05:26.000000000 +0200
@@ -7936,7 +7936,8 @@ bool
 auto_var_in_fn_p (const_tree var, const_tree fn)
 {
   return (DECL_P (var) && DECL_CONTEXT (var) == fn
-	  && (((TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == PARM_DECL)
+	  && ((((TREE_CODE (var) == VAR_DECL && ! DECL_EXTERNAL (var))
+		|| TREE_CODE (var) == PARM_DECL)
 	       && ! TREE_STATIC (var))
 	      || TREE_CODE (var) == LABEL_DECL
 	      || TREE_CODE (var) == RESULT_DECL));
--- gcc/testsuite/c-c++-common/pr43942.c.jj	2010-04-30 12:03:34.000000000 +0200
+++ gcc/testsuite/c-c++-common/pr43942.c	2010-04-30 11:59:26.000000000 +0200
@@ -0,0 +1,33 @@
+/* PR debug/43942 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+extern int f1 (int);
+
+int
+f2 (int x)
+{
+  extern int v;
+  return f1 (x);
+}
+
+void
+f3 (void)
+{
+  f2 (0);
+}
+
+static inline int
+f4 (int x)
+{
+  extern int w;
+  if (w)
+    return f1 (x);
+  return 0;
+}
+
+void
+f5 (void)
+{
+  f4 (0);
+}

	Jakub



More information about the Gcc-patches mailing list