This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c/5163
- From: Jakub Jelinek <jakub at redhat dot com>
- To: rth at redhat dot com, aoliva at redhat dot com
- Cc: aj at suse dot de, gcc-patches at gcc dot gnu dot org
- Date: Fri, 21 Dec 2001 23:43:57 +0100
- Subject: [PATCH] Fix PR c/5163
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Assigning one extern declaration as abstract origin to another one certainly
cannot work. This patch fixes the testcase (and bootstrapped with no make
check regressions), though I wonder whether the test shouldn't be extended
to && ! DECL_EXTERNAL (newdecl) too (or why is actually a DECL_EXTERNAL ever
marked DECL_INLINE).
2001-12-21 Jakub Jelinek <jakub@redhat.com>
* c-decl.c (duplicate_decls): Don't set abstract origin to origin
if olddecl from different binding level is external.
Fixes PR c/5163.
* gcc.dg/20011221-1.c: New test.
--- gcc/c-decl.c.jj Tue Dec 18 01:28:02 2001
+++ gcc/c-decl.c Fri Dec 21 18:52:00 2001
@@ -2019,7 +2019,7 @@ duplicate_decls (newdecl, olddecl, diffe
DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
if (DECL_INLINE (newdecl))
DECL_ABSTRACT_ORIGIN (newdecl)
- = (different_binding_level
+ = ((different_binding_level && ! DECL_EXTERNAL (olddecl))
? DECL_ORIGIN (olddecl)
: DECL_ABSTRACT_ORIGIN (olddecl));
}
--- gcc/testsuite/gcc.dg/20011221-1.c.jj Sat Dec 22 00:18:38 2001
+++ gcc/testsuite/gcc.dg/20011221-1.c Sat Dec 22 00:24:10 2001
@@ -0,0 +1,14 @@
+/* Origin: PR c/5163 from aj@suse.de. */
+/* { dg-do compile } */
+/* { dg-options "-O3 -g" } */
+
+extern int bar (int);
+
+int
+foo (void)
+{
+ extern int bar (int);
+
+ return bar (5);
+}
+
Jakub