diff options
author | Joseph Myers <jsm28@cam.ac.uk> | 2001-06-11 14:26:19 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2001-06-11 14:26:19 +0100 |
commit | 1552f8745719c1b62efc50579e200c7e851924c5 (patch) | |
tree | 28ef0c84630cc4987e22cb7097cb3d5b25adff66 | |
parent | cff75d2efee00dc45d4b9856c7b94c6660bd6e90 (diff) | |
download | gcc-1552f8745719c1b62efc50579e200c7e851924c5.zip gcc-1552f8745719c1b62efc50579e200c7e851924c5.tar.gz gcc-1552f8745719c1b62efc50579e200c7e851924c5.tar.bz2 |
re PR c/3116 (Bug with using oldstyle prototype declarations)
* 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:
* gcc.c-torture/compile/20010611-1.c: New test.
From-SVN: r43186
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-decl.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/20010611-1.c | 24 |
4 files changed, 40 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 20948ad..c39562b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 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. + +2001-06-11 Joseph S. Myers <jsm28@cam.ac.uk> + * doc/objc.texi: Use more logical markup. Use TeX dashes. 2001-06-11 Joseph S. Myers <jsm28@cam.ac.uk> diff --git a/gcc/c-decl.c b/gcc/c-decl.c index b68f772..5d50394 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d125520..fd0720c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2001-06-11 Joseph S. Myers <jsm28@cam.ac.uk> + * gcc.c-torture/compile/20010611-1.c: New test. + +2001-06-11 Joseph S. Myers <jsm28@cam.ac.uk> + * gcc.dg/c99-tag-1.c: Add more tests. 2001-06-10 Alexandre Oliva <aoliva@redhat.com> diff --git a/gcc/testsuite/gcc.c-torture/compile/20010611-1.c b/gcc/testsuite/gcc.c-torture/compile/20010611-1.c new file mode 100644 index 0000000..87723bd --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20010611-1.c @@ -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; +} |