public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions
@ 2004-08-27 6:14 anton at samba dot org
2004-08-27 6:16 ` [Bug c/17205] " pinskia at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: anton at samba dot org @ 2004-08-27 6:14 UTC (permalink / raw)
To: gcc-bugs
gcc version 3.5.0 20040827 (experimental)
A 2.6 kernel compilation encountered a link failure. The following sequence
shows how things fail if a function protoype appears inside another function:
#define BROKE
#ifndef BROKE
static void foo(void);
#endif
int main()
{
#ifdef BROKE
static void foo(void);
#endif
foo();
}
static void foo(void)
{
printf("bar\n");
}
define BROKE and foo disappears completely, undefine it and it works as
expected. To be honest Im not even sure this is valid C.
--
Summary: Strange behaviour when function prototypes appear inside
other functions
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: anton at samba dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17205] Strange behaviour when function prototypes appear inside other functions
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
@ 2004-08-27 6:16 ` pinskia at gcc dot gnu dot org
2004-08-27 6:17 ` [Bug c/17205] [3.5 Regression] " pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-27 6:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-08-27 06:16 -------
This is not valid C.
We should be warning or erroring out.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-08-27 06:16:44
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17205] [3.5 Regression] Strange behaviour when function prototypes appear inside other functions
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
2004-08-27 6:16 ` [Bug c/17205] " pinskia at gcc dot gnu dot org
@ 2004-08-27 6:17 ` pinskia at gcc dot gnu dot org
2004-08-27 9:44 ` jsm at polyomino dot org dot uk
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-27 6:17 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
GCC target triplet|powerpc64-unknown-linux-gnu |
Keywords| |diagnostic, wrong-code
Summary|Strange behaviour when |[3.5 Regression] Strange
|function prototypes appear |behaviour when function
|inside other functions |prototypes appear inside
| |other functions
Target Milestone|--- |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17205] [3.5 Regression] Strange behaviour when function prototypes appear inside other functions
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
2004-08-27 6:16 ` [Bug c/17205] " pinskia at gcc dot gnu dot org
2004-08-27 6:17 ` [Bug c/17205] [3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-08-27 9:44 ` jsm at polyomino dot org dot uk
2004-08-27 13:51 ` geoffk at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-08-27 9:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jsm at polyomino dot org dot uk 2004-08-27 09:44 -------
Subject: Re: Strange behaviour when function prototypes appear
inside other functions
On Fri, 27 Aug 2004, pinskia at gcc dot gnu dot org wrote:
> This is not valid C.
> We should be warning or erroring out.
To be precise, it's compile-time undefined for block-scope function
declarations to have any storage-class specifier other than extern. I
don't object to removing this undocumented extension, but this bug report
shows it does have users.
The problem appears with a compiler from before my patch for bug 13801
went in, so it is not a problem caused by that patch. However, an
appropriate fix if we keep the extension would probably be along the lines
I suggested for a possible future refinement to that patch: add an
internal scope between the external scope and the file scope, which stores
hidden declarations of objects and functions with internal linkage used
for type checking the same way as the external scope, then merge the
handling of static function declarations at block scope with the handling
of external and file scope declarations. (So everything with external
linkage goes in the external scope, in addition to its proper scope, and
everything with internal linkage in a given translation unit goes in the
internal scope, in addition to its proper scope, static function
declarations at block scope are defined as having internal linkage, and
the internal scope, just like the external scope, accumulates composite
type information from all declarations, while the file scope and scopes
below that have the type information from visible declarations only.)
I might look at doing this, but not immediately given the problem isn't
caused by my patch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17205] [3.5 Regression] Strange behaviour when function prototypes appear inside other functions
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
` (2 preceding siblings ...)
2004-08-27 9:44 ` jsm at polyomino dot org dot uk
@ 2004-08-27 13:51 ` geoffk at gcc dot gnu dot org
2004-08-30 22:19 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2004-08-27 13:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From geoffk at gcc dot gnu dot org 2004-08-27 13:51 -------
This is probably related to 12738.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17205] [3.5 Regression] Strange behaviour when function prototypes appear inside other functions
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
` (3 preceding siblings ...)
2004-08-27 13:51 ` geoffk at gcc dot gnu dot org
@ 2004-08-30 22:19 ` cvs-commit at gcc dot gnu dot org
2004-08-30 22:23 ` geoffk at gcc dot gnu dot org
2004-09-01 22:12 ` cvs-commit at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-08-30 22:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-08-30 22:19 -------
Subject: Bug 17205
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: geoffk@gcc.gnu.org 2004-08-30 22:19:24
Modified files:
gcc : ChangeLog c-decl.c
gcc/testsuite : ChangeLog
gcc/testsuite/gcc.c-torture/compile: 920625-2.c
gcc/testsuite/gcc.c-torture/execute: 20010605-1.c nest-stdar-1.c
gcc/testsuite/gcc.dg: 20011130-1.c 20021014-1.c 20030331-2.c
Added files:
gcc/testsuite/gcc.dg: funcdef-storage-1.c
Log message:
2004-08-30 Geoffrey Keating <geoffk@apple.com>
PR 12738
PR 17205
Radar 3460526
Radar 3775729
* c-decl.c (grokdeclarator): Produce error for 'static' on local
function declaration.
Index: testsuite/ChangeLog
2004-08-30 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/funcdef-storage-1.c: New.
* gcc.c-torture/compile/920625-2.c: Don't use 'static' to declare
an extern function in local scope.
* gcc.c-torture/execute/20010605-1.c: Don't use 'static inline' to
declare an 'auto inline' function in local scope.
* gcc.dg/20011130-1.c: Likewise.
* gcc.c-torture/execute/nest-stdar-1.c: Don't use 'static' to declare
an 'auto' function in local scope.
* gcc.dg/20021014-1.c: Likewise.
* gcc.dg/20030331-2.c: Likewise.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5161&r2=2.5162
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.565&r2=1.566
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4211&r2=1.4212
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/920625-2.c.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20010605-1.c.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/nest-stdar-1.c.diff?cvsroot=gcc&r1=1.2&r2=1.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/funcdef-storage-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20011130-1.c.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20021014-1.c.diff?cvsroot=gcc&r1=1.10&r2=1.11
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030331-2.c.diff?cvsroot=gcc&r1=1.3&r2=1.4
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17205] [3.5 Regression] Strange behaviour when function prototypes appear inside other functions
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
` (4 preceding siblings ...)
2004-08-30 22:19 ` cvs-commit at gcc dot gnu dot org
@ 2004-08-30 22:23 ` geoffk at gcc dot gnu dot org
2004-09-01 22:12 ` cvs-commit at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2004-08-30 22:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From geoffk at gcc dot gnu dot org 2004-08-30 22:23 -------
Fixed, by declaring this code invalid and producing an error message on it. The kernel will need to be
changed to Not Do That, by moving the prototype for the 'static' function to file scope.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/17205] [3.5 Regression] Strange behaviour when function prototypes appear inside other functions
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
` (5 preceding siblings ...)
2004-08-30 22:23 ` geoffk at gcc dot gnu dot org
@ 2004-09-01 22:12 ` cvs-commit at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-09-01 22:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-09-01 22:12 -------
Subject: Bug 17205
CVSROOT: /cvs/gcc
Module name: gcc
Branch: apple-ppc-branch
Changes by: geoffk@gcc.gnu.org 2004-09-01 22:12:16
Modified files:
gcc : c-decl.c
gcc/testsuite/gcc.c-torture/compile: 920625-2.c
gcc/testsuite/gcc.c-torture/execute: 20010605-1.c nest-stdar-1.c
gcc/testsuite/gcc.dg: 20011130-1.c 20021014-1.c 20030331-2.c
Added files:
gcc/testsuite/gcc.dg: funcdef-storage-1.c
Log message:
PR 12738
PR 17205
Radar 3460526
Radar 3775729
* c-decl.c (grokdeclarator): Produce error for 'static' on local
function declaration.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.334.2.87.2.19&r2=1.334.2.87.2.20
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/compile/920625-2.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.2&r2=1.2.116.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20010605-1.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.2&r2=1.2.92.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/nest-stdar-1.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.2&r2=1.2.116.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/funcdef-storage-1.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=NONE&r2=1.2.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20011130-1.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1&r2=1.1.88.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20021014-1.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.1.8.9&r2=1.1.8.9.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/20030331-2.c.diff?cvsroot=gcc&only_with_tag=apple-ppc-branch&r1=1.2.4.1.8.1&r2=1.2.4.1.8.2
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17205
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-09-01 22:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-27 6:14 [Bug c/17205] New: Strange behaviour when function prototypes appear inside other functions anton at samba dot org
2004-08-27 6:16 ` [Bug c/17205] " pinskia at gcc dot gnu dot org
2004-08-27 6:17 ` [Bug c/17205] [3.5 Regression] " pinskia at gcc dot gnu dot org
2004-08-27 9:44 ` jsm at polyomino dot org dot uk
2004-08-27 13:51 ` geoffk at gcc dot gnu dot org
2004-08-30 22:19 ` cvs-commit at gcc dot gnu dot org
2004-08-30 22:23 ` geoffk at gcc dot gnu dot org
2004-09-01 22:12 ` cvs-commit 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).