public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39556]  New: statics in C99 inline functions later declared extern
@ 2009-03-25 20:04 jsm28 at gcc dot gnu dot org
  2009-03-30  1:10 ` [Bug c/39556] " jsm28 at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-25 20:04 UTC (permalink / raw)
  To: gcc-bugs

C99 prohibits an "inline definition" of a function with external linkage
from containing modifiable static variables or references to file-scope
static variables or functions.

A definition is an inline definition only if all file-scope declarations
for the function in the translation unit use "inline" and do not use
"extern".  Thus, this cannot be determined until the end of the translation
unit.  GCC gives the diagnostics for the above constraint too soon, leading
to the following valid examples being wrongly rejected with -std=c99
-pedantic-errors.  It needs to defer them and see at the end of the
translation unit whether the definition is an inline definition after all.

Example 1:
static int a;
inline int f (void) { return a; }
int f (void);

Example 2:
inline void f (void) { static int a; }
extern inline void f (void);


-- 
           Summary: statics in C99 inline functions later declared extern
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org
OtherBugsDependingO 16989
             nThis:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39556


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/39556] statics in C99 inline functions later declared extern
  2009-03-25 20:04 [Bug c/39556] New: statics in C99 inline functions later declared extern jsm28 at gcc dot gnu dot org
@ 2009-03-30  1:10 ` jsm28 at gcc dot gnu dot org
  2009-04-26 13:40 ` jsm28 at gcc dot gnu dot org
  2009-04-26 13:42 ` jsm28 at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30  1:10 UTC (permalink / raw)
  To: gcc-bugs



-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-03-30 01:09:57
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39556


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/39556] statics in C99 inline functions later declared extern
  2009-03-25 20:04 [Bug c/39556] New: statics in C99 inline functions later declared extern jsm28 at gcc dot gnu dot org
  2009-03-30  1:10 ` [Bug c/39556] " jsm28 at gcc dot gnu dot org
@ 2009-04-26 13:40 ` jsm28 at gcc dot gnu dot org
  2009-04-26 13:42 ` jsm28 at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-04-26 13:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jsm28 at gcc dot gnu dot org  2009-04-26 13:40 -------
Subject: Bug 39556

Author: jsm28
Date: Sun Apr 26 13:40:19 2009
New Revision: 146800

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146800
Log:
        PR c/39556
        * c-tree.h (enum c_inline_static_type): New.
        (record_inline_static): Declare.
        * c-decl.c (struct c_inline_static, c_inline_statics,
        record_inline_static, check_inline_statics): New.
        (pop_file_scope): Call check_inline_statics.
        (start_decl): Call record_inline_static instead of pedwarning
        directly for static in inline function.
        * c-typeck.c (build_external_ref): Call record_inline_static
        instead of pedwarning directly for static referenced in inline
        function.

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

Added:
    trunk/gcc/testsuite/gcc.dg/inline-34.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-decl.c
    trunk/gcc/c-tree.h
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39556


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/39556] statics in C99 inline functions later declared extern
  2009-03-25 20:04 [Bug c/39556] New: statics in C99 inline functions later declared extern jsm28 at gcc dot gnu dot org
  2009-03-30  1:10 ` [Bug c/39556] " jsm28 at gcc dot gnu dot org
  2009-04-26 13:40 ` jsm28 at gcc dot gnu dot org
@ 2009-04-26 13:42 ` jsm28 at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-04-26 13:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jsm28 at gcc dot gnu dot org  2009-04-26 13:41 -------
Fixed for 4.5.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |4.5.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39556


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-26 13:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-25 20:04 [Bug c/39556] New: statics in C99 inline functions later declared extern jsm28 at gcc dot gnu dot org
2009-03-30  1:10 ` [Bug c/39556] " jsm28 at gcc dot gnu dot org
2009-04-26 13:40 ` jsm28 at gcc dot gnu dot org
2009-04-26 13:42 ` jsm28 at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).