aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2005-04-01 17:16:38 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2005-04-01 17:16:38 +0100
commit2c83be0cf08fc0b535aec0211f599acc38fa076e (patch)
tree1a4fa012965c447b6382b9419014c82666144cec /gcc
parent57ecec57492f5f3c32845a9a2cb12ae45dc0da03 (diff)
downloadgcc-2c83be0cf08fc0b535aec0211f599acc38fa076e.zip
gcc-2c83be0cf08fc0b535aec0211f599acc38fa076e.tar.gz
gcc-2c83be0cf08fc0b535aec0211f599acc38fa076e.tar.bz2
c-decl.c (validate_proto_after_old_defn): Look at TYPE_MAIN_VARIANT of argument types.
* c-decl.c (validate_proto_after_old_defn): Look at TYPE_MAIN_VARIANT of argument types. testsuite: * gcc.dg/old-style-then-proto-1.c: New test. From-SVN: r97403
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-decl.c7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/old-style-then-proto-1.c44
4 files changed, 56 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1fc8813..2f3c64f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2005-04-01 Joseph S. Myers <joseph@codesourcery.com>
+
+ * c-decl.c (validate_proto_after_old_defn): Look at
+ TYPE_MAIN_VARIANT of argument types.
+
2005-04-01 Paul Brook <paul@codesourcery.com>
* config/arm/arm.c (thumb_call_via_label): Include space for SP.
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index cb8fd9d..9d82b9a 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -1043,8 +1043,7 @@ validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
tree newargs, oldargs;
int i;
- /* ??? Elsewhere TYPE_MAIN_VARIANT is not used in this context. */
-#define END_OF_ARGLIST(t) (TYPE_MAIN_VARIANT (t) == void_type_node)
+#define END_OF_ARGLIST(t) ((t) == void_type_node)
oldargs = TYPE_ACTUAL_ARG_TYPES (oldtype);
newargs = TYPE_ARG_TYPES (newtype);
@@ -1052,8 +1051,8 @@ validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
for (;;)
{
- tree oldargtype = TREE_VALUE (oldargs);
- tree newargtype = TREE_VALUE (newargs);
+ tree oldargtype = TYPE_MAIN_VARIANT (TREE_VALUE (oldargs));
+ tree newargtype = TYPE_MAIN_VARIANT (TREE_VALUE (newargs));
if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype))
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 116ae34..2f207eb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2005-04-01 Joseph S. Myers <joseph@codesourcery.com>
+
+ * gcc.dg/old-style-then-proto-1.c: New test.
+
2005-04-01 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* gfortran.fortran-torture/execute/backspace.f90: Check
diff --git a/gcc/testsuite/gcc.dg/old-style-then-proto-1.c b/gcc/testsuite/gcc.dg/old-style-then-proto-1.c
new file mode 100644
index 0000000..abe02d0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/old-style-then-proto-1.c
@@ -0,0 +1,44 @@
+/* Test for old-style definition followed by prototype declaration.
+ Mismatched qualifiers used to be wrongly forbidden. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void f1() {}
+void f1(void); /* { dg-warning "warning: prototype for 'f1' follows non-prototype definition" } */
+
+void f2() {} /* { dg-error "error: previous definition of 'f2' was here" } */
+void f2(int); /* { dg-error "error: prototype for 'f2' declares more arguments than previous old-style definition" } */
+
+void f3(a) int a; {} /* { dg-error "error: previous definition of 'f3' was here" } */
+void f3(void); /* { dg-error "error: prototype for 'f3' declares fewer arguments than previous old-style definition" } */
+
+void f4(a) int a; {}
+void f4(int); /* { dg-warning "warning: prototype for 'f4' follows non-prototype definition" } */
+
+void f5(a) int a; {} /* { dg-error "error: previous definition of 'f5' was here" } */
+void f5(int, int); /* { dg-error "error: prototype for 'f5' declares more arguments than previous old-style definition" } */
+
+void f6(a) int a; {} /* { dg-error "error: previous definition of 'f6' was here" } */
+void f6(int, ...); /* { dg-error "error: conflicting types for 'f6'" } */
+
+void f7(a, b) int a, b; {} /* { dg-error "error: previous definition of 'f7' was here" } */
+void f7(int); /* { dg-error "error: prototype for 'f7' declares fewer arguments than previous old-style definition" } */
+
+void f8(a, b) int a, b; {} /* { dg-error "error: previous definition of 'f8' was here" } */
+void f8(int, ...); /* { dg-error "error: conflicting types for 'f8'" } */
+
+void f9(a, b) int a, b; {}
+void f9(int, int); /* { dg-warning "warning: prototype for 'f9' follows non-prototype definition" } */
+
+void f10(a, b) int a, b; {} /* { dg-error "error: previous definition of 'f10' was here" } */
+void f10(int, long); /* { dg-error "error: prototype for 'f10' declares argument 2 with incompatible type" } */
+
+void f11(a, b) int a, b; {} /* { dg-error "error: previous definition of 'f11' was here" } */
+void f11(long, int); /* { dg-error "error: prototype for 'f11' declares argument 1 with incompatible type" } */
+
+void f12(a, b) const int a; volatile int b; {}
+void f12(volatile int, const int); /* { dg-warning "warning: prototype for 'f12' follows non-prototype definition" } */
+
+void f13(a) const int a[2][2]; {} /* { dg-error "error: previous definition of 'f13' was here" } */
+void f13(volatile int [2][2]); /* { dg-error "error: prototype for 'f13' declares argument 1 with incompatible type" } */