]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c/57574 (-std=c99 inline function incorrectly has external linkage with prior...
authorJoseph Myers <joseph@codesourcery.com>
Fri, 29 Nov 2013 01:30:42 +0000 (01:30 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Fri, 29 Nov 2013 01:30:42 +0000 (01:30 +0000)
PR c/57574
c:
* c-decl.c (merge_decls): Clear DECL_EXTERNAL for a definition of
an inline function following a static declaration.

testsuite:
* gcc.dg/inline-35.c: New test.

From-SVN: r205506

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/inline-35.c [new file with mode: 0644]

index 5121acdc18724924bbbc59dc968fddd29fd6f89a..7016ecb4bf9f9f2169a93de7ba626c01de57d1e3 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-29  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/57574
+       * c-decl.c (merge_decls): Clear DECL_EXTERNAL for a definition of
+       an inline function following a static declaration.
+
 2013-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/59310
index c019a3eec3218f0fde54b90ece71dab53700c7a5..27be7fc1b031ba6d42e0c973cef967c0f5b74482 100644 (file)
@@ -2343,6 +2343,14 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
       && !current_function_decl)
     DECL_EXTERNAL (newdecl) = 0;
 
+  /* An inline definition following a static declaration is not
+     DECL_EXTERNAL.  */
+  if (new_is_definition
+      && (DECL_DECLARED_INLINE_P (newdecl)
+         || DECL_DECLARED_INLINE_P (olddecl))
+      && !TREE_PUBLIC (olddecl))
+    DECL_EXTERNAL (newdecl) = 0;
+
   if (DECL_EXTERNAL (newdecl))
     {
       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
index f0d18af7de2a54c1e70d63ad98742bc56893b393..cbe455eb0aa6ed92c9fe91b6fb1a11477fb18e35 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-29  Joseph Myers  <joseph@codesourcery.com>
+
+       PR c/57574
+       * gcc.dg/inline-35.c: New test.
+
 2013-11-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/59297
diff --git a/gcc/testsuite/gcc.dg/inline-35.c b/gcc/testsuite/gcc.dg/inline-35.c
new file mode 100644 (file)
index 0000000..ebbb8df
--- /dev/null
@@ -0,0 +1,19 @@
+/* A function definition of an inline function following a static
+   declaration does not make an inline definition in C99/C11 terms.
+   PR 57574.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+
+static int n;
+
+static inline int f1 (void);
+inline int f1 (void) { return n; }
+
+static int f2 (void);
+inline int f2 (void) { return n; }
+
+static inline int f3 (void);
+int f3 (void) { return n; }
+
+static int f4 (void);
+int f4 (void) { return n; }
This page took 0.079944 seconds and 5 git commands to generate.