c-decl.c (merge_decls): Use !current_function_decl to check for extern declaration...
authorJoseph Myers <joseph@codesourcery.com>
Thu, 26 Jun 2008 15:40:56 +0000 (16:40 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Thu, 26 Jun 2008 15:40:56 +0000 (16:40 +0100)
* 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
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/inline-32.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/inline-32a.c [new file with mode: 0644]

index 5e8a970687372493ed6161bd3977d3e06491641c..525895866728f95b6b30afcd9a249e6f7722ed35 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-26  Joseph Myers  <joseph@codesourcery.com>
+
+       * 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  <dave.anglin@gcc-cnrc.gc.ca>
 
        * config.gcc (hppa[12]*-*-hpux10*): Don't use fixproto.
index 38c1581b3ff103f3abaacb47bf749ff7f6ea6965..18ad11901f97962da9b9b42e50121cd51ed607ca 100644 (file)
@@ -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))
index d2df6992b1b5d714506bc16b85ddb9d380c69462..01a008f3c186d545bb1acfc7d5f1b0d97cf6d33b 100644 (file)
@@ -1,3 +1,7 @@
+2008-06-26  Joseph Myers  <joseph@codesourcery.com>
+
+       * gcc.dg/inline-32.c, gcc.dg/inline-32a.c: New tests.
+
 2008-06-26  Ira Rosen  <irar@il.ibm.com>
 
        * 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 (file)
index 0000000..bfcafd5
--- /dev/null
@@ -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 (file)
index 0000000..a2bde0a
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+int f (void) { return 0; }