diff options
author | Joseph Myers <joseph@codesourcery.com> | 2013-11-29 01:30:42 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2013-11-29 01:30:42 +0000 |
commit | 6763b9f73682fcfd494d3133cfd17bc5d914286a (patch) | |
tree | 40fc29c743ee6ca77329f7595611e4100a4b9bd1 | |
parent | b76f5d160b9922e4513a146c82d304ce8c07e167 (diff) | |
download | gcc-6763b9f73682fcfd494d3133cfd17bc5d914286a.zip gcc-6763b9f73682fcfd494d3133cfd17bc5d914286a.tar.gz gcc-6763b9f73682fcfd494d3133cfd17bc5d914286a.tar.bz2 |
re PR c/57574 (-std=c99 inline function incorrectly has external linkage with prior static declaration)
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
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/inline-35.c | 19 |
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 5121acd..7016ecb 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -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 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index c019a3e..27be7fc 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f0d18af..cbe455e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..ebbb8df --- /dev/null +++ b/gcc/testsuite/gcc.dg/inline-35.c @@ -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; } |