From: Jakub Jelinek Date: Fri, 30 Jan 2009 20:46:32 +0000 (+0100) Subject: re PR target/39013 (Missing @PLT when -fpie is used) X-Git-Tag: releases/gcc-4.4.0~691 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0728ae0d8311979f9e73498d2701bce8216adf1;p=thirdparty%2Fgcc.git re PR target/39013 (Missing @PLT when -fpie is used) PR target/39013 * c-decl.c (pop_scope): Set DECL_EXTERNAL for functions declared inline but never defined. * gcc.target/i386/pr39013-1.c: New test. * gcc.target/i386/pr39013-2.c: New test. From-SVN: r143803 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c700951184b8..b3ae08395c67 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-01-30 Jakub Jelinek + + PR target/39013 + * c-decl.c (pop_scope): Set DECL_EXTERNAL for functions declared + inline but never defined. + 2009-01-30 Wolfgang Gellerich * config/s390/s390.md (*insv_reg_extimm): Removed. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 6ebee1a337b4..9f65af4efaca 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -781,14 +781,18 @@ pop_scope (void) error ("nested function %q+D declared but never defined", p); undef_nested_function = true; } - /* C99 6.7.4p6: "a function with external linkage... declared - with an inline function specifier ... shall also be defined in the - same translation unit." */ else if (DECL_DECLARED_INLINE_P (p) && TREE_PUBLIC (p) - && !DECL_INITIAL (p) - && !flag_gnu89_inline) - pedwarn (input_location, 0, "inline function %q+D declared but never defined", p); + && !DECL_INITIAL (p)) + { + /* C99 6.7.4p6: "a function with external linkage... declared + with an inline function specifier ... shall also be defined + in the same translation unit." */ + if (!flag_gnu89_inline) + pedwarn (input_location, 0, + "inline function %q+D declared but never defined", p); + DECL_EXTERNAL (p) = 1; + } goto common_symbol; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c43d9c022d9f..67522c6d4cbf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2009-01-30 Jakub Jelinek + PR target/39013 + * gcc.target/i386/pr39013-1.c: New test. + * gcc.target/i386/pr39013-2.c: New test. + PR c++/39028 * g++.dg/ext/label12.C: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr39013-1.c b/gcc/testsuite/gcc.target/i386/pr39013-1.c new file mode 100644 index 000000000000..25f02fcdba65 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr39013-1.c @@ -0,0 +1,15 @@ +/* PR target/39013 */ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-options "-O2 -fpie -std=gnu89" } */ + +inline int foo (void); +extern inline int bar (void); + +int +main (void) +{ + return foo () + bar (); +} + +/* { dg-final { scan-assembler "foo@PLT" } } */ +/* { dg-final { scan-assembler "bar@PLT" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr39013-2.c b/gcc/testsuite/gcc.target/i386/pr39013-2.c new file mode 100644 index 000000000000..615d54900f84 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr39013-2.c @@ -0,0 +1,15 @@ +/* PR target/39013 */ +/* { dg-do compile { target *-*-linux* } } */ +/* { dg-options "-O2 -fpie -std=gnu99" } */ + +inline int foo (void); /* { dg-warning "declared but never defined" } */ +extern inline int bar (void); /* { dg-warning "declared but never defined" } */ + +int +main (void) +{ + return foo () + bar (); +} + +/* { dg-final { scan-assembler "foo@PLT" } } */ +/* { dg-final { scan-assembler "bar@PLT" } } */