public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/3116: Bug with using oldstyle prototype declarations
@ 2001-06-11 2:06 Andreas Jaeger
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Jaeger @ 2001-06-11 2:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 3116
>Category: c
>Synopsis: Bug with using oldstyle prototype declarations
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Jun 11 02:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:
>Release: 3.1 20010610 (experimental) (also 3.0 20010609)
>Organization:
SuSE
>Environment:
System: Linux gee 2.2.19 #1 Mon Apr 30 20:46:41 GMT 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /cvs/gcc/configure --prefix=/opt/gcc-3.1-devel --enable-shared --enable-threads=posix --with-gnu-as --with-gnu-ld --disable-nls --with-system-zlib --enable-languages=c,objc,c++,f77,java
>Description:
Compile the appended code, you get:
gee:~/tmp:[0]$ /opt/gcc-3.1-devel/bin/gcc -Wall -c fgetws.c
fgetws.c: In function `fgetws':
fgetws.c:18: argument `fp' doesn't match prototype
fgetws.c:11: prototype declaration
>How-To-Repeat:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct _IO_FILE {
int _flags;
};
typedef struct _IO_FILE __FILE;
typedef struct _IO_FILE _IO_FILE;
typedef long int wchar_t;
extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
__FILE *__restrict __stream);
#if 1
wchar_t *
fgetws (buf, n, fp)
wchar_t *buf;
int n;
_IO_FILE *fp;
{
return (wchar_t *)0;
}
#else
wchar_t *
fgetws (wchar_t *buf,int n, _IO_FILE * fp)
{
return (wchar_t *)0;
}
#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The other case (#if 0) works, only old style prototypes are broken.
This is a regression from gcc 2.95.3.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c/3116: Bug with using oldstyle prototype declarations
@ 2001-06-11 6:48 jsm28
0 siblings, 0 replies; 3+ messages in thread
From: jsm28 @ 2001-06-11 6:48 UTC (permalink / raw)
To: aj, gcc-bugs, gcc-prs, jsm28, nobody
Synopsis: Bug with using oldstyle prototype declarations
State-Changed-From-To: open->closed
State-Changed-By: jsm28
State-Changed-When: Mon Jun 11 06:48:44 2001
State-Changed-Why:
Now fixed.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3116&database=gcc
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c/3116: Bug with using oldstyle prototype declarations
@ 2001-06-11 6:36 Joseph S. Myers
0 siblings, 0 replies; 3+ messages in thread
From: Joseph S. Myers @ 2001-06-11 6:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/3116; it has been noted by GNATS.
From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: Andreas Jaeger <aj@suse.de>
Cc: <gcc-gnats@gcc.gnu.org>, <gcc-patches@gcc.gnu.org>
Subject: Re: c/3116: Bug with using oldstyle prototype declarations
Date: Mon, 11 Jun 2001 14:30:07 +0100 (BST)
On Mon, 11 Jun 2001, Andreas Jaeger wrote:
> Compile the appended code, you get:
> gee:~/tmp:[0]$ /opt/gcc-3.1-devel/bin/gcc -Wall -c fgetws.c
> fgetws.c: In function `fgetws':
> fgetws.c:18: argument `fp' doesn't match prototype
> fgetws.c:11: prototype declaration
> This is a regression from gcc 2.95.3.
Fixed thus.
Bootstrapped with no regressions on i686-pc-linux-gnu. Applied to
mainline and 3.0 branch.
2001-06-11 Joseph S. Myers <jsm28@cam.ac.uk>
* c-decl.c (store_parm_decls): When comparing types in an
old-style function declaration with those from a previous
prototype, compare the unqualified versions of parameter types.
Fixes PR c/3116.
testsuite:
2001-06-11 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.c-torture/compile/20010611-1.c: New test.
--- c-decl.c.orig Mon Jun 11 10:31:10 2001
+++ c-decl.c Mon Jun 11 11:23:43 2001
@@ -6436,9 +6436,11 @@ store_parm_decls ()
"prototype declaration");
break;
}
- /* Type for passing arg must be consistent
- with that declared for the arg. */
- if (! comptypes (DECL_ARG_TYPE (parm), TREE_VALUE (type)))
+ /* Type for passing arg must be consistent with that
+ declared for the arg. ISO C says we take the unqualified
+ type for parameters declared with qualified type. */
+ if (! comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
+ TYPE_MAIN_VARIANT (TREE_VALUE (type))))
{
if (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
== TYPE_MAIN_VARIANT (TREE_VALUE (type)))
--- testsuite/gcc.c-torture/compile/20010611-1.c.orig Mon Mar 26 23:57:02 2001
+++ testsuite/gcc.c-torture/compile/20010611-1.c Mon Jun 11 11:26:56 2001
@@ -0,0 +1,24 @@
+/* Origin: PR c/3116 from Andreas Jaeger <aj@suse.de>. */
+/* When determining type compatibility of function types, we must remove
+ qualifiers from argument types. We used to fail to do this properly
+ in store_parm_decls when comparing prototype and non-prototype
+ declarations. */
+struct _IO_FILE {
+ int _flags;
+};
+
+typedef struct _IO_FILE __FILE;
+typedef struct _IO_FILE _IO_FILE;
+typedef long int wchar_t;
+
+extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
+ __FILE *__restrict __stream);
+
+wchar_t *
+fgetws (buf, n, fp)
+ wchar_t *buf;
+ int n;
+ _IO_FILE *fp;
+{
+ return (wchar_t *)0;
+}
--
Joseph S. Myers
jsm28@cam.ac.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-06-11 6:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-11 2:06 c/3116: Bug with using oldstyle prototype declarations Andreas Jaeger
2001-06-11 6:36 Joseph S. Myers
2001-06-11 6:48 jsm28
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).