From 74b0ec7c400f3ad1e08300ed7d5f79b437ec6b39 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 26 Jun 2008 16:40:56 +0100 Subject: [PATCH] c-decl.c (merge_decls): Use !current_function_decl to check for extern declaration of C99 inline... * c-decl.c (merge_decls): Use !current_function_decl to check for extern declaration of C99 inline function being at file scope. testsuite: * gcc.dg/inline-32.c, gcc.dg/inline-32a.c: New tests. From-SVN: r137149 --- gcc/ChangeLog | 5 +++++ gcc/c-decl.c | 3 +-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/inline-32.c | 11 +++++++++++ gcc/testsuite/gcc.dg/inline-32a.c | 3 +++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/inline-32.c create mode 100644 gcc/testsuite/gcc.dg/inline-32a.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5e8a9706873..52589586672 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-06-26 Joseph Myers + + * c-decl.c (merge_decls): Use !current_function_decl to check for + extern declaration of C99 inline function being at file scope. + 2008-06-25 John David Anglin * config.gcc (hppa[12]*-*-hpux10*): Don't use fixproto. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 38c1581b3ff..18ad11901f9 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1764,8 +1764,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) || !DECL_EXTERNAL (olddecl)) && DECL_EXTERNAL (newdecl) && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (newdecl)) - && (DECL_CONTEXT (newdecl) == NULL_TREE - || TREE_CODE (DECL_CONTEXT (newdecl)) != FUNCTION_DECL)) + && !current_function_decl) DECL_EXTERNAL (newdecl) = 0; if (DECL_EXTERNAL (newdecl)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2df6992b1b..01a008f3c18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-06-26 Joseph Myers + + * gcc.dg/inline-32.c, gcc.dg/inline-32a.c: New tests. + 2008-06-26 Ira Rosen * testsuite/lib/target-supports.exp diff --git a/gcc/testsuite/gcc.dg/inline-32.c b/gcc/testsuite/gcc.dg/inline-32.c new file mode 100644 index 00000000000..bfcafd5dbba --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-32.c @@ -0,0 +1,11 @@ +/* { dg-do link } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +/* { dg-additional-sources inline-32a.c } */ +inline int f (void) { return 0; } + +int +main (void) +{ + extern int f(); + return f (); +} diff --git a/gcc/testsuite/gcc.dg/inline-32a.c b/gcc/testsuite/gcc.dg/inline-32a.c new file mode 100644 index 00000000000..a2bde0aac4b --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-32a.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ +int f (void) { return 0; } -- 2.30.2