[Bug c/88726] [7 Regression] GCC thinks that translation unit does not contain a definition of inline function.

2019-01-16 Thread jsm28 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88726

Joseph S. Myers  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Joseph S. Myers  ---
Also now fixed for GCC 7.5.

[Bug c/88726] [7 Regression] GCC thinks that translation unit does not contain a definition of inline function.

2019-01-16 Thread jsm28 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88726

--- Comment #5 from Joseph S. Myers  ---
Author: jsm28
Date: Wed Jan 16 21:40:33 2019
New Revision: 267987

URL: https://gcc.gnu.org/viewcvs?rev=267987=gcc=rev
Log:
Fix diagnostics for never-defined inline and nested functions (PR c/88720, PR
c/88726).

Bugs 88720 and 88726 report issues where a function is declared inline
in an inner scope, resulting in spurious diagnostics about it being
declared but never defined when that scope is left (possibly in some
cases also wrongly referring to the function as a nested function).
These are regressions that were introduced with the support for C99
inline semantics in 4.3 (they don't appear with 4.2; it's possible
some aspects of the bugs might have been introduced later than 4.3).

For the case of functions being wrongly referred to as nested,
DECL_EXTERNAL was not the right condition for a function being
non-nested; TREE_PUBLIC is appropriate for the case of non-nested
functions with external linkage, while !b->nested means this is the
outermost scope in which the function was declared and so avoids
catching the case of a file-scope static being redeclared inline
inside a function.

For the non-nested, external-linkage case, the code attempts to avoid
duplicate diagnostics by diagnosing only when scope != external_scope,
but actually scope == external_scope is more appropriate, as it's only
when the file and external scopes are popped that the code can
actually tell whether a function ended up being defined, and all such
functions will appear in the (GCC-internal) external scope.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/c:
Backport from mainline
2019-01-07  Joseph Myers  

PR c/88720
PR c/88726
* c-decl.c (pop_scope): Use TREE_PUBLIC and b->nested to determine
whether a function is nested, not DECL_EXTERNAL.  Diagnose inline
functions declared but never defined only for external scope, not
for other scopes.

gcc/testsuite:
Backport from mainline
2019-01-07  Joseph Myers  

PR c/88720
PR c/88726
* gcc.dg/inline-40.c, gcc.dg/inline-41.c: New tests.

Added:
branches/gcc-7-branch/gcc/testsuite/gcc.dg/inline-40.c
branches/gcc-7-branch/gcc/testsuite/gcc.dg/inline-41.c
Modified:
branches/gcc-7-branch/gcc/c/ChangeLog
branches/gcc-7-branch/gcc/c/c-decl.c
branches/gcc-7-branch/gcc/testsuite/ChangeLog

[Bug c/88726] [7 Regression] GCC thinks that translation unit does not contain a definition of inline function.

2019-01-15 Thread jsm28 at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88726

Joseph S. Myers  changed:

   What|Removed |Added

   Target Milestone|8.3 |7.5
Summary|[7/8 Regression] GCC thinks |[7 Regression] GCC thinks
   |that translation unit does  |that translation unit does
   |not contain a definition of |not contain a definition of
   |inline function.|inline function.

--- Comment #4 from Joseph S. Myers  ---
Also now fixed for GCC 8.3.