public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
@ 2008-01-29 15:25 ` jakub at gcc dot gnu dot org
  2008-01-29 15:48 ` rguenth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-29 15:25 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


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


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

* [Bug c/35017]  New: [4.3 Regression] PR11377 pedwarns even about valid code
@ 2008-01-29 15:25 jakub at gcc dot gnu dot org
  2008-01-29 15:25 ` [Bug c/35017] " jakub at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-29 15:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118357 introduced pedwarns
about any static decls in external linkage inline functions, but ISO C99
6.4.7/3
has:
"An inline definition of a function with external linkage shall not contain a
definition of a modifiable object with static storage duration, and shall not
contain a reference to an identifier with internal linkage."
In -std=c99:

inline int foo (void) { static const int c = 6; return c; }

the static variable c isn't modifiable, so the first condition doesn't apply,
and from 6.2.2 I gather c has no linkage rather than internal linkage and so
the other condition doesn't apply either.

In -std=c99:

static const int c = 6;
inline int foo (void) { return c; }

I believe c has internal linkage and thus it is invalid (and therefore
correctly diagnosed by the trunk).


-- 
           Summary: [4.3 Regression] PR11377 pedwarns even about valid code
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
  2008-01-29 15:25 ` [Bug c/35017] " jakub at gcc dot gnu dot org
@ 2008-01-29 15:48 ` rguenth at gcc dot gnu dot org
  2008-01-29 16:06 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-29 15:48 UTC (permalink / raw)
  To: gcc-bugs



-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, rejects-valid
           Priority|P3                          |P2


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
  2008-01-29 15:25 ` [Bug c/35017] " jakub at gcc dot gnu dot org
  2008-01-29 15:48 ` rguenth at gcc dot gnu dot org
@ 2008-01-29 16:06 ` jakub at gcc dot gnu dot org
  2008-01-29 17:27 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-29 16:06 UTC (permalink / raw)
  To: gcc-bugs



-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-01-29 15:54:31
               date|                            |


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-01-29 16:06 ` jakub at gcc dot gnu dot org
@ 2008-01-29 17:27 ` pinskia at gcc dot gnu dot org
  2008-01-29 17:52 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-01-29 17:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-01-29 17:07 -------
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11377 says otherwise.


-- 


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-01-29 17:27 ` pinskia at gcc dot gnu dot org
@ 2008-01-29 17:52 ` jakub at gcc dot gnu dot org
  2008-01-29 18:00 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-29 17:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2008-01-29 17:31 -------
Created an attachment (id=15051)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15051&action=view)
gcc43-pr35017.patch

TREE_READONLY isn't modifiable, so I guess that part is quite clear and I'm
also
pretty sure about the possibility to reference static const vars declared in
the function.
What is more unclear is in what kind of inline functions this should be warned
about.  6.7.4p3 talks about inline definition of a function, is that function
definition with inline keyword in this context (i.e. any non-static inline
function) or is that inline definition in the 6.7.4p6 sense (one where there is
no external definition)?
The attached patch implements the first choice, leaving the original conditions
for current_function_decl in both places would keep the second choice.
Joseph?


-- 


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-01-29 17:52 ` jakub at gcc dot gnu dot org
@ 2008-01-29 18:00 ` jakub at gcc dot gnu dot org
  2008-01-29 19:37 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-29 18:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2008-01-29 17:39 -------
BTW, the patch I've attached doesn't bootstrap, got an error on bitmap.c.
Simplified testcase:
typedef int bitmap_element;
typedef struct { bitmap_element *first; } *bitmap;
extern void bitmap_clear (bitmap);

static void bitmap_elt_clear_from (bitmap, bitmap_element *);

void
bitmap_elt_clear_from (bitmap head, bitmap_element *elt)
{
  (void) head;
  (void) elt;
}

inline void
bitmap_clear (bitmap head)
{
  if (head->first)
    bitmap_elt_clear_from (head, head->first);
}

If this is valid ISO C99, then I'll need to adjust the patch.


-- 


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-01-29 18:00 ` jakub at gcc dot gnu dot org
@ 2008-01-29 19:37 ` jakub at gcc dot gnu dot org
  2008-01-29 19:52 ` joseph at codesourcery dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-29 19:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2008-01-29 17:48 -------
Created an attachment (id=15052)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15052&action=view)
gcc43-pr35017.patch

Alternative patch, which only pedwarns in inline definitions as defined in
4.7.6p6 as before, just doesn't warn when it should not.


-- 


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-01-29 19:37 ` jakub at gcc dot gnu dot org
@ 2008-01-29 19:52 ` joseph at codesourcery dot com
  2008-01-29 23:46 ` jakub at gcc dot gnu dot org
  2008-01-30  0:03 ` jakub at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2008-01-29 19:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from joseph at codesourcery dot com  2008-01-29 18:24 -------
Subject: Re:  [4.3 Regression] PR11377 pedwarns even about valid
 code

On Tue, 29 Jan 2008, jakub at gcc dot gnu dot org wrote:

> TREE_READONLY isn't modifiable, so I guess that part is quite clear and I'm
> also
> pretty sure about the possibility to reference static const vars declared in
> the function.
> What is more unclear is in what kind of inline functions this should be warned
> about.  6.7.4p3 talks about inline definition of a function, is that function
> definition with inline keyword in this context (i.e. any non-static inline
> function) or is that inline definition in the 6.7.4p6 sense (one where there is
> no external definition)?
> The attached patch implements the first choice, leaving the original conditions
> for current_function_decl in both places would keep the second choice.
> Joseph?

I think it means inline definition as in 6.7.4p6 (where whether it's an 
inline definition depends on whether there are subsequent declarations 
after the definition with extern or without inline, but getting the 
diagnostics right for such cases is a separate bug).


-- 


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2008-01-29 19:52 ` joseph at codesourcery dot com
@ 2008-01-29 23:46 ` jakub at gcc dot gnu dot org
  2008-01-30  0:03 ` jakub at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-29 23:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2008-01-29 23:19 -------
Subject: Bug 35017

Author: jakub
Date: Tue Jan 29 23:19:07 2008
New Revision: 131945

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131945
Log:
        PR c/35017
        * c-decl.c (start_decl): Don't pedwarn about TREE_READONLY
        static decls.
        * c-typeck.c (build_external_ref): Don't pedwarn about
        static vars in current function's scope.

        * gcc.dg/inline-25.c: New test.
        * gcc.dg/inline-26.c: New test.
        * gcc.dg/inline-27.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/inline-25.c
    trunk/gcc/testsuite/gcc.dg/inline-26.c
    trunk/gcc/testsuite/gcc.dg/inline-27.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-decl.c
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c/35017] [4.3 Regression] PR11377 pedwarns even about valid code
  2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2008-01-29 23:46 ` jakub at gcc dot gnu dot org
@ 2008-01-30  0:03 ` jakub at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2008-01-30  0:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2008-01-29 23:22 -------
Fixed.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2008-01-29 23:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-29 15:25 [Bug c/35017] New: [4.3 Regression] PR11377 pedwarns even about valid code jakub at gcc dot gnu dot org
2008-01-29 15:25 ` [Bug c/35017] " jakub at gcc dot gnu dot org
2008-01-29 15:48 ` rguenth at gcc dot gnu dot org
2008-01-29 16:06 ` jakub at gcc dot gnu dot org
2008-01-29 17:27 ` pinskia at gcc dot gnu dot org
2008-01-29 17:52 ` jakub at gcc dot gnu dot org
2008-01-29 18:00 ` jakub at gcc dot gnu dot org
2008-01-29 19:37 ` jakub at gcc dot gnu dot org
2008-01-29 19:52 ` joseph at codesourcery dot com
2008-01-29 23:46 ` jakub at gcc dot gnu dot org
2008-01-30  0:03 ` jakub 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).